[jboss-cvs] jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions ...

Max Rydahl Andersen mandersen at jboss.com
Thu Sep 21 18:58:36 EDT 2006


  User: mandersen
  Date: 06/09/21 18:58:36

  Modified:    hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions     
                        HQLScratchpadAction.java CriteriaEditorAction.java
  Added:       hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions     
                        OpenQueryEditorAction.java ExecuteQueryAction.java
  Removed:     hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions     
                        ExecuteHQLAction.java
  Log:
  HBX-763 open hql and criteria editor should always be active
  HBX-762 Show run button and console combo inside the query/criteria editor
  
  Revision  Changes    Path
  1.5       +5 -25     jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/HQLScratchpadAction.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HQLScratchpadAction.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/HQLScratchpadAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- HQLScratchpadAction.java	7 Jul 2006 13:51:09 -0000	1.4
  +++ HQLScratchpadAction.java	21 Sep 2006 22:58:36 -0000	1.5
  @@ -21,41 +21,21 @@
    */
   package org.hibernate.eclipse.console.actions;
   
  -import java.util.Iterator;
  -
  -import org.eclipse.swt.widgets.Event;
  -import org.hibernate.HibernateException;
   import org.hibernate.console.ConsoleConfiguration;
   import org.hibernate.console.ImageConstants;
   import org.hibernate.eclipse.console.HibernateConsolePlugin;
   import org.hibernate.eclipse.console.utils.EclipseImages;
   
  -public class HQLScratchpadAction extends ConsoleConfigurationBasedAction {
  +public class HQLScratchpadAction extends OpenQueryEditorAction {
   	public HQLScratchpadAction() {
   		super( "HQL Editor" );
   		setImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.HQL_EDITOR));
   		setToolTipText("Open HQL Editor");
  -		setEnabledWhenNoSessionFactory( true );
  -		setEnabled( false );
  -	}
  -
  -	public void runWithEvent(Event event) {
  -		run();
  -	}
  -
  -	protected void doRun() {
  -		for (Iterator i = getSelectedNonResources().iterator(); i.hasNext();) {
  -			try {
  -				Object node = i.next();
  -				if(node instanceof ConsoleConfiguration) {
  -					final ConsoleConfiguration config = (ConsoleConfiguration) node;
  -					HibernateConsolePlugin.getDefault().openScratchHQLEditor(config.getName(), "");
  -				}
  -			} catch(HibernateException he) {
  -				HibernateConsolePlugin.getDefault().showError(null, "Exception while trying to open HQL editor", he);
  -			}
  +		setEnabled( true );
   		} 
   					
  +	protected void openQueryEditor(ConsoleConfiguration config, String query) {
  +		HibernateConsolePlugin.getDefault().openScratchHQLEditor(config==null?null:config.getName(), query);		
   	}
   	
   }
  \ No newline at end of file
  
  
  
  1.4       +6 -26     jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CriteriaEditorAction.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CriteriaEditorAction.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CriteriaEditorAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- CriteriaEditorAction.java	7 Jul 2006 13:51:09 -0000	1.3
  +++ CriteriaEditorAction.java	21 Sep 2006 22:58:36 -0000	1.4
  @@ -21,41 +21,21 @@
    */
   package org.hibernate.eclipse.console.actions;
   
  -import java.util.Iterator;
  -
  -import org.eclipse.swt.widgets.Event;
  -import org.hibernate.HibernateException;
   import org.hibernate.console.ConsoleConfiguration;
   import org.hibernate.console.ImageConstants;
   import org.hibernate.eclipse.console.HibernateConsolePlugin;
   import org.hibernate.eclipse.console.utils.EclipseImages;
   
  -public class CriteriaEditorAction extends ConsoleConfigurationBasedAction {
  +public class CriteriaEditorAction extends OpenQueryEditorAction {
   	public CriteriaEditorAction() {
   		super( "Hibernate Criteria Editor" );
   		setImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.CRITERIA_EDITOR));
   		setToolTipText("Open Hibernate Criteria Editor");
  -		setEnabled( false );
  -		setEnabledWhenNoSessionFactory( true );
  +		setEnabled( true );		
   	}
   
  -	public void runWithEvent(Event event) {
  -		run();
  -	}
  +	protected void openQueryEditor(ConsoleConfiguration config, String query) {
  +		HibernateConsolePlugin.getDefault().openCriteriaEditor( config==null?null:config.getName(), query );
   
  -	protected void doRun() {
  -		for (Iterator i = getSelectedNonResources().iterator(); i.hasNext();) {
  -			try {
  -				Object node = i.next();
  -				if(node instanceof ConsoleConfiguration) {
  -					final ConsoleConfiguration config = (ConsoleConfiguration) node;
  -					HibernateConsolePlugin.getDefault().openCriteriaEditor(config.getName(), "");
  -				}
  -			} catch(HibernateException he) {
  -				HibernateConsolePlugin.getDefault().showError(null, "Exception while trying to start Criteria Editor", he);
  -			}
   		} 
  -					
  -	}
  -	
   }
  \ No newline at end of file
  
  
  
  1.1      date: 2006/09/21 22:58:36;  author: mandersen;  state: Exp;jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenQueryEditorAction.java
  
  Index: OpenQueryEditorAction.java
  ===================================================================
  package org.hibernate.eclipse.console.actions;
  
  import java.util.Iterator;
  
  import org.eclipse.swt.widgets.Event;
  import org.eclipse.ui.actions.SelectionListenerAction;
  import org.hibernate.HibernateException;
  import org.hibernate.console.ConsoleConfiguration;
  import org.hibernate.eclipse.console.HibernateConsolePlugin;
  
  public abstract class OpenQueryEditorAction extends SelectionListenerAction {
  
  	protected OpenQueryEditorAction(String text) {
  		super( text );
  	}
  
  	public void runWithEvent(Event event) {
  		doRun();
  	}
  
  	protected void doRun() {
  		boolean showed = false;
  		for (Iterator i = getSelectedNonResources().iterator(); i.hasNext();) {
  			try {
  				Object node = i.next();
  				if(node instanceof ConsoleConfiguration) {
  					final ConsoleConfiguration config = (ConsoleConfiguration) node;
  					openQueryEditor( config, "" );
  					showed = true;
  				} 
  			} catch(HibernateException he) {
  				HibernateConsolePlugin.getDefault().showError(null, "Exception while trying to open HQL editor", he);
  			}
  		}
  		
  		if(!showed) {
  			openQueryEditor( null, "" );			
  		}					
  	}
  
  	protected abstract void openQueryEditor(final ConsoleConfiguration config, String query);
  }
  
  
  
  1.1      date: 2006/09/21 22:58:36;  author: mandersen;  state: Exp;jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ExecuteQueryAction.java
  
  Index: ExecuteQueryAction.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  package org.hibernate.eclipse.console.actions;
  
  import org.eclipse.jface.action.Action;
  import org.eclipse.jface.action.IAction;
  import org.eclipse.swt.widgets.Event;
  import org.hibernate.console.ConsoleConfiguration;
  import org.hibernate.console.ImageConstants;
  import org.hibernate.eclipse.console.QueryEditor;
  import org.hibernate.eclipse.console.utils.EclipseImages;
  
  /**
   * @author max
   *
   */
  public class ExecuteQueryAction extends Action {
  
  	private QueryEditor editor;
  	
  	public ExecuteQueryAction() {		
  		setImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.EXECUTE) );
  		initTextAndToolTip();
  	}
  
  
  	public ExecuteQueryAction(QueryEditor editor) {
  		this();
  		setHibernateQueryEditor( editor );
  	}
  
  	public void run() {
  		execute(editor );
  	}
  	
  	public void runWithEvent(Event event) {
  		super.runWithEvent( event );
  	}
  
  	protected void execute(QueryEditor queryEditor) {
  		try {
  			ConsoleConfiguration cfg = queryEditor.getConsoleConfiguration();
  			if(cfg!=null) {
  				if (!cfg.isSessionFactoryCreated()) {
  					if (queryEditor.askUserForConfiguration(cfg.getName())) {
  						if(cfg.getConfiguration()==null) {
  							cfg.build();
  						}
  						cfg.buildSessionFactory();
  						queryEditor.executeQuery(cfg);						
  					}
  				} else {
  					queryEditor.executeQuery(cfg);					
  				}
  			} 
  		}
  		finally {			
  			initTextAndToolTip();
  		}
  		
  	}
  
  	private void initTextAndToolTip() {
  		setText("Run HQL");
  		setToolTipText("Run HQL");
  	}
  
  	public void run(IAction action) {
  		run();
  	}
  
  	public void setHibernateQueryEditor(QueryEditor editor) {
  		this.editor = editor;		
  	}
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list