Author: dgeraskov
Date: 2008-07-09 09:25:33 -0400 (Wed, 09 Jul 2008)
New Revision: 9105
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ClearAction.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2270
'Clear' button removed from toolbar and menu.
'Clear' button added to the editor's toolbar.
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2008-07-09
13:19:02 UTC (rev 9104)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2008-07-09
13:25:33 UTC (rev 9105)
@@ -289,28 +289,29 @@
<part id="org.hibernate.eclipse.criteriaeditor.CriteriaEditor"/>
</actionSetPartAssociation>
</extension>
- <extension
+ <!--extension
point="org.eclipse.ui.editorActions">
<editorContribution
id="org.hibernate.eclipse.hqleditor.HQLEditorContributions"
targetID="org.hibernate.eclipse.hqleditor.HQLEditor">
<action
- actionID="clearEditor"
-
class="org.hibernate.eclipse.console.actions.ClearHQLEditorAction"
- icon="icons/images/clear.gif"
-
id="org.hibernate.eclipse.console.actions.ClearHQLEditorAction"
- label="&Clear HQL Editor"
- menubarPath="HQL/hqlGroup"
- style="push"
- toolbarPath="hqlGroup"
- tooltip="Clear HQL Editor"/>
+ actionID="clearEditor"
+
class="org.hibernate.eclipse.console.actions.ClearHQLEditorAction"
+ icon="icons/images/clear.gif"
+ id="org.hibernate.eclipse.console.actions.ClearHQLEditorAction"
+ label="&Clear HQL Editor"
+ menubarPath="HQL/hqlGroup"
+ style="push"
+ toolbarPath="hqlGroup"
+ tooltip="Clear HQL Editor">
+ </action>
<menu
id="HQL"
label="H&QL">
<separator name="hqlGroup"/>
</menu>
</editorContribution>
- </extension>
+ </extension-->
<extension
point = "org.eclipse.ui.elementFactories">
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java 2008-07-09
13:19:02 UTC (rev 9104)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java 2008-07-09
13:25:33 UTC (rev 9105)
@@ -29,6 +29,7 @@
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.QueryInputModel;
+import org.hibernate.eclipse.console.actions.ClearAction;
import org.hibernate.eclipse.console.actions.ExecuteQueryAction;
public abstract class AbstractQueryEditor extends TextEditor implements
@@ -36,6 +37,7 @@
private ToolBarManager tbm;
private ExecuteQueryAction execAction = null;
+ private ClearAction clearAction = null;
final private QueryInputModel queryInputModel;
private String defPartName;
@@ -143,20 +145,17 @@
tbm = new ToolBarManager( bar );
execAction = new ExecuteQueryAction( this );
- //getDocumentProvider().addElementStateListener(listener)
- /*getSourceViewer().addTextListener(new ITextListener(){
+ clearAction = new ClearAction( this );
- public void textChanged(TextEvent event) {
- System.out.println(event.getText());
+ ActionContributionItem item = new ActionContributionItem( execAction );
- }});*/
- ActionContributionItem item = new ActionContributionItem(
- execAction );
-
tbm.add( item );
+
+ item = new ActionContributionItem( clearAction );
+ tbm.add( item );
ControlContribution cc = new ConfigurationCombo( "hql-target", this );
//$NON-NLS-1$
- tbm.add( cc );
+ tbm.add( cc );
tbm.add( new Separator() );
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ClearAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ClearAction.java 2008-07-09
13:19:02 UTC (rev 9104)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ClearAction.java 2008-07-09
13:25:33 UTC (rev 9105)
@@ -22,11 +22,13 @@
package org.hibernate.eclipse.console.actions;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.hibernate.console.ImageConstants;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.utils.EclipseImages;
@@ -38,6 +40,7 @@
public class ClearAction extends Action {
private ITextViewer fViewer;
+ private ITextEditor fTextEditor;
/**
* Constructs an action to clear the document associated with a text viewer.
@@ -55,6 +58,12 @@
//setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_CLEAR));
//PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
IConsoleHelpContextIds.CLEAR_CONSOLE_ACTION);
}
+
+ public ClearAction(ITextEditor textEditor) {
+ fTextEditor = textEditor;
+ setImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.CLEAR) );
+ setToolTipText(HibernateConsoleMessages.ClearAction_clear_editor);
+ }
/* (non-Javadoc)
* @see org.eclipse.jface.action.IAction#run()
@@ -62,11 +71,19 @@
public void run() {
BusyIndicator.showWhile(getStandardDisplay(), new Runnable() {
public void run() {
- IDocument document = fViewer.getDocument();
+ IDocument document = null;
+ if (fViewer != null){
+ document = fViewer.getDocument();
+ } else {
+ Assert.isNotNull(fTextEditor);
+ Assert.isNotNull(fTextEditor.getDocumentProvider());
+ Assert.isNotNull(fTextEditor.getEditorInput());
+ document =
fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput());
+ }
if (document != null) {
document.set(""); //$NON-NLS-1$
}
- fViewer.setSelectedRange(0, 0);
+ if (fViewer != null) fViewer.setSelectedRange(0, 0);
}
});
}