Author: dgeraskov
Date: 2008-04-08 09:11:53 -0400 (Tue, 08 Apr 2008)
New Revision: 7412
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/criteria_editor_connect.gif
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/hql_editor_connect.gif
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/criteria_editor.gif
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/hql_editor.gif
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/criteriaeditor/CriteriaEditor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2020
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/criteria_editor.gif
===================================================================
(Binary files differ)
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/criteria_editor_connect.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/criteria_editor_connect.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/hql_editor.gif
===================================================================
(Binary files differ)
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/hql_editor_connect.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/hql_editor_connect.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
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-04-08
12:31:19 UTC (rev 7411)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java 2008-04-08
13:11:53 UTC (rev 7412)
@@ -40,7 +40,6 @@
private String defPartName;
private Image defTitleImage;
private Image connectedTitleImage;
- private String connectedImageFilePath = "icons/images/connected.gif";
// to enable execution of queries from files - hack for HBX-744
private String consoleConfigurationName;
@@ -247,7 +246,7 @@
defTitleImage = getTitleImage();
setPartName(defPartName + "->" + editor.getTitle());
if (connectedTitleImage == null){
- connectedTitleImage =
HibernateConsolePlugin.getImageDescriptor(connectedImageFilePath).createImage();
+ connectedTitleImage =
HibernateConsolePlugin.getImageDescriptor(getConnectedImageFilePath()).createImage();
}
setTitleImage(connectedTitleImage);
}
@@ -261,4 +260,6 @@
}
connectedTitleImage.dispose();
}
+
+ protected abstract String getConnectedImageFilePath();
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/criteriaeditor/CriteriaEditor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/criteriaeditor/CriteriaEditor.java 2008-04-08
12:31:19 UTC (rev 7411)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/criteriaeditor/CriteriaEditor.java 2008-04-08
13:11:53 UTC (rev 7412)
@@ -202,5 +202,9 @@
control.setLayoutData( new GridData( GridData.FILL_BOTH ) );
}
-
+
+ @Override
+ protected String getConnectedImageFilePath() {
+ return "icons/images/criteria_editor_connect.gif"; //$NON-NLS-1$
+ }
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java 2008-04-08
12:31:19 UTC (rev 7411)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java 2008-04-08
13:11:53 UTC (rev 7412)
@@ -68,101 +68,101 @@
public static final String PLUGIN_NAME = HibernateConsolePlugin.ID;
public static final String HELP_CONTEXT_ID = PLUGIN_NAME + ".hqleditorhelp";
//$NON-NLS-1$
- /** The HQL code scanner, which is used for colorizing the edit text. */
- private HQLCodeScanner fHQLCodeScanner;
- /** The document setup participant object, which is used partition the edit text. */
- private HQLEditorDocumentSetupParticipant docSetupParticipant;
- /** The projection (code folding) support object. */
- private ProjectionSupport fProjectionSupport;
+ /** The HQL code scanner, which is used for colorizing the edit text. */
+ private HQLCodeScanner fHQLCodeScanner;
+ /** The document setup participant object, which is used partition the edit text. */
+ private HQLEditorDocumentSetupParticipant docSetupParticipant;
+ /** The projection (code folding) support object. */
+ private ProjectionSupport fProjectionSupport;
-
- /**
- * Constructs an instance of this class. This is the default constructor.
- */
- public HQLEditor() {
- super();
- }
-
- /**
- * Creates and installs the editor actions.
- *
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
- */
- protected void createActions() {
- super.createActions();
- ResourceBundle bundle = getResourceBundle();
-
- IAction a = new TextOperationAction( bundle,
- "ContentAssistProposal.", this,
ISourceViewer.CONTENTASSIST_PROPOSALS ); //$NON-NLS-1$
- a.setActionDefinitionId( ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS
);
- setAction( "ContentAssistProposal", a ); //$NON-NLS-1$
-
- a = new TextOperationAction( bundle, "ContentAssistTip.", this,
ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION ); //$NON-NLS-1$
- a.setActionDefinitionId(
ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION );
- setAction( "ContentAssistTip", a ); //$NON-NLS-1$
-
- a = new TextOperationAction( bundle, "ContentFormat.", this,
ISourceViewer.FORMAT ); //$NON-NLS-1$
- setAction( "ContentFormat", a ); //$NON-NLS-1$
-
- /*a = new HQLConnectAction( bundle, "HQLEditor.connectAction." );
//$NON-NLS-1$
- setAction( "HQLEditor.connectAction", a ); //$NON-NLS-1$
- */
-
- /*a = new HQLDisconnectAction( bundle, "HQLEditor.disconnectAction." );
//$NON-NLS-1$
- setAction( "HQLEditor.disconnectAction", a ); //$NON-NLS-1$
- */
-
-// a = new ExecuteQueryAction( this ); //$NON-NLS-1$
-// setAction( "HQLEditor.runAction", a ); //$NON-NLS-1$
-
- /*a = new HQLSetStatementTerminatorAction( bundle,
"HQLEditor.setStatementTerminatorAction." ); //$NON-NLS-1$
- setAction( "HQLEditor.setStatementTerminatorAction", a );
//$NON-NLS-1$
- */
- }
-
+
+ /**
+ * Constructs an instance of this class. This is the default constructor.
+ */
+ public HQLEditor() {
+ super();
+ }
+
+ /**
+ * Creates and installs the editor actions.
+ *
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
+ */
+ protected void createActions() {
+ super.createActions();
+ ResourceBundle bundle = getResourceBundle();
+
+ IAction a = new TextOperationAction( bundle,
+ "ContentAssistProposal.", this,
ISourceViewer.CONTENTASSIST_PROPOSALS ); //$NON-NLS-1$
+ a.setActionDefinitionId( ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS );
+ setAction( "ContentAssistProposal", a ); //$NON-NLS-1$
+
+ a = new TextOperationAction( bundle, "ContentAssistTip.", this,
ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION ); //$NON-NLS-1$
+ a.setActionDefinitionId(
ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION );
+ setAction( "ContentAssistTip", a ); //$NON-NLS-1$
+
+ a = new TextOperationAction( bundle, "ContentFormat.", this,
ISourceViewer.FORMAT ); //$NON-NLS-1$
+ setAction( "ContentFormat", a ); //$NON-NLS-1$
+
+ /*a = new HQLConnectAction( bundle, "HQLEditor.connectAction." );
//$NON-NLS-1$
+ setAction( "HQLEditor.connectAction", a ); //$NON-NLS-1$
+ */
+
+ /*a = new HQLDisconnectAction( bundle, "HQLEditor.disconnectAction." );
//$NON-NLS-1$
+ setAction( "HQLEditor.disconnectAction", a ); //$NON-NLS-1$
+ */
+
+ // a = new ExecuteQueryAction( this ); //$NON-NLS-1$
+ // setAction( "HQLEditor.runAction", a ); //$NON-NLS-1$
+
+ /*a = new HQLSetStatementTerminatorAction( bundle,
"HQLEditor.setStatementTerminatorAction." ); //$NON-NLS-1$
+ setAction( "HQLEditor.setStatementTerminatorAction", a ); //$NON-NLS-1$
+ */
+ }
+
private ResourceBundle getResourceBundle() {
return ResourceBundle.getBundle( Messages.BUNDLE_NAME );
}
-
+
/**
- * Creates the SWT controls for the editor.
- *
- * @see
org.eclipse.ui.texteditor.AbstractTextEditor#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- public void createPartControl( Composite parent ) {
- parent.setLayout( new GridLayout(1,false) );
-
- createToolbar(parent);
-
- super.createPartControl( parent );
-
- if (getSourceViewer() != null ){
+ * Creates the SWT controls for the editor.
+ *
+ * @see
org.eclipse.ui.texteditor.AbstractTextEditor#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl( Composite parent ) {
+ parent.setLayout( new GridLayout(1,false) );
+
+ createToolbar(parent);
+
+ super.createPartControl( parent );
+
+ if (getSourceViewer() != null ){
getSourceViewer().addTextListener(new ITextListener(){
-
+
public void textChanged(TextEvent event) {
updateExecButton();
}});
}
-
- // move to base class?
- Control control = parent.getChildren()[1];
- control.setLayoutData( new GridData( GridData.FILL_BOTH ) );
-
- setProjectionSupport( createProjectionSupport() );
-
- /* Now that we have enabled source folding, make sure everything is
- * expanded.
- */
- ProjectionViewer viewer = (ProjectionViewer) getSourceViewer();
- viewer.doOperation( ProjectionViewer.TOGGLE );
-
- /* Set a help context ID to enable F1 help. */
- getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( parent,
HELP_CONTEXT_ID );
-
- // the following is needed to make sure the editor area gets focus when editing
after query execution
- // TODO: find a better way since this is triggered on evey mouse click and key
stroke in the editor area
- StyledText textWidget = getSourceViewer().getTextWidget();
+
+ // move to base class?
+ Control control = parent.getChildren()[1];
+ control.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+ setProjectionSupport( createProjectionSupport() );
+
+ /* Now that we have enabled source folding, make sure everything is
+ * expanded.
+ */
+ ProjectionViewer viewer = (ProjectionViewer) getSourceViewer();
+ viewer.doOperation( ProjectionViewer.TOGGLE );
+
+ /* Set a help context ID to enable F1 help. */
+ getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( parent,
HELP_CONTEXT_ID );
+
+ // the following is needed to make sure the editor area gets focus when editing
after query execution
+ // TODO: find a better way since this is triggered on evey mouse click and key
stroke in the editor area
+ StyledText textWidget = getSourceViewer().getTextWidget();
textWidget.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
@@ -177,234 +177,238 @@
}
});
- }
-
- /**
- * Creates, configures, and returns a <code>ProjectionSupport</code>
- * object for this editor.
- *
- * @return the <code>ProjectSupport</code> object to use with this
editor
- */
- protected ProjectionSupport createProjectionSupport() {
- ProjectionViewer viewer = (ProjectionViewer) getSourceViewer();
- ProjectionSupport projSupport = new ProjectionSupport( viewer,
getAnnotationAccess(), getSharedColors() );
- projSupport.addSummarizableAnnotationType(
"org.eclipse.ui.workbench.texteditor.error" ); //$NON-NLS-1$
- projSupport.addSummarizableAnnotationType(
"org.eclipse.ui.workbench.texteditor.warning" ); //$NON-NLS-1$
- projSupport.install();
-
- return projSupport;
- }
-
- /**
- * Creates the source viewer to be used by this editor.
- *
- * @see
org.eclipse.ui.texteditor.AbstractTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite,
- * org.eclipse.jface.text.source.IVerticalRuler, int)
- */
- protected ISourceViewer createSourceViewer( Composite parent, IVerticalRuler ruler,
int styles ) {
- HQLSourceViewer viewer = new HQLSourceViewer( parent, ruler, getOverviewRuler(),
isOverviewRulerVisible(),
- styles );
-
- return viewer;
- }
-
- /**
- * Creates the source viewer configuation to be used by this editor.
- *
- * @return the new source viewer configuration object
- */
- protected HQLSourceViewerConfiguration createSourceViewerConfiguration() {
- HQLSourceViewerConfiguration config = new HQLSourceViewerConfiguration( this );
-
- return config;
- }
-
- /**
- * Sets the input of the outline page after this class has set input.
- *
- * @param input the new input for the editor
- * @see
org.eclipse.ui.editors.text.TextEditor#doSetInput(org.eclipse.ui.IEditorInput)
- */
- public void doSetInput( IEditorInput input ) throws CoreException {
- super.doSetInput( input );
-
- /* Make sure the document partitioner is set up. The document setup
- * participant sets up document partitioning, which is used for text
- * colorizing and other text features.
- */
- IDocumentProvider docProvider = this.getDocumentProvider();
- if (docProvider != null) {
- IDocument doc = docProvider.getDocument( input );
- if (doc != null) {
- HQLEditorDocumentSetupParticipant docSetupParticipant =
getDocumentSetupParticipant();
- docSetupParticipant.setup( doc );
- }
- }
-
- }
-
- /**
- * Sets up this editor's context menu before it is made visible.
- *
- * @see
org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- protected void editorContextMenuAboutToShow( IMenuManager menu ) {
- super.editorContextMenuAboutToShow( menu );
-
- menu.add( new Separator() );
- addAction( menu, "ContentAssistProposal" ); //$NON-NLS-1$
- addAction( menu, "ContentAssistTip" ); //$NON-NLS-1$
- addAction( menu, "ContentFormat" ); //$NON-NLS-1$
-
- menu.add( new Separator() );
- /*if (getConnectionInfo() == null) {
- addAction( menu, "HQLEditor.connectAction" ); //$NON-NLS-1$
- }
- else {
- addAction( menu, "HQLEditor.disconnectAction" ); //$NON-NLS-1$
- }*/
- addAction( menu, "HQLEditor.runAction" ); //$NON-NLS-1$
- //addAction( menu, "HQLEditor.setStatementTerminatorAction" );
//$NON-NLS-1$
- }
-
- /**
- * Gets an adapter for the given class. Returns the HQL content outline page
- * if the get request is for an outline page. Otherwise returns a projection
- * adapter if one hasn't already been created.
- *
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- * @see
org.eclipse.jface.text.source.projection.ProjectionSupport#getAdapter(org.eclipse.jface.text.source.ISourceViewer,
- * java.lang.Class)
- */
- public Object getAdapter( Class classForWhichAdapterNeeded ) {
- Object adapter = null;
-
- if(IQueryParametersPage.class.equals( classForWhichAdapterNeeded )) {
- return new QueryParametersPage(this);
- }
- /* Get and return the content outline page, if that's what's requested.
*/
- if (IContentOutlinePage.class.equals( classForWhichAdapterNeeded )) {
-// HQLEditorContentOutlinePage outlinePage = getOutlinePage();
-// if (outlinePage == null) {
-// outlinePage = createContentOutlinePage();
-// setOutlinePage( outlinePage );
-// if (getEditorInput() != null) {
-// outlinePage.setInput( getEditorInput() );
-// }
-// }
- // adapter = outlinePage;
- adapter = null;
- }
- /* Delegate getting the adapter to the projection support object,
- * if there is one. Projection refers to the ability to visibly collapse
- * and expand sections of the document.
- */
- else if (adapter == null) {
- ProjectionSupport projSupport = getProjectionSupport();
- if (projSupport != null) {
- adapter = projSupport.getAdapter( getSourceViewer(),
classForWhichAdapterNeeded );
- }
- }
-
- /* If we still don't have an adapter let the superclass handle it. */
- if (adapter == null) {
- adapter = super.getAdapter( classForWhichAdapterNeeded );
- }
-
- return adapter;
- }
-
- /**
- * Gets the document setup participant object associated with this editor.
- * The setup participant sets the partitioning type for the document.
- *
- * @return the current document setup participant
- */
- public HQLEditorDocumentSetupParticipant getDocumentSetupParticipant() {
- if (docSetupParticipant == null) {
- docSetupParticipant = new HQLEditorDocumentSetupParticipant();
- }
- return docSetupParticipant;
- }
-
-
- /**
- * Gets the <code>ProjectionSupport</code> object associated with this
- * editor.
- *
- * @return the current <code>ProjectionSupport</code> object
- */
- protected ProjectionSupport getProjectionSupport() {
- return fProjectionSupport;
- }
-
-
- /**
- * Gets the HQL source code text scanner. Creates a default one if it
- * doesn't exist yet.
- *
- * @return the HQL source code text scanner
- */
- public HQLCodeScanner getHQLCodeScanner() {
- if (fHQLCodeScanner == null) {
- fHQLCodeScanner = new HQLCodeScanner( getHQLColorProvider() );
- }
- return fHQLCodeScanner;
- }
-
-
- /**
- * Gets the color provider for colorizing HQL source code.
- *
- * @return the HQL color provider
- */
- public HQLColors getHQLColorProvider() {
- return new HQLColors();
- }
-
- /**
- * Initializes the editor.
- *
- * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor()
- */
- protected void initializeEditor() {
- super.initializeEditor();
- setSourceViewerConfiguration( createSourceViewerConfiguration() );
- setRangeIndicator( new DefaultRangeIndicator() );
- }
-
-
- /**
- * Sets the document setup participant object associated with this editor to
- * the given object. The setup participant sets the partitioning type for
- * the document.
- *
- * @return the current document setup participant
- */
- public void setDocumentSetupParticipant( HQLEditorDocumentSetupParticipant
docSetupParticipant ) {
- this.docSetupParticipant = docSetupParticipant;
- }
-
- /**
- * Sets the <code>ProjectionSupport</code> object associated with this
- * editor.
- *
- * @param projSupport the <code>ProjectionSupport</code> object to use
- */
- protected void setProjectionSupport( ProjectionSupport projSupport ) {
- fProjectionSupport = projSupport;
- }
-
+ }
- public ITextViewer getTextViewer() {
- return getSourceViewer();
- }
-
-
+ /**
+ * Creates, configures, and returns a <code>ProjectionSupport</code>
+ * object for this editor.
+ *
+ * @return the <code>ProjectSupport</code> object to use with this editor
+ */
+ protected ProjectionSupport createProjectionSupport() {
+ ProjectionViewer viewer = (ProjectionViewer) getSourceViewer();
+ ProjectionSupport projSupport = new ProjectionSupport( viewer,
getAnnotationAccess(), getSharedColors() );
+ projSupport.addSummarizableAnnotationType(
"org.eclipse.ui.workbench.texteditor.error" ); //$NON-NLS-1$
+ projSupport.addSummarizableAnnotationType(
"org.eclipse.ui.workbench.texteditor.warning" ); //$NON-NLS-1$
+ projSupport.install();
+
+ return projSupport;
+ }
+
+ /**
+ * Creates the source viewer to be used by this editor.
+ *
+ * @see
org.eclipse.ui.texteditor.AbstractTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite,
+ * org.eclipse.jface.text.source.IVerticalRuler, int)
+ */
+ protected ISourceViewer createSourceViewer( Composite parent, IVerticalRuler ruler, int
styles ) {
+ HQLSourceViewer viewer = new HQLSourceViewer( parent, ruler, getOverviewRuler(),
isOverviewRulerVisible(),
+ styles );
+
+ return viewer;
+ }
+
+ /**
+ * Creates the source viewer configuation to be used by this editor.
+ *
+ * @return the new source viewer configuration object
+ */
+ protected HQLSourceViewerConfiguration createSourceViewerConfiguration() {
+ HQLSourceViewerConfiguration config = new HQLSourceViewerConfiguration( this );
+
+ return config;
+ }
+
+ /**
+ * Sets the input of the outline page after this class has set input.
+ *
+ * @param input the new input for the editor
+ * @see org.eclipse.ui.editors.text.TextEditor#doSetInput(org.eclipse.ui.IEditorInput)
+ */
+ public void doSetInput( IEditorInput input ) throws CoreException {
+ super.doSetInput( input );
+
+ /* Make sure the document partitioner is set up. The document setup
+ * participant sets up document partitioning, which is used for text
+ * colorizing and other text features.
+ */
+ IDocumentProvider docProvider = this.getDocumentProvider();
+ if (docProvider != null) {
+ IDocument doc = docProvider.getDocument( input );
+ if (doc != null) {
+ HQLEditorDocumentSetupParticipant docSetupParticipant =
getDocumentSetupParticipant();
+ docSetupParticipant.setup( doc );
+ }
+ }
+
+ }
+
+ /**
+ * Sets up this editor's context menu before it is made visible.
+ *
+ * @see
org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
+ */
+ protected void editorContextMenuAboutToShow( IMenuManager menu ) {
+ super.editorContextMenuAboutToShow( menu );
+
+ menu.add( new Separator() );
+ addAction( menu, "ContentAssistProposal" ); //$NON-NLS-1$
+ addAction( menu, "ContentAssistTip" ); //$NON-NLS-1$
+ addAction( menu, "ContentFormat" ); //$NON-NLS-1$
+
+ menu.add( new Separator() );
+ /*if (getConnectionInfo() == null) {
+ addAction( menu, "HQLEditor.connectAction" ); //$NON-NLS-1$
+ }
+ else {
+ addAction( menu, "HQLEditor.disconnectAction" ); //$NON-NLS-1$
+ }*/
+ addAction( menu, "HQLEditor.runAction" ); //$NON-NLS-1$
+ //addAction( menu, "HQLEditor.setStatementTerminatorAction" );
//$NON-NLS-1$
+ }
+
+ /**
+ * Gets an adapter for the given class. Returns the HQL content outline page
+ * if the get request is for an outline page. Otherwise returns a projection
+ * adapter if one hasn't already been created.
+ *
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ * @see
org.eclipse.jface.text.source.projection.ProjectionSupport#getAdapter(org.eclipse.jface.text.source.ISourceViewer,
+ * java.lang.Class)
+ */
+ public Object getAdapter( Class classForWhichAdapterNeeded ) {
+ Object adapter = null;
+
+ if(IQueryParametersPage.class.equals( classForWhichAdapterNeeded )) {
+ return new QueryParametersPage(this);
+ }
+ /* Get and return the content outline page, if that's what's requested. */
+ if (IContentOutlinePage.class.equals( classForWhichAdapterNeeded )) {
+ // HQLEditorContentOutlinePage outlinePage = getOutlinePage();
+ // if (outlinePage == null) {
+ // outlinePage = createContentOutlinePage();
+ // setOutlinePage( outlinePage );
+ // if (getEditorInput() != null) {
+ // outlinePage.setInput( getEditorInput() );
+ // }
+ // }
+ // adapter = outlinePage;
+ adapter = null;
+ }
+ /* Delegate getting the adapter to the projection support object,
+ * if there is one. Projection refers to the ability to visibly collapse
+ * and expand sections of the document.
+ */
+ else if (adapter == null) {
+ ProjectionSupport projSupport = getProjectionSupport();
+ if (projSupport != null) {
+ adapter = projSupport.getAdapter( getSourceViewer(),
classForWhichAdapterNeeded );
+ }
+ }
+
+ /* If we still don't have an adapter let the superclass handle it. */
+ if (adapter == null) {
+ adapter = super.getAdapter( classForWhichAdapterNeeded );
+ }
+
+ return adapter;
+ }
+
+ /**
+ * Gets the document setup participant object associated with this editor.
+ * The setup participant sets the partitioning type for the document.
+ *
+ * @return the current document setup participant
+ */
+ public HQLEditorDocumentSetupParticipant getDocumentSetupParticipant() {
+ if (docSetupParticipant == null) {
+ docSetupParticipant = new HQLEditorDocumentSetupParticipant();
+ }
+ return docSetupParticipant;
+ }
+
+
+ /**
+ * Gets the <code>ProjectionSupport</code> object associated with this
+ * editor.
+ *
+ * @return the current <code>ProjectionSupport</code> object
+ */
+ protected ProjectionSupport getProjectionSupport() {
+ return fProjectionSupport;
+ }
+
+
+ /**
+ * Gets the HQL source code text scanner. Creates a default one if it
+ * doesn't exist yet.
+ *
+ * @return the HQL source code text scanner
+ */
+ public HQLCodeScanner getHQLCodeScanner() {
+ if (fHQLCodeScanner == null) {
+ fHQLCodeScanner = new HQLCodeScanner( getHQLColorProvider() );
+ }
+ return fHQLCodeScanner;
+ }
+
+
+ /**
+ * Gets the color provider for colorizing HQL source code.
+ *
+ * @return the HQL color provider
+ */
+ public HQLColors getHQLColorProvider() {
+ return new HQLColors();
+ }
+
+ /**
+ * Initializes the editor.
+ *
+ * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor()
+ */
+ protected void initializeEditor() {
+ super.initializeEditor();
+ setSourceViewerConfiguration( createSourceViewerConfiguration() );
+ setRangeIndicator( new DefaultRangeIndicator() );
+ }
+
+
+ /**
+ * Sets the document setup participant object associated with this editor to
+ * the given object. The setup participant sets the partitioning type for
+ * the document.
+ *
+ * @return the current document setup participant
+ */
+ public void setDocumentSetupParticipant( HQLEditorDocumentSetupParticipant
docSetupParticipant ) {
+ this.docSetupParticipant = docSetupParticipant;
+ }
+
+ /**
+ * Sets the <code>ProjectionSupport</code> object associated with this
+ * editor.
+ *
+ * @param projSupport the <code>ProjectionSupport</code> object to use
+ */
+ protected void setProjectionSupport( ProjectionSupport projSupport ) {
+ fProjectionSupport = projSupport;
+ }
+
+
+ public ITextViewer getTextViewer() {
+ return getSourceViewer();
+ }
+
+
+
+ public void executeQuery(ConsoleConfiguration cfg) {
+ cfg.executeHQLQuery(getQueryString(), getQueryInputModel().getCopyForQuery() );
+ }
- public void executeQuery(ConsoleConfiguration cfg) {
- cfg.executeHQLQuery(getQueryString(), getQueryInputModel().getCopyForQuery() );
- }
-
+ @Override
+ protected String getConnectedImageFilePath() {
+ return "icons/images/hql_editor_connect.gif"; //$NON-NLS-1$
+ }
}