[hg] main-silver: #223391: View-specific column settings introdu...

  • From:
  • To:
  • Subject: [hg] main-silver: #223391: View-specific column settings introdu...
  • Date: Wed, 19 Dec 2012 06:17:55 -0800

changeset 9d38a38149f2 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/9d38a38149f2
description:
        #223391: View-specific column settings introduced.

diffstat:

 
spi.debugger.ui/src/org/netbeans/modules/debugger/ui/models/ColumnModels.java 
    |  74 +++++++--
 
spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/ViewModelListener.java
 |   6 +
 2 files changed, 61 insertions(+), 19 deletions(-)

diffs (191 lines):

diff --git 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/models/ColumnModels.java
 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/models/ColumnModels.java
--- 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/models/ColumnModels.java
+++ 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/models/ColumnModels.java
@@ -109,6 +109,7 @@
 
         Properties properties = Properties.getDefault ().
             getProperties ("debugger").getProperties ("views");
+        private Properties viewProperties = null;
 
         public AbstractColumn(String id, String displayName, String 
shortDescription,
                               Class type) {
@@ -144,6 +145,10 @@
             return id;
         }
 
+        public void setViewPath(String viewPath) {
+            viewProperties = properties.getProperties(viewPath);
+        }
+
         public String getDisplayName() {
             return NbBundle.getBundle 
(ColumnModels.class).getString(displayName);
         }
@@ -164,7 +169,7 @@
          */
         @Override
         public void setVisible (boolean visible) {
-            properties.setBoolean (getID () + ".visible", visible);
+            setBooleanProperty(".visible", visible);
         }
 
         /**
@@ -175,7 +180,7 @@
         @Override
         public void setSorted (boolean sorted) {
             if (sortable) {
-                properties.setBoolean (getID () + ".sorted", sorted);
+                setBooleanProperty(".sorted", sorted);
             }
         }
 
@@ -188,10 +193,7 @@
         @Override
         public void setSortedDescending (boolean sortedDescending) {
             if (sortable) {
-                properties.setBoolean (
-                    getID () + ".sortedDescending",
-                    sortedDescending
-                 );
+                setBooleanProperty(".sortedDescending", sortedDescending);
             }
         }
 
@@ -202,7 +204,7 @@
          */
         @Override
         public int getCurrentOrderNumber () {
-            int cn = properties.getInt (getID () + ".currentOrderNumber", 
-1);
+            int cn = getIntProperty(".currentOrderNumber", -1);
             if (cn >= 0 && !properties.getBoolean("outlineOrdering", false)) 
{
                 cn++; // Shift the old TreeTable ordering, which did not 
count the first nodes column.
             }
@@ -216,10 +218,7 @@
          */
         @Override
         public void setCurrentOrderNumber (int newOrderNumber) {
-            properties.setInt (
-                getID () + ".currentOrderNumber",
-                newOrderNumber
-            );
+            setIntProperty(".currentOrderNumber", newOrderNumber);
             properties.setBoolean("outlineOrdering", true);
         }
 
@@ -230,7 +229,7 @@
          */
         @Override
         public int getColumnWidth () {
-            return properties.getInt (getID () + ".columnWidth", 150);
+            return getIntProperty(".columnWidth", 150);
         }
 
         /**
@@ -240,7 +239,7 @@
          */
         @Override
         public void setColumnWidth (int newColumnWidth) {
-            properties.setInt (getID () + ".columnWidth", newColumnWidth);
+            setIntProperty(".columnWidth", newColumnWidth);
         }
 
         /**
@@ -250,7 +249,7 @@
          */
         @Override
         public boolean isVisible () {
-            return properties.getBoolean (getID () + ".visible", 
defaultVisible);
+            return getBooleanProperty(".visible", defaultVisible);
         }
 
         @Override
@@ -266,7 +265,7 @@
         @Override
         public boolean isSorted () {
             if (sortable) {
-                return properties.getBoolean (getID () + ".sorted", false);
+                return getBooleanProperty(".sorted", false);
             } else {
                 return false;
             }
@@ -281,10 +280,7 @@
         @Override
         public boolean isSortedDescending () {
             if (sortable) {
-                return properties.getBoolean (
-                    getID () + ".sortedDescending",
-                    false
-                );
+                return getBooleanProperty(".sortedDescending", false);
             } else {
                 return false;
             }
@@ -307,6 +303,46 @@
             return useTableCellEditor ? new WatchesTableCellEditor() : null;
         }
 
+        private boolean getBooleanProperty(String propName, boolean 
defaultValue) {
+            propName = getID () + propName;
+            if (viewProperties != null &&
+                viewProperties.getBoolean(propName, true) == 
viewProperties.getBoolean(propName, false)) {
+                // it is defined in the view:
+                return viewProperties.getBoolean (propName, defaultValue);
+            } else {
+                return properties.getBoolean (propName, defaultValue);
+            }
+        }
+        
+        private void setBooleanProperty(String propName, boolean value) {
+            propName = getID () + propName;
+            if (viewProperties != null) {
+                viewProperties.setBoolean(propName, value);
+            } else {
+                properties.setBoolean(propName, value);
+            }
+        }
+        
+        private int getIntProperty(String propName, int defaultValue) {
+            propName = getID () + propName;
+            if (viewProperties != null &&
+                viewProperties.getInt(propName, 0) == 
viewProperties.getInt(propName, -1)) {
+                // it is defined in the view:
+                return viewProperties.getInt (propName, defaultValue);
+            } else {
+                return properties.getInt (propName, defaultValue);
+            }
+        }
+
+        private void setIntProperty(String propName, int value) {
+            propName = getID () + propName;
+            if (viewProperties != null) {
+                viewProperties.setInt(propName, value);
+            } else {
+                properties.setInt(propName, value);
+            }
+        }
+        
     }
 
     /**
diff --git 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/ViewModelListener.java
 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/ViewModelListener.java
--- 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/ViewModelListener.java
+++ 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/ViewModelListener.java
@@ -73,6 +73,7 @@
 import org.netbeans.api.debugger.DebuggerManager;
 import org.netbeans.api.debugger.DebuggerManagerAdapter;
 import org.netbeans.api.debugger.Session;
+import org.netbeans.modules.debugger.ui.models.ColumnModels;
 import org.netbeans.spi.debugger.ContextProvider;
 import org.netbeans.spi.debugger.SessionProvider;
 import org.netbeans.spi.debugger.ui.ViewLifecycle.ModelUpdateListener;
@@ -402,6 +403,11 @@
             }
             asynchModelFilters = cp.lookup (searchPath, 
AsynchronousModelFilter.class);
         }
+        for (Object model : columnModels) {
+            if (model instanceof ColumnModels.AbstractColumn) {
+                ((ColumnModels.AbstractColumn) model).setViewPath(viewPath);
+            }
+        }
         //rp = (e != null) ? e.lookupFirst(null, RequestProcessor.class) : 
null;
 
         if (View.LOCALS_VIEW_NAME.equals(viewType) && 
(VariablesViewButtons.isResultsViewNested() ||

[hg] main-silver: #223391: View-specific column settings introdu...

mentlicher 12/19/2012

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close