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

Max Rydahl Andersen mandersen at jboss.com
Mon Oct 23 09:22:55 EDT 2006


  User: mandersen
  Date: 06/10/23 09:22:55

  Modified:    hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards   
                        ConsoleConfigurationWizardPage.java
                        UpDownListComposite.java
                        ConsoleConfigurationCreationWizard.java
  Log:
  HBX-597 New Hibernate Configuration wizard is missing the Classpath list
  HBX-786 Remove the requirement for users to specify the classpath
  
  Revision  Changes    Path
  1.23      +142 -27   jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConsoleConfigurationWizardPage.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -b -r1.22 -r1.23
  --- ConsoleConfigurationWizardPage.java	15 Sep 2006 09:19:17 -0000	1.22
  +++ ConsoleConfigurationWizardPage.java	23 Oct 2006 13:22:55 -0000	1.23
  @@ -65,6 +65,8 @@
   import org.eclipse.swt.widgets.Button;
   import org.eclipse.swt.widgets.Composite;
   import org.eclipse.swt.widgets.Label;
  +import org.eclipse.swt.widgets.TabFolder;
  +import org.eclipse.swt.widgets.TabItem;
   import org.eclipse.swt.widgets.Table;
   import org.eclipse.swt.widgets.TableItem;
   import org.eclipse.swt.widgets.Text;
  @@ -73,6 +75,8 @@
   import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
   import org.hibernate.eclipse.console.HibernateConsolePlugin;
   import org.hibernate.eclipse.console.utils.DialogSelectionHelper;
  +import org.hibernate.eclipse.console.utils.ProjectUtils;
  +import org.hibernate.util.StringHelper;
   import org.xml.sax.EntityResolver;
   
   /**
  @@ -85,6 +89,7 @@
   	private Text propertyFileText;
   	private Text configurationFileText;
   	private Text configurationNameText;
  +	private Text projectNameText;
   	private EclipseConsoleConfiguration oldConfiguaration = null;
   	private Button enableAnnotations; 
   	
  @@ -96,6 +101,7 @@
   	private boolean configurationFileWillBeCreated;
   	private Button confbutton;
   	private Button entbutton;
  +	private Button useProjectClassPath;
   	
   	/**
   	 * Constructor for SampleNewWizardPage.
  @@ -112,14 +118,15 @@
   	 * @see IDialogPage#createControl(Composite)
   	 */
   	public void createControl(Composite parent) {
  -		Composite container = new Composite(parent, SWT.NULL);
  +		TabFolder folder = new TabFolder(parent,SWT.TOP);
  +		
  +		//Composite container = new Composite(parent, SWT.NULL);
  +				
   		GridLayout layout = new GridLayout();
  -		container.setLayout(layout);
  +		//container.setLayout(layout);
   		layout.numColumns = 3;
   		layout.verticalSpacing = 9;		
   		
  -		Label label;
  -		Button button;
   		GridData gd;
   		
   		ModifyListener modifyListener = new ModifyListener() {
  @@ -128,6 +135,37 @@
   			}
   		};
   		
  +		
  +		Composite general = createGeneral( folder, modifyListener );		
  +		TabItem item = new TabItem(folder, SWT.NONE);
  +		item.setControl( general );
  +		item.setText( "General" );
  +		
  +		Composite composite = buildClassPathTable(folder);
  +		item = new TabItem(folder, SWT.NONE);
  +		item.setControl( composite );
  +		item.setText( "Classpath" );
  +		
  +		composite = buildMappingFileTable(folder);
  +		item = new TabItem(folder, SWT.NONE);
  +		item.setControl( composite );
  +		item.setText( "Mappings" );
  +		
  +		initialize();
  +		dialogChanged();
  +		setControl(folder);
  +	}
  +
  +	private Composite createGeneral(Composite parent, ModifyListener modifyListener) {
  +		Composite container = new Composite(parent, SWT.NULL);
  +		GridLayout gridLayout = new GridLayout();
  +		gridLayout.numColumns = 3;
  +		gridLayout.verticalSpacing = 9;		
  +		
  +		container.setLayout(gridLayout);
  +		Label label;
  +		Button button;
  +		GridData gd;
   		label = new Label(container, SWT.NULL);
   		label.setText("&Name:");
   		
  @@ -138,6 +176,25 @@
   		configurationNameText.addModifyListener(modifyListener);
   				
   		label = new Label(container, SWT.NULL);
  +		label.setText("Pro&ject:");
  +		
  +		projectNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
  +		gd = new GridData(GridData.FILL_HORIZONTAL);
  +		projectNameText.setLayoutData(gd);
  +		projectNameText.addModifyListener(modifyListener);
  +		
  +		
  +		button = new Button(container, SWT.PUSH);
  +		button.setText("Browse...");
  +		button.addSelectionListener(new SelectionAdapter() {
  +			public void widgetSelected(SelectionEvent e) {
  +				handleProjectBrowse();
  +			}
  +		});
  +		
  +		
  +		
  +		label = new Label(container, SWT.NULL);
   		label.setText("&Property file:");
   		
   		propertyFileText = new Text(container, SWT.BORDER | SWT.SINGLE);
  @@ -201,15 +258,7 @@
   			}
   		});		
   				
  -		UpDownListComposite composite = buildMappingFileTable(container);
  -		gd = createGridData();
  -		composite.setLayoutData(gd);
  -		composite = buildClassPathTable(container);
  -		gd = createGridData();
  -		composite.setLayoutData(gd);
  -		initialize();
  -		dialogChanged();
  -		setControl(container);
  +		return container;
   	}
   
   	protected void handleEntityResolverBrowse() {
  @@ -230,8 +279,14 @@
   	}
   	
   	
  -	private UpDownListComposite buildClassPathTable(Composite parent) {
  -		classPathViewer = new UpDownListComposite(parent, SWT.NONE, "Classpath (only add path for POJO and driver - No Hibernate jars!)") {
  +	private Composite buildClassPathTable(Composite parent) {
  +		Composite c = new Composite(parent, SWT.None);
  +		GridLayout gridLayout = new GridLayout();
  +		gridLayout.numColumns = 1;
  +		gridLayout.verticalSpacing = 9;
  +		c.setLayout( gridLayout );
  +		
  +		classPathViewer = new UpDownListComposite(c, SWT.NONE, "Additional classpath (Hibernate jars not necessary!)") {
   			protected Object[] handleAdd(int idx) {
   
   				TableItem[] items = getTable().getItems();
  @@ -261,7 +316,29 @@
   			}
   			
   		};
  -		return classPathViewer; 
  +		GridData gd = new GridData();
  +		gd.grabExcessHorizontalSpace = true;
  +		gd.grabExcessVerticalSpace = true;
  +		gd.verticalAlignment = GridData.FILL;
  +		gd.horizontalAlignment = GridData.FILL;
  +		classPathViewer.setLayoutData( gd );
  +		
  +		useProjectClassPath = new Button(c, SWT.CHECK);
  +		useProjectClassPath.setSelection( true );
  +		useProjectClassPath.setText("Include default classpath from project");
  +		useProjectClassPath.addSelectionListener(new SelectionListener() {
  +		
  +			public void widgetDefaultSelected(SelectionEvent e) {
  +				dialogChanged();
  +			}
  +		
  +			public void widgetSelected(SelectionEvent e) {
  +				dialogChanged();		
  +			}
  +		});
  +		
  +		
  +		return c; 
   	}
   
   	private UpDownListComposite buildMappingFileTable(Composite parent) {
  @@ -282,6 +359,14 @@
   				dialogChanged();
   			}
   		};
  +		
  +		GridData gd;
  +		gd = new GridData(GridData.FILL_BOTH);
  +		
  +		gd.horizontalSpan = 3;
  +		gd.verticalSpan = 1;
  +		
  +		mappingFilesViewer.setLayoutData( gd );
   		return mappingFilesViewer;
   	}
   	
  @@ -325,8 +410,7 @@
   			} else if(proxy.getType() == IResource.FOLDER) {
   				if(javaProject!=null) {
   					if(javaProject.getOutputLocation().isPrefixOf(fullPath) ) {
  -						classpath.add(fullPath);
  -						//System.out.println("SKIPPING " + proxy.getName() );
  +						//classpath.add(fullPath);
   						return false; // skip output locations
   					}
   				}
  @@ -382,22 +466,27 @@
                       v.javaProject = JavaCore.create(project);
                   }
                   
  -				if(v.javaProject!=null) configurationNameText.setText(v.javaProject.getElementName() );
  +				if(v.javaProject!=null) {
  +					configurationNameText.setText(v.javaProject.getElementName() );
  +					projectNameText.setText(v.javaProject.getElementName());
  +				}
   				if (v.propertyFile!=null) propertyFileText.setText(v.propertyFile.toOSString() );
   				if (v.configFile!=null) configurationFileText.setText(v.configFile.toOSString() );
   				if (!v.mappings.isEmpty() ) mappingFilesViewer.add(v.mappings.toArray(), false);
   				if (!v.classpath.isEmpty() ) classPathViewer.add(v.classpath.toArray(), false);
  +				useProjectClassPath.setSelection( true );
   
  -                
  -				if(v.javaProject!=null) {
  -					classPathViewer.add(locateTypes(v.javaProject).toArray(), false);				
  -				}
  +				//if(v.javaProject!=null) {
  +					//classPathViewer.add(locateTypes(v.javaProject).toArray(), false);				
  +				//}
   			} else if (obj instanceof EclipseConsoleConfiguration) {
   				// trying to edit an EXISTING consoleconfiguration
   				EclipseConsoleConfiguration cc = (EclipseConsoleConfiguration) obj;
   				EclipseConsoleConfigurationPreferences prefs = (EclipseConsoleConfigurationPreferences) cc.getPreferences();
   				
   				configurationNameText.setText(prefs.getName() );
  +				if(prefs.getProjectName()!=null) projectNameText.setText( prefs.getProjectName() );
  +				useProjectClassPath.setSelection( prefs.useProjectClasspath() );
   				if(prefs.getPropertyFilename()!=null) propertyFileText.setText(prefs.getPropertyFilename().toOSString() );
   				if(prefs.getCfgFile()!=null) configurationFileText.setText(prefs.getCfgFile().toOSString() );
   				if(prefs.getMappings()!=null) mappingFilesViewer.add(prefs.getMappings(),false);
  @@ -405,6 +494,7 @@
   				if(prefs.getEntityResolverName()!=null) entityResolverClassNameText.setText(prefs.getEntityResolverName());
   				enableAnnotations.setSelection(prefs.useAnnotations());
   				
  +				
   				oldConfiguaration = cc;
   			}
   			
  @@ -487,12 +577,22 @@
   	}
   
   	private void handlePropertyFileBrowse() {
  -		IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(),  getPropertyFilePath(), new IPath[0], "Select property file", "Choose file to use as hibernate.properties", new String[] {"properties"}, false, false, true);
  +		IPath[] paths = org.hibernate.eclipse.console.utils.xpl.DialogSelectionHelper.chooseFileEntries(getShell(),  getPropertyFilePath(), new IPath[0], "Select property file", "Choose file to use as hibernate.properties", new String[] {"properties"}, false, false, true);
   		if(paths!=null && paths.length==1) {
   			propertyFileText.setText( (paths[0]).toOSString() );
   		}
   	}
   	
  +	private void handleProjectBrowse() {
  +		IJavaProject paths = DialogSelectionHelper.chooseJavaProject( getShell(), ProjectUtils.findJavaProject( propertyFileText.getText() ), "Select java project", "The (optional) java project is used to determine the default classpath" );
  +		if(paths!=null) {
  +			projectNameText.setText( paths.getProject().getName() );
  +		} else {
  +			projectNameText.setText("");
  +		}
  +	}
  +	
  +	
   	private void handleConfigurationFileBrowse() {
   		IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(),  getConfigurationFilePath(), new IPath[0], "Select hibernate.cfg.xml file", "Choose file to use as hibernate.cfg.xml", new String[] {"cfg.xml"}, false, false, true);
   		if(paths!=null && paths.length==1) {
  @@ -519,6 +619,13 @@
   			}
   		}
   		
  +		if(getProjectName()!=null && StringHelper.isNotEmpty(getProjectName().trim())) {
  +			IJavaProject findJavaProject = ProjectUtils.findJavaProject( getProjectName() );
  +			if(findJavaProject==null || !findJavaProject.exists()) {
  +				updateStatus("The Java project " + getProjectName() + " does not exist.");
  +				return;
  +			}
  +		}
   		if (propertyFilename.length() == 0 && configurationFilename.trim().length() == 0) {
   			updateStatus("Property or Configuration file must be specified");
   			return;
  @@ -549,6 +656,10 @@
   		updateStatus(null);
   	}
   
  +	String getProjectName() {
  +		return projectNameText.getText();
  +	}
  +
   	String getConfigurationName() {
   		return configurationNameText.getText();
   	}
  @@ -609,6 +720,10 @@
   		return enableAnnotations.getSelection();
   	}
   
  +	public boolean useProjectClassPath() {
  +		return useProjectClassPath.getSelection();
  +	}
  +
   }
   
   
  
  
  
  1.8       +9 -10     jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UpDownListComposite.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- UpDownListComposite.java	7 Jul 2006 13:51:10 -0000	1.7
  +++ UpDownListComposite.java	23 Oct 2006 13:22:55 -0000	1.8
  @@ -79,8 +79,8 @@
   
   	private void initialize() {
   		createGroup();
  -		this.setLayout(new GridLayout());
  -		setSize(new org.eclipse.swt.graphics.Point(588,291));
  +		GridLayout gridLayout = new GridLayout();		
  +		this.setLayout(gridLayout);
   	}
   
   	/**
  @@ -92,7 +92,6 @@
   		gridLayout.numColumns = 2;
   		GridData gridData = new org.eclipse.swt.layout.GridData();
   		gridData.grabExcessHorizontalSpace = true;
  -		//gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
   		gridData.grabExcessVerticalSpace = true;
   		gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
   		gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
  @@ -112,15 +111,15 @@
   		GridData gridData1 = new org.eclipse.swt.layout.GridData();
   		gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
   		gridData1.grabExcessHorizontalSpace = true;
  -		gridData1.grabExcessVerticalSpace = false;
  +		gridData1.grabExcessVerticalSpace = true;
   		gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
   		gridData1.heightHint = 20;
   		gridData1.widthHint = 20;
   		
  -		table = new Table(group, SWT.FULL_SELECTION);
  -		table.setHeaderVisible(true);
  +		table = new Table(group, SWT.FULL_SELECTION | SWT.BORDER);
  +		table.setHeaderVisible(false);
   		table.setLayoutData(gridData1);
  -		table.setLinesVisible(true);
  +		table.setLinesVisible(false);
   		createColumns(table);
   		
   		table.addSelectionListener(new SelectionListener() {
  @@ -141,9 +140,9 @@
   	}
   
   	protected void createColumns(Table table) {
  -		TableColumn column = new TableColumn(table, SWT.NULL);
  -		column.setText("Name");
  -		column.setWidth(1000);
  +		/*TableColumn column = new TableColumn(table, SWT.NULL);
  +		column.setText("NXame");
  +		column.setWidth(10);*/
   	}
   
   	/**
  
  
  
  1.10      +6 -3      jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConsoleConfigurationCreationWizard.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- ConsoleConfigurationCreationWizard.java	21 Sep 2006 22:34:47 -0000	1.9
  +++ ConsoleConfigurationCreationWizard.java	23 Oct 2006 13:22:55 -0000	1.10
  @@ -92,10 +92,12 @@
   		final boolean annotations = confPage.useAnnotations();
   		final IPath[] mappings = confPage.getMappingFiles();
   		final IPath[] classpaths = confPage.getClassPath();
  +		final boolean useProjectClasspath = confPage.useProjectClassPath();
  +		final String projectName = confPage.getProjectName();
   		IRunnableWithProgress op = new IRunnableWithProgress() {
   			public void run(IProgressMonitor monitor) throws InvocationTargetException {
   				try {
  -					createConsoleConfiguration(confPage.getOldConfiguration(), configName, annotations, entityResolver, propertyFile, fileName, mappings, classpaths, monitor);
  +					createConsoleConfiguration(confPage.getOldConfiguration(), configName, annotations, projectName, useProjectClasspath, entityResolver, propertyFile, fileName, mappings, classpaths, monitor);
   				} catch (CoreException e) {
   					throw new InvocationTargetException(e);
   				} finally {
  @@ -126,13 +128,14 @@
   	static private void createConsoleConfiguration(
   			EclipseConsoleConfiguration oldConfig,
   			String configName,
  -			boolean annotations, String entityResolver, IPath propertyFilename,
  +			boolean annotations, String projectName, boolean useProjectClasspath, String entityResolver, IPath propertyFilename,
   			IPath cfgFile, IPath[] mappings, IPath[] classpaths, IProgressMonitor monitor)
   		throws CoreException {
   
   		monitor.beginTask("Configuring Hibernate Console" + propertyFilename, IProgressMonitor.UNKNOWN);
   								
  -		ConsoleConfigurationPreferences ccp = new EclipseConsoleConfigurationPreferences(configName, annotations, entityResolver, cfgFile, propertyFilename, mappings, classpaths);
  +		ConsoleConfigurationPreferences ccp = new EclipseConsoleConfigurationPreferences(configName, annotations, projectName, useProjectClasspath, entityResolver, cfgFile, propertyFilename, mappings, classpaths);
  +		
   		
   		final ConsoleConfiguration cfg = new EclipseConsoleConfiguration(ccp);
   			
  
  
  



More information about the jboss-cvs-commits mailing list