# HG changeset patch # User Matthias Bläsing # Date 1330790544 -3600 # Branch dbfixes # Node ID 791b32b7935781f250c7d7da7c01875f91573968 # Parent ca6b87487dc0982c7678a135c2d6d75644a1b8e5 Implement actionPerformed(ActionEvent ae) to fix problem running SQLs after netbeans was shutdown (CTRL-SHIFT-E shortcut) - Fixes also the Run SQL Selection case) diff --git a/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/actions/SQLExecutionBaseAction.java b/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/actions/SQLExecutionBaseAction.java --- a/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/actions/SQLExecutionBaseAction.java +++ b/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/actions/SQLExecutionBaseAction.java @@ -41,7 +41,6 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.db.sql.editor.ui.actions; import java.awt.Component; @@ -76,7 +75,7 @@ public SQLExecutionBaseAction() { initialize(); - + // allow subclasses to set the name for the "master" action if (getValue(Action.NAME) == null) { putValue(Action.NAME, getDisplayName(null)); @@ -86,7 +85,7 @@ putValue("iconBase", iconBase); } } - + protected void initialize() { // allows subclasses to e.g. set noIconInMenu } @@ -107,7 +106,18 @@ protected abstract void actionPerformed(SQLExecution sqlExecution); + @Override public void actionPerformed(ActionEvent e) { + SQLExecution sqlExecution = null; + if (e.getSource() instanceof Lookup.Provider) { + Lookup l = ((Lookup.Provider) e.getSource()).getLookup(); + sqlExecution = l.lookup(SQLExecution.class); + } else if (e.getSource() instanceof Lookup) { + sqlExecution = ((Lookup) e.getSource()).lookup(SQLExecution.class); + } + if (sqlExecution != null) { + actionPerformed(sqlExecution); + } } public Action createContextAwareInstance(Lookup actionContext) { @@ -128,7 +138,6 @@ private final SQLExecutionBaseAction parent; private final Lookup.Result result; - private SQLExecution sqlExecution; private PropertyChangeListener listener; @@ -137,6 +146,7 @@ result = actionContext.lookup(new Lookup.Template(SQLExecution.class)); result.addLookupListener(new LookupListener() { + public void resultChanged(LookupEvent ev) { ContextAwareDelegate.this.resultChanged(); } @@ -159,8 +169,9 @@ Iterator iterator = result.allInstances().iterator(); if (iterator.hasNext()) { - setSQLExecution((SQLExecution)iterator.next()); + setSQLExecution((SQLExecution) iterator.next()); listener = new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { propertyChanged(evt.getPropertyName()); } @@ -181,6 +192,7 @@ private void propertyChanged(String propertyName) { if (propertyName == null || SQLExecution.PROP_EXECUTING.equals(propertyName)) { Mutex.EVENT.readAccess(new Runnable() { + public void run() { boolean enabled = false; SQLExecution sqlExecution = getSQLExecution();