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 208901
Collapse All | Expand All

(-)a/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/actions/SQLExecutionBaseAction.java (-5 / +17 lines)
Lines 41-47 Link Here
41
 * Version 2 license, then the option applies only if the new code is
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
45
package org.netbeans.modules.db.sql.editor.ui.actions;
44
package org.netbeans.modules.db.sql.editor.ui.actions;
46
45
47
import java.awt.Component;
46
import java.awt.Component;
Lines 76-82 Link Here
76
75
77
    public SQLExecutionBaseAction() {
76
    public SQLExecutionBaseAction() {
78
        initialize();
77
        initialize();
79
        
78
80
        // allow subclasses to set the name for the "master" action
79
        // allow subclasses to set the name for the "master" action
81
        if (getValue(Action.NAME) == null) {
80
        if (getValue(Action.NAME) == null) {
82
            putValue(Action.NAME, getDisplayName(null));
81
            putValue(Action.NAME, getDisplayName(null));
Lines 86-92 Link Here
86
            putValue("iconBase", iconBase);
85
            putValue("iconBase", iconBase);
87
        }
86
        }
88
    }
87
    }
89
    
88
90
    protected void initialize() {
89
    protected void initialize() {
91
        // allows subclasses to e.g. set noIconInMenu
90
        // allows subclasses to e.g. set noIconInMenu
92
    }
91
    }
Lines 107-113 Link Here
107
106
108
    protected abstract void actionPerformed(SQLExecution sqlExecution);
107
    protected abstract void actionPerformed(SQLExecution sqlExecution);
109
108
109
    @Override
110
    public void actionPerformed(ActionEvent e) {
110
    public void actionPerformed(ActionEvent e) {
111
        SQLExecution sqlExecution = null;
112
        if (e.getSource() instanceof Lookup.Provider) {
113
            Lookup l = ((Lookup.Provider) e.getSource()).getLookup();
114
            sqlExecution = l.lookup(SQLExecution.class);
115
        } else if (e.getSource() instanceof Lookup) {
116
            sqlExecution = ((Lookup) e.getSource()).lookup(SQLExecution.class);
117
        }
118
        if (sqlExecution != null) {
119
            actionPerformed(sqlExecution);
120
        }
111
    }
121
    }
112
122
113
    public Action createContextAwareInstance(Lookup actionContext) {
123
    public Action createContextAwareInstance(Lookup actionContext) {
Lines 128-134 Link Here
128
138
129
        private final SQLExecutionBaseAction parent;
139
        private final SQLExecutionBaseAction parent;
130
        private final Lookup.Result<SQLExecution> result;
140
        private final Lookup.Result<SQLExecution> result;
131
132
        private SQLExecution sqlExecution;
141
        private SQLExecution sqlExecution;
133
        private PropertyChangeListener listener;
142
        private PropertyChangeListener listener;
134
143
Lines 137-142 Link Here
137
146
138
            result = actionContext.lookup(new Lookup.Template<SQLExecution>(SQLExecution.class));
147
            result = actionContext.lookup(new Lookup.Template<SQLExecution>(SQLExecution.class));
139
            result.addLookupListener(new LookupListener() {
148
            result.addLookupListener(new LookupListener() {
149
140
                public void resultChanged(LookupEvent ev) {
150
                public void resultChanged(LookupEvent ev) {
141
                    ContextAwareDelegate.this.resultChanged();
151
                    ContextAwareDelegate.this.resultChanged();
142
                }
152
                }
Lines 159-166 Link Here
159
169
160
            Iterator<? extends SQLExecution> iterator = result.allInstances().iterator();
170
            Iterator<? extends SQLExecution> iterator = result.allInstances().iterator();
161
            if (iterator.hasNext()) {
171
            if (iterator.hasNext()) {
162
                setSQLExecution((SQLExecution)iterator.next());
172
                setSQLExecution((SQLExecution) iterator.next());
163
                listener = new PropertyChangeListener() {
173
                listener = new PropertyChangeListener() {
174
164
                    public void propertyChange(PropertyChangeEvent evt) {
175
                    public void propertyChange(PropertyChangeEvent evt) {
165
                        propertyChanged(evt.getPropertyName());
176
                        propertyChanged(evt.getPropertyName());
166
                    }
177
                    }
Lines 181-186 Link Here
181
        private void propertyChanged(String propertyName) {
192
        private void propertyChanged(String propertyName) {
182
            if (propertyName == null || SQLExecution.PROP_EXECUTING.equals(propertyName)) {
193
            if (propertyName == null || SQLExecution.PROP_EXECUTING.equals(propertyName)) {
183
                Mutex.EVENT.readAccess(new Runnable() {
194
                Mutex.EVENT.readAccess(new Runnable() {
195
184
                    public void run() {
196
                    public void run() {
185
                        boolean enabled = false;
197
                        boolean enabled = false;
186
                        SQLExecution sqlExecution = getSQLExecution();
198
                        SQLExecution sqlExecution = getSQLExecution();

Return to bug 208901