Code cleanup

This commit is contained in:
drdev
2014-01-25 02:48:36 +00:00
parent a3fb6de6b3
commit b198e8a40e
4 changed files with 30 additions and 26 deletions

View File

@@ -125,8 +125,9 @@ public class DeckProxy implements InventoryItem {
if (sbSize == Integer.MIN_VALUE) { if (sbSize == Integer.MIN_VALUE) {
CardPool sb = getDeck().get(DeckSection.Sideboard); CardPool sb = getDeck().get(DeckSection.Sideboard);
sbSize = sb == null ? -1 : sb.countAll(); sbSize = sb == null ? -1 : sb.countAll();
if( sbSize == 0 ) if (sbSize == 0) {
sbSize = -1; sbSize = -1;
}
} }
return sbSize; return sbSize;
} }
@@ -144,8 +145,8 @@ public class DeckProxy implements InventoryItem {
private static void addDecksRecursivelly(List<DeckProxy> list, String path, IStorage<Deck> folder) { private static void addDecksRecursivelly(List<DeckProxy> list, String path, IStorage<Deck> folder) {
for (IStorage<Deck> f : folder.getFolders()) { for (IStorage<Deck> f : folder.getFolders()) {
String subPath = (StringUtils.isBlank(path) ? "" : path) + "/" + f.getName(); String subPath = (StringUtils.isBlank(path) ? "" : path) + "/" + f.getName();
addDecksRecursivelly(list, subPath, f); addDecksRecursivelly(list, subPath, f);
} }
for (Deck d : folder) { for (Deck d : folder) {
@@ -179,20 +180,23 @@ public class DeckProxy implements InventoryItem {
} }
public void reloadFromStorage() { public void reloadFromStorage() {
if( null != storage ) if (storage != null) {
deck = storage.get(getName()); deck = storage.get(getName());
}
invalidateCache(); invalidateCache();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateInStorage() { public void updateInStorage() {
if ( storage instanceof StorageImmediatelySerialized<?> ) if (storage instanceof StorageImmediatelySerialized<?>) {
((StorageImmediatelySerialized<IHasName>)storage).add(deck); ((StorageImmediatelySerialized<IHasName>)storage).add(deck);
}
} }
public void deleteFromStorage() { public void deleteFromStorage() {
if ( storage instanceof StorageImmediatelySerialized<?> ) if (storage instanceof StorageImmediatelySerialized<?>) {
storage.delete(getName()); storage.delete(getName());
}
} }
private static class ThemeDeckGenerator extends DeckProxy { private static class ThemeDeckGenerator extends DeckProxy {

View File

@@ -254,16 +254,16 @@ public enum CCurrentDeck implements ICDoc {
return null; return null;
} }
/** The Constant HTML_FILTER. */ /** The Constant HTML_FILTER. */
public static final FileFilter HTML_FILTER = new FileFilter() { public static final FileFilter HTML_FILTER = new FileFilter() {
@Override @Override
public boolean accept(final File f) { public boolean accept(final File f) {
return f.getName().endsWith(".html") || f.isDirectory(); return f.getName().endsWith(".html") || f.isDirectory();
} }
@Override @Override
public String getDescription() { public String getDescription() {
return "Proxy File .html"; return "Proxy File .html";
} }
}; };
} }

View File

@@ -47,8 +47,7 @@ public class DeckController<T extends DeckBase> {
* @param view0 the view0 * @param view0 the view0
* @param newModelCreator0 the new model creator0 * @param newModelCreator0 the new model creator0
*/ */
public DeckController(final IStorage<T> folder0, final ACEditorBase<?, T> view0, public DeckController(final IStorage<T> folder0, final ACEditorBase<?, T> view0, final Supplier<T> newModelCreator0) {
final Supplier<T> newModelCreator0) {
this.rootFolder = folder0; this.rootFolder = folder0;
this.currentFolder = rootFolder; this.currentFolder = rootFolder;
this.view = view0; this.view = view0;
@@ -94,7 +93,7 @@ public class DeckController<T extends DeckBase> {
if (model.getName().isEmpty()) { if (model.getName().isEmpty()) {
return true; return true;
} }
final T modelStored = this.currentFolder.get(this.model.getName()); final T modelStored = this.currentFolder.get(this.model.getName());
// checks presence in dictionary only. // checks presence in dictionary only.
if (modelStored == this.model) { if (modelStored == this.model) {
@@ -142,13 +141,15 @@ public class DeckController<T extends DeckBase> {
} }
public void load(final String path, final String name) { public void load(final String path, final String name) {
if ( StringUtils.isBlank(path)) if (StringUtils.isBlank(path)) {
currentFolder = rootFolder; currentFolder = rootFolder;
else }
else {
currentFolder = rootFolder.tryGetFolder(path); currentFolder = rootFolder.tryGetFolder(path);
}
load(name); load(name);
} }
/** /**
* Load. * Load.
* *

View File

@@ -353,7 +353,7 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
* *
* @return generic type of items * @return generic type of items
*/ */
public Class<T> getGenericType() { public Class<T> getGenericType() {
return this.genericType; return this.genericType;
} }
@@ -407,7 +407,6 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
*/ */
public void setPool(final ItemPool<T> poolView, boolean infinite) { public void setPool(final ItemPool<T> poolView, boolean infinite) {
this.setPoolImpl(ItemPool.createFrom(poolView, this.genericType), infinite); this.setPoolImpl(ItemPool.createFrom(poolView, this.genericType), infinite);
} }
public void setPool(final ItemPool<T> pool0) { public void setPool(final ItemPool<T> pool0) {
@@ -1046,7 +1045,7 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
public Iterable<ListSelectionListener> getSelectionListeners() { public Iterable<ListSelectionListener> getSelectionListeners() {
return selectionListeners; return selectionListeners;
} }
public void setItemActivateCommand(Command itemActivateCommand0) { public void setItemActivateCommand(Command itemActivateCommand0) {
this.itemActivateCommand = itemActivateCommand0; this.itemActivateCommand = itemActivateCommand0;
} }