This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 154176
Collapse All | Expand All

(-)db/nbproject/project.xml (-1 / +1 lines)
Lines 73-79 Link Here
73
                    <compile-dependency/>
73
                    <compile-dependency/>
74
                    <run-dependency>
74
                    <run-dependency>
75
                        <release-version>0-1</release-version>
75
                        <release-version>0-1</release-version>
76
                        <specification-version>0.3</specification-version>
76
                        <specification-version>1.2</specification-version>
77
                    </run-dependency>
77
                    </run-dependency>
78
                </dependency>
78
                </dependency>
79
                <dependency>
79
                <dependency>
(-)db/src/org/netbeans/api/db/explorer/node/Bundle.properties (-1 / +2 lines)
Lines 263-270 Link Here
263
catalogSeparator=Catalog separator
263
catalogSeparator=Catalog separator
264
Yes=Yes
264
Yes=Yes
265
No=No
265
No=No
266
System=System
267
SystemDesc=System table
266
268
267
268
# Queries
269
# Queries
269
270
270
PROP_proceduresQuery=Procedures query
271
PROP_proceduresQuery=Procedures query
(-)db/src/org/netbeans/modules/db/explorer/action/AddColumnAction.java (-2 / +9 lines)
Lines 68-76 Link Here
68
68
69
    @Override
69
    @Override
70
    protected boolean enable(Node[] activatedNodes) {
70
    protected boolean enable(Node[] activatedNodes) {
71
        boolean result = activatedNodes.length == 1 &&
71
        boolean result = false;
72
                activatedNodes[0].getLookup().lookup(TableNode.class) != null;
73
72
73
        if (activatedNodes.length == 1) {
74
            TableNode tn = activatedNodes[0].getLookup().lookup(TableNode.class);
75
76
            if (tn != null && (!tn.isSystem())) {
77
                result = true;
78
            }
79
        }
80
        
74
        return result;
81
        return result;
75
    }
82
    }
76
83
(-)db/src/org/netbeans/modules/db/explorer/action/GrabTableAction.java (-1 / +6 lines)
Lines 50-55 Link Here
50
import org.netbeans.lib.ddl.impl.Specification;
50
import org.netbeans.lib.ddl.impl.Specification;
51
import org.netbeans.modules.db.explorer.DatabaseConnection;
51
import org.netbeans.modules.db.explorer.DatabaseConnection;
52
import org.netbeans.modules.db.explorer.DbUtilities;
52
import org.netbeans.modules.db.explorer.DbUtilities;
53
import org.netbeans.modules.db.explorer.node.TableListNode;
53
import org.netbeans.modules.db.explorer.node.TableNode;
54
import org.netbeans.modules.db.explorer.node.TableNode;
54
import org.openide.DialogDisplayer;
55
import org.openide.DialogDisplayer;
55
import org.openide.NotifyDescriptor;
56
import org.openide.NotifyDescriptor;
Lines 81-88 Link Here
81
        boolean enabled = false;
82
        boolean enabled = false;
82
83
83
        if (activatedNodes.length == 1) {
84
        if (activatedNodes.length == 1) {
84
            enabled = activatedNodes[0].getLookup().lookup(TableNode.class) != null;
85
            TableNode tn = activatedNodes[0].getLookup().lookup(TableNode.class);
86
            
87
            if (tn != null && (! tn.isSystem())) {
88
                enabled = true;
85
        }
89
        }
90
        }
86
91
87
        return enabled;
92
        return enabled;
88
    }
93
    }
(-)db/src/org/netbeans/modules/db/explorer/action/RecreateTableAction.java (-1 / +4 lines)
Lines 58-63 Link Here
58
import org.netbeans.modules.db.explorer.dlg.LabeledTextFieldDialog;
58
import org.netbeans.modules.db.explorer.dlg.LabeledTextFieldDialog;
59
import org.netbeans.modules.db.explorer.node.SchemaNameProvider;
59
import org.netbeans.modules.db.explorer.node.SchemaNameProvider;
60
import org.netbeans.modules.db.explorer.node.TableListNode;
60
import org.netbeans.modules.db.explorer.node.TableListNode;
61
import org.netbeans.modules.db.explorer.node.TableNode;
61
import org.openide.DialogDisplayer;
62
import org.openide.DialogDisplayer;
62
import org.openide.NotifyDescriptor;
63
import org.openide.NotifyDescriptor;
63
import org.openide.filesystems.FileChooserBuilder;
64
import org.openide.filesystems.FileChooserBuilder;
Lines 81-89 Link Here
81
        boolean enabled = false;
82
        boolean enabled = false;
82
83
83
        if (activatedNodes.length == 1) {
84
        if (activatedNodes.length == 1) {
85
            TableNode tn = activatedNodes[0].getLookup().lookup(TableNode.class);
86
            
84
            DatabaseConnection dbconn = activatedNodes[0].getLookup().lookup(DatabaseConnection.class);
87
            DatabaseConnection dbconn = activatedNodes[0].getLookup().lookup(DatabaseConnection.class);
85
88
86
            if (dbconn != null) {
89
            if (dbconn != null && tn != null && (! tn.isSystem())) {
87
                enabled = DatabaseConnection.isVitalConnection(dbconn.getConnection(), dbconn);
90
                enabled = DatabaseConnection.isVitalConnection(dbconn.getConnection(), dbconn);
88
            }
91
            }
89
        }
92
        }
(-)db/src/org/netbeans/modules/db/explorer/node/Bundle.properties (-1 / +3 lines)
Lines 68-74 Link Here
68
ND_ProcedureParam=Stored Procedure Parameter
68
ND_ProcedureParam=Stored Procedure Parameter
69
ND_Root=Database Explorer Module Home
69
ND_Root=Database Explorer Module Home
70
ND_Schema=Schema
70
ND_Schema=Schema
71
ND_TableList=List of Tables
71
ND_TableList=List of tables
72
ND_SystemTableList=List of system tables
72
ND_Table=Table
73
ND_Table=Table
73
ND_ViewList=List of Views
74
ND_ViewList=List of Views
74
ND_View=View
75
ND_View=View
Lines 81-86 Link Here
81
ProcedureListNode_DISPLAYNAME=Procedures
82
ProcedureListNode_DISPLAYNAME=Procedures
82
RootNode_DISPLAYNAME=Databases
83
RootNode_DISPLAYNAME=Databases
83
TableListNode_DISPLAYNAME=Tables
84
TableListNode_DISPLAYNAME=Tables
85
SystemTableListNode_DISPLAYNAME=System Tables
84
ViewListNode_DISPLAYNAME=Views
86
ViewListNode_DISPLAYNAME=Views
85
87
86
StoredProcedure=Stored procedure
88
StoredProcedure=Stored procedure
(-)db/src/org/netbeans/modules/db/explorer/node/TableListNode.java (-5 / +21 lines)
Lines 61-71 Link Here
61
 */
61
 */
62
public class TableListNode extends BaseNode implements SchemaNameProvider {
62
public class TableListNode extends BaseNode implements SchemaNameProvider {
63
    private static final String NAME = "Tables"; // NOI18N
63
    private static final String NAME = "Tables"; // NOI18N
64
    private static final String SYSTEM_NAME = "SystemTables"; // NOI18N
64
    private static final String ICONBASE = "org/netbeans/modules/db/resources/folder.gif"; // NOI18N
65
    private static final String ICONBASE = "org/netbeans/modules/db/resources/folder.gif"; // NOI18N
65
    private static final String FOLDER = "TableList"; //NOI18N
66
    private static final String FOLDER = "TableList"; //NOI18N
67
    private static final String SYSTEM_FOLDER = "SystemTableList"; //NOI18N
66
68
67
    private MetadataElementHandle<Schema> schemaHandle;
69
    private MetadataElementHandle<Schema> schemaHandle;
68
    private final DatabaseConnection connection;
70
    private final DatabaseConnection connection;
71
    private final boolean system;
69
72
70
    /**
73
    /**
71
     * Create an instance of TableListNode.
74
     * Create an instance of TableListNode.
Lines 73-87 Link Here
73
     * @param dataLookup the lookup to use when creating node providers
76
     * @param dataLookup the lookup to use when creating node providers
74
     * @return the TableListNode instance
77
     * @return the TableListNode instance
75
     */
78
     */
76
    public static TableListNode create(NodeDataLookup dataLookup, NodeProvider provider) {
79
    public static TableListNode create(NodeDataLookup dataLookup, NodeProvider provider, boolean system) {
77
        TableListNode node = new TableListNode(dataLookup, provider);
80
        TableListNode node = new TableListNode(dataLookup, provider, system);
78
        node.setup();
81
        node.setup();
79
        return node;
82
        return node;
80
    }
83
    }
81
84
82
    private TableListNode(NodeDataLookup lookup, NodeProvider provider) {
85
    private TableListNode(NodeDataLookup lookup, NodeProvider provider, boolean system) {
83
        super(new ChildNodeFactory(lookup), lookup, FOLDER, provider);
86
        super(new ChildNodeFactory(lookup), lookup, system ? SYSTEM_FOLDER : FOLDER, provider);
84
        connection = getLookup().lookup(DatabaseConnection.class);
87
        this.connection = getLookup().lookup(DatabaseConnection.class);
88
        this.system = system;
85
    }
89
    }
86
    
90
    
87
    @SuppressWarnings("unchecked")
91
    @SuppressWarnings("unchecked")
Lines 91-103 Link Here
91
    
95
    
92
    @Override
96
    @Override
93
    public String getName() {
97
    public String getName() {
98
        if(system) {
94
        return NAME;
99
        return NAME;
100
        } else {
101
            return SYSTEM_NAME;
95
    }
102
    }
103
    }
96
104
97
    @Override
105
    @Override
98
    public String getDisplayName() {
106
    public String getDisplayName() {
107
        if(system) {
108
            return NbBundle.getMessage (TableListNode.class, "SystemTableListNode_DISPLAYNAME"); // NOI18N
109
        } else {
99
        return NbBundle.getMessage (TableListNode.class, "TableListNode_DISPLAYNAME"); // NOI18N
110
        return NbBundle.getMessage (TableListNode.class, "TableListNode_DISPLAYNAME"); // NOI18N
100
    }
111
    }
112
    }
101
113
102
    @Override
114
    @Override
103
    public String getIconBase() {
115
    public String getIconBase() {
Lines 106-113 Link Here
106
118
107
    @Override
119
    @Override
108
    public String getShortDescription() {
120
    public String getShortDescription() {
121
        if(system) {
122
            return NbBundle.getMessage (TableListNode.class, "ND_SystemTableList"); //NOI18N
123
        } else {
109
        return NbBundle.getMessage (TableListNode.class, "ND_TableList"); //NOI18N
124
        return NbBundle.getMessage (TableListNode.class, "ND_TableList"); //NOI18N
110
    }
125
    }
126
    }
111
127
112
    @Override
128
    @Override
113
    public HelpCtx getHelpCtx() {
129
    public HelpCtx getHelpCtx() {
(-)db/src/org/netbeans/modules/db/explorer/node/TableListNodeProvider.java (-3 / +21 lines)
Lines 61-78 Link Here
61
    private static class FactoryHolder {
61
    private static class FactoryHolder {
62
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
62
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
63
            public TableListNodeProvider createInstance(Lookup lookup) {
63
            public TableListNodeProvider createInstance(Lookup lookup) {
64
                TableListNodeProvider provider = new TableListNodeProvider(lookup);
64
                TableListNodeProvider provider = new TableListNodeProvider(lookup, false);
65
                return provider;
65
                return provider;
66
            }
66
            }
67
        };
67
        };
68
    }
68
    }
69
69
70
    private TableListNodeProvider(Lookup lookup) {
70
    // lazy initialization holder class idiom for static fields is used
71
    // for retrieving the factory
72
    public static NodeProviderFactory getSystemFactory() {
73
        return SystamFactoryHolder.FACTORY;
74
    }
75
76
    private static class SystamFactoryHolder {
77
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
78
            public TableListNodeProvider createInstance(Lookup lookup) {
79
                TableListNodeProvider provider = new TableListNodeProvider(lookup, true);
80
                return provider;
81
            }
82
        };
83
    }
84
85
    private final boolean system;
86
    
87
    private TableListNodeProvider(Lookup lookup, boolean system) {
71
        super(lookup);
88
        super(lookup);
89
        this.system = system;
72
    }
90
    }
73
91
74
    @Override
92
    @Override
75
    protected BaseNode createNode(NodeDataLookup lookup) {
93
    protected BaseNode createNode(NodeDataLookup lookup) {
76
        return TableListNode.create(lookup, this);
94
        return TableListNode.create(lookup, this, system);
77
    }
95
    }
78
}
96
}
(-)db/src/org/netbeans/modules/db/explorer/node/TableNode.java (-2 / +10 lines)
Lines 80-85 Link Here
80
public class TableNode extends BaseNode implements SchemaNameProvider {
80
public class TableNode extends BaseNode implements SchemaNameProvider {
81
    private static final String ICONBASE = "org/netbeans/modules/db/resources/table.gif"; // NOI18N
81
    private static final String ICONBASE = "org/netbeans/modules/db/resources/table.gif"; // NOI18N
82
    private static final String FOLDER = "Table"; //NOI18N
82
    private static final String FOLDER = "Table"; //NOI18N
83
    private static final String SYSTEM = "System";
84
    private static final String SYSTEMDESC = "SystemDesc";
83
    private static final Map<Node, Object> NODES_TO_REFRESH =
85
    private static final Map<Node, Object> NODES_TO_REFRESH =
84
            new WeakHashMap<Node, Object>();
86
            new WeakHashMap<Node, Object>();
85
87
Lines 96-101 Link Here
96
    }
98
    }
97
99
98
    private String name = ""; // NOI18N
100
    private String name = ""; // NOI18N
101
    private boolean system = false;
99
    private final MetadataElementHandle<Table> tableHandle;
102
    private final MetadataElementHandle<Table> tableHandle;
100
    private final DatabaseConnection connection;
103
    private final DatabaseConnection connection;
101
104
Lines 122-128 Link Here
122
                                return ;
125
                                return ;
123
                            }
126
                            }
124
                            name = table.getName();
127
                            name = table.getName();
125
128
                            system = table.isSystem();
126
                            updateProperties(table);
129
                            updateProperties(table);
127
                        }
130
                        }
128
                    }
131
                    }
Lines 140-145 Link Here
140
143
141
        addProperty(CATALOG, CATALOGDESC, String.class, false, getCatalogName());
144
        addProperty(CATALOG, CATALOGDESC, String.class, false, getCatalogName());
142
        addProperty(SCHEMA, SCHEMADESC, String.class, false, getSchemaName());
145
        addProperty(SCHEMA, SCHEMADESC, String.class, false, getSchemaName());
146
        addProperty(SYSTEM, SYSTEMDESC, Boolean.class, false, isSystem());
143
    }
147
    }
144
148
145
    public MetadataElementHandle<Table> getTableHandle() {
149
    public MetadataElementHandle<Table> getTableHandle() {
Lines 184-190 Link Here
184
    @Override
188
    @Override
185
    public boolean canDestroy() {
189
    public boolean canDestroy() {
186
        DatabaseConnector connector = connection.getConnector();
190
        DatabaseConnector connector = connection.getConnector();
187
        return connector.supportsCommand(Specification.DROP_TABLE);
191
        return (! system) && connector.supportsCommand(Specification.DROP_TABLE);
188
    }
192
    }
189
193
190
    @Override
194
    @Override
Lines 202-207 Link Here
202
        return ICONBASE;
206
        return ICONBASE;
203
    }
207
    }
204
208
209
    public boolean isSystem() {
210
        return system;
211
    }
212
205
    @Override
213
    @Override
206
    public String getShortDescription() {
214
    public String getShortDescription() {
207
        return NbBundle.getMessage (TableNode.class, "ND_Table"); //NOI18N
215
        return NbBundle.getMessage (TableNode.class, "ND_Table"); //NOI18N
(-)db/src/org/netbeans/modules/db/explorer/node/TableNodeProvider.java (-3 / +24 lines)
Lines 75-92 Link Here
75
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
75
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
76
            @Override
76
            @Override
77
            public TableNodeProvider createInstance(Lookup lookup) {
77
            public TableNodeProvider createInstance(Lookup lookup) {
78
                TableNodeProvider provider = new TableNodeProvider(lookup);
78
                TableNodeProvider provider = new TableNodeProvider(lookup, false);
79
                return provider;
79
                return provider;
80
            }
80
            }
81
        };
81
        };
82
    }
82
    }
83
83
84
    // lazy initialization holder class idiom for static fields is used
85
    // for retrieving the factory
86
    public static NodeProviderFactory getSystemFactory() {
87
        return SystemFactoryHolder.FACTORY;
88
    }
89
90
    private static class SystemFactoryHolder {
91
        static final NodeProviderFactory FACTORY = new NodeProviderFactory() {
92
            @Override
93
            public TableNodeProvider createInstance(Lookup lookup) {
94
                TableNodeProvider provider = new TableNodeProvider(lookup, true);
95
                return provider;
96
            }
97
        };
98
    }
99
84
    private final DatabaseConnection connection;
100
    private final DatabaseConnection connection;
101
    private final boolean system;
85
    private MetadataElementHandle<Schema> schemaHandle;
102
    private MetadataElementHandle<Schema> schemaHandle;
86
103
87
    @SuppressWarnings("unchecked")
104
    @SuppressWarnings("unchecked")
88
    private TableNodeProvider(Lookup lookup) {
105
    private TableNodeProvider(Lookup lookup, boolean system) {
89
        super(lookup, new TableComparator());
106
        super(lookup, new TableComparator());
107
        this.system = system;
90
        connection = getLookup().lookup(DatabaseConnection.class);
108
        connection = getLookup().lookup(DatabaseConnection.class);
91
        schemaHandle = getLookup().lookup(MetadataElementHandle.class);
109
        schemaHandle = getLookup().lookup(MetadataElementHandle.class);
92
    }
110
    }
Lines 108-113 Link Here
108
                            if (schema != null) {
126
                            if (schema != null) {
109
                                Collection<Table> tables = schema.getTables();
127
                                Collection<Table> tables = schema.getTables();
110
                                for (Table table : tables) {
128
                                for (Table table : tables) {
129
                                    if( ((! system) && table.isSystem()) ||
130
                                            (system && (! table.isSystem()))) {
131
                                        continue;
132
                                    }
111
                                    MetadataElementHandle<Table> handle = MetadataElementHandle.create(table);
133
                                    MetadataElementHandle<Table> handle = MetadataElementHandle.create(table);
112
                                    Collection<Node> matches = getNodes(handle);
134
                                    Collection<Node> matches = getNodes(handle);
113
                                    if (matches.size() > 0) {
135
                                    if (matches.size() > 0) {
Lines 116-122 Link Here
116
                                        NodeDataLookup lookup = new NodeDataLookup();
138
                                        NodeDataLookup lookup = new NodeDataLookup();
117
                                        lookup.add(connection);
139
                                        lookup.add(connection);
118
                                        lookup.add(handle);
140
                                        lookup.add(handle);
119
120
                                        newList.add(TableNode.create(lookup, TableNodeProvider.this));
141
                                        newList.add(TableNode.create(lookup, TableNodeProvider.this));
121
                                    }
142
                                    }
122
                                }
143
                                }
(-)db/src/org/netbeans/modules/db/resources/mf-layer.xml (+26 lines)
Lines 189-194 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>
192
                    <file name="ViewListNodeProviderFactory.instance">
197
                    <file name="ViewListNodeProviderFactory.instance">
193
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.db.explorer.node.ViewListNodeProvider.getFactory"/>
198
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.db.explorer.node.ViewListNodeProvider.getFactory"/>
194
                        <attr name="instanceOf" stringvalue="org.netbeans.api.db.explorer.node.NodeProviderFactory"/>
199
                        <attr name="instanceOf" stringvalue="org.netbeans.api.db.explorer.node.NodeProviderFactory"/>
Lines 243-248 Link Here
243
                    </file>
248
                    </file>
244
                </folder>
249
                </folder>
245
            </folder>
250
            </folder>
251
            <folder name="SystemTableList">
252
                <folder name="NodeProviders">
253
                    <file name="TableNodeProviderFactory.instance">
254
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.db.explorer.node.TableNodeProvider.getSystemFactory"/>
255
                        <attr name="instanceOf" stringvalue="org.netbeans.api.db.explorer.node.NodeProviderFactory"/>
256
                        <attr name="position" intvalue="100"/>
257
                    </file>
258
                </folder>
259
                <folder name="Actions">
260
                    <file name="org-netbeans-modules-db-explorer-action-ExecuteCommandAction.instance">
261
                        <attr name="position" intvalue="250"/>
262
                    </file>
263
                    <file name="Separator2.instance">
264
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
265
                        <attr name="position" intvalue="300"/>
266
                    </file>
267
                    <file name="org-netbeans-modules-db-explorer-action-RefreshAction.instance">
268
                        <attr name="position" intvalue="350"/>
269
                    </file>
270
                </folder>
271
            </folder>
246
            <folder name="Table">
272
            <folder name="Table">
247
                <folder name="NodeProviders">
273
                <folder name="NodeProviders">
248
                    <file name="ColumnNodeProviderFactory.instance">
274
                    <file name="ColumnNodeProviderFactory.instance">

Return to bug 154176