Author: vyemialyanchyk
Date: 2009-12-30 11:09:08 -0500 (Wed, 30 Dec 2009)
New Revision: 19619
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/pindown.png
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/pinup.png
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/StickResTabAction.java
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/HibernateConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
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
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/HQLQueryPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ImageConstants.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ImageMap.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/JavaPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/QueryPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4451 - fixed
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/HQLQueryPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/HQLQueryPage.java 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/HQLQueryPage.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -118,6 +118,10 @@
public String getQueryString() {
return queryString; // cannot use query since it might be null because of an error!
}
+ public void setQueryString(String queryString) {
+ this.queryString = queryString;
+ list = null;
+ }
public List<String> getPathNames() {
List<String> l = Collections.emptyList();
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ImageConstants.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ImageConstants.java 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ImageConstants.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -125,4 +125,10 @@
public static final String RELOAD = "images/reload.gif"; //$NON-NLS-1$
public static final String ERROR = "images/error.gif"; //$NON-NLS-1$
+ public static final String PINUP = "PINUP"; //$NON-NLS-1$
+ public static final String PINUP_PATH = "images/pinup.png"; //$NON-NLS-1$
+
+ public static final String PINDOWN = "PINDOWN"; //$NON-NLS-1$
+ public static final String PINDOWN_PATH = "images/pindown.png"; //$NON-NLS-1$
+
}
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ImageMap.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ImageMap.java 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ImageMap.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -75,6 +75,8 @@
declareRegistryImage(CHECKBOX_FULL, "images/xpl/complete_tsk.gif");
//$NON-NLS-1$
declareRegistryImage(RELOAD, "images/reload.gif"); //$NON-NLS-1$
declareRegistryImage(ERROR, "images/error.gif"); //$NON-NLS-1$
+ declareRegistryImage(PINUP, PINUP_PATH);
+ declareRegistryImage(PINDOWN, PINDOWN_PATH);
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/JavaPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/JavaPage.java 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/JavaPage.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -151,6 +151,11 @@
public String getQueryString() {
return criteriaCode;
}
+ public void setQueryString(String queryString) {
+ this.criteriaCode = queryString;
+ list = null;
+ ip = null;
+ }
public void release() {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/QueryPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/QueryPage.java 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/QueryPage.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -60,6 +60,7 @@
* @return
*/
public abstract String getQueryString();
+ public abstract void setQueryString(String str);
/**
* @return
*/
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/pindown.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/pindown.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/pinup.png
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/pinup.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
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 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.hibernate.eclipse.console;
import java.io.File;
@@ -45,7 +55,6 @@
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.ide.FileStoreEditorInput;
-import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
import org.eclipse.ui.internal.editors.text.NLSUtility;
import org.eclipse.ui.part.FileEditorInput;
@@ -55,6 +64,7 @@
import org.hibernate.console.QueryInputModel;
import org.hibernate.eclipse.console.actions.ClearAction;
import org.hibernate.eclipse.console.actions.ExecuteQueryAction;
+import org.hibernate.eclipse.console.actions.StickResTabAction;
public abstract class AbstractQueryEditor extends TextEditor implements
QueryEditor, IShowEditorInput {
@@ -62,6 +72,7 @@
private ToolBarManager tbm;
private ExecuteQueryAction execAction = null;
private ClearAction clearAction = null;
+ private StickResTabAction stickResTabAction = null;
final private QueryInputModel queryInputModel;
private String defPartName;
@@ -71,6 +82,8 @@
// to enable execution of queries from files - hack for HBX-744
private String consoleConfigurationName;
+ protected boolean pinToOneResTab = false;
+
public AbstractQueryEditor() {
queryInputModel = new QueryInputModel();
}
@@ -187,9 +200,9 @@
tbm = new ToolBarManager( bar );
execAction = new ExecuteQueryAction( this );
clearAction = new ClearAction( this );
+ stickResTabAction = new StickResTabAction( this );
ActionContributionItem item = new ActionContributionItem( execAction );
-
tbm.add( item );
item = new ActionContributionItem( clearAction );
@@ -270,6 +283,10 @@
};
tbm.add(cc);
+ tbm.add( new Separator() );
+ item = new ActionContributionItem( stickResTabAction );
+ tbm.add( item );
+
tbm.update( true );
}
@@ -313,6 +330,7 @@
* @see
org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#performSaveAs(IProgressMonitor)
* the same method except line:
"dialog.setOriginalName(getSaveAsFileExtension());"
*/
+ @SuppressWarnings("restriction")
protected void performSaveAs(IProgressMonitor progressMonitor) {
Shell shell= getSite().getShell();
final IEditorInput input= getEditorInput();
@@ -457,4 +475,12 @@
}
return false;
}
+
+ public boolean getPinToOneResTab() {
+ return pinToOneResTab;
+ }
+
+ public void setPinToOneResTab(boolean pinToOneResTab) {
+ this.pinToOneResTab = pinToOneResTab;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -45,6 +45,7 @@
public static String BuildSessionFactoryAction_exception_while_start_hibernate;
public static String BuildSessionFactoryAction_start_hibernate_resulted;
public static String ClearAction_clear_editor;
+ public static String StickResTabAction_stick_editor;
public static String CloseQueryPageAction_close_query_page;
public static String ConsoleConfigurationBasedAction_problem_while_executing;
public static String CriteriaEditorAction_hibernate_criteria_editor;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-12-30
16:09:08 UTC (rev 19619)
@@ -38,6 +38,7 @@
BuildSessionFactoryAction_exception_while_start_hibernate=Exception while
connecting/starting Hibernate
BuildSessionFactoryAction_start_hibernate_resulted=Starting Hibernate resulted in a
UnsupportedClassVersionError.\nThis can occur if you are running eclipse with JDK 1.4 and
your domain classes require JDK 1.5. \n\nResolution: Run eclipse with JDK 1.5.
ClearAction_clear_editor=Clear editor
+StickResTabAction_stick_editor=Stick results to one tab
CloseQueryPageAction_close_query_page=Close query page
ConsoleConfigurationBasedAction_problem_while_executing=Problem while executing {0}
({1})
CriteriaEditorAction_hibernate_criteria_editor=Hibernate Criteria Editor
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/StickResTabAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/StickResTabAction.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/StickResTabAction.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.AbstractQueryEditor;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+
+/**
+ * Actor to pin/unpin query results tab to the editor.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class StickResTabAction extends Action {
+
+ private ITextViewer fViewer;
+ private ITextEditor fTextEditor;
+
+ public StickResTabAction(ITextViewer viewer) {
+ super(HibernateConsoleMessages.StickResTabAction_stick_editor, AS_CHECK_BOX);
+ fViewer = viewer;
+ setToolTipText(HibernateConsoleMessages.StickResTabAction_stick_editor);
+ AbstractQueryEditor queryEditor = getQueryEditor();
+ boolean checked = false;
+ if (queryEditor != null) {
+ checked = queryEditor.getPinToOneResTab();
+ }
+ setChecked(checked);
+ setImageDescriptor(EclipseImages.getImageDescriptor(
+ checked ? ImageConstants.PINDOWN : ImageConstants.PINUP));
+ }
+
+ public StickResTabAction(ITextEditor textEditor) {
+ super(HibernateConsoleMessages.StickResTabAction_stick_editor, AS_CHECK_BOX);
+ fTextEditor = textEditor;
+ setToolTipText(HibernateConsoleMessages.StickResTabAction_stick_editor);
+ AbstractQueryEditor queryEditor = getQueryEditor();
+ boolean checked = false;
+ if (queryEditor != null) {
+ checked = queryEditor.getPinToOneResTab();
+ }
+ setChecked(checked);
+ setImageDescriptor(EclipseImages.getImageDescriptor(
+ checked ? ImageConstants.PINDOWN : ImageConstants.PINUP));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+ setImageDescriptor(EclipseImages.getImageDescriptor(
+ isChecked() ? ImageConstants.PINDOWN : ImageConstants.PINUP));
+ AbstractQueryEditor queryEditor = getQueryEditor();
+ if (queryEditor != null) {
+ queryEditor.setPinToOneResTab(isChecked());
+ }
+ }
+
+ public AbstractQueryEditor getQueryEditor() {
+ if (fTextEditor instanceof AbstractQueryEditor) {
+ return (AbstractQueryEditor)fTextEditor;
+ }
+ if (fViewer instanceof AbstractQueryEditor) {
+ return (AbstractQueryEditor)fViewer;
+ }
+ return null;
+ }
+}
\ No newline at end of file
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 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/criteriaeditor/CriteriaEditor.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -56,8 +56,12 @@
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.TextOperationAction;
+import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.console.QueryPage;
+import org.hibernate.console.execution.ExecutionContext.Command;
import org.hibernate.eclipse.console.AbstractQueryEditor;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
@@ -125,6 +129,8 @@
return docSetupParticipant;
}
+ protected QueryPage queryPage = null;
+
public void executeQuery(ConsoleConfiguration cfg) {
final IWorkbenchPage activePage = getEditorSite().getPage();
try {
@@ -133,7 +139,21 @@
// ignore
}
- cfg.executeBSHQuery(getQueryString(), getQueryInputModel().getCopyForQuery() );
+ if (queryPage == null || !getPinToOneResTab()) {
+ queryPage = cfg.executeBSHQuery(getQueryString(),
getQueryInputModel().getCopyForQuery() );
+ } else {
+ final ConsoleConfiguration cfg0 = cfg;
+ cfg.execute(new Command() {
+ public Object execute() {
+ KnownConfigurations.getInstance().getQueryPageModel().remove(queryPage);
+ Session session = cfg0.getSessionFactory().openSession();
+ queryPage.setQueryString(getQueryString());
+ queryPage.setSession(session);
+ KnownConfigurations.getInstance().getQueryPageModel().add(queryPage);
+ return null;
+ }
+ });
+ }
}
protected IEvaluationContext getEvaluationContext(IJavaProject project) {
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 2009-12-30
14:32:39 UTC (rev 19618)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java 2009-12-30
16:09:08 UTC (rev 19619)
@@ -53,7 +53,11 @@
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.hibernate.Session;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.console.QueryPage;
+import org.hibernate.console.execution.ExecutionContext.Command;
import org.hibernate.eclipse.console.AbstractQueryEditor;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
@@ -406,19 +410,32 @@
return getSourceViewer();
}
+ protected QueryPage queryPage = null;
+ public void executeQuery(ConsoleConfiguration cfg) {
+ final IWorkbenchPage activePage = getEditorSite().getPage();
+ try {
+ activePage.showView(QueryPageTabView.ID);
+ } catch (PartInitException e) {
+ // ignore
+ }
+ if (queryPage == null || !getPinToOneResTab()) {
+ queryPage = cfg.executeHQLQuery(getQueryString(),
getQueryInputModel().getCopyForQuery() );
+ } else {
+ final ConsoleConfiguration cfg0 = cfg;
+ cfg.execute(new Command() {
+ public Object execute() {
+ KnownConfigurations.getInstance().getQueryPageModel().remove(queryPage);
+ Session session = cfg0.getSessionFactory().openSession();
+ queryPage.setQueryString(getQueryString());
+ queryPage.setSession(session);
+ KnownConfigurations.getInstance().getQueryPageModel().add(queryPage);
+ return null;
+ }
+ });
+ }
+ }
- public void executeQuery(ConsoleConfiguration cfg) {
- final IWorkbenchPage activePage = getEditorSite().getPage();
- try {
- activePage.showView(QueryPageTabView.ID);
- } catch (PartInitException e) {
- // ignore
- }
-
- cfg.executeHQLQuery(getQueryString(), getQueryInputModel().getCopyForQuery() );
- }
-
@Override
protected String getConnectedImageFilePath() {
return "icons/images/hql_editor_connect.gif"; //$NON-NLS-1$