use global

This commit is contained in:
momo 2015-12-15 14:32:41 -05:00
parent 7e2ba785ed
commit 91ccfdcf0d

View File

@ -72,6 +72,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
private final DummyNodeListener dummyNodeListener = new DummyNodeListener(); private final DummyNodeListener dummyNodeListener = new DummyNodeListener();
private static final String DUMMY_NODE_DISPLAY_NAME = NbBundle.getMessage(DataResultViewerTable.class, "DataResultViewerTable.dummyNodeDisplayName"); private static final String DUMMY_NODE_DISPLAY_NAME = NbBundle.getMessage(DataResultViewerTable.class, "DataResultViewerTable.dummyNodeDisplayName");
private Node currentRoot; private Node currentRoot;
private String currentRootItemType;
/** /**
* Creates a DataResultViewerTable object that is compatible with node * Creates a DataResultViewerTable object that is compatible with node
@ -347,12 +348,12 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
*/ */
private void setupTable(final Node root) { private void setupTable(final Node root) {
String type = "";
if(root instanceof TableFilterNode) { if(root instanceof TableFilterNode) {
TableFilterNode filterNode = (TableFilterNode) root; TableFilterNode filterNode = (TableFilterNode) root;
type = filterNode.getItemType(); currentRootItemType = filterNode.getItemType();
} }
else { else {
currentRootItemType = "";
Logger.getLogger(DataResultViewerTable.class.getName()).log(Level.INFO, Logger.getLogger(DataResultViewerTable.class.getName()).log(Level.INFO,
"Node {0} is not TableFilterNode, columns are going to be in default order", root.getName()); "Node {0} is not TableFilterNode, columns are going to be in default order", root.getName());
} }
@ -366,10 +367,10 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
} }
if(currentRoot != null && !propertiesAcc.isEmpty()) { if(currentRoot != null && !propertiesAcc.isEmpty()) {
storeProperties(currentRoot, type); storeProperties();
} }
currentRoot = root; currentRoot = root;
List<Node.Property<?>> props = loadProperties(currentRoot, type); List<Node.Property<?>> props = loadProperties();
/* /*
* OutlineView makes the first column be the result of * OutlineView makes the first column be the result of
@ -443,29 +444,29 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
} }
// Store the column arrangements of the given Node. // Store the column arrangements of the given Node.
private void storeProperties(Node root, String type) { private void storeProperties() {
if(type.isEmpty()) if(currentRootItemType.isEmpty())
return; return;
List<Node.Property<?>> props = new ArrayList<>(propertiesAcc); List<Node.Property<?>> props = new ArrayList<>(propertiesAcc);
for (int i = 0; i < props.size(); i++) { for (int i = 0; i < props.size(); i++) {
Property<?> prop = props.get(i); Property<?> prop = props.get(i);
NbPreferences.forModule(this.getClass()).put(getUniqueName(root, prop, type), String.valueOf(i)); NbPreferences.forModule(this.getClass()).put(getUniqueName(prop), String.valueOf(i));
} }
} }
// Load the column arrangement stored for the given node if exists. // Load the column arrangement stored for the given node if exists.
private List<Node.Property<?>> loadProperties(Node root, String type) { private List<Node.Property<?>> loadProperties() {
propertiesAcc.clear(); propertiesAcc.clear();
this.getAllChildPropertyHeadersRec(root, 100); this.getAllChildPropertyHeadersRec(currentRoot, 100);
List<Node.Property<?>> props = new ArrayList<>(propertiesAcc); List<Node.Property<?>> props = new ArrayList<>(propertiesAcc);
// If type is not defined, use default order for columns // If type is not defined, use default order for columns
if(type.isEmpty()) if(currentRootItemType.isEmpty())
return props; return props;
List<Node.Property<?>> orderedProps = new ArrayList<>(propertiesAcc); List<Node.Property<?>> orderedProps = new ArrayList<>(propertiesAcc);
for (Property<?> prop : props) { for (Property<?> prop : props) {
Integer value = Integer.valueOf(NbPreferences.forModule(this.getClass()).get(getUniqueName(root, prop, type), "-1")); Integer value = Integer.valueOf(NbPreferences.forModule(this.getClass()).get(getUniqueName(prop), "-1"));
if (value >= 0) { if (value >= 0) {
/** /**
* The original contents of orderedProps do not matter when setting the new ordered values. The reason * The original contents of orderedProps do not matter when setting the new ordered values. The reason
@ -482,8 +483,8 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
} }
// Get unique name for node and it's property. // Get unique name for node and it's property.
private String getUniqueName(Node root, Property<?> prop, String type) { private String getUniqueName(Property<?> prop) {
return Case.getCurrentCase().getName() + "." + type + "." return Case.getCurrentCase().getName() + "." + currentRootItemType + "."
+ prop.getName().replaceAll("[^a-zA-Z0-9_]", "") + ".columnOrder"; + prop.getName().replaceAll("[^a-zA-Z0-9_]", "") + ".columnOrder";
} }