Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 154176 | Differences between
and this patch

Collapse All | Expand All

(-)a/db/src/org/netbeans/api/db/explorer/node/Bundle.properties (+2 lines)
 Lines 144-149    Link Here 
144
KeySeqDescription=Keyseq
144
KeySeqDescription=Keyseq
145
ConnectionProperties=Connection properties
145
ConnectionProperties=Connection properties
146
ConnectionPropertiesDescription=Connection properties
146
ConnectionPropertiesDescription=Connection properties
147
SeparateSystemTables=Show system tables separately
148
SeparateSystemTablesDescription=Use special node for system tables
147
149
148
# Booleans
150
# Booleans
149
151
(-)a/db/src/org/netbeans/modules/db/explorer/DatabaseConnection.java (+12 lines)
 Lines 164-169    Link Here 
164
     */
164
     */
165
    private Properties connectionProperties = new Properties();
165
    private Properties connectionProperties = new Properties();
166
166
167
    private volatile boolean separateSystemTables = false;
168
167
    /**
169
    /**
168
     * The API DatabaseConnection (delegates to this instance)
170
     * The API DatabaseConnection (delegates to this instance)
169
     */
171
     */
 Lines 1335-1338    Link Here 
1335
    public boolean isImportantCatalog(String database) {
1337
    public boolean isImportantCatalog(String database) {
1336
        return importantCatalogs != null && importantCatalogs.contains(database);
1338
        return importantCatalogs != null && importantCatalogs.contains(database);
1337
    }
1339
    }
1340
1341
    public boolean isSeparateSystemTables() {
1342
        return separateSystemTables;
1343
    }
1344
1345
    public void setSeparateSystemTables(boolean separateSystemTables) {
1346
        boolean oldVal = this.separateSystemTables;
1347
        this.separateSystemTables = separateSystemTables;
1348
        propertySupport.firePropertyChange("separateSystemTables", oldVal, separateSystemTables); //NOI18N
1349
    }
1338
}
1350
}
(-)a/db/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertor.java (+8 lines)
 Lines 252-257    Link Here 
252
        for (String importantDatabase : handler.importantCatalogs) {
252
        for (String importantDatabase : handler.importantCatalogs) {
253
            dbconn.addImportantCatalog(importantDatabase);
253
            dbconn.addImportantCatalog(importantDatabase);
254
        }
254
        }
255
        dbconn.setSeparateSystemTables(handler.separateSystemTables);
255
        LOGGER.fine("Created DatabaseConnection[" + dbconn.toString() + "] from file: " + handler.connectionFileName);
256
        LOGGER.fine("Created DatabaseConnection[" + dbconn.toString() + "] from file: " + handler.connectionFileName);
256
257
257
        return dbconn;
258
        return dbconn;
 Lines 431-436    Link Here 
431
                    pw.println("  </connection-property>");             //NOI18N
432
                    pw.println("  </connection-property>");             //NOI18N
432
                }
433
                }
433
            }
434
            }
435
            if (instance.isSeparateSystemTables()) {
436
                pw.println("  <separate-system-tables value='true'/>"); //NOI18N
437
            }
434
            pw.println("</connection>"); //NOI18N
438
            pw.println("</connection>"); //NOI18N
435
        }        
439
        }        
436
    }
440
    }
 Lines 450-455    Link Here 
450
        private static final String ELEMENT_IMPORTANT_SCHEMA = "important-schema"; //NOI18N
454
        private static final String ELEMENT_IMPORTANT_SCHEMA = "important-schema"; //NOI18N
451
        private static final String ELEMENT_IMPORTANT_CATALOG = "important-catalog"; //NOI18N
455
        private static final String ELEMENT_IMPORTANT_CATALOG = "important-catalog"; //NOI18N
452
        private static final String ELEMENT_CONNECTION_PROPERTY = "connection-property"; // NOI18N
456
        private static final String ELEMENT_CONNECTION_PROPERTY = "connection-property"; // NOI18N
457
        private static final String ELEMENT_SEPARATE_SYS_TABLES = "separate-system-tables"; //NOI18N
453
        private static final String ELEMENT_CONNECTION_PROPERTY_NAME = "name"; // NOI18N
458
        private static final String ELEMENT_CONNECTION_PROPERTY_NAME = "name"; // NOI18N
454
        private static final String ELEMENT_CONNECTION_PROPERTY_VALUE = "value"; // NOI18N
459
        private static final String ELEMENT_CONNECTION_PROPERTY_VALUE = "value"; // NOI18N
455
        private static final String ATTR_PROPERTY_VALUE = "value"; // NOI18N
460
        private static final String ATTR_PROPERTY_VALUE = "value"; // NOI18N
 Lines 467-472    Link Here 
467
        String user;
472
        String user;
468
        String displayName;
473
        String displayName;
469
        Properties connectionProperties;
474
        Properties connectionProperties;
475
        boolean separateSystemTables = false;
470
        List<String> importantSchemas = new ArrayList<String>();
476
        List<String> importantSchemas = new ArrayList<String>();
471
        List<String> importantCatalogs = new ArrayList<String>();
477
        List<String> importantCatalogs = new ArrayList<String>();
472
        
478
        
 Lines 534-539    Link Here 
534
                importantSchemas.add(value);
540
                importantSchemas.add(value);
535
            } else if (ELEMENT_IMPORTANT_CATALOG.equals(qName)) {
541
            } else if (ELEMENT_IMPORTANT_CATALOG.equals(qName)) {
536
                importantCatalogs.add(value);
542
                importantCatalogs.add(value);
543
            } else if (ELEMENT_SEPARATE_SYS_TABLES.equals(qName)) {
544
                separateSystemTables = Boolean.parseBoolean(value);
537
            }
545
            }
538
        }
546
        }
539
547
(-)a/db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java (+9 lines)
 Lines 73-78    Link Here 
73
import org.openide.util.HelpCtx;
73
import org.openide.util.HelpCtx;
74
import org.openide.util.NbBundle;
74
import org.openide.util.NbBundle;
75
import org.openide.util.RequestProcessor;
75
import org.openide.util.RequestProcessor;
76
import org.openide.util.WeakListeners;
76
import org.openide.util.actions.SystemAction;
77
import org.openide.util.actions.SystemAction;
77
import org.openide.util.datatransfer.ExTransferable;
78
import org.openide.util.datatransfer.ExTransferable;
78
79
 Lines 86-91    Link Here 
86
    private static final String DISCONNECTEDICONBASE = "org/netbeans/modules/db/resources/connectionDisconnected.gif"; // NOI18N
87
    private static final String DISCONNECTEDICONBASE = "org/netbeans/modules/db/resources/connectionDisconnected.gif"; // NOI18N
87
    private static final String CONNECTIONPROPERTIES = "ConnectionProperties"; //NOI18N
88
    private static final String CONNECTIONPROPERTIES = "ConnectionProperties"; //NOI18N
88
    private static final String CONNECTIONPROPERTIESDESC = "ConnectionPropertiesDescription"; //NOI18N
89
    private static final String CONNECTIONPROPERTIESDESC = "ConnectionPropertiesDescription"; //NOI18N
90
    private static final String SEPARATESYSTEMTABLES = "SeparateSystemTables"; //NOI18N
91
    private static final String SEPARATESYSTEMTABLESDESC = "SeparateSystemTablesDescription"; //NOI18N
89
    private static final String FOLDER = "Connection"; // NOI18N
92
    private static final String FOLDER = "Connection"; // NOI18N
90
    private static final RequestProcessor RP = new RequestProcessor(ConnectionNode.class.getName());
93
    private static final RequestProcessor RP = new RequestProcessor(ConnectionNode.class.getName());
91
    
94
    
 Lines 103-108    Link Here 
103
    
106
    
104
    // the connection
107
    // the connection
105
    private final DatabaseConnection connection;
108
    private final DatabaseConnection connection;
109
    private PropertyChangeListener propertyChangeListener;
106
110
107
    /**
111
    /**
108
     * Constructor
112
     * Constructor
 Lines 167-172    Link Here 
167
            refreshNode = false;
171
            refreshNode = false;
168
        } else if (nps.getName().equals(CONNECTIONPROPERTIES)) {
172
        } else if (nps.getName().equals(CONNECTIONPROPERTIES)) {
169
            connection.setConnectionProperties((Properties) val);
173
            connection.setConnectionProperties((Properties) val);
174
        } else if (nps.getName().equals(SEPARATESYSTEMTABLES)
175
                && val instanceof Boolean) {
176
            connection.setSeparateSystemTables((Boolean) val);
177
            refreshNode = false;
170
        }
178
        }
171
179
172
        super.setPropertyValue(nps, val);
180
        super.setPropertyValue(nps, val);
 Lines 188-193    Link Here 
188
            addProperty(USER, USERDESC, String.class, !connected, connection.getUser());
196
            addProperty(USER, USERDESC, String.class, !connected, connection.getUser());
189
            addProperty(REMEMBERPW, REMEMBERPWDESC,
197
            addProperty(REMEMBERPW, REMEMBERPWDESC,
190
                    Boolean.class, !connected, connection.rememberPassword());
198
                    Boolean.class, !connected, connection.rememberPassword());
199
            addProperty(SEPARATESYSTEMTABLES, SEPARATESYSTEMTABLESDESC, Boolean.class, true, connection.isSeparateSystemTables());
191
            addProperty(CONNECTIONPROPERTIES, CONNECTIONPROPERTIESDESC, Properties.class, !connected, connection.getConnectionProperties());
200
            addProperty(CONNECTIONPROPERTIES, CONNECTIONPROPERTIESDESC, Properties.class, !connected, connection.getConnectionProperties());
192
            Property<?> ps = getSheet().get(Sheet.PROPERTIES).get(CONNECTIONPROPERTIES);
201
            Property<?> ps = getSheet().get(Sheet.PROPERTIES).get(CONNECTIONPROPERTIES);
193
            ps.setValue("canEditAsText", Boolean.FALSE);                //NOI18N
202
            ps.setValue("canEditAsText", Boolean.FALSE);                //NOI18N
(-)a/db/src/org/netbeans/modules/db/explorer/node/TableListNode.java (-21 / +34 lines)
 Lines 60-65    Link Here 
60
 * @author Rob Englander
60
 * @author Rob Englander
61
 */
61
 */
62
public class TableListNode extends BaseNode implements SchemaNameProvider {
62
public class TableListNode extends BaseNode implements SchemaNameProvider {
63
64
    public enum Type {
65
66
        SYSTEM, STANDARD, ALL
67
    }
68
63
    private static final String NAME = "Tables"; // NOI18N
69
    private static final String NAME = "Tables"; // NOI18N
64
    private static final String SYSTEM_NAME = "SystemTables"; // NOI18N
70
    private static final String SYSTEM_NAME = "SystemTables"; // NOI18N
65
    private static final String ICONBASE = "org/netbeans/modules/db/resources/folder.gif"; // NOI18N
71
    private static final String ICONBASE = "org/netbeans/modules/db/resources/folder.gif"; // NOI18N
 Lines 68-74    Link Here 
68
74
69
    private MetadataElementHandle<Schema> schemaHandle;
75
    private MetadataElementHandle<Schema> schemaHandle;
70
    private final DatabaseConnection connection;
76
    private final DatabaseConnection connection;
71
    private final boolean system;
77
    private final Type type;
72
78
73
    /**
79
    /**
74
     * Create an instance of TableListNode.
80
     * Create an instance of TableListNode.
 Lines 76-91    Link Here 
76
     * @param dataLookup the lookup to use when creating node providers
82
     * @param dataLookup the lookup to use when creating node providers
77
     * @return the TableListNode instance
83
     * @return the TableListNode instance
78
     */
84
     */
79
    public static TableListNode create(NodeDataLookup dataLookup, NodeProvider provider, boolean system) {
85
    public static TableListNode create(NodeDataLookup dataLookup, NodeProvider provider, Type type) {
80
        TableListNode node = new TableListNode(dataLookup, provider, system);
86
        TableListNode node = new TableListNode(dataLookup, provider, type);
81
        node.setup();
87
        node.setup();
82
        return node;
88
        return node;
83
    }
89
    }
84
90
85
    private TableListNode(NodeDataLookup lookup, NodeProvider provider, boolean system) {
91
    private TableListNode(NodeDataLookup lookup, NodeProvider provider, Type type) {
86
        super(new ChildNodeFactory(lookup), lookup, system ? SYSTEM_FOLDER : FOLDER, provider);
92
        super(new ChildNodeFactory(lookup), lookup, Type.SYSTEM.equals(type) ? SYSTEM_FOLDER : FOLDER, provider);
87
        this.connection = getLookup().lookup(DatabaseConnection.class);
93
        this.connection = getLookup().lookup(DatabaseConnection.class);
88
        this.system = system;
94
        this.type = type;
89
    }
95
    }
90
    
96
    
91
    @SuppressWarnings("unchecked")
97
    @SuppressWarnings("unchecked")
 Lines 95-114    Link Here 
95
    
101
    
96
    @Override
102
    @Override
97
    public String getName() {
103
    public String getName() {
98
        if(system) {
104
        switch (type) {
99
        return NAME;
105
            case SYSTEM:
100
        } else {
106
                return SYSTEM_NAME;
101
            return SYSTEM_NAME;
107
            default:
102
    }
108
                return NAME;
109
        }
103
    }
110
    }
104
111
105
    @Override
112
    @Override
106
    public String getDisplayName() {
113
    public String getDisplayName() {
107
        if(system) {
114
        switch (type) {
108
            return NbBundle.getMessage (TableListNode.class, "SystemTableListNode_DISPLAYNAME"); // NOI18N
115
            case SYSTEM:
109
        } else {
116
                return NbBundle.getMessage(TableListNode.class, "SystemTableListNode_DISPLAYNAME"); // NOI18N
110
        return NbBundle.getMessage (TableListNode.class, "TableListNode_DISPLAYNAME"); // NOI18N
117
            default:
111
    }
118
                return NbBundle.getMessage(TableListNode.class, "TableListNode_DISPLAYNAME"); // NOI18N
119
        }
112
    }
120
    }
113
121
114
    @Override
122
    @Override
 Lines 118-128    Link Here 
118
126
119
    @Override
127
    @Override
120
    public String getShortDescription() {
128
    public String getShortDescription() {
121
        if(system) {
129
        switch (type) {
122
            return NbBundle.getMessage (TableListNode.class, "ND_SystemTableList"); //NOI18N
130
            case SYSTEM:
123
        } else {
131
                return NbBundle.getMessage(TableListNode.class, "ND_SystemTableList"); //NOI18N
124
        return NbBundle.getMessage (TableListNode.class, "ND_TableList"); //NOI18N
132
            default:
125
    }
133
                return NbBundle.getMessage(TableListNode.class, "ND_TableList"); //NOI18N
134
        }
126
    }
135
    }
127
136
128
    @Override
137
    @Override
 Lines 182-185    Link Here 
182
191
183
        return array[0];
192
        return array[0];
184
    }
193
    }
194
195
    public Type getType() {
196
        return type;
197
    }
185
}
198
}
(-)a/db/src/org/netbeans/modules/db/explorer/node/TableListNodeProvider.java (-25 / +84 lines)
 Lines 42-96    Link Here 
42
42
43
package org.netbeans.modules.db.explorer.node;
43
package org.netbeans.modules.db.explorer.node;
44
44
45
import org.netbeans.api.db.explorer.node.BaseNode;
45
import java.beans.PropertyChangeEvent;
46
import java.beans.PropertyChangeListener;
47
import java.util.ArrayList;
48
import java.util.Comparator;
49
import java.util.List;
50
import org.netbeans.api.db.explorer.node.NodeProvider;
46
import org.netbeans.api.db.explorer.node.NodeProviderFactory;
51
import org.netbeans.api.db.explorer.node.NodeProviderFactory;
52
import org.netbeans.modules.db.explorer.DatabaseConnection;
53
import org.netbeans.modules.db.explorer.node.TableListNode.Type;
54
import org.netbeans.modules.db.metadata.model.api.MetadataElementHandle;
55
import org.netbeans.modules.db.metadata.model.api.Schema;
56
import org.openide.nodes.Node;
47
import org.openide.util.Lookup;
57
import org.openide.util.Lookup;
58
import org.openide.util.WeakListeners;
48
59
49
/**
60
/**
50
 *
61
 *
51
 * @author Rob Englander
62
 * @author Rob Englander
52
 */
63
 */
53
public class TableListNodeProvider extends ConnectedNodeProvider {
64
public class TableListNodeProvider extends NodeProvider {
54
    
65
    
66
    private final DatabaseConnection connection;
67
    private PropertyChangeListener propertyChangeListener;
68
    private boolean setup = false;
69
55
    // lazy initialization holder class idiom for static fields is used
70
    // lazy initialization holder class idiom for static fields is used
56
    // for retrieving the factory
71
    // for retrieving the factory
57
    public static NodeProviderFactory getFactory() {
72
    public static NodeProviderFactory getFactory() {
58
        return FactoryHolder.FACTORY;
73
        return FactoryHolder.FACTORY;
59
    }
74
    }
60
75
76
    @Override
77
    protected void initialize() {
78
        if (connection.getConnector().isDisconnected()) {
79
            removeAllNodes();
80
            setup = false;
81
        } else {
82
            if (!setup) {
83
                setNodesForCurrentSettings();
84
                setup = true;
85
            }
86
        }
87
        if (propertyChangeListener == null) {
88
            propertyChangeListener = new PropertyChangeListener() {
89
90
                @Override
91
                public void propertyChange(PropertyChangeEvent evt) {
92
                    if (evt.getPropertyName().equals("separateSystemTables")) { //NOI18N
93
                        setNodesForCurrentSettings();
94
                    }
95
                }
96
            };
97
            connection.addPropertyChangeListener(WeakListeners.propertyChange(
98
                    propertyChangeListener, connection));
99
        }
100
    }
101
102
    private void setNodesForCurrentSettings() {
103
        List<Node> newList = new ArrayList<>();
104
        if (connection.isSeparateSystemTables()) {
105
            newList.add(TableListNode.create(createLookup(), this, Type.STANDARD));
106
            newList.add(TableListNode.create(createLookup(), this, Type.SYSTEM));
107
        } else {
108
            newList.add(TableListNode.create(createLookup(), this, Type.ALL));
109
        }
110
        setNodes(newList);
111
    }
112
113
    /**
114
     * Create a lookup for TableListNode. Each TableListNode needs a unique
115
     * lookup, because it will be used as key for the node.
116
     */
117
    private NodeDataLookup createLookup() {
118
        NodeDataLookup lookup = new NodeDataLookup();
119
        lookup.add(connection);
120
121
        MetadataElementHandle<Schema> schemaHandle = getLookup().lookup(MetadataElementHandle.class);
122
        if (schemaHandle != null) {
123
            lookup.add(schemaHandle);
124
        }
125
        return lookup;
126
    }
127
61
    private static class FactoryHolder {
128
    private static class FactoryHolder {
62
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
129
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
130
            @Override
63
            public TableListNodeProvider createInstance(Lookup lookup) {
131
            public TableListNodeProvider createInstance(Lookup lookup) {
64
                TableListNodeProvider provider = new TableListNodeProvider(lookup, false);
132
                TableListNodeProvider provider = new TableListNodeProvider(lookup);
65
                return provider;
133
                return provider;
66
            }
134
            }
67
        };
135
        };
68
    }
136
    }
69
137
70
    // lazy initialization holder class idiom for static fields is used
138
    private TableListNodeProvider(Lookup lookup) {
71
    // for retrieving the factory
139
        super(lookup, new TableListNodeComparator());
72
    public static NodeProviderFactory getSystemFactory() {
140
        connection = getLookup().lookup(DatabaseConnection.class);
73
        return SystamFactoryHolder.FACTORY;
74
    }
141
    }
75
142
76
    private static class SystamFactoryHolder {
143
    private static class TableListNodeComparator implements Comparator<Node> {
77
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
144
78
            public TableListNodeProvider createInstance(Lookup lookup) {
145
        @Override
79
                TableListNodeProvider provider = new TableListNodeProvider(lookup, true);
146
        public int compare(Node o1, Node o2) {
80
                return provider;
147
            if (o1 instanceof TableListNode && o2 instanceof TableListNode) {
148
                return (((TableListNode) o1).getType().equals(Type.SYSTEM))
149
                        ? 1 : -1;
150
            } else {
151
                return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
81
            }
152
            }
82
        };
153
        }
83
    }
84
85
    private final boolean system;
86
    
87
    private TableListNodeProvider(Lookup lookup, boolean system) {
88
        super(lookup);
89
        this.system = system;
90
    }
91
92
    @Override
93
    protected BaseNode createNode(NodeDataLookup lookup) {
94
        return TableListNode.create(lookup, this, system);
95
    }
154
    }
96
}
155
}
(-)a/db/src/org/netbeans/modules/db/explorer/node/TableNodeProvider.java (-2 / +2 lines)
 Lines 126-133    Link Here 
126
                            if (schema != null) {
126
                            if (schema != null) {
127
                                Collection<Table> tables = schema.getTables();
127
                                Collection<Table> tables = schema.getTables();
128
                                for (Table table : tables) {
128
                                for (Table table : tables) {
129
                                    if( ((! system) && table.isSystem()) ||
129
                                    if (connection.isSeparateSystemTables() && ((!system) && table.isSystem())
130
                                            (system && (! table.isSystem()))) {
130
                                            || (system && (!table.isSystem()))) {
131
                                        continue;
131
                                        continue;
132
                                    }
132
                                    }
133
                                    MetadataElementHandle<Table> handle = MetadataElementHandle.create(table);
133
                                    MetadataElementHandle<Table> handle = MetadataElementHandle.create(table);
(-)a/db/src/org/netbeans/modules/db/resources/mf-layer.xml (-5 lines)
 Lines 189-199    Link Here 
189
                        <attr name="instanceOf" stringvalue="org.netbeans.api.db.explorer.node.NodeProviderFactory"/>
189
                        <attr name="instanceOf" stringvalue="org.netbeans.api.db.explorer.node.NodeProviderFactory"/>
190
                        <attr name="position" intvalue="200"/>
190
                        <attr name="position" intvalue="200"/>
191
                    </file>
191
                    </file>
192
                    <file name="TableListNodeProviderFactory2.instance">
193
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.db.explorer.node.TableListNodeProvider.getSystemFactory"/>
194
                        <attr name="instanceOf" stringvalue="org.netbeans.api.db.explorer.node.NodeProviderFactory"/>
195
                        <attr name="position" intvalue="225"/>
196
                    </file>
197
                    <file name="ViewListNodeProviderFactory.instance">
192
                    <file name="ViewListNodeProviderFactory.instance">
198
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.db.explorer.node.ViewListNodeProvider.getFactory"/>
193
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.db.explorer.node.ViewListNodeProvider.getFactory"/>
199
                        <attr name="instanceOf" stringvalue="org.netbeans.api.db.explorer.node.NodeProviderFactory"/>
194
                        <attr name="instanceOf" stringvalue="org.netbeans.api.db.explorer.node.NodeProviderFactory"/>

Return to bug 154176
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo