Save and restore selected tab for each pane

Avoid refreshing entire Deck Editor when opening a deck
This commit is contained in:
drdev
2013-07-28 00:50:38 +00:00
parent 0c9a29000e
commit 5da85b079a
4 changed files with 65 additions and 30 deletions

View File

@@ -8,14 +8,13 @@ Forge Beta: 07-##-2013 ver 1.4.4
Release Notes
-------------
-All Decks updates-
Can double click row for deck to open it (in addition to clicking edit icon)
Fixed bug where hover effect didn't work the first time hovering over a row that had just been deselected
-Improvements to color/card Type filters
- Deck Editor and General UI improvements -
You can now right-click on a color filter button to show only cards of that color, filtering out all other colors. Similar with card type filter buttons.
Can double click row for deck to open it (in addition to clicking edit icon)
The selected tab on each draggable pane will now be remembered between sessions
Fixed bug where hover effect didn't work the first time hovering over a row that had just been deselected
Fixed bug where middle and right clicking buttons did the same behavior as left clicking, and fixed bug where clicking multiple buttons quickly (such as filters) while moving the mouse around would result in clicks not registering sometimes.
Fixed bug where entire Deck Editor would refresh when opening a deck (causing Card Catalog to flicker)
- Card Zoomer -

View File

@@ -205,6 +205,8 @@ public enum FControl {
* Switches between display states in top level JFrame.
*/
public void changeState(Screens screen) {
if (this.state == screen) { return; }
clearChildren(JLayeredPane.DEFAULT_LAYER);
this.state = screen;

View File

@@ -46,6 +46,7 @@ public final class SLayoutIO {
public final static String y = "y";
public final static String w = "w";
public final static String h = "h";
public final static String sel = "sel";
public final static String doc = "doc";
}
@@ -113,10 +114,13 @@ public final class SLayoutIO {
writer.add(TAB);
writer.add(EF.createStartElement("", "", "cell"));
writer.add(EF.createAttribute(Property.x.toString(), String.valueOf(Math.rint(bounds.getX() * 100000) / 100000)));
writer.add(EF.createAttribute(Property.y.toString(), String.valueOf(Math.rint(bounds.getY() * 100000) / 100000)));
writer.add(EF.createAttribute(Property.w.toString(), String.valueOf(Math.rint(bounds.getW() * 100000) / 100000)));
writer.add(EF.createAttribute(Property.h.toString(), String.valueOf(Math.rint(bounds.getH() * 100000) / 100000)));
writer.add(EF.createAttribute(Property.x, String.valueOf(Math.rint(bounds.getX() * 100000) / 100000)));
writer.add(EF.createAttribute(Property.y, String.valueOf(Math.rint(bounds.getY() * 100000) / 100000)));
writer.add(EF.createAttribute(Property.w, String.valueOf(Math.rint(bounds.getW() * 100000) / 100000)));
writer.add(EF.createAttribute(Property.h, String.valueOf(Math.rint(bounds.getH() * 100000) / 100000)));
if (cell.getSelected() != null) {
writer.add(EF.createAttribute(Property.sel, cell.getSelected().getDocumentID().toString()));
}
writer.add(NEWLINE);
for (final IVDoc<? extends ICDoc> vDoc : cell.getDocs()) {
@@ -157,7 +161,7 @@ public final class SLayoutIO {
view.removeAllDragCells();
// Read a model for new layout
MapOfLists<RectangleOfDouble, EDocID> model = null;
MapOfLists<LayoutInfo, EDocID> model = null;
boolean usedCustomPrefsFile = false;
@@ -206,38 +210,60 @@ public final class SLayoutIO {
// Apply new layout
DragCell cell = null;
for(Entry<RectangleOfDouble, Collection<EDocID>> kv : model.entrySet()) {
cell = new DragCell();
cell.setRoughBounds(kv.getKey());
for(Entry<LayoutInfo, Collection<EDocID>> kv : model.entrySet()) {
LayoutInfo layoutInfo = kv.getKey();
DragCell cell = new DragCell();
cell.setRoughBounds(layoutInfo.getBounds());
FView.SINGLETON_INSTANCE.addDragCell(cell);
for(EDocID edoc : kv.getValue()) {
try {
//System.out.println(String.format("adding doc %s -> %s", edoc, edoc.getDoc()));
cell.addDoc(edoc.getDoc());
} catch (IllegalArgumentException e) {
}
catch (IllegalArgumentException e) {
System.err.println("Failed to get doc for " + edoc);
}
}
if (layoutInfo.getSelectedId() != null) {
cell.setSelected(layoutInfo.getSelectedId().getDoc());
}
}
// Rough bounds are all in place; resize the window.
SResizingUtil.resizeWindow();
}
private static MapOfLists<RectangleOfDouble, EDocID> readLayout(final XMLEventReader reader) throws XMLStreamException
private static class LayoutInfo
{
private final RectangleOfDouble bounds;
private final EDocID selectedId;
public LayoutInfo(RectangleOfDouble bounds0, EDocID selectedId0) {
this.bounds = bounds0;
this.selectedId = selectedId0;
}
public RectangleOfDouble getBounds() {
return this.bounds;
}
public EDocID getSelectedId() {
return this.selectedId;
}
}
private static MapOfLists<LayoutInfo, EDocID> readLayout(final XMLEventReader reader) throws XMLStreamException
{
XMLEvent event;
StartElement element;
Iterator<?> attributes;
Attribute attribute;
EDocID selectedId = null;
double x0 = 0, y0 = 0, w0 = 0, h0 = 0;
MapOfLists<RectangleOfDouble, EDocID> model = new HashMapOfLists<RectangleOfDouble, EDocID>(CollectionSuppliers.<EDocID>arrayLists());
MapOfLists<LayoutInfo, EDocID> model = new HashMapOfLists<LayoutInfo, EDocID>(CollectionSuppliers.<EDocID>arrayLists());
RectangleOfDouble currentKey = null;
LayoutInfo currentKey = null;
while (null != reader && reader.hasNext()) {
event = reader.nextEvent();
@@ -248,15 +274,15 @@ public final class SLayoutIO {
attributes = element.getAttributes();
while (attributes.hasNext()) {
attribute = (Attribute) attributes.next();
double val = Double.parseDouble(attribute.getValue());
String atrName = attribute.getName().toString();
if (atrName.equals(Property.x)) x0 = val;
else if (atrName.equals(Property.y)) y0 = val;
else if (atrName.equals(Property.w)) w0 = val;
else if (atrName.equals(Property.h)) h0 = val;
if (atrName.equals(Property.x)) x0 = Double.parseDouble(attribute.getValue());
else if (atrName.equals(Property.y)) y0 = Double.parseDouble(attribute.getValue());
else if (atrName.equals(Property.w)) w0 = Double.parseDouble(attribute.getValue());
else if (atrName.equals(Property.h)) h0 = Double.parseDouble(attribute.getValue());
else if (atrName.equals(Property.sel)) selectedId = EDocID.valueOf(attribute.getValue());
}
currentKey = new RectangleOfDouble(x0, y0, w0, h0);
currentKey = new LayoutInfo(new RectangleOfDouble(x0, y0, w0, h0), selectedId);
}
else if (element.getName().getLocalPart().equals(Property.doc)) {
event = reader.nextEvent();

View File

@@ -229,8 +229,15 @@ public final class SRearrangingUtil {
pnlPreview.setBounds(0, 0, 0, 0);
// Source and target are the same?
if (dropzone.equals(Dropzone.NONE)) { return; }
if (cellTarget.equals(cellSrc) && cellSrc.getDocs().size() == 1) { return; }
if (dropzone.equals(Dropzone.NONE) || (cellTarget.equals(cellSrc) && cellSrc.getDocs().size() == 1))
{
if (srcSelectedDoc != cellSrc.getSelected())
{
SLayoutIO.saveLayout(null); //still need to save layout if selection changed
}
srcSelectedDoc = null;
return;
}
// Prep vals for possible resize
tempX = cellTarget.getX();
@@ -300,6 +307,7 @@ public final class SRearrangingUtil {
cellTarget.updateRoughBounds();
cellSrc.setSelected(srcSelectedDoc);
srcSelectedDoc = null;
cellSrc.refresh();
cellTarget.refresh();
cellNew.validate();