JBoss Tools SVN: r3792 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-09-25 12:06:51 -0400 (Tue, 25 Sep 2007)
New Revision: 3792
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF
Log:
Added Require-Bundle: org.eclipse.core.variables
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF 2007-09-25 15:10:41 UTC (rev 3791)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/META-INF/MANIFEST.MF 2007-09-25 16:06:51 UTC (rev 3792)
@@ -62,5 +62,6 @@
org.eclipse.ui.navigator,
org.eclipse.jdt.launching,
org.eclipse.jdt.debug.ui,
- org.eclipse.core.filesystem
+ org.eclipse.core.filesystem,
+ org.eclipse.core.variables
Eclipse-LazyStart: true
17 years, 3 months
JBoss Tools SVN: r3791 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-09-25 11:10:41 -0400 (Tue, 25 Sep 2007)
New Revision: 3791
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/SeamUtil.java
Log:
fake class to workaround jboss-seam-gen.jar dependency
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/SeamUtil.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/SeamUtil.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/SeamUtil.java 2007-09-25 15:10:41 UTC (rev 3791)
@@ -0,0 +1,21 @@
+package org.hibernate.eclipse.launch;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class SeamUtil {
+
+ public String lower(String name)
+ {
+ return name.substring(0, 1).toLowerCase() + name.substring(1);
+ }
+ public String upper(String name)
+ {
+ return name.substring(0, 1).toUpperCase() + name.substring(1);
+ }
+ public Set set()
+ {
+ return new HashSet();
+ }
+
+}
17 years, 3 months
JBoss Tools SVN: r3790 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse: launch and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-09-25 11:06:43 -0400 (Tue, 25 Sep 2007)
New Revision: 3790
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java
Log:
JBIDE-946 support for eclipse variables
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2007-09-25 14:55:42 UTC (rev 3789)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2007-09-25 15:06:43 UTC (rev 3790)
@@ -1,22 +1,24 @@
package org.hibernate.eclipse.console.model.impl;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.apache.lucene.util.StringHelper;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.HibernateConsoleRuntimeException;
import org.hibernate.eclipse.launch.HibernateLaunchConstants;
import org.hibernate.eclipse.launch.PathHelper;
-
import org.hibernate.tool.hbm2x.Exporter;
import org.hibernate.tool.hbm2x.GenericExporter;
+import org.hibernate.util.StringHelper;
/**
* ExporterFactory is used in UI to hold additional configuration for Exporter definitions
@@ -146,8 +148,22 @@
return inputProperties.containsKey( string );
}
- public Exporter createConfiguredExporter(Configuration cfg, File outputdir,
- String[] templatePaths, Properties globalProperties) {
+ /** Method that resolves an expression through eclipses built-in variable manager.
+ * @throws CoreException if expression could not be evaluated. */
+ private String resolve(String expression) throws CoreException {
+ if(expression==null) return null;
+ IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
+
+ return variableManager.performStringSubstitution(expression, false);
+ }
+
+ /**
+ * Creates exporter with the specified settings; also resolves any relevant properties via Eclipse VariablesPlugin.
+ * @throws CoreException in case of resolve variables issues.
+ */
+ public Exporter createConfiguredExporter(Configuration cfg, String defaultOutputDirectory,
+ String customTemplatePath, Properties globalProperties) throws CoreException {
+
Exporter exporter = getExporterDefinition().createExporterInstance();
Properties props = new Properties();
@@ -156,41 +172,41 @@
exporter.setProperties(props);
- exporter.setOutputDirectory(outputdir);
+ exporter.setOutputDirectory(new File(defaultOutputDirectory));
if(props.containsKey("outputdir")) {
- String loc = PathHelper.getLocationAsStringPath(props.getProperty("outputdir"));
+ String resolvedOutputDir = resolve(props.getProperty("outputdir"));
+ String loc = PathHelper.getLocationAsStringPath(resolvedOutputDir);
if(loc==null) {
- throw new HibernateConsoleRuntimeException("Output directory '" + props.getProperty("outputdir") + "' in " + getExporterDefinition().getDescription() + " does not exist.");
+ throw new HibernateConsoleRuntimeException("Output directory '" + resolvedOutputDir + "' in " + getExporterDefinition().getDescription() + " does not exist.");
}
props.remove("outputdir"); // done to avoid validation check in hibernate tools templates
- if(org.hibernate.util.StringHelper.isNotEmpty(loc)) { // only set if something valid found
+ if(StringHelper.isNotEmpty(loc)) { // only set if something valid found
exporter.setOutputDirectory(new File(loc));
}
- } else {
-
- }
+ }
exporter.setConfiguration(cfg);
+ List templatePathList = new ArrayList();
if(props.containsKey("template_path")) {
- String locationAsStringPath = PathHelper.getLocationAsStringPath(props.getProperty("template_path"));
+ String resolveTemplatePath = resolve(props.getProperty("template_path"));
+ String locationAsStringPath = PathHelper.getLocationAsStringPath(resolveTemplatePath);
if(locationAsStringPath==null) {
- throw new HibernateConsoleRuntimeException("Template directory '" + props.getProperty("template_path") + "' in " + getExporterDefinition().getDescription() + " does not exist.");
- }
-
- String[] newPath = new String[templatePaths.length+1];
- System.arraycopy(templatePaths, 0, newPath, 0, templatePaths.length);
-
- newPath[templatePaths.length] = locationAsStringPath;
-
- exporter.setTemplatePath(newPath);
+ throw new HibernateConsoleRuntimeException("Template directory '" + resolveTemplatePath + "' in " + getExporterDefinition().getDescription() + " does not exist.");
+ } else {
+ templatePathList.add(locationAsStringPath);
+ }
props.remove("template_path"); // done to avoid validation check in hibernate tools templates
- } else {
- exporter.setTemplatePath(templatePaths);
}
+ String resolvedCustomTemplatePath = resolve(customTemplatePath);
+ if(StringHelper.isNotEmpty(resolvedCustomTemplatePath)) {
+ templatePathList.add(resolvedCustomTemplatePath);
+ }
+ exporter.setTemplatePath((String[]) templatePathList.toArray(new String[templatePathList.size()]));
+
- // special handling for GenericExporter (should be delegated via plugin.xml)
- if(exporter instanceof GenericExporter) {
+ // special handling for GenericExporter (TODO: be delegated via plugin.xml)
+ if(getExporterDefinition().getId().equals("org.hibernate.tools.hbmtemplate")) {
GenericExporter ge = (GenericExporter) exporter;
ge.setFilePattern(props.getProperty("file_pattern", null));
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2007-09-25 14:55:42 UTC (rev 3789)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2007-09-25 15:06:43 UTC (rev 3790)
@@ -197,7 +197,7 @@
return null;
- final String outputPathRes = PathHelper.getLocationAsStringPath( attributes.getOutputPath() );
+ final String outputPathRes = PathHelper.getLocationAsStringPath(attributes.getOutputPath());
final String templatePath = PathHelper.getLocationAsStringPath(attributes.getTemplatePath());
@@ -216,12 +216,11 @@
private ArtifactCollector artifactCollector = new ArtifactCollector();
public Object execute() {
- File outputdir = new File( outputPathRes );
- String[] templatePaths = new String[0];
-
- if(StringHelper.isNotEmpty(templatePath)) {
- templatePaths = new String[] { templatePath };
+ String templatePaths = null;
+
+ if(StringHelper.isNotEmpty(templatePath)) {
+ templatePaths = templatePath;
}
// Global properties
@@ -236,7 +235,12 @@
Properties globalProperties = new Properties();
globalProperties.putAll(props);
- Exporter exporter = exporterFactories[i].createConfiguredExporter(cfg, outputdir, templatePaths, globalProperties);
+ Exporter exporter;
+ try {
+ exporter = exporterFactories[i].createConfiguredExporter(cfg, outputPathRes, templatePaths, globalProperties);
+ } catch (CoreException e) {
+ throw new HibernateConsoleRuntimeException("Error while setting up " + exporterFactories[i].getExporterDefinition(), e);
+ }
exporter.start();
monitor.worked(1);
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2007-09-25 14:55:42 UTC (rev 3789)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2007-09-25 15:06:43 UTC (rev 3790)
@@ -28,6 +28,8 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
@@ -121,7 +123,7 @@
outputdir = new StringButtonDialogField(new IStringButtonAdapter() {
public void changeControlPressed(DialogField field) {
- IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(), getOutputDirectory(), new IPath[0], "Select output directory", "Choose directory in which the generated files will be stored", new String[] {"cfg.xml"}, false, true, false);
+ IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(), PathHelper.pathOrNull(outputdir.getText()), new IPath[0], "Select output directory", "Choose directory in which the generated files will be stored", new String[] {"cfg.xml"}, false, true, false);
if(paths!=null && paths.length==1) {
outputdir.setText( ( (paths[0]).toOSString() ) );
}
@@ -262,7 +264,7 @@
return;
}
- String msg = PathHelper.checkDirectory(getOutputDirectory(), "output directory", false);
+ String msg = PathHelper.checkDirectory(outputdir.getText(), "output directory", false);
if (msg!=null) {
updateStatus(msg);
@@ -286,7 +288,7 @@
}
if(useOwnTemplates.isSelected() ) {
- msg = PathHelper.checkDirectory(getTemplateDirectory(), "template directory", true);
+ msg = PathHelper.checkDirectory(templatedir.getText(), "template directory", true);
if (msg!=null) {
updateStatus(msg);
return;
@@ -357,15 +359,20 @@
return reverseengineer.isSelected();
}
- public IPath getOutputDirectory() {
- return PathHelper.pathOrNull(outputdir.getText() );
+ private String resolve(String expression) {
+ if(expression==null) return null;
+ IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
+
+ try {
+ return variableManager.performStringSubstitution(expression, false);
+ } catch (CoreException e) {
+ // ignore possible errors during substitution and just return the orginal expression
+ return expression;
+ }
}
-
- public IPath getTemplateDirectory() {
- return PathHelper.pathOrNull(templatedir.getText() );
- }
-
- public String getOutputPackage() {
+
+
+ String getOutputPackage() {
return packageName.getText();
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2007-09-25 14:55:42 UTC (rev 3789)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2007-09-25 15:06:43 UTC (rev 3790)
@@ -161,7 +161,7 @@
public static void saveExporterFactories(
ILaunchConfigurationWorkingCopy configuration,
- List exporterFactories, List enabledExporters, Set deletedExporterIds) {
+ List exporterFactories, Set enabledExporters, Set deletedExporterIds) {
List names = new ArrayList();
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java 2007-09-25 14:55:42 UTC (rev 3789)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java 2007-09-25 15:06:43 UTC (rev 3790)
@@ -96,7 +96,7 @@
private Button enableJDK5;
- private List selectedExporters;
+ private Set selectedExporters;
private Set deletedExporterIds;
@@ -125,7 +125,7 @@
* @see IDialogPage#createControl(Composite)
*/
public void createControl(Composite parent) {
- selectedExporters = new ArrayList();
+ selectedExporters = new HashSet();
deletedExporterIds = new HashSet();
// ScrolledComposite scrolled = new ScrolledComposite(parent,
// SWT.V_SCROLL | SWT.H_SCROLL);
@@ -356,7 +356,9 @@
ExporterFactory exporterFactory = new ExporterFactory( expDef, initialName );
observableFactoryList.add(exporterFactory);
+ selectedExporters.add(exporterFactory);
((CheckboxTableViewer)getTableViewer()).setChecked(exporterFactory, true);
+
}
protected void handleRemove() {
@@ -720,7 +722,7 @@
String str = (String) ef.getProperties().get("outputdir");
String msg = null;
if(str!=null) {
- msg = PathHelper.checkDirectory(PathHelper.pathOrNull(str), "Output directory for " + ef.getExporterDefinition().getDescription(), false);
+ msg = PathHelper.checkDirectory(str, "Output directory for " + ef.getExporterDefinition().getDescription(), false);
if(msg!=null) {
updateStatus(msg);
return;
@@ -729,7 +731,7 @@
str = (String) ef.getProperties().get("template_path");
if(str!=null) {
- msg = PathHelper.checkDirectory(PathHelper.pathOrNull(str), "Template directory for " + ef.getExporterDefinition().getDescription(), true);
+ msg = PathHelper.checkDirectory(str, "Template directory for " + ef.getExporterDefinition().getDescription(), true);
if(msg!=null) {
updateStatus(msg);
return;
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java 2007-09-25 14:55:42 UTC (rev 3789)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java 2007-09-25 15:06:43 UTC (rev 3790)
@@ -6,12 +6,16 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
// TODO: move to internal.
public class PathHelper {
public static String getLocationAsStringPath(String path) {
+ if(path==null) return null;
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource member = PathHelper.findMember(root, path);
if(member==null) {
@@ -38,15 +42,55 @@
else return resource.getRawLocation();
}
+
+ static private String resolve(String expression) {
+ if(expression==null) return null;
+ IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
+
+ try {
+ return variableManager.performStringSubstitution(expression, false);
+ } catch (CoreException e) {
+ return expression;
+ }
+ }
+
public static Path pathOrNull(String p) {
+ return pathOrNull(p, false);
+ }
+
+ public static Path pathOrNull(String p, boolean resolveVariables) {
+ if(resolveVariables && p!=null) {
+ p = resolve(p);
+ }
if(p==null || p.trim().length()==0) {
return null;
} else {
return new Path(p);
}
}
-
- static public String checkDirectory(IPath path, String name, boolean checkFilesystem) {
+
+ /**
+ * Checks if directory exists.
+ * Handles variables replacement too.
+ *
+ * @param strpath
+ * @param name
+ * @param checkFilesystem
+ * @return
+ */
+ static public String checkDirectory(String strpath, String name, boolean checkFilesystem) {
+ if(strpath.indexOf("${") >= 0) { //$NON-NLS-1$
+ IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
+ try {
+ manager.validateStringVariables(strpath);
+ }
+ catch (CoreException e) {
+ return name + " has invalid variable references [" + e.getMessage() + "]";
+ }
+ }
+
+ IPath path = pathOrNull(resolve(strpath));
+
if (checkFilesystem) {
if (path != null && new File(path.toOSString()).exists()) {
return null;
@@ -64,10 +108,11 @@
} else {
return name + " has to be a folder or project [" + path + "]";
}
- } else {
+ } else {
return name + " does not exist [" + path + "]";
}
return null;
}
+
}
17 years, 3 months
JBoss Tools SVN: r3789 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-09-25 10:55:42 -0400 (Tue, 25 Sep 2007)
New Revision: 3789
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/J2EEProjects.java
Log:
JBIDE-769
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/J2EEProjects.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/J2EEProjects.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/J2EEProjects.java 2007-09-25 14:55:42 UTC (rev 3789)
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+
+/**
+ * Helper class that collects related J2EE projects for
+ * a given 'seed' project.
+ *
+ * If seed project is EAR, it's referenced projects are used to fill
+ * lists with WAR and EJB projects.
+ *
+ * If seed project is referenced by a EAR project (the first occurrence is taken),
+ * that EAR is used as seed project.
+ *
+ * If seed project is WAR or EJB not referenced by any EAR project,
+ * field 'ear' remains null, and only lists 'wars' and 'ejbs' are available.
+ *
+ * Also this class provides helper methods to obtain root folders
+ * for involved EAR, WAR and EJB projects.
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class J2EEProjects {
+ IProject ear;
+ List<IProject> wars = new ArrayList<IProject>();
+ List<IProject> ejbs = new ArrayList<IProject>();
+
+ /**
+ * Returns instance of J2EEProjects
+ * if parameter project is a J2EE project,
+ * otherwise null is returned.
+ * If parameter project is EAR, referenced projects
+ * are used to fill lists 'wars' and ears'
+ * If parameter project is WAR or EJB and has referencing EAR,
+ * then that EAR project is considered as current project,
+ * otherwise referenced EJB projects are put to 'ears' list.
+ * @param project
+ * @return
+ */
+ public static J2EEProjects create(IProject project) {
+ boolean isWar = J2EEProjectUtilities.isDynamicWebProject(project);
+ boolean isEar = J2EEProjectUtilities.isEARProject(project);
+ boolean isEJB = J2EEProjectUtilities.isEJBProject(project);
+ if(!isEar && !isEJB && !isWar) return null;
+ return new J2EEProjects(project);
+ }
+
+ private J2EEProjects(IProject project) {
+ if(J2EEProjectUtilities.isDynamicWebProject(project)) {
+ wars.add(project);
+ } else if(J2EEProjectUtilities.isEARProject(project)) {
+ ear = project;
+ } else if(J2EEProjectUtilities.isEJBProject(project)) {
+ ejbs.add(project);
+ }
+ if(ear == null) {
+ IProject[] ps = J2EEProjectUtilities.getReferencingEARProjects(project);
+ if(ps != null && ps.length > 0) ear = ps[0];
+ }
+ if(ear != null || wars.size() > 0) {
+ IProject seed = (ear != null) ? ear : project;
+ IVirtualComponent component = ComponentCore.createComponent(seed);
+ IVirtualReference[] rs = component.getReferences();
+ for (int i = 0; i < rs.length; i++) {
+ IVirtualComponent c = rs[i].getReferencedComponent();
+ if(c == null) continue;
+ IProject p = c.getRootFolder().getProject();
+ if(J2EEProjectUtilities.isDynamicWebProject(p)) {
+ if(!wars.contains(p)) wars.add(p);
+ } else if(J2EEProjectUtilities.isEJBProject(project)) {
+ if(!ejbs.contains(p)) ejbs.add(p);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns EAR project or null, if WAR project is not used by EAR.
+ * @return
+ */
+ public IProject getEARProject() {
+ return ear;
+ }
+
+ /**
+ * Returns Content folder of EAR project or null
+ * if EAR is not available.
+ * @return
+ */
+ public IFolder getEARContentFolder() {
+ if(ear == null) return null;
+ IVirtualComponent component = ComponentCore.createComponent(ear);
+ IPath path = component.getRootFolder().getProjectRelativePath();
+ return path == null ? null : ear.getFolder(path);
+ }
+
+ /**
+ * Returns list of WAR projects.
+ * @return
+ */
+ public List<IProject> getWARProjects() {
+ return wars;
+ }
+
+ /**
+ * Returns Content folder for first found WAR project.
+ * @return
+ */
+ public IFolder getWARContentFolder() {
+ if(wars.size() == 0) return null;
+ IVirtualComponent component = ComponentCore.createComponent(wars.get(0));
+ IPath path = component.getRootFolder().getProjectRelativePath();
+ return path == null ? null : wars.get(0).getFolder(path);
+ }
+
+ /**
+ * Returns list of EJB projects.
+ * @return
+ */
+ public List<IProject> getEJBProjects() {
+ return ejbs;
+ }
+
+ /**
+ * Returns source roots for first found EJB project.
+ * @return
+ */
+ public IResource[] getEJBSourceRoots() {
+ return ejbs.size() == 0 ? new IResource[0] : EclipseResourceUtil.getJavaSourceRoots(ejbs.get(0));
+ }
+
+}
17 years, 3 months
JBoss Tools SVN: r3788 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-09-25 09:09:51 -0400 (Tue, 25 Sep 2007)
New Revision: 3788
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list/AbstractTreeWizardView.java
Log:
JBIDE-942
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list/AbstractTreeWizardView.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list/AbstractTreeWizardView.java 2007-09-25 12:53:01 UTC (rev 3787)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list/AbstractTreeWizardView.java 2007-09-25 13:09:51 UTC (rev 3788)
@@ -27,6 +27,7 @@
protected CommandBar allBar = new CommandBar();
protected TreeViewer treeViewer;
protected CheckTreeProvider provider = new CheckTreeProvider();
+ protected TreeItemSelectionManager treeSelectionManager;
protected String[][] vs = new String[0][];
CheckObject object = new CheckObject(null, new String[]{"", "yes"});
int expandingLevel = 2;
@@ -108,7 +109,7 @@
Control tc = treeViewer.getControl();
tc.setLayoutData(new GridData(GridData.FILL_BOTH));
initTree();
- new TreeItemSelectionManager(treeViewer, new Flipper());
+ treeSelectionManager = new TreeItemSelectionManager(treeViewer, new Flipper());
treeViewer.expandToLevel(expandingLevel);
Control bc = allBar.createControl(composite);
bc.setLayoutData(new GridData(GridData.FILL_VERTICAL));
@@ -142,21 +143,10 @@
protected void enableAll() {
enableHierarchy(object);
- Tree tree = treeViewer.getTree();
- enable(tree.getItems());
+ treeSelectionManager.update();
treeViewer.refresh();
}
- private void enable(TreeItem[] items) {
- for (int i = 0; i < items.length; i++) {
- if(!items[i].getChecked()) {
- items[i].setChecked(true);
- treeViewer.refresh(items[i]);
- }
- enable(items[i].getItems());
- }
- }
-
private void enableHierarchy(CheckObject o) {
CheckObject[] os = o.getChildren();
for (int i = 0; i < os.length; i++) {
@@ -170,12 +160,7 @@
for (int i = 0; i < os.length; i++) {
os[i].setEnabled(false);
}
- Tree tree = treeViewer.getTree();
- TreeItem[] items = tree.getItems();
- for (int i = 0; i < items.length; i++) {
- items[i].setChecked(false);
- treeViewer.refresh(items[i]);
- }
+ treeSelectionManager.update();
treeViewer.refresh();
}
17 years, 3 months
JBoss Tools SVN: r3787 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-09-25 08:53:01 -0400 (Tue, 25 Sep 2007)
New Revision: 3787
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list/AbstractTreeWizardView.java
Log:
JBIDE-942
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list/AbstractTreeWizardView.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list/AbstractTreeWizardView.java 2007-09-25 12:24:32 UTC (rev 3786)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/query/list/AbstractTreeWizardView.java 2007-09-25 12:53:01 UTC (rev 3787)
@@ -142,8 +142,20 @@
protected void enableAll() {
enableHierarchy(object);
+ Tree tree = treeViewer.getTree();
+ enable(tree.getItems());
treeViewer.refresh();
}
+
+ private void enable(TreeItem[] items) {
+ for (int i = 0; i < items.length; i++) {
+ if(!items[i].getChecked()) {
+ items[i].setChecked(true);
+ treeViewer.refresh(items[i]);
+ }
+ enable(items[i].getItems());
+ }
+ }
private void enableHierarchy(CheckObject o) {
CheckObject[] os = o.getChildren();
@@ -158,9 +170,15 @@
for (int i = 0; i < os.length; i++) {
os[i].setEnabled(false);
}
+ Tree tree = treeViewer.getTree();
+ TreeItem[] items = tree.getItems();
+ for (int i = 0; i < items.length; i++) {
+ items[i].setChecked(false);
+ treeViewer.refresh(items[i]);
+ }
treeViewer.refresh();
}
-
+
class Flipper implements TreeItemSelectionManager.Listener {
public void flip(TreeItem item) {
if(item == null) return;
17 years, 3 months
JBoss Tools SVN: r3786 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe: editor and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-09-25 08:24:32 -0400 (Tue, 25 Sep 2007)
New Revision: 3786
Added:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDebugUtil.java
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FlatIterator.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-945
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2007-09-25 09:11:59 UTC (rev 3785)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2007-09-25 12:24:32 UTC (rev 3786)
@@ -58,7 +58,6 @@
* @param dragetElement
*/
public void startDragSession(nsIDOMEvent domEvent) {
- //TODO Max Areshkau
nsISupportsArray transArray = (nsISupportsArray) getComponentManager()
.createInstanceByContractID(CID_SUPPORTSARRAY, null,
nsISupportsArray.NS_ISUPPORTSARRAY_IID);
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-09-25 09:11:59 UTC (rev 3785)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-09-25 12:24:32 UTC (rev 3786)
@@ -122,6 +122,7 @@
import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
+import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.jboss.tools.vpe.editor.util.VpeDndUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.selbar.SelectionBar;
@@ -189,6 +190,7 @@
public final static String MODEL_FLAVOR = ModelTransfer.MODEL; //$NON-NLS-1$
public VpeController(VpeEditorPart editPart){
+
this.editPart = editPart;
dropWindow = new VpeDropWindow(editPart.getSite().getShell());
}
@@ -405,11 +407,15 @@
}
// INodeSelectionListener implementation
+ //TODO Max Areshkau remove if don't used
+ //looks like that this method can be removed
public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
- List nodes = event.getSelectedNodes();
+ //TODO Max Areshkau Improve selection notification
+ // do not use event.getSelectedNodes(), use instead base selection notification
+ List<?> nodes = event.getSelectedNodes();
if (nodes != null && nodes.size() > 0) {
Node sourceNode = (Node)nodes.get(0);
if (VpeDebug.printSourceSelectionEvent) {
@@ -423,6 +429,7 @@
}
// ITextSelectionListener implementation
+ //TODO Max Areshau looks like this method don't used
public void textSelectionChanged(TextSelectionChangedEvent event) {
if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
@@ -2395,4 +2402,18 @@
visualBuilder.getDnd().dragDrop(domEvent,this);
}
+ /**
+ * @return the selectionBuilder
+ */
+ public VpeSelectionBuilder getSelectionBuilder() {
+ return selectionBuilder;
+ }
+
+ /**
+ * @param selectionBuilder the selectionBuilder to set
+ */
+ public void setSelectionBuilder(VpeSelectionBuilder selectionBuilder) {
+ this.selectionBuilder = selectionBuilder;
+ }
+
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-09-25 09:11:59 UTC (rev 3785)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-09-25 12:24:32 UTC (rev 3786)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor;
+import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -19,6 +20,7 @@
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
@@ -45,8 +47,12 @@
import org.jboss.tools.vpe.editor.util.FlatIterator;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TextUtil;
+import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
+import org.jboss.tools.vpe.xulrunner.editor.XulRunnerVpeUtils;
+import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMKeyEvent;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsISelection;
import org.w3c.dom.Attr;
import org.w3c.dom.Comment;
import org.w3c.dom.Node;
@@ -71,6 +77,12 @@
public static final int VK_PAGE_UP = 0x21;
public static final int VK_HOME = 0x24;
public static final int VK_END = 0x23;
+
+ //directions for looking nearest node when we are using navigation keys
+ private static final int UP=0;
+ private static final int DOWN=1;
+ private static final int LEFT=2;
+ private static final int RIGHT=3;
StructuredTextEditor sourceEditor;
VpeDomMapping domMapping;
@@ -164,7 +176,8 @@
if (keyCode == VK_ENTER) {
return split();
} else if (keyCode == VK_LEFT && !shiftKey) {
- return moveLeft();
+ //TODO Max Areshkau (Optimize Move Left)
+ return moveLeft();
} else if (keyCode == VK_UP && !shiftKey) {
return moveUp(false);
} else if (keyCode == VK_RIGHT && !shiftKey) {
@@ -410,8 +423,7 @@
} else {
break;
}
-// sourceEditor.getAction(ITextEditorActionDefinitionIds.DELETE_NEXT).run();
-// selection = sourceSelectionBuilder.getSelection();
+
}
return selection;
@@ -1425,23 +1437,25 @@
if (eo > 0) {
setSourceFocus(attrSelStart - 1);
return true;
- } else {
- return moveCursorToPrevVisualNode(selection.getFocusNode());
- }
+ }
+// else {
+// return moveCursorToPrevVisualNode(selection.getFocusNode());
+// }
}
- } else {
- return moveCursorToPrevVisualNode(selection.getFocusNode());
- }
+ }
+// else {
+// return moveCursorToPrevVisualNode(selection.getFocusNode());
+// }
} else {
if (selection.getFocusNode().getNodeType() == Node.TEXT_NODE ||
selection.getFocusNode().getNodeType() == Node.COMMENT_NODE) {
int so = ((IndexedRegion)selection.getFocusNode()).getStartOffset();
int eo = ((IndexedRegion)selection.getFocusNode()).getEndOffset();
- if (selection.getFocusOffset() <= 0) {
-
- return moveCursorToPrevVisualNode(selection.getFocusNode());
- }
+// if (selection.getFocusOffset() <= 0) {
+//
+// return moveCursorToPrevVisualNode(selection.getFocusNode());
+// }
int fo = selection.getFocusOffset();
@@ -1464,20 +1478,21 @@
diff++;
}
- if (fo + diff < 0||diff==0) {
+// if (fo + diff < 0||diff==0) {
+//
+// return moveCursorToPrevVisualNode(selection.getFocusNode());
+// }
- return moveCursorToPrevVisualNode(selection.getFocusNode());
- }
-
setSourceFocus(so + fo + diff);
return true;
- } else if (selection.getFocusNode().getNodeType() == Node.ELEMENT_NODE) {
- // Move to second position of the visual attribute (because we're placed
- // either before first char of visual attribute or not in visual attribute
- // but still in the beginning of the element
-
- return moveCursorToPrevVisualNode(selection.getFocusNode());
- }
+ }
+// else if (selection.getFocusNode().getNodeType() == Node.ELEMENT_NODE) {
+// // Move to second position of the visual attribute (because we're placed
+// // either before first char of visual attribute or not in visual attribute
+// // but still in the beginning of the element
+//
+// return moveCursorToPrevVisualNode(selection.getFocusNode());
+// }
}
return false;
@@ -1502,6 +1517,7 @@
boolean moveCursorToNextVisualNode(Node node) {
+ //node text implementation of node(node from source editor)
Node next = node;
while (next != null) {
next = getNextFlatNode(next);
@@ -1531,6 +1547,7 @@
}
nsIDOMNode visualNode = domMapping.getVisualNode(next);
if (visualNode != null && HTML.TAG_INPUT.equalsIgnoreCase(visualNode.getNodeName())) {
+ //sets the focus to some node
setSourceFocus(((IndexedRegion)next).getStartOffset());
return true;
}
@@ -1539,42 +1556,42 @@
return true;
}
- boolean moveCursorToPrevVisualNode(Node node) {
- Node prev = node;
- while (prev != null) {
- prev = getPreviousFlatNode(prev);
- if (prev == null) {
- // Fix for first char in first text node
- setSourceFocus(0);
- return true;
- }
- if (prev.getNodeType() == Node.TEXT_NODE) {
- int eo = ((IndexedRegion)prev).getEndOffset();
- int shift = 0;
- char[] chars = ((TextImpl)prev).getValueSource().toCharArray();
- while ((shift < chars.length) && isTextToSkip(chars, chars.length - shift - 1)) {
- shift++;
- }
- if (shift < chars.length) {
- eo -= shift;
- }
- setSourceFocus(eo);
- return true;
- } else if (prev.getNodeType() == Node.ELEMENT_NODE) {
- Attr attr = getVisualNodeSourceAttribute(prev);
- if (attr != null) {
- int attrSelStart = ((ElementImpl)attr.getOwnerElement()).getStartOffset() + ((AttrImpl)attr).getValueRegion().getStart() + 1;
- int attrSelLength = ((AttrImpl)attr).getValue().length();
- setSourceFocus(attrSelStart + attrSelLength - 1);
- return true;
- }
- nsIDOMNode visualNode = domMapping.getVisualNode(prev);
- if (visualNode != null && "input".equalsIgnoreCase(visualNode.getNodeName())) {
- setSourceFocus(((IndexedRegion)prev).getStartOffset());
- return true;
- }
- }
- }
+ boolean _moveCursorToPrevVisualNode(Node node) {
+// Node prev = node;
+// while (prev != null) {
+// prev = getPreviousFlatNode(prev);
+// if (prev == null) {
+// // Fix for first char in first text node
+// setSourceFocus(0);
+// return true;
+// }
+// if (prev.getNodeType() == Node.TEXT_NODE) {
+// int eo = ((IndexedRegion)prev).getEndOffset();
+// int shift = 0;
+// char[] chars = ((TextImpl)prev).getValueSource().toCharArray();
+// while ((shift < chars.length) && isTextToSkip(chars, chars.length - shift - 1)) {
+// shift++;
+// }
+// if (shift < chars.length) {
+// eo -= shift;
+// }
+// setSourceFocus(eo);
+// return true;
+// } else if (prev.getNodeType() == Node.ELEMENT_NODE) {
+// Attr attr = getVisualNodeSourceAttribute(prev);
+// if (attr != null) {
+// int attrSelStart = ((ElementImpl)attr.getOwnerElement()).getStartOffset() + ((AttrImpl)attr).getValueRegion().getStart() + 1;
+// int attrSelLength = ((AttrImpl)attr).getValue().length();
+// setSourceFocus(attrSelStart + attrSelLength - 1);
+// return true;
+// }
+// nsIDOMNode visualNode = domMapping.getVisualNode(prev);
+// if (visualNode != null && "input".equalsIgnoreCase(visualNode.getNodeName())) {
+// // setSourceFocus(((IndexedRegion)prev).getStartOffset());
+// return true;
+// }
+// }
+// }
return true;
}
@@ -1593,14 +1610,14 @@
return false;
}
- private Node _getNextNode(Node node) {
- Node next = null;
- do {
- next = node.getNextSibling();
- node = node.getParentNode();
- } while (next == null && node != null);
- return next;
- }
+// private Node _getNextNode(Node node) {
+// Node next = null;
+// do {
+// next = node.getNextSibling();
+// node = node.getParentNode();
+// } while (next == null && node != null);
+// return next;
+// }
private Node getNextNode(Node node) {
Node next = null;
@@ -1673,24 +1690,38 @@
}
private boolean moveUp(boolean extend) {
- // TODO Max Areshkau figure out
+
+ VpeDebugUtil.debugInfo("MoveUp\n");
+
+ nsIDOMElement visualELement = getNearestNode(getSelectedNode(), UP);
+ Node sourceNode = domMapping.getSourceNode(visualELement);
+ setSourceFocus(((IndexedRegion)sourceNode).getStartOffset());
+ if(visualELement!=null) {
+ VpeDebugUtil.debugInfo("["+visualELement.getNodeName()+"]");
+ // pageContext.getEditPart().getController().getXulRunnerEditor().setSelectionRectangle(element, resizerConstrains, scroll)
+ }
+// TODO Max Areshkau figure out
// frameSelection.lineMove(false, extend);
return true;
}
private boolean moveDown(boolean extend) {
- // TODO Max Areshkau figure out
+ VpeDebugUtil.debugInfo("moveDown()");
+// TODO Max Areshkau figure out
// frameSelection.lineMove(true, extend);
return true;
}
- private boolean moveHome(boolean extend) {
- // TODO Max Areshkau figure out
+ private boolean moveHome(boolean extend) {
+// TODO Max Areshkau figure out
// frameSelection.intraLineMove(false, extend);
return true;
}
+
private boolean moveEnd(boolean extend) {
+
+ VpePlugin.getDefault().logInfo("MoveEnd");
// TODO Max Areshkau figure out
// frameSelection.intraLineMove(true, extend);
return true;
@@ -1698,13 +1729,70 @@
private boolean moveLeft(boolean extend) {
// TODO Max Areshkau figure out
+ VpePlugin.getDefault().logInfo("MoveLeft");
// frameSelection.characterMove(false, extend);
return true;
}
+ /**
+ *
+ * @param currentNode - node from which we will be look nearest node
+ * @param direction - direction on which we will be look for node
+ * @return nearest node in one of four directions(UP, DOWN, LEFT, RIGHT)
+ */
+ private nsIDOMElement getNearestNode(nsIDOMElement currentNode, int direction) {
+ if(currentNode==null) {
+ return null;
+ }
+ Collection<nsIDOMNode> elements = domMapping.getVisualMap().keySet();
+ nsIDOMElement nearestElement=null;
+ Rectangle curentElementRect = XulRunnerVpeUtils.getElementBounds(currentNode);
+ Rectangle domElementRect=null;
+ nsIDOMElement domElement;
+ int minlenght = Integer.MAX_VALUE;
+ int currentLenght = 0;
+ //TODO Max Areshkau optimize cycle
+ for(nsIDOMNode nsDOMNode : elements) {
+ currentLenght=Integer.MAX_VALUE;
+ domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if(nearestElement==null) {
+ nearestElement=domElement;
+ continue;
+ }
+ domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
+ if(UP==direction&&domElementRect.y<curentElementRect.y) {
+ currentLenght= curentElementRect.y-domElementRect.y;
+
+ if(currentLenght < minlenght) {
+ minlenght = currentLenght;
+ nearestElement=domElement;
+ VpePlugin.getPluginLog().logInfo("current node is"+nearestElement.getNodeName());
+ } else if(currentLenght==minlenght&&Math.abs(curentElementRect.x-XulRunnerVpeUtils.getElementBounds(nearestElement).x)
+ >Math.abs(curentElementRect.x-domElementRect.x)) {
+ minlenght=currentLenght;
+ nearestElement=domElement;
+ VpePlugin.getPluginLog().logInfo("current node is"+nearestElement.getNodeName());
+ }
+ }
+ }
+
+ return nearestElement;
+ }
+
private boolean moveRight(boolean extend) {
// TODO Max Areshkau figure out
// frameSelection.characterMove(true, extend);
+ VpePlugin.getDefault().logInfo("MoveRight");
return true;
}
+
+ private VpeSelectionBuilder getSelectionBuilder() {
+
+ return pageContext.getEditPart().getController().getSelectionBuilder();
+ }
+
+ private nsIDOMElement getSelectedNode() {
+
+ return pageContext.getEditPart().getController().getXulRunnerEditor().getLastSelectedElement();
+ }
}
\ No newline at end of file
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2007-09-25 09:11:59 UTC (rev 3785)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2007-09-25 12:24:32 UTC (rev 3786)
@@ -322,7 +322,7 @@
}
}
- public Map getVisualMap() {
+ public Map<nsIDOMNode, VpeNodeMapping> getVisualMap() {
return visualMap;
}
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-09-25 09:11:59 UTC (rev 3785)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-09-25 12:24:32 UTC (rev 3786)
@@ -125,8 +125,7 @@
*/
public void handleEvent(nsIDOMEvent domEvent) {
//TODO To many information in LOG
- //VpePlugin.getDefault().logInfo("VPE was handled+EventType is["+domEvent.getType()+"]");
-
+ //VpePlugin.getDefault().logInfo("VPE was handled+EventType is["+domEvent.getType()+"]");
try{
if(getEditorDomEventListener()==null){
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FlatIterator.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FlatIterator.java 2007-09-25 09:11:59 UTC (rev 3785)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FlatIterator.java 2007-09-25 12:24:32 UTC (rev 3786)
@@ -12,7 +12,7 @@
import org.eclipse.wst.xml.core.internal.document.TextImpl;
import org.w3c.dom.Node;
-
+//TODO Max Areshkau used to iterate over the nodes in navigatio by keys, but if we click left
public class FlatIterator {
public static Node previous(Node forNode) {
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDebugUtil.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDebugUtil.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDebugUtil.java 2007-09-25 12:24:32 UTC (rev 3786)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+
+* Copyright (c) 2007 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
+*
+* Contributors:
+* Red Hat, Inc. - initial API and implementation
+******************************************************************************/
+package org.jboss.tools.vpe.editor.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * @author Max Areshkau (mareshkau(a)exadel.com)
+ *
+ *Class created to print debug info
+ */
+public class VpeDebugUtil {
+
+ private static final SimpleDateFormat formatter = new SimpleDateFormat();
+ static {
+ formatter.applyPattern("hh:mm:ss.SSS");
+ }
+ /**
+ * Prints debug info on console
+ * @param msg
+ */
+ public static void debugInfo(String msg) {
+
+ if(Platform.inDebugMode()) {
+
+ System.out.print(formatter.format(new Date())+":"+ msg);
+ }
+ }
+}
17 years, 3 months
JBoss Tools SVN: r3785 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-09-25 05:11:59 -0400 (Tue, 25 Sep 2007)
New Revision: 3785
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java
Log:
missing pathhelper
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java 2007-09-25 09:11:59 UTC (rev 3785)
@@ -0,0 +1,73 @@
+package org.hibernate.eclipse.launch;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+// TODO: move to internal.
+public class PathHelper {
+
+ public static String getLocationAsStringPath(String path) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource member = PathHelper.findMember(root, path);
+ if(member==null) {
+ if (new File(path).exists()){
+ return path;
+ } else {
+ return null;
+ }
+ } else {
+ return PathHelper.getLocation( member ).toOSString();
+ }
+ }
+
+ public static IResource findMember(IWorkspaceRoot root, String path) {
+ Path pathOrNull = PathHelper.pathOrNull(path);
+ if(pathOrNull==null) return null;
+ return root.findMember(pathOrNull);
+ }
+
+ public static IPath getLocation(final IResource resource) {
+ if (resource.getRawLocation() == null) {
+ return resource.getLocation();
+ }
+ else return resource.getRawLocation();
+ }
+
+ public static Path pathOrNull(String p) {
+ if(p==null || p.trim().length()==0) {
+ return null;
+ } else {
+ return new Path(p);
+ }
+ }
+
+ static public String checkDirectory(IPath path, String name, boolean checkFilesystem) {
+ if (checkFilesystem) {
+ if (path != null && new File(path.toOSString()).exists()) {
+ return null;
+ }
+ }
+
+ IResource res= ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (res != null) {
+ int resType= res.getType();
+ if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
+ IProject proj= res.getProject();
+ if (!proj.isOpen() ) {
+ return "Project for " + name + " is closed [" + path + "]";
+ }
+ } else {
+ return name + " has to be a folder or project [" + path + "]";
+ }
+ } else {
+ return name + " does not exist [" + path + "]";
+ }
+ return null;
+ }
+
+}
17 years, 3 months
JBoss Tools SVN: r3784 - in trunk/seam/plugins/org.jboss.tools.seam.ui: src/org/jboss/tools/seam/ui/wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-25 04:39:17 -0400 (Tue, 25 Sep 2007)
New Revision: 3784
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizardPage1.java
Removed:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationVizardPage1.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizardPage1.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-930
Seam Conversation and seam entity added
Simple Implementation for generate default values added
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2007-09-25 08:39:17 UTC (rev 3784)
@@ -50,25 +50,25 @@
class="org.eclipse.core.resources.IResource">
</selection>
</wizard>
- <wizard
+ <wizard
category="org.jboss.tools.seam.ui"
- class="org.jboss.tools.seam.ui.wizard.SeamGenerateEnitiesWizard"
+ class="org.jboss.tools.seam.ui.wizard.SeamConversationWizard"
icon="icons/seam16.png"
- id="org.jboss.tools.seam.ui.SeamGenerateEntitiesWizard"
- name="Seam Generate Entities">
+ id="org.jboss.tools.seam.ui.wizard.SeamConversationWizard"
+ name="Seam Conversation">
<description>
- Generate Entities
+ description body text
</description>
<selection
class="org.eclipse.core.resources.IResource">
</selection>
</wizard>
- <!--wizard
+ <wizard
category="org.jboss.tools.seam.ui"
class="org.jboss.tools.seam.ui.wizard.SeamEntityWizard"
- icon="icons/sample.gif"
- id="org.jboss.tools.seam.ui.wizard3"
+ icon="icons/seam16.png"
+ id="org.jboss.tools.seam.ui.wizard.SeamEntityWizard"
name="Seam Entity">
<description>
description body text
@@ -77,19 +77,20 @@
class="org.eclipse.core.resources.IResource">
</selection>
</wizard>
- <wizard
+ <wizard
category="org.jboss.tools.seam.ui"
- class="org.jboss.tools.seam.ui.wizard.SeamConversationWizard"
- icon="icons/sample.gif"
- id="org.jboss.tools.seam.ui.wizard4"
- name="Seam Conversation">
+ class="org.jboss.tools.seam.ui.wizard.SeamGenerateEnitiesWizard"
+ icon="icons/seam16.png"
+ id="org.jboss.tools.seam.ui.wizard.SeamGenerateEnitiesWizard"
+ name="Seam Generate Entities">
<description>
- description body text
+ Generate Entities
</description>
<selection
class="org.eclipse.core.resources.IResource">
</selection>
- </wizard-->
+ </wizard>
+
</extension>
<extension
point="org.eclipse.wst.common.project.facet.ui.wizardPages">
@@ -134,8 +135,14 @@
id="org.jboss.tools.seam.ui.wizard.SeamFormWizard">
</newWizardShortcut>
<newWizardShortcut
- id="org.jboss.tools.seam.ui.SeamGenerateEntitiesWizard">
+ id="org.jboss.tools.seam.ui.wizard.SeamEntityWizard">
</newWizardShortcut>
+ <newWizardShortcut
+ id="org.jboss.tools.seam.ui.wizard.SeamConversationWizard">
+ </newWizardShortcut>
+ <newWizardShortcut
+ id="org.jboss.tools.seam.ui.wizard.SeamGenerateEnitiesWizard">
+ </newWizardShortcut>
</perspectiveExtension>
</extension>
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -81,10 +81,10 @@
// initialize ear files mapping
ACTION_EAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/ActionBean.java",
- "${" + IParameter.SEAM_EAR_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_BEAN_NAME +"}.java"});
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_BEAN_NAME +"}.java"});
ACTION_EAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/Action.java",
- "${" + IParameter.SEAM_EAR_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
ACTION_EAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/test/ActionTest.java",
"${" + IParameter.SEAM_TEST_PROJECT_LOCATION_PATH + "}/test-src/${" + ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH + "}/${"+ IParameter.SEAM_LOCAL_INTERFACE_NAME +"}Test.java"});
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -10,6 +10,10 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.beans.PropertyChangeEvent;
+
+import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
+
/**
* @author eskimo
*
@@ -30,4 +34,26 @@
protected void createEditors() {
addEditors(SeamWizardFactory.createActionFormFieldEditors(SeamWizardUtils.getSelectedProjectName()));
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getPropertyName().equals(IParameter.SEAM_COMPONENT_NAME)) {
+ if(event.getNewValue()==null||"".equals(event.getNewValue().toString().trim())) {
+ setDefaultValue(IParameter.SEAM_COMPONENT_NAME, "");
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "");
+ setDefaultValue(IParameter.SEAM_BEAN_NAME, "");
+ setDefaultValue(IParameter.SEAM_METHOD_NAME, "");
+ setDefaultValue(IParameter.SEAM_PAGE_NAME, "");
+ } else {
+ String value = event.getNewValue().toString();
+ String valueU = value.substring(0,1).toUpperCase() + value.substring(1);
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "I" + valueU);
+ setDefaultValue(IParameter.SEAM_BEAN_NAME, valueU+"Bean");
+ String valueL = value.substring(0,1).toLowerCase() + value.substring(1);
+ setDefaultValue(IParameter.SEAM_METHOD_NAME, valueL);
+ setDefaultValue(IParameter.SEAM_PAGE_NAME, valueL);
+ }
+ }
+ super.propertyChange(event);
+ }
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -81,7 +81,10 @@
vars.put(elem.getName(),elem.getValue().toString());
}
+ loadCustomVariables(vars);
+
String actionFolder = vars.get(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString();
+ String entityFolder = vars.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME).toString();
String testFolder = vars.get(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME).toString();
IVirtualComponent com = ComponentCore.createComponent(project);
@@ -92,19 +95,22 @@
vars.put(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME, SeamRuntimeManager.getInstance().getRuntimeForProject(project).getHomeDir());
vars.put(IParameter.SEAM_PROJECT_LOCATION_PATH,project.getLocation().toFile().toString());
vars.put(IParameter.SEAM_PROJECT_WEBCONTENT_PATH,webRootContainer.getLocation().toFile().toString());
- vars.put(IParameter.SEAM_EAR_PROJECT_LOCATION_PATH,project.getLocation().removeLastSegments(1).append(project.getName()+"-ejb").toFile().toString());
+ vars.put(IParameter.SEAM_EJB_PROJECT_LOCATION_PATH,project.getLocation().removeLastSegments(1).append(project.getName()+"-ejb").toFile().toString());
vars.put(IParameter.SEAM_TEST_PROJECT_LOCATION_PATH,project.getLocation().removeLastSegments(1).append(project.getName()+"-test").toFile().toString());
vars.put(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH, actionFolder.replace('.','/'));
vars.put(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME, actionFolder);
vars.put(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH, testFolder.replace('.','/'));
vars.put(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME, testFolder);
+ vars.put(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_PATH, entityFolder.replace('.','/'));
+ vars.put(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME, entityFolder);
+
List<String[]> fileMapping = getFileMappings(vars);
List<String[]> fileMappingCopy = applayVariables(fileMapping,vars);
FilterSetCollection filters = getFilterSetCollection(vars);
for (String[] mapping : fileMappingCopy) {
- if(SeamCorePlugin.getDefault().isDebugging()) {
+// if(SeamCorePlugin.getDefault().isDebugging()) {
System.out.println(mapping[0] + "->" + mapping[1]);
- }
+// }
AntCopyUtils.copyFileToFile(new File(mapping[0]),new File(mapping[1]),filters,true);
}
@@ -190,4 +196,8 @@
public File getSeamFolder(Map<String, Object> vars) {
return new File(vars.get(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME).toString(),"seam-gen");
}
+
+ protected void loadCustomVariables(Map<String, Object> vars) {
+
+ }
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -138,6 +138,13 @@
return editorRegistry.get(name);
}
+
+ public void setDefaultValue(String name, Object value) {
+ IFieldEditor editor = getEditor(name);
+ editor.removePropertyChangeListener(this);
+ editor.setValue(value);
+ editor.addPropertyChangeListener(this);
+ }
/**
*
* @author eskimo
@@ -172,7 +179,6 @@
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent event) {
- // TODO - finish validation
Map errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValue(), null);
Deleted: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationVizardPage1.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationVizardPage1.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationVizardPage1.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.seam.ui.wizard;
-
-/**
- * @author eskimo
- *
- */
-public class SeamConversationVizardPage1 extends SeamBaseWizardPage {
-
- public SeamConversationVizardPage1() {
- super("seam.new.conversation.page1","Seam Conversation",null);
- setMessage("Select the name of the new Seam Conversation. A set of classes " +
- "managing a coversation will be created.");
- }
-
- protected void createEditors() {
- addEditors(SeamWizardFactory.createActionFormFieldEditors(SeamWizardUtils.getSelectedProjectName()));
- }
-}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -11,6 +11,7 @@
package org.jboss.tools.seam.ui.wizard;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -21,39 +22,64 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.INewWizard;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.wizard.SeamEntityWizard.SeamEntityCreateOperation;
public class SeamConversationWizard extends SeamBaseWizard implements INewWizard {
public SeamConversationWizard() {
super(CREATE_SEAM_CONVERSATION);
setWindowTitle("reate New Conversation");
- addPage(new SeamConversationVizardPage1());
+ addPage(new SeamConversationWizardPage1());
}
- public static final IUndoableOperation CREATE_SEAM_CONVERSATION = new SeamBaseOperation("Action creating operation"){
+ public static final IUndoableOperation CREATE_SEAM_CONVERSATION = new SeamConversationCreateOperation();
+ /**
+ *
+ * TODO move operations to core plugin
+ */
+ public static class SeamConversationCreateOperation extends SeamBaseOperation{
+
+ /**
+ * @param label
+ */
+ public SeamConversationCreateOperation() {
+ super(("Entity creating operation"));
+ }
- public File getBeanFile(Map<String, Object> vars) {
- return new File(getSeamFolder(vars),"src/ActionJavaBean.java");
+ @Override
+ public List<String[]> getFileMappings(Map<String, Object> vars) {
+ if("war".equals(vars.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS)))
+ return ACTION_WAR_MAPPING;
+ else
+ return ACTION_EAR_MAPPING;
}
- public File getTestClassFile(Map<String, Object> vars) {
- return new File(getSeamFolder(vars),"test/ActionTest.java");
- }
+ public static final List<String[]> ACTION_WAR_MAPPING = new ArrayList<String[]>();
- public File getTestngXmlFile(Map<String, Object> vars) {
- return new File(getSeamFolder(vars),"test/testng.xml");
- }
+ public static final List<String[]> ACTION_EAR_MAPPING = new ArrayList<String[]>();
- public File getPageXhtml(Map<String, Object> vars) {
- return new File(getSeamFolder(vars),"view/action.xhtml");
+ static {
+ // initialize war files mapping
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/ConversationBean.java",
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_BEAN_NAME +"}.java"});
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/Conversation.java",
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/view/conversation.xhtml",
+ "${" + IParameter.SEAM_PROJECT_WEBCONTENT_PATH + "}/${" + IParameter.SEAM_PAGE_NAME +"}.xhtml"});
+
+ // initialize ear files mapping
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/ConversationBean.java",
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_BEAN_NAME +"}.java"});
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/Conversation.java",
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
+ ACTION_EAR_MAPPING.add(ACTION_WAR_MAPPING.get(2));
}
-
- @Override
- public List<String[]> getFileMappings(Map<String, Object> vars) {
- // TODO Auto-generated method stub
- return null;
- }
-
};
}
Copied: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizardPage1.java (from rev 3394, trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationVizardPage1.java)
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizardPage1.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizardPage1.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.seam.ui.wizard;
+
+import java.beans.PropertyChangeEvent;
+import java.util.Map;
+
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
+import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
+import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
+import org.jboss.tools.seam.ui.widget.editor.LabelFieldEditor;
+import org.jboss.tools.seam.ui.wizard.SeamBaseWizardPage.GridLayoutComposite;
+
+/**
+ * @author eskimo
+ *
+ */
+public class SeamConversationWizardPage1 extends SeamBaseWizardPage {
+
+ public SeamConversationWizardPage1() {
+ super("seam.new.conversation.page1","Seam Conversation",null);
+ setMessage("Select the name of the new Seam Conversation. A set of classes " +
+ "managing a coversation will be created.");
+ }
+
+ protected void createEditors() {
+ addEditors(SeamWizardFactory.createActionFormFieldEditors(SeamWizardUtils.getSelectedProjectName()));
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ setControl(new GridLayoutComposite(parent));
+
+ if (!"".equals(editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValue())){
+ Map errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(
+ getEditor(IParameter.SEAM_PROJECT_NAME).getValue(), null);
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ getEditor(IParameter.SEAM_BEAN_NAME).setEnabled(false);
+ }
+ }
+ setPageComplete(false);
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getPropertyName().equals(IParameter.SEAM_COMPONENT_NAME)) {
+ if(event.getNewValue()==null||"".equals(event.getNewValue().toString().trim())) {
+ setDefaultValue(IParameter.SEAM_COMPONENT_NAME, "");
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "");
+ setDefaultValue(IParameter.SEAM_BEAN_NAME, "");
+ setDefaultValue(IParameter.SEAM_METHOD_NAME, "");
+ setDefaultValue(IParameter.SEAM_PAGE_NAME, "");
+ } else {
+ String value = event.getNewValue().toString();
+ String valueU = value.substring(0,1).toUpperCase() + value.substring(1);
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "I" + valueU);
+ setDefaultValue(IParameter.SEAM_BEAN_NAME, valueU+"Bean");
+ String valueL = value.substring(0,1).toLowerCase() + value.substring(1);
+ setDefaultValue(IParameter.SEAM_METHOD_NAME, valueL);
+ setDefaultValue(IParameter.SEAM_PAGE_NAME, valueL);
+ }
+ }
+ super.propertyChange(event);
+ }
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -11,6 +11,7 @@
package org.jboss.tools.seam.ui.wizard;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -21,6 +22,8 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.INewWizard;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.widget.editor.INamedElement;
/**
* @author eskimo
@@ -39,30 +42,72 @@
// TODO move operations to core plugin
- public static final IUndoableOperation CREATE_SEAM_ENTITY = new SeamBaseOperation("Action creating operation"){
-
- public File getBeanFile(Map<String, Object> vars) {
- return new File(getSeamFolder(vars),"src/ActionJavaBean.java");
- }
-
- public File getTestClassFile(Map<String, Object> vars) {
- return new File(getSeamFolder(vars),"test/ActionTest.java");
- }
-
- public File getTestngXmlFile(Map<String, Object> vars) {
- return new File(getSeamFolder(vars),"test/testng.xml");
- }
-
- public File getPageXhtml(Map<String, Object> vars) {
- return new File(getSeamFolder(vars),"view/action.xhtml");
- }
+ public static final IUndoableOperation CREATE_SEAM_ENTITY = new SeamEntityCreateOperation();
+ /**
+ *
+ * TODO move operations to core plugin
+ */
+ public static class SeamEntityCreateOperation extends SeamBaseOperation{
+
+ @Override
+ protected void loadCustomVariables(Map<String, Object> vars) {
+ String entityClassname = vars.get(IParameter.SEAM_ENTITY_CLASS_NAME).toString();
+ String seamComponentName = entityClassname.substring(0,1).toLowerCase()+entityClassname.substring(1);
+ vars.put(IParameter.SEAM_COMPONENT_NAME,seamComponentName);
+ }
- @Override
- public List<String[]> getFileMappings(Map<String, Object> vars) {
- // TODO Auto-generated method stub
- return null;
- }
+ /**
+ * @param label
+ */
+ public SeamEntityCreateOperation() {
+ super(("Entity creating operation"));
+ }
+
+ @Override
+ public List<String[]> getFileMappings(Map<String, Object> vars) {
+ if("war".equals(vars.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS)))
+ return ACTION_WAR_MAPPING;
+ else
+ return ACTION_EAR_MAPPING;
+ }
+
+ public static final List<String[]> ACTION_WAR_MAPPING = new ArrayList<String[]>();
+
+ public static final List<String[]> ACTION_EAR_MAPPING = new ArrayList<String[]>();
+
+ static {
+ // initialize war files mapping
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/Entity.java",
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}.java"});
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/EntityHome.java",
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}Home.java"});
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/EntityList.java",
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}List.java"});
+
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/view/edit.xhtml",
+ "${" + IParameter.SEAM_PROJECT_WEBCONTENT_PATH + "}/${" + IParameter.SEAM_MASTER_PAGE_NAME +"}.xhtml"});
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/view/list.xhtml",
+ "${" + IParameter.SEAM_PROJECT_WEBCONTENT_PATH + "}/${" + IParameter.SEAM_PAGE_NAME +"}.xhtml"});
+
- };
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/Entity.java",
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}.java"});
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/EntityHome.java",
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}Home.java"});
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/EntityList.java",
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}List.java"});
+ ACTION_EAR_MAPPING.add(ACTION_WAR_MAPPING.get(3));
+ ACTION_EAR_MAPPING.add(ACTION_WAR_MAPPING.get(4));
+ }
+ };
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -11,6 +11,21 @@
package org.jboss.tools.seam.ui.wizard;
+import java.beans.PropertyChangeEvent;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
+import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
+import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
+import org.jboss.tools.seam.ui.widget.editor.LabelFieldEditor;
+import org.jboss.tools.seam.ui.wizard.SeamBaseWizardPage.GridLayoutComposite;
+
/**
* @author eskimo
*
@@ -35,4 +50,71 @@
addEditor(SeamWizardFactory.createSeamMasterPageNameFieldEditor());
addEditor(SeamWizardFactory.createSeamPageNameFieldEditor());
}
+
+ public void createControl(Composite parent) {
+ setControl(new GridLayoutComposite(parent));
+ setPageComplete(false);
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getPropertyName().equals(IParameter.SEAM_ENTITY_CLASS_NAME)) {
+ if(event.getNewValue()==null||"".equals(event.getNewValue().toString().trim())) {
+ setDefaultValue(IParameter.SEAM_COMPONENT_NAME, "");
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "");
+ setDefaultValue(IParameter.SEAM_BEAN_NAME, "");
+ setDefaultValue(IParameter.SEAM_METHOD_NAME, "");
+ setDefaultValue(IParameter.SEAM_PAGE_NAME, "");
+ } else {
+ String value = event.getNewValue().toString();
+ String valueU = value.substring(0,1).toUpperCase() + value.substring(1);
+ String valueL = value.substring(0,1).toLowerCase() + value.substring(1);
+ setDefaultValue(IParameter.SEAM_MASTER_PAGE_NAME, valueL+"-edit");
+ setDefaultValue(IParameter.SEAM_PAGE_NAME, valueL+"-list");
+ }
+ }
+
+ Map errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValue(), null);
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ getEditor(IParameter.SEAM_BEAN_NAME).setEnabled(false);
+ return;
+ }
+
+ IResource project = getSelectedProject();
+
+
+ errors = ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_ENTITY_CLASS_NAME).getValue(), null);
+
+ if(errors.size()>0) {
+ setErrorMessage(NLS.bind(errors.get(IValidator.DEFAULT_ERROR).toString(),"Entity class name"));
+ setPageComplete(false);
+ return;
+ }
+
+ errors = ValidatorFactory.FILE_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_MASTER_PAGE_NAME).getValue(), (Object)new Object[]{"Entity master page",project});
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+
+ errors = ValidatorFactory.FILE_NAME_VALIDATOR.validate(
+ editorRegistry.get(IParameter.SEAM_PAGE_NAME).getValue(), (Object)new Object[]{"Page",project});
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+
+ setErrorMessage(null);
+ setMessage(null);
+ setPageComplete(true);
+ }
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -98,10 +98,10 @@
// initialize ear files mapping
FORM_EAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/FormActionBean.java",
- "${" + IParameter.SEAM_EAR_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_BEAN_NAME +"}.java"});
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_BEAN_NAME +"}.java"});
FORM_EAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/FormAction.java",
- "${" + IParameter.SEAM_EAR_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
+ "${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH + "}/ejbModule/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
FORM_EAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/test/FormTest.java",
"${" + IParameter.SEAM_TEST_PROJECT_LOCATION_PATH + "}/test-src/${" + ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH + "}/${"+ IParameter.SEAM_LOCAL_INTERFACE_NAME +"}Test.java"});
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizardPage1.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizardPage1.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizardPage1.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -10,7 +10,11 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.beans.PropertyChangeEvent;
+import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
+
+
/**
* @author eskimo
*
@@ -29,4 +33,26 @@
protected void createEditors() {
addEditors(SeamWizardFactory.createActionFormFieldEditors(SeamWizardUtils.getSelectedProjectName()));
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getPropertyName().equals(IParameter.SEAM_COMPONENT_NAME)) {
+ if(event.getNewValue()==null||"".equals(event.getNewValue().toString().trim())) {
+ setDefaultValue(IParameter.SEAM_COMPONENT_NAME, "");
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "");
+ setDefaultValue(IParameter.SEAM_BEAN_NAME, "");
+ setDefaultValue(IParameter.SEAM_METHOD_NAME, "");
+ setDefaultValue(IParameter.SEAM_PAGE_NAME, "");
+ } else {
+ String value = event.getNewValue().toString();
+ String valueU = value.substring(0,1).toUpperCase() + value.substring(1);
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "I" + valueU);
+ setDefaultValue(IParameter.SEAM_BEAN_NAME, valueU+"Bean");
+ String valueL = value.substring(0,1).toLowerCase() + value.substring(1);
+ setDefaultValue(IParameter.SEAM_METHOD_NAME, valueL);
+ setDefaultValue(IParameter.SEAM_PAGE_NAME, valueL);
+ }
+ }
+ super.propertyChange(event);
+ }
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -25,6 +25,7 @@
import org.eclipse.ui.dialogs.ListDialog;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamFacetPreference;
import org.jboss.tools.seam.internal.core.SeamProject;
@@ -40,8 +41,8 @@
*/
public SeamProjectSelectionDialog(Shell parent) {
super(parent);
- setTitle("Seam Projects");
- setMessage("Select Seam Project");
+ setTitle("Seam Web Projects");
+ setMessage("Select Seam Web Project");
setLabelProvider(new WorkbenchLabelProvider());
setInput(new Object());
setContentProvider(new IStructuredContentProvider() {
@@ -51,7 +52,8 @@
try {
if(project.hasNature(SeamProject.NATURE_ID)
&& SeamCorePlugin.getSeamPreferences(project)!=null
- && project.getAdapter(IFacetedProject.class)!=null) {
+ && project.getAdapter(IFacetedProject.class)!=null
+ && ((IFacetedProject)project.getAdapter(IFacetedProject.class)).hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.web"))) {
seamProjects.add(project);
}
} catch (CoreException e) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2007-09-25 07:27:00 UTC (rev 3783)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2007-09-25 08:39:17 UTC (rev 3784)
@@ -73,7 +73,7 @@
*/
public static IFieldEditor createSeamMasterPageNameFieldEditor() {
return SwtFieldEditorFactory.INSTANCE.createTextEditor(
- IParameter.SEAM_PAGE_NAME, "Master page name:", "");
+ IParameter.SEAM_MASTER_PAGE_NAME, "Master page name:", "");
}
public static final IFieldEditor[] createActionFormFieldEditors(String defaultSelection) {
17 years, 3 months
JBoss Tools SVN: r3783 - in trunk/hibernatetools: plugins/org.hibernate.eclipse.console and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-09-25 03:27:00 -0400 (Tue, 25 Sep 2007)
New Revision: 3783
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettings.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettings.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/schema/exporters.exsd
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ExtensionManager.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterDefinition.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/LaunchConfigurationTabGroup.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ExporterTest.java
Log:
JBIDE-880
JBIDE-857
JBIDE-941
HBX-625
In short: eclipse code generation can now also have multiple exporters (of the same kind) and supports <hbmtemplate> too.
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -194,6 +194,7 @@
String str = properties.getProperty( "hibernate.transaction.manager_lookup_class" );
if(str != null && StringHelper.isEmpty( str )) {
properties.setProperty( "hibernate.transaction.manager_lookup_class", "org.hibernate.console.FakeTransactionManagerLookup");
+ //properties.setProperty( "hibernate.transaction.factory_class", "");
}
}
@@ -201,6 +202,9 @@
if(localCfg==null) {
localCfg = buildConfiguration( properties, includeMappings );
} else {
+ //Properties origProperties = cfg.getProperties();
+ //origProperties.putAll(properties);
+ //cfg.setProperties(origProperties);
// TODO: this is actually only for jdbc reveng...
//localCfg = configureStandardConfiguration( includeMappings, localCfg, properties );
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2007-09-25 07:27:00 UTC (rev 3783)
@@ -8,7 +8,7 @@
<perspective
icon="icons/hibernate_small_icon.gif"
class="org.hibernate.eclipse.console.HibernateConsolePerspectiveFactory"
- name="Hibernate Console"
+ name="Hibernate"
id="org.hibernate.eclipse.console.HibernateConsolePerspective"/>
</extension>
<extension
@@ -368,7 +368,7 @@
category="org.hibernate.eclipse.launchcategory"
id="org.hibernate.eclipse.launch.CodeGenerationLaunchGroup"
image="icons/images/hibernate_launch.png"
- label="Hibernate Code Generation..."
+ label="Hibernate Code Generation"
mode="run"
title="Select or configure a code generation to run"/>
<launchGroup
@@ -376,7 +376,7 @@
category="org.hibernate.eclipse.launchcategory"
id="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchGroup"
image="icons/images/hibernate_launch.png"
- label="Hibernate Console Configuration..."
+ label="Hibernate Console Configuration"
mode="run"
title="Select or configure a console configuration to run"/>
</extension>
@@ -405,12 +405,33 @@
name="jdk5"
type="boolean"
value="false"/>
+ <property
+ description="Output directory"
+ name="outputdir"
+ type="directory"
+ value=""/>
+ <property
+ description="Template directory"
+ name="template_path"
+ type="path"
+ value=""/>
</exporter>
<exporter
classname="org.hibernate.tool.hbm2x.HibernateMappingExporter"
description="Hibernate XML Mappings (.hbm.xml)"
icon="icons/images/hibernate_mapping.gif"
- id="org.hibernate.tools.hbm2hbmxml"/>
+ id="org.hibernate.tools.hbm2hbmxml">
+ <property
+ description="Output directory"
+ name="outputdir"
+ type="directory"
+ value=""/>
+ <property
+ description="Template directory"
+ name="template_path"
+ type="path"
+ value=""/>
+ </exporter>
<exporter
classname="org.hibernate.tool.hbm2x.DAOExporter"
description="DAO code (.java)"
@@ -426,13 +447,65 @@
name="jdk5"
type="boolean"
value="false"/>
+ <property
+ description="Output directory"
+ name="outputdir"
+ type="directory"
+ value=""/>
+ <property
+ description="Template directory"
+ name="template_path"
+ type="path"
+ value=""/>
</exporter>
-
+ <exporter
+ classname="org.hibernate.tool.hbm2x.GenericExporter"
+ description="Generic Exporter (<hbmtemplate>)"
+ icon="icons/images/hibernate_mapping.gif"
+ id="org.hibernate.tools.hbmtemplate">
+ <property
+ description="Output directory"
+ name="outputdir"
+ type="directory"
+ value=""/>
+ <property
+ description="Template directory"
+ name="template_path"
+ type="path"
+ value=""/>
+ <property
+ description="File pattern"
+ name="file_pattern"
+ type="string"
+ value="${package-name}/${class-name}.java"/>
+ <property
+ description="For each"
+ name="for_each"
+ type="string"
+ value="entity, component"/>
+ <property
+ description="Template name"
+ name="template_name"
+ type="string"
+ value="pojo/Pojo.ftl"/>
+ </exporter>
+
<exporter
classname="org.hibernate.tool.hbm2x.HibernateConfigurationExporter"
description="Hibernate XML Configuration (.cfg.xml)"
icon="icons/hibernate_small_icon.gif"
- id="org.hibernate.tools.hbm2cfgxml"/>
+ id="org.hibernate.tools.hbm2cfgxml">
+ <property
+ description="Output directory"
+ name="outputdir"
+ type="directory"
+ value=""/>
+ <property
+ description="Template directory"
+ name="template_path"
+ type="path"
+ value=""/>
+ </exporter>
<exporter
classname="org.hibernate.tool.hbm2x.DocExporter"
description="Schema Documentation (.html)"
@@ -443,6 +516,16 @@
name="dot.executable"
type="string"
value="dot.exe"/>
+ <property
+ description="Output directory"
+ name="outputdir"
+ type="directory"
+ value=""/>
+ <property
+ description="Template directory"
+ name="template_path"
+ type="path"
+ value=""/>
</exporter>
<!-- <exporter
classname="org.hibernate.tool.hbm2x.seam.SeamExporter"
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/schema/exporters.exsd
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/schema/exporters.exsd 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/schema/exporters.exsd 2007-09-25 07:27:00 UTC (rev 3783)
@@ -125,6 +125,10 @@
</enumeration>
<enumeration value="boolean">
</enumeration>
+ <enumeration value="directory">
+ </enumeration>
+ <enumeration value="path">
+ </enumeration>
</restriction>
</simpleType>
</attribute>
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ExtensionManager.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ExtensionManager.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ExtensionManager.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -41,6 +41,8 @@
package org.hibernate.eclipse.console;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -53,7 +55,7 @@
{
public static final String EXPORTERS_EXTENSION_ID = "org.hibernate.eclipse.console.exporters";
- public static IExtension[] findExtensions (String extensionId)
+ private static IExtension[] findExtensions (String extensionId)
{
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = registry.getExtensionPoint(extensionId);
@@ -77,4 +79,19 @@
return (ExporterDefinition[]) exporters.toArray(new ExporterDefinition[exporters.size()]);
}
+
+ /**
+ * return map of ExporterDefinitions keyed by id
+ */
+ public static Map findExporterDefinitionsAsMap() {
+ Map result = new HashMap();
+
+ ExporterDefinition[] findExporterDefinitions = findExporterDefinitions();
+ for (int i = 0; i < findExporterDefinitions.length; i++) {
+ ExporterDefinition exporterDefinition = findExporterDefinitions[i];
+ result.put(exporterDefinition.getId(), exporterDefinition);
+ }
+
+ return result;
+ }
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterDefinition.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterDefinition.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -40,8 +40,10 @@
*/
package org.hibernate.eclipse.console.model.impl;
+import java.io.File;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -49,11 +51,19 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.hibernate.cfg.Configuration;
import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.eclipse.HibernatePlugin;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.tool.hbm2x.Exporter;
import org.hibernate.util.ReflectHelper;
+/**
+ * Represents what is specified in plugin.xml about possible exporters.
+ *
+ */
public class ExporterDefinition {
+
final private String classname;
final private String description;
@@ -105,6 +115,7 @@
return properties;
}
+
public Exporter createExporterInstance() {
Exporter exporter = null;
@@ -131,7 +142,7 @@
return iconDescriptor;
}
- public Map getProperties() {
+ public Map getExporterProperties() {
return properties;
}
@@ -144,7 +155,9 @@
enabled = configuration.getAttribute( id, false );
}
catch (CoreException e) {
- e.printStackTrace(); // TODO-marshall: bad!
+ // log and assume false
+ HibernateConsolePlugin.getDefault().log(e);
+ return false;
}
return enabled;
@@ -153,4 +166,6 @@
public String getId() {
return id;
}
+
+
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -1,14 +1,28 @@
package org.hibernate.eclipse.console.model.impl;
+import java.io.File;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.apache.lucene.util.StringHelper;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.hibernate.eclipse.launch.PathHelper;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.GenericExporter;
+/**
+ * ExporterFactory is used in UI to hold additional configuration for Exporter definitions
+ * @author max
+ *
+ */
public class ExporterFactory {
private ExporterDefinition definition;
@@ -16,14 +30,17 @@
final Map inputProperties;
private boolean enabled = true;
+
+ private final String exporterId;
- public ExporterFactory(ExporterDefinition definition) {
+ public ExporterFactory(ExporterDefinition definition, String exporterId) {
this.definition = definition;
+ this.exporterId = exporterId;
inputProperties = new HashMap();
}
public Map getDefaultExporterProperties() {
- return definition.getProperties();
+ return definition.getExporterProperties();
}
@@ -39,7 +56,7 @@
if(inputProperties.containsKey( key )) {
return (String) inputProperties.get( key );
} else {
- ExporterProperty ep = (ExporterProperty) definition.getProperties().get( key );
+ ExporterProperty ep = (ExporterProperty) definition.getExporterProperties().get( key );
if(ep!=null) {
return ep.getDefaultValue();
} else {
@@ -60,33 +77,60 @@
return definition;
}
+ // todo: move to ExporterAttributes together with isEnabled functionallity...
+ String getLaunchAttributePrefix(String exporterId) {
+ return HibernateLaunchConstants.ATTR_EXPORTERS + "." + exporterId;
+ }
+
public boolean isEnabled(ILaunchConfiguration configuration) {
boolean enabled = false;
try {
- // if we put this in some "namespace" we should have a way to either
- // migrate an existing one...
- enabled = configuration.getAttribute( definition.getId(), false );
+ if(configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List)null)==null) {
+ enabled = configuration.getAttribute( getId(), false );
+ } else {
+ enabled = configuration.getAttribute( getLaunchAttributePrefix( getId() ), false );
}
- catch (CoreException e) {
- e.printStackTrace(); // TODO-marshall: bad!
+ } catch(CoreException ce) {
+ // ignore; assume false
+ enabled=false;
}
-
+
setEnabled( enabled );
return isEnabled();
}
- public void setEnabled(ILaunchConfigurationWorkingCopy configuration, boolean enabled) {
+ public void setEnabled(ILaunchConfigurationWorkingCopy configuration, boolean enabled, boolean oldSettings) {
setEnabled( enabled );
- configuration.setAttribute( definition.getId(), isEnabled() );
+ if(oldSettings) {
+ configuration.setAttribute( getId(), isEnabled() );
+ } else {
+ configuration.setAttribute( getLaunchAttributePrefix( getId() ), isEnabled());
+ }
}
+
+ public void setEnabled(ILaunchConfigurationWorkingCopy configuration, boolean enabled) {
+
+ boolean oldSettings = true;
+ try {
+ if(configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List)null)==null) {
+ oldSettings = true;
+ } else {
+ oldSettings = false;
+ }
+ } catch(CoreException ce) {
+ // ignore and assume settings are old
+ }
+ setEnabled(configuration, enabled, oldSettings);
+ }
+
public Map getProperties() {
return inputProperties;
}
public String getId() {
- return getExporterDefinition().getId(); // TODO: namespacing
+ return exporterId;
}
public void setProperties(Map props) {
@@ -95,11 +139,69 @@
}
public ExporterProperty getExporterProperty(String key) {
- return (ExporterProperty) definition.getProperties().get( key );
+ return (ExporterProperty) definition.getExporterProperties().get( key );
}
public boolean hasLocalValueFor(String string) {
return inputProperties.containsKey( string );
}
+ public Exporter createConfiguredExporter(Configuration cfg, File outputdir,
+ String[] templatePaths, Properties globalProperties) {
+ Exporter exporter = getExporterDefinition().createExporterInstance();
+
+ Properties props = new Properties();
+ props.putAll(globalProperties);
+ props.putAll(getProperties());
+
+ exporter.setProperties(props);
+
+ exporter.setOutputDirectory(outputdir);
+ if(props.containsKey("outputdir")) {
+ String loc = PathHelper.getLocationAsStringPath(props.getProperty("outputdir"));
+ if(loc==null) {
+ throw new HibernateConsoleRuntimeException("Output directory '" + props.getProperty("outputdir") + "' in " + getExporterDefinition().getDescription() + " does not exist.");
+ }
+ props.remove("outputdir"); // done to avoid validation check in hibernate tools templates
+ if(org.hibernate.util.StringHelper.isNotEmpty(loc)) { // only set if something valid found
+ exporter.setOutputDirectory(new File(loc));
+ }
+ } else {
+
+ }
+
+ exporter.setConfiguration(cfg);
+
+ if(props.containsKey("template_path")) {
+ String locationAsStringPath = PathHelper.getLocationAsStringPath(props.getProperty("template_path"));
+ if(locationAsStringPath==null) {
+ throw new HibernateConsoleRuntimeException("Template directory '" + props.getProperty("template_path") + "' in " + getExporterDefinition().getDescription() + " does not exist.");
+ }
+
+ String[] newPath = new String[templatePaths.length+1];
+ System.arraycopy(templatePaths, 0, newPath, 0, templatePaths.length);
+
+ newPath[templatePaths.length] = locationAsStringPath;
+
+ exporter.setTemplatePath(newPath);
+ props.remove("template_path"); // done to avoid validation check in hibernate tools templates
+ } else {
+ exporter.setTemplatePath(templatePaths);
+ }
+
+ // special handling for GenericExporter (should be delegated via plugin.xml)
+ if(exporter instanceof GenericExporter) {
+ GenericExporter ge = (GenericExporter) exporter;
+
+ ge.setFilePattern(props.getProperty("file_pattern", null));
+ props.remove("file_pattern");
+ ge.setTemplateName(props.getProperty("template_name",null));
+ props.remove("template_name");
+ ge.setForEach(props.getProperty("for_each",null));
+ props.remove("for_each");
+
+ }
+ return exporter;
+ }
+
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/UpDownListComposite.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -23,6 +23,9 @@
import java.util.Iterator;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
@@ -58,8 +61,12 @@
private Button[] addButtons;
private TableViewer tableView;
- private ILabelProvider provider = null;
+ private IBaseLabelProvider provider = null;
private final String title;
+
+ private final boolean checkboxInTable;
+
+ private IContentProvider contentProvider;
public UpDownListComposite(Composite parent, int style) {
@@ -67,13 +74,15 @@
}
public UpDownListComposite(Composite parent, int style, String title) {
- this( parent, style, title, null);
+ this( parent, style, title, false, null, null);
}
- public UpDownListComposite(Composite parent, int style, String title, ILabelProvider provider) {
+ public UpDownListComposite(Composite parent, int style, String title, boolean checkboxInTable, IBaseLabelProvider provider, IContentProvider contentProvider) {
super( parent, style );
this.title = title;
+ this.checkboxInTable = checkboxInTable;
this.provider = provider;
+ this.contentProvider = contentProvider;
initialize();
}
@@ -116,7 +125,7 @@
gridData1.heightHint = 20;
gridData1.widthHint = 20;
- table = new Table(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI );
+ table = new Table(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | (checkboxInTable?SWT.CHECK:SWT.NONE));
table.setHeaderVisible(false);
table.setLayoutData(gridData1);
table.setLinesVisible(false);
@@ -134,8 +143,9 @@
});
- tableView = new TableViewer(table);
+ tableView = checkboxInTable?new CheckboxTableViewer(table):new TableViewer(table);
if(provider!=null) tableView.setLabelProvider(provider);
+ if(contentProvider!=null) tableView.setContentProvider(contentProvider);
}
@@ -217,11 +227,11 @@
private void handleButtonPressed(Button button) {
if (button == removeButton) {
- handleRemoveButtonPressed(tableView);
+ handleRemove();
} else if (button == upButton) {
- moveSelectionUp(tableView);
+ moveSelectionUp();
} else if (button == downButton) {
- moveSelectionDown(tableView);
+ moveSelectionDown();
} else {
for (int i = 0; i < addButtons.length; i++) {
Button but = addButtons[i];
@@ -235,8 +245,8 @@
}
- private void moveSelectionDown(TableViewer viewer) {
- Table table = viewer.getTable();
+ protected void moveSelectionDown() {
+ Table table = tableView.getTable();
int indices[]= table.getSelectionIndices();
if (indices.length < 1) {
return;
@@ -246,25 +256,27 @@
for (int i = indices.length - 1; i >= 0; i--) {
int index= indices[i];
if (index < max) {
- move (viewer, table.getItem(index), index + 1);
+ move (tableView, table.getItem(index), index + 1);
newSelection[i]= index + 1;
}
}
table.setSelection(newSelection);
+ listChanged();
}
- private void moveSelectionUp(TableViewer viewer) {
- Table table = viewer.getTable();
+ protected void moveSelectionUp() {
+ Table table = tableView.getTable();
int indices[]= table.getSelectionIndices();
int newSelection[]= new int[indices.length];
for (int i = 0; i < indices.length; i++) {
int index= indices[i];
if (index > 0) {
- move (viewer, table.getItem(index), index - 1);
+ move (tableView, table.getItem(index), index - 1);
newSelection[i]= index - 1;
}
}
table.setSelection(newSelection);
+ listChanged();
}
/**
@@ -276,20 +288,22 @@
viewer.insert(data, index);
}
- private void handleRemoveButtonPressed(TableViewer viewer) {
- IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ protected void handleRemove() {
+ IStructuredSelection selection = (IStructuredSelection) tableView.getSelection();
if (selection != null) {
int numSelected= selection.size();
Iterator iterator= selection.iterator();
while (iterator.hasNext() ) {
Object item= iterator.next();
- viewer.remove(item);
+ tableView.remove(item);
}
listChanged();
}
}
+
+
private void handleAddButtonPressed(int i) {
Object[] o = handleAdd(i);
if(o!=null) {
@@ -320,7 +334,7 @@
Table builderTable= tableView.getTable();
TableItem[] items = builderTable.getSelection();
boolean validSelection= items != null && items.length > 0;
- boolean enableRemove= validSelection;
+ boolean enableRemove=validSelection;
boolean enableUp= validSelection;
boolean enableDown= validSelection;
if (validSelection) {
@@ -338,6 +352,10 @@
public Table getTable() {
return tableView.getTable();
}
+
+ public TableViewer getTableViewer() {
+ return tableView;
+ }
public void clear() {
tableView.getTable().removeAll();
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -176,7 +176,7 @@
}
private void refreshOutputDir(String outputdir) {
- IResource bufferRes = findMember(ResourcesPlugin.getWorkspace().getRoot(), outputdir);
+ IResource bufferRes = PathHelper.findMember(ResourcesPlugin.getWorkspace().getRoot(), outputdir);
if (bufferRes != null && bufferRes.isAccessible()) {
try {
@@ -187,63 +187,41 @@
}
}
- private Path pathOrNull(String p) {
- if(p==null || p.trim().length()==0) {
- return null;
- } else {
- return new Path(p);
- }
- }
-
- private ArtifactCollector runExporters (final ExporterAttributes attributes, final ExporterFactory[] exporters, final IProgressMonitor monitor)
+ private ArtifactCollector runExporters (final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final IProgressMonitor monitor)
throws CoreException
{
- monitor.beginTask("Generating code for " + attributes.getConsoleConfigurationName(), exporters.length + 1);
+ monitor.beginTask("Generating code for " + attributes.getConsoleConfigurationName(), exporterFactories.length + 1);
if (monitor.isCanceled())
return null;
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- final IResource resource = findMember( root, attributes.getOutputPath() );
- final IResource templateres = findMember(root, attributes.getTemplatePath());
- String templatePath = null;
+ final String outputPathRes = PathHelper.getLocationAsStringPath( attributes.getOutputPath() );
- if (new File(attributes.getTemplatePath()).exists())
- {
- templatePath = attributes.getTemplatePath();
- }
-
- /*if (!resource.exists() || !(resource instanceof IContainer) ) {
- throwCoreException("Output directory \"" + configName + "\" does not exist.");
- }*/
- /*IContainer container = (IContainer) resource;*/
-
+ final String templatePath = PathHelper.getLocationAsStringPath(attributes.getTemplatePath());
+
ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
if (attributes.isReverseEngineer()) {
monitor.subTask("reading jdbc metadata");
}
- final Configuration cfg = buildConfiguration(attributes, cc, root);
+ final Configuration cfg = buildConfiguration(attributes, cc, ResourcesPlugin.getWorkspace().getRoot());
monitor.worked(1);
if (monitor.isCanceled())
return null;
-
- final String finalTemplatePath = templatePath;
+
return (ArtifactCollector) cc.execute(new Command() {
private ArtifactCollector artifactCollector = new ArtifactCollector();
public Object execute() {
- File outputdir = getLocation( resource ).toFile();
+ File outputdir = new File( outputPathRes );
String[] templatePaths = new String[0];
-
- if(templateres!=null) {
- templatePaths = new String[] { getLocation( templateres ).toOSString() }; // TODO: this should not be..should it ?
- } else if (finalTemplatePath != null) {
- templatePaths = new String[] { finalTemplatePath };
+
+ if(StringHelper.isNotEmpty(templatePath)) {
+ templatePaths = new String[] { templatePath };
}
// Global properties
@@ -251,32 +229,21 @@
props.put("ejb3", ""+attributes.isEJB3Enabled());
props.put("jdk5", ""+attributes.isJDK5Enabled());
- for (int i = 0; i < exporters.length; i++)
+ for (int i = 0; i < exporterFactories.length; i++)
{
- monitor.subTask(exporters[i].getExporterDefinition().getDescription());
+ monitor.subTask(exporterFactories[i].getExporterDefinition().getDescription());
- Properties exporterProperties = new Properties();
- exporterProperties.putAll(props);
- exporterProperties.putAll(exporters[i].getProperties());
+ Properties globalProperties = new Properties();
+ globalProperties.putAll(props);
- Exporter exporter = exporters[i].getExporterDefinition().createExporterInstance();
+ Exporter exporter = exporterFactories[i].createConfiguredExporter(cfg, outputdir, templatePaths, globalProperties);
- configureExporter (cfg, outputdir, templatePaths, exporterProperties, exporter);
-
exporter.start();
monitor.worked(1);
}
return getArtififactCollector();
}
- private void configureExporter(final Configuration cfg, File outputdir, String[] templatePaths, Properties props, Exporter exporter) {
- exporter.setProperties(props);
- exporter.setOutputDirectory(outputdir);
- exporter.setConfiguration(cfg);
- exporter.setTemplatePath(templatePaths);
- exporter.setArtifactCollector(getArtififactCollector());
- }
-
private ArtifactCollector getArtififactCollector() {
return artifactCollector ;
}
@@ -285,24 +252,11 @@
}
- private IResource findMember(IWorkspaceRoot root, String path) {
- Path pathOrNull = pathOrNull(path);
- if(pathOrNull==null) return null;
- return root.findMember(pathOrNull);
- }
-
- private IPath getLocation(final IResource resource) {
- if (resource.getRawLocation() == null) {
- return resource.getLocation();
- }
- else return resource.getRawLocation();
- }
-
private Configuration buildConfiguration(final ExporterAttributes attributes, ConsoleConfiguration cc, IWorkspaceRoot root) {
final boolean reveng = attributes.isReverseEngineer();
final String reverseEngineeringStrategy = attributes.getRevengStrategy();
final boolean preferBasicCompositeids = attributes.isPreferBasicCompositeIds();
- final IResource revengres = findMember( root, attributes.getRevengSettings());
+ final IResource revengres = PathHelper.findMember( root, attributes.getRevengSettings());
if(reveng) {
Configuration configuration = null;
@@ -332,7 +286,7 @@
if(revengres!=null) {
/*Configuration configuration = cc.buildWith(new Configuration(), false);*/
/*Settings settings = cc.getSettings(configuration);*/
- File file = getLocation( revengres ).toFile();
+ File file = PathHelper.getLocation( revengres ).toFile();
OverrideRepository repository = new OverrideRepository();///*settings.getDefaultCatalogName(),settings.getDefaultSchemaName()*/);
repository.addFile(file);
res = repository.getReverseEngineeringStrategy(res);
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettings.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettings.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettings.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -1,480 +0,0 @@
-/*
- * 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.launch;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.jdt.core.JavaConventions;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
-import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.ImageConstants;
-import org.hibernate.console.KnownConfigurations;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.eclipse.console.utils.DialogSelectionHelper;
-import org.hibernate.eclipse.console.utils.EclipseImages;
-import org.hibernate.eclipse.console.wizards.NewReverseEngineeringFileWizard;
-
-public class CodeGenerationSettings extends AbstractLaunchConfigurationTab {
-
- private ComboDialogField consoleConfigurationName;
-
- private IStructuredSelection selection;
-
- private SelectionButtonDialogField reverseengineer;
-
- private StringButtonDialogField outputdir;
-
- private StringButtonDialogField reverseEngineeringSettings;
-
- private StringButtonDialogField reverseEngineeringStrategy;
-
- private StringDialogField packageName;
-
- private SelectionButtonDialogField preferRawCompositeIds;
- private SelectionButtonDialogField autoVersioning;
- private SelectionButtonDialogField autoManyToMany;
-
- private SelectionButtonDialogField useOwnTemplates;
- private DirectoryBrowseField templatedir;
-
-
-
- public CodeGenerationSettings() {
- super();
- }
-
- public void createControl(Composite parent) {
-
- //initializeDialogUnits(parent);
-
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
-
- container.setLayout(layout);
- layout.numColumns = 4;
- layout.verticalSpacing = 10;
-
- consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
- consoleConfigurationName.setLabelText("Console &configuration:");
- ConsoleConfiguration[] cfg = KnownConfigurations.getInstance().getConfigurationsSortedByName();
- String[] names = new String[cfg.length];
- for (int i = 0; i < cfg.length; i++) {
- ConsoleConfiguration configuration = cfg[i];
- names[i] = configuration.getName();
- }
- consoleConfigurationName.setItems(names);
-
- IDialogFieldListener fieldlistener = new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- dialogChanged();
- }
- };
-
- consoleConfigurationName.setDialogFieldListener(fieldlistener);
-
- outputdir = new StringButtonDialogField(new IStringButtonAdapter() {
- public void changeControlPressed(DialogField field) {
- IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(), getOutputDirectory(), new IPath[0], "Select output directory", "Choose directory in which the generated files will be stored", new String[] {"cfg.xml"}, false, true, false);
- if(paths!=null && paths.length==1) {
- outputdir.setText( ( (paths[0]).toOSString() ) );
- }
- }
- });
- outputdir.setDialogFieldListener(fieldlistener);
- outputdir.setLabelText("Output &directory:");
- outputdir.setButtonLabel("&Browse...");
-
- templatedir = new DirectoryBrowseField(null, null, "Select template directory", "Choose directory containing custom templates");
- templatedir.setDialogFieldListener(fieldlistener);
- templatedir.setLabelText("Template &directory:");
- templatedir.setFilesystemBrowseLabel("&Filesystem...");
- templatedir.setWorkspaceBrowseLabel("&Workspace...");
-
- packageName = new StringDialogField();
- packageName.setDialogFieldListener(fieldlistener);
- packageName.setLabelText("&Package:");
-
- reverseEngineeringStrategy = new StringButtonDialogField(new IStringButtonAdapter() {
-
- public void changeControlPressed(DialogField field) {
- String string = DialogSelectionHelper.chooseImplementation(ReverseEngineeringStrategy.class.getName(), reverseEngineeringStrategy.getText(), "Choose a reverse engineering strategy", getShell());
- if(string!=null) {
- reverseEngineeringStrategy.setText(string);
- }
- }
- });
- reverseEngineeringStrategy.setDialogFieldListener(fieldlistener);
- reverseEngineeringStrategy.setLabelText("reveng. s&trategy:");
- reverseEngineeringStrategy.setButtonLabel("&Browse...");
-
- reverseEngineeringSettings= new StringButtonDialogField(new IStringButtonAdapter() {
- public void changeControlPressed(DialogField field) {
- int defaultChoice = 0;
- IPath reverseEngineeringSettingsFile = getReverseEngineeringSettingsFile();
-
- if(reverseEngineeringSettingsFile==null) {
- defaultChoice = 0;
- } else {
- defaultChoice = 1;
- }
- MessageDialog dialog = new MessageDialog(getShell(),
- "Setup reverse engineering",
- null,
- "Do you want to create a new reveng.xml or use an existing file ?",
- MessageDialog.QUESTION,
- new String[] { "Create &new...", "Use &existing...", IDialogConstants.CANCEL_LABEL},
- defaultChoice);
- int answer = dialog.open();
- if(answer==0) { // create new
- NewReverseEngineeringFileWizard wizard = new NewReverseEngineeringFileWizard();
- wizard.init(PlatformUI.getWorkbench(), selection );
- wizard.setSelectConfiguration(getConfigurationName());
- IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- WizardDialog wdialog = new WizardDialog(win.getShell(), wizard);
- wdialog.open(); // This opens a dialog
- IPath createdFilePath = wizard.getCreatedFilePath();
- if(createdFilePath!=null) {
- reverseEngineeringSettings.setText(createdFilePath.toOSString());
- }
- } else if (answer==1) { // use existing
- IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(), reverseEngineeringSettingsFile, new IPath[0], "Select reverse engineering settings file", "Choose file from which settings for the reverse engineering will be read", new String[] {"reveng.xml"}, false, false, true);
- if(paths!=null && paths.length==1) {
- reverseEngineeringSettings.setText( ( (paths[0]).toOSString() ) );
- }
- }
- }
- });
- reverseEngineeringSettings.setDialogFieldListener(fieldlistener);
- reverseEngineeringSettings.setLabelText("reveng.&xml:");
- reverseEngineeringSettings.setButtonLabel("&Setup...");
-
- reverseengineer = new SelectionButtonDialogField(SWT.CHECK);
- reverseengineer.setLabelText("Reverse engineer from JDBC Connection");
- reverseengineer.setDialogFieldListener(fieldlistener);
-
- useOwnTemplates = new SelectionButtonDialogField(SWT.CHECK);
- useOwnTemplates.setDialogFieldListener(fieldlistener);
- useOwnTemplates.setLabelText("Use custom templates (for custom file generation)");
-
- preferRawCompositeIds = new SelectionButtonDialogField(SWT.CHECK);
- preferRawCompositeIds.setLabelText("Generate basic typed composite ids");
- preferRawCompositeIds.setSelection(true);
- preferRawCompositeIds.setDialogFieldListener(fieldlistener);
-
- autoManyToMany = new SelectionButtonDialogField(SWT.CHECK);
- autoManyToMany.setLabelText("Detect many-to-many tables");
- autoManyToMany.setSelection(true);
- autoManyToMany.setDialogFieldListener(fieldlistener);
-
- autoVersioning = new SelectionButtonDialogField(SWT.CHECK);
- autoVersioning.setLabelText("Detect optimistic lock columns");
- autoVersioning.setSelection(true);
- autoVersioning.setDialogFieldListener(fieldlistener);
-
- useOwnTemplates.attachDialogField(templatedir);
- reverseengineer.attachDialogFields(new DialogField[] { packageName, preferRawCompositeIds, reverseEngineeringSettings, reverseEngineeringStrategy, autoManyToMany, autoVersioning });
-
- consoleConfigurationName.doFillIntoGrid(container, 4);
- Control[] controls = outputdir.doFillIntoGrid(container, 4);
- // Hack to tell the text field to stretch!
- ( (GridData)controls[1].getLayoutData() ).grabExcessHorizontalSpace=true;
- reverseengineer.doFillIntoGrid(container, 4);
- packageName.doFillIntoGrid(container, 4);
- reverseEngineeringSettings.doFillIntoGrid(container, 4);
- reverseEngineeringStrategy.doFillIntoGrid(container, 4);
-
- fillLabel(container);
- preferRawCompositeIds.doFillIntoGrid(container, 3);
- fillLabel(container);
- autoVersioning.doFillIntoGrid(container, 3);
- fillLabel(container);
- autoManyToMany.doFillIntoGrid(container, 3);
- useOwnTemplates.doFillIntoGrid(container, 4);
- controls = templatedir.doFillIntoGrid(container, 4);
- // Hack to tell the text field to stretch!
- ( (GridData)controls[1].getLayoutData() ).grabExcessHorizontalSpace=true;
-
- dialogChanged();
- setControl(container);
- }
-
- private void fillLabel(Composite container) {
- new Label(container, SWT.NULL);
- }
-
-
- private void dialogChanged() {
- boolean configSelected = getConfigurationName().length()==0;
- outputdir.setEnabled(!configSelected);
- reverseengineer.setEnabled(!configSelected);
- useOwnTemplates.setEnabled(!configSelected);
-
- if (configSelected) {
- updateStatus("Console configuration must be specified");
- return;
- }
-
- String msg = checkDirectory(getOutputDirectory(), "output directory", false);
-
- if (msg!=null) {
- updateStatus(msg);
- return;
- }
-
- if(packageName.isEnabled() && getOutputPackage().length()>0) {
- IStatus val= JavaConventions.validatePackageName(getOutputPackage() );
- if (val.getSeverity() == IStatus.ERROR || val.getSeverity() == IStatus.WARNING) {
- updateStatus(val.getMessage() );
- return;
- }
- }
-
- if(reverseEngineeringSettings.getText().trim().length()>0) {
- msg = checkFile(getReverseEngineeringSettingsFile(), "reveng.xml");
- if(msg!=null) {
- updateStatus(msg);
- return;
- }
- }
-
- if(useOwnTemplates.isSelected() ) {
- msg = checkDirectory(getTemplateDirectory(), "template directory", true);
- if (msg!=null) {
- updateStatus(msg);
- return;
- } else {
- // imprecise and inefficient to check recursively all for .vm
- /*IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(getTemplateDirectory() );
- IResource[] files = new IFile[0];
- boolean found = false;
-
- if(resource.getType() == IResource.FOLDER) {
- try {
- found = ( (IFolder)resource).accept(new IResourceProxyVisitor() {
-
- public boolean visit(IResourceProxy proxy) throws CoreException {
- return false;
- }
-
- });
- } catch (CoreException e) {
- // noop
- }
- }
-
- if(!found) {
- setMessage("No templates (*.vm) found in template directory", IMessageProvider.WARNING);
- } else {
- setMessage(null);
- }*/
- }
- } else {
- setMessage(null);
- }
-
- updateStatus(null);
- }
-
-
-
- protected String checkDirectory(IPath path, String name, boolean checkFilesystem) {
- if (checkFilesystem) {
- if (path != null && new File(path.toOSString()).exists()) {
- return null;
- }
- }
-
- IResource res= ResourcesPlugin.getWorkspace().getRoot().findMember(path);
- if (res != null) {
- int resType= res.getType();
- if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
- IProject proj= res.getProject();
- if (!proj.isOpen() ) {
- return "Project for " + name + " is closed";
- }
- } else {
- return name + " has to be a folder or project";
- }
- } else {
- return name + " does not exist";
- }
- return null;
- }
-
- protected String checkFile(IPath path, String name) {
- IResource res= ResourcesPlugin.getWorkspace().getRoot().findMember(path);
- if (res != null) {
- int resType= res.getType();
- if (resType == IResource.FILE) {
- return null;
- } else {
- return name + " must be a file";
- }
- } else {
- return name + " does not exist";
- }
- }
-
- private void updateStatus(String message) {
- setErrorMessage(message);
- updateLaunchConfigurationDialog();
- }
-
- public String getConfigurationName() {
- return consoleConfigurationName.getText();
- }
-
- private Path pathOrNull(String p) {
- if(p==null || p.trim().length()==0) {
- return null;
- } else {
- return new Path(p);
- }
- }
-
-
- /**
- * @return
- */
- public boolean isReverseEngineerEnabled() {
- return reverseengineer.isSelected();
- }
-
- public IPath getOutputDirectory() {
- return pathOrNull(outputdir.getText() );
- }
-
- public IPath getTemplateDirectory() {
- return pathOrNull(templatedir.getText() );
- }
-
- public String getOutputPackage() {
- return packageName.getText();
- }
-
-
- private IPath getReverseEngineeringSettingsFile() {
- return pathOrNull(reverseEngineeringSettings.getText() );
- }
-
- private String getReverseEngineeringStrategy() {
- return reverseEngineeringStrategy.getText();
- }
-
- public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
-// try {
-// attributes = new ExporterAttributes(configuration);
-// } catch (CoreException ce) {
-// HibernateConsolePlugin.getDefault().logErrorMessage("Problem when setting up defaults for launch configuration", ce);
-// }
- }
-
- public void initializeFrom(ILaunchConfiguration configuration) {
- try {
- ExporterAttributes attributes = new ExporterAttributes(configuration);
- consoleConfigurationName.setText(attributes.getConsoleConfigurationName());
- preferRawCompositeIds.setSelection(attributes.isPreferBasicCompositeIds());
- autoManyToMany.setSelection( attributes.detectManyToMany() );
- autoVersioning.setSelection( attributes.detectOptimisticLock() );
- outputdir.setText(safeText(attributes.getOutputPath()));
- reverseengineer.setSelection(attributes.isReverseEngineer());
- reverseEngineeringSettings.setText(safeText(attributes.getRevengSettings()));
- reverseEngineeringStrategy.setText(safeText(attributes.getRevengStrategy()));
- useOwnTemplates.setSelection(attributes.isUseOwnTemplates());
- packageName.setText(safeText(attributes.getPackageName()));
- templatedir.setText(safeText(attributes.getTemplatePath()));
- } catch (CoreException ce) {
- HibernateConsolePlugin.getDefault().logErrorMessage("Problem when reading hibernate tools launch configuration", ce);
- }
- }
-
- private String safeText(String text) {
- return text==null?"":text;
- }
-
- private String strOrNull(String text) {
- if(text==null || text.trim().length()==0) {
- return null;
- } else {
- return text;
- }
- }
-
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, strOrNull(outputdir.getText()));
- configuration.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, preferRawCompositeIds.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, autoManyToMany.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, autoVersioning.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, isReverseEngineerEnabled());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_STRATEGY, strOrNull(reverseEngineeringStrategy.getText()));
- configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_SETTINGS, strOrNull(reverseEngineeringSettings.getText()));
-
-
- configuration.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, useOwnTemplates.isSelected());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, strOrNull(templatedir.getText()));
-
- configuration.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, getConfigurationName());
- configuration.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, getOutputPackage());
-
- }
-
- public String getName() {
- return "Main";
- }
-
- public Image getImage() {
- return EclipseImages.getImage(ImageConstants.MINI_HIBERNATE);
- }
-
-
-}
Copied: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java (from rev 3703, trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettings.java)
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -0,0 +1,447 @@
+/*
+ * 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.launch;
+
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.utils.DialogSelectionHelper;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.console.wizards.NewReverseEngineeringFileWizard;
+
+public class CodeGenerationSettingsTab extends AbstractLaunchConfigurationTab {
+
+ private ComboDialogField consoleConfigurationName;
+
+ private IStructuredSelection selection;
+
+ private SelectionButtonDialogField reverseengineer;
+
+ private StringButtonDialogField outputdir;
+
+ private StringButtonDialogField reverseEngineeringSettings;
+
+ private StringButtonDialogField reverseEngineeringStrategy;
+
+ private StringDialogField packageName;
+
+ private SelectionButtonDialogField preferRawCompositeIds;
+ private SelectionButtonDialogField autoVersioning;
+ private SelectionButtonDialogField autoManyToMany;
+
+ private SelectionButtonDialogField useOwnTemplates;
+ private DirectoryBrowseField templatedir;
+
+
+
+ public CodeGenerationSettingsTab() {
+ super();
+ }
+
+ public void createControl(Composite parent) {
+
+ //initializeDialogUnits(parent);
+
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+
+ container.setLayout(layout);
+ layout.numColumns = 4;
+ layout.verticalSpacing = 10;
+
+ consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
+ consoleConfigurationName.setLabelText("Console &configuration:");
+ ConsoleConfiguration[] cfg = KnownConfigurations.getInstance().getConfigurationsSortedByName();
+ String[] names = new String[cfg.length];
+ for (int i = 0; i < cfg.length; i++) {
+ ConsoleConfiguration configuration = cfg[i];
+ names[i] = configuration.getName();
+ }
+ consoleConfigurationName.setItems(names);
+
+ IDialogFieldListener fieldlistener = new IDialogFieldListener() {
+ public void dialogFieldChanged(DialogField field) {
+ dialogChanged();
+ }
+ };
+
+ consoleConfigurationName.setDialogFieldListener(fieldlistener);
+
+ outputdir = new StringButtonDialogField(new IStringButtonAdapter() {
+ public void changeControlPressed(DialogField field) {
+ IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(), getOutputDirectory(), new IPath[0], "Select output directory", "Choose directory in which the generated files will be stored", new String[] {"cfg.xml"}, false, true, false);
+ if(paths!=null && paths.length==1) {
+ outputdir.setText( ( (paths[0]).toOSString() ) );
+ }
+ }
+ });
+ outputdir.setDialogFieldListener(fieldlistener);
+ outputdir.setLabelText("Output &directory:");
+ outputdir.setButtonLabel("&Browse...");
+
+ templatedir = new DirectoryBrowseField(null, null, "Select template directory", "Choose directory containing custom templates");
+ templatedir.setDialogFieldListener(fieldlistener);
+ templatedir.setLabelText("Template &directory:");
+ templatedir.setFilesystemBrowseLabel("&Filesystem...");
+ templatedir.setWorkspaceBrowseLabel("&Workspace...");
+
+ packageName = new StringDialogField();
+ packageName.setDialogFieldListener(fieldlistener);
+ packageName.setLabelText("&Package:");
+
+ reverseEngineeringStrategy = new StringButtonDialogField(new IStringButtonAdapter() {
+
+ public void changeControlPressed(DialogField field) {
+ String string = DialogSelectionHelper.chooseImplementation(ReverseEngineeringStrategy.class.getName(), reverseEngineeringStrategy.getText(), "Choose a reverse engineering strategy", getShell());
+ if(string!=null) {
+ reverseEngineeringStrategy.setText(string);
+ }
+ }
+ });
+ reverseEngineeringStrategy.setDialogFieldListener(fieldlistener);
+ reverseEngineeringStrategy.setLabelText("reveng. s&trategy:");
+ reverseEngineeringStrategy.setButtonLabel("&Browse...");
+
+ reverseEngineeringSettings= new StringButtonDialogField(new IStringButtonAdapter() {
+ public void changeControlPressed(DialogField field) {
+ int defaultChoice = 0;
+ IPath reverseEngineeringSettingsFile = getReverseEngineeringSettingsFile();
+
+ if(reverseEngineeringSettingsFile==null) {
+ defaultChoice = 0;
+ } else {
+ defaultChoice = 1;
+ }
+ MessageDialog dialog = new MessageDialog(getShell(),
+ "Setup reverse engineering",
+ null,
+ "Do you want to create a new reveng.xml or use an existing file ?",
+ MessageDialog.QUESTION,
+ new String[] { "Create &new...", "Use &existing...", IDialogConstants.CANCEL_LABEL},
+ defaultChoice);
+ int answer = dialog.open();
+ if(answer==0) { // create new
+ NewReverseEngineeringFileWizard wizard = new NewReverseEngineeringFileWizard();
+ wizard.init(PlatformUI.getWorkbench(), selection );
+ wizard.setSelectConfiguration(getConfigurationName());
+ IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ WizardDialog wdialog = new WizardDialog(win.getShell(), wizard);
+ wdialog.open(); // This opens a dialog
+ IPath createdFilePath = wizard.getCreatedFilePath();
+ if(createdFilePath!=null) {
+ reverseEngineeringSettings.setText(createdFilePath.toOSString());
+ }
+ } else if (answer==1) { // use existing
+ IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(), reverseEngineeringSettingsFile, new IPath[0], "Select reverse engineering settings file", "Choose file from which settings for the reverse engineering will be read", new String[] {"reveng.xml"}, false, false, true);
+ if(paths!=null && paths.length==1) {
+ reverseEngineeringSettings.setText( ( (paths[0]).toOSString() ) );
+ }
+ }
+ }
+ });
+ reverseEngineeringSettings.setDialogFieldListener(fieldlistener);
+ reverseEngineeringSettings.setLabelText("reveng.&xml:");
+ reverseEngineeringSettings.setButtonLabel("&Setup...");
+
+ reverseengineer = new SelectionButtonDialogField(SWT.CHECK);
+ reverseengineer.setLabelText("Reverse engineer from JDBC Connection");
+ reverseengineer.setDialogFieldListener(fieldlistener);
+
+ useOwnTemplates = new SelectionButtonDialogField(SWT.CHECK);
+ useOwnTemplates.setDialogFieldListener(fieldlistener);
+ useOwnTemplates.setLabelText("Use custom templates (for custom file generation)");
+
+ preferRawCompositeIds = new SelectionButtonDialogField(SWT.CHECK);
+ preferRawCompositeIds.setLabelText("Generate basic typed composite ids");
+ preferRawCompositeIds.setSelection(true);
+ preferRawCompositeIds.setDialogFieldListener(fieldlistener);
+
+ autoManyToMany = new SelectionButtonDialogField(SWT.CHECK);
+ autoManyToMany.setLabelText("Detect many-to-many tables");
+ autoManyToMany.setSelection(true);
+ autoManyToMany.setDialogFieldListener(fieldlistener);
+
+ autoVersioning = new SelectionButtonDialogField(SWT.CHECK);
+ autoVersioning.setLabelText("Detect optimistic lock columns");
+ autoVersioning.setSelection(true);
+ autoVersioning.setDialogFieldListener(fieldlistener);
+
+ useOwnTemplates.attachDialogField(templatedir);
+ reverseengineer.attachDialogFields(new DialogField[] { packageName, preferRawCompositeIds, reverseEngineeringSettings, reverseEngineeringStrategy, autoManyToMany, autoVersioning });
+
+ consoleConfigurationName.doFillIntoGrid(container, 4);
+ Control[] controls = outputdir.doFillIntoGrid(container, 4);
+ // Hack to tell the text field to stretch!
+ ( (GridData)controls[1].getLayoutData() ).grabExcessHorizontalSpace=true;
+ reverseengineer.doFillIntoGrid(container, 4);
+ packageName.doFillIntoGrid(container, 4);
+ reverseEngineeringSettings.doFillIntoGrid(container, 4);
+ reverseEngineeringStrategy.doFillIntoGrid(container, 4);
+
+ fillLabel(container);
+ preferRawCompositeIds.doFillIntoGrid(container, 3);
+ fillLabel(container);
+ autoVersioning.doFillIntoGrid(container, 3);
+ fillLabel(container);
+ autoManyToMany.doFillIntoGrid(container, 3);
+ useOwnTemplates.doFillIntoGrid(container, 4);
+ controls = templatedir.doFillIntoGrid(container, 4);
+ // Hack to tell the text field to stretch!
+ ( (GridData)controls[1].getLayoutData() ).grabExcessHorizontalSpace=true;
+
+ dialogChanged();
+ setControl(container);
+ }
+
+ private void fillLabel(Composite container) {
+ new Label(container, SWT.NULL);
+ }
+
+
+ private void dialogChanged() {
+ boolean configSelected = getConfigurationName().length()==0;
+ outputdir.setEnabled(!configSelected);
+ reverseengineer.setEnabled(!configSelected);
+ useOwnTemplates.setEnabled(!configSelected);
+
+ if (configSelected) {
+ updateStatus("Console configuration must be specified");
+ return;
+ }
+
+ String msg = PathHelper.checkDirectory(getOutputDirectory(), "output directory", false);
+
+ if (msg!=null) {
+ updateStatus(msg);
+ return;
+ }
+
+ if(packageName.isEnabled() && getOutputPackage().length()>0) {
+ IStatus val= JavaConventions.validatePackageName(getOutputPackage() );
+ if (val.getSeverity() == IStatus.ERROR || val.getSeverity() == IStatus.WARNING) {
+ updateStatus(val.getMessage() );
+ return;
+ }
+ }
+
+ if(reverseEngineeringSettings.getText().trim().length()>0) {
+ msg = checkFile(getReverseEngineeringSettingsFile(), "reveng.xml");
+ if(msg!=null) {
+ updateStatus(msg);
+ return;
+ }
+ }
+
+ if(useOwnTemplates.isSelected() ) {
+ msg = PathHelper.checkDirectory(getTemplateDirectory(), "template directory", true);
+ if (msg!=null) {
+ updateStatus(msg);
+ return;
+ } else {
+ // imprecise and inefficient to check recursively all for .vm
+ /*IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(getTemplateDirectory() );
+ IResource[] files = new IFile[0];
+ boolean found = false;
+
+ if(resource.getType() == IResource.FOLDER) {
+ try {
+ found = ( (IFolder)resource).accept(new IResourceProxyVisitor() {
+
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ return false;
+ }
+
+ });
+ } catch (CoreException e) {
+ // noop
+ }
+ }
+
+ if(!found) {
+ setMessage("No templates (*.vm) found in template directory", IMessageProvider.WARNING);
+ } else {
+ setMessage(null);
+ }*/
+ }
+ } else {
+ setMessage(null);
+ }
+
+ updateStatus(null);
+ }
+
+
+
+ protected String checkFile(IPath path, String name) {
+ IResource res= ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (res != null) {
+ int resType= res.getType();
+ if (resType == IResource.FILE) {
+ return null;
+ } else {
+ return name + " must be a file";
+ }
+ } else {
+ return name + " does not exist";
+ }
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ updateLaunchConfigurationDialog();
+ }
+
+ public String getConfigurationName() {
+ return consoleConfigurationName.getText();
+ }
+
+
+
+ /**
+ * @return
+ */
+ public boolean isReverseEngineerEnabled() {
+ return reverseengineer.isSelected();
+ }
+
+ public IPath getOutputDirectory() {
+ return PathHelper.pathOrNull(outputdir.getText() );
+ }
+
+ public IPath getTemplateDirectory() {
+ return PathHelper.pathOrNull(templatedir.getText() );
+ }
+
+ public String getOutputPackage() {
+ return packageName.getText();
+ }
+
+
+ private IPath getReverseEngineeringSettingsFile() {
+ return PathHelper.pathOrNull(reverseEngineeringSettings.getText() );
+ }
+
+ private String getReverseEngineeringStrategy() {
+ return reverseEngineeringStrategy.getText();
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+// try {
+// attributes = new ExporterAttributes(configuration);
+// } catch (CoreException ce) {
+// HibernateConsolePlugin.getDefault().logErrorMessage("Problem when setting up defaults for launch configuration", ce);
+// }
+ }
+
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ ExporterAttributes attributes = new ExporterAttributes(configuration);
+ consoleConfigurationName.setText(attributes.getConsoleConfigurationName());
+ preferRawCompositeIds.setSelection(attributes.isPreferBasicCompositeIds());
+ autoManyToMany.setSelection( attributes.detectManyToMany() );
+ autoVersioning.setSelection( attributes.detectOptimisticLock() );
+ outputdir.setText(safeText(attributes.getOutputPath()));
+ reverseengineer.setSelection(attributes.isReverseEngineer());
+ reverseEngineeringSettings.setText(safeText(attributes.getRevengSettings()));
+ reverseEngineeringStrategy.setText(safeText(attributes.getRevengStrategy()));
+ useOwnTemplates.setSelection(attributes.isUseOwnTemplates());
+ packageName.setText(safeText(attributes.getPackageName()));
+ templatedir.setText(safeText(attributes.getTemplatePath()));
+ } catch (CoreException ce) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Problem when reading hibernate tools launch configuration", ce);
+ }
+ }
+
+ private String safeText(String text) {
+ return text==null?"":text;
+ }
+
+ private String strOrNull(String text) {
+ if(text==null || text.trim().length()==0) {
+ return null;
+ } else {
+ return text;
+ }
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, strOrNull(outputdir.getText()));
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, preferRawCompositeIds.isSelected());
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, autoManyToMany.isSelected());
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, autoVersioning.isSelected());
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, isReverseEngineerEnabled());
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_STRATEGY, strOrNull(reverseEngineeringStrategy.getText()));
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_SETTINGS, strOrNull(reverseEngineeringSettings.getText()));
+
+
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, useOwnTemplates.isSelected());
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, strOrNull(templatedir.getText()));
+
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, getConfigurationName());
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, getOutputPackage());
+
+ }
+
+ public String getName() {
+ return "Main";
+ }
+
+ public Image getImage() {
+ return EclipseImages.getImage(ImageConstants.MINI_HIBERNATE);
+ }
+
+
+}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -42,12 +42,16 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.hibernate.console.HibernateConsoleRuntimeException;
import org.hibernate.eclipse.console.ExtensionManager;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.model.impl.ExporterDefinition;
@@ -99,24 +103,120 @@
templatePath = null;
}
- ExporterDefinition[] exDefinitions = ExtensionManager.findExporterDefinitions();
-
- exporterFactories = new ArrayList();
- for (int i = 0; i < exDefinitions.length; i++) {
- ExporterDefinition expDef = exDefinitions[i];
- ExporterFactory exporterFactory = new ExporterFactory( expDef );
- exporterFactory.isEnabled( configuration );
- exporterFactories.add( exporterFactory );
- Map props = configuration.getAttribute( exporterFactory.getId()
- + ".properties", new HashMap() );
- exporterFactory.setProperties( props );
- }
+ exporterFactories = readExporterFactories(configuration);
} catch (CoreException e) {
throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
}
}
+
+ static String getLaunchAttributePrefix(String exporterId) {
+ return HibernateLaunchConstants.ATTR_EXPORTERS + "." + exporterId;
+ }
+ private List readExporterFactories(ILaunchConfiguration configuration) throws CoreException {
+
+ List exporterNames = configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List)null);
+
+ if(exporterNames!=null) {
+ Map exDefinitions = ExtensionManager.findExporterDefinitionsAsMap();
+ List factories = new ArrayList();
+
+ for (Iterator iterator = exporterNames.iterator(); iterator.hasNext();) {
+ String exporterId = (String) iterator.next();
+ String extensionId = configuration.getAttribute(getLaunchAttributePrefix(exporterId) + ".extension_id", (String)null);
+
+ ExporterDefinition expDef = (ExporterDefinition) exDefinitions.get(extensionId);
+ if(expDef==null) {
+ throw new HibernateConsoleRuntimeException("Could not locate exporter for '" + extensionId + "' in " + configuration.getName());
+ } else {
+ ExporterFactory exporterFactory = new ExporterFactory( expDef, exporterId );
+ exporterFactory.isEnabled( configuration );
+ factories.add( exporterFactory );
+ Map props = configuration.getAttribute( getLaunchAttributePrefix(exporterFactory.getId())
+ + ".properties", new HashMap() );
+ exporterFactory.setProperties( props );
+ }
+ }
+ return factories;
+
+ } else {
+ // fall back to old way of reading if list of exporters does not exist.
+ ExporterDefinition[] exDefinitions = ExtensionManager.findExporterDefinitions();
+ List factories = new ArrayList();
+
+ for (int i = 0; i < exDefinitions.length; i++) {
+ ExporterDefinition expDef = exDefinitions[i];
+ ExporterFactory exporterFactory = new ExporterFactory( expDef, expDef.getId() );
+ exporterFactory.isEnabled( configuration );
+ factories.add( exporterFactory );
+ Map props = configuration.getAttribute( getLaunchAttributePrefix(exporterFactory.getId())
+ + ".properties", new HashMap() );
+ exporterFactory.setProperties( props );
+ }
+
+ return factories;
+ }
+ }
+
+ public static void saveExporterFactories(
+ ILaunchConfigurationWorkingCopy configuration,
+ List exporterFactories, List enabledExporters, Set deletedExporterIds) {
+
+
+ List names = new ArrayList();
+ for (Iterator iter = exporterFactories.iterator(); iter.hasNext();) {
+ ExporterFactory ef = (ExporterFactory) iter.next();
+ configuration.setAttribute(getLaunchAttributePrefix(ef.getId()) + ".extension_id", ef.getExporterDefinition().getId());
+ boolean enabled = enabledExporters.contains( ef );
+ String propertiesId = getLaunchAttributePrefix(ef.getId()) + ".properties";
+ names.add(ef.getId());
+ ef.setEnabled( configuration, enabled, false );
+
+ HashMap map = new HashMap(ef.getProperties());
+
+ if(map.isEmpty()) {
+ configuration.setAttribute( propertiesId, (Map)null );
+ } else {
+ configuration.setAttribute( propertiesId, map );
+ }
+ }
+
+ deletedExporterIds.removeAll(names);
+
+ for (Iterator iterator = deletedExporterIds.iterator(); iterator.hasNext();) {
+ String deleted = (String) iterator.next();
+
+ configuration.setAttribute( getLaunchAttributePrefix( deleted ), (String)null);
+ configuration.setAttribute(getLaunchAttributePrefix(deleted ) + ".extension_id", (String)null);
+ configuration.setAttribute(getLaunchAttributePrefix(deleted), (String)null);
+ }
+
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, names);
+ }
+
+ public static void oldSaveExporterFactories(
+ ILaunchConfigurationWorkingCopy configuration,
+ List exporterFactories, List enabledExporters) {
+
+
+ for (Iterator iter = exporterFactories.iterator(); iter.hasNext();) {
+ ExporterFactory ef = (ExporterFactory) iter.next();
+ boolean enabled = enabledExporters.contains( ef );
+ String propertiesId = ef.getId() + ".properties";
+
+ ef.setEnabled( configuration, enabled, true );
+
+ HashMap map = new HashMap(ef.getProperties());
+
+ if(map.isEmpty()) {
+ configuration.setAttribute( propertiesId, (Map)null );
+ } else {
+ configuration.setAttribute( propertiesId, map );
+ }
+ }
+ }
+
private Path pathOrNull(String p) {
if(p==null || p.trim().length()==0) {
@@ -247,6 +347,7 @@
public boolean detectOptimisticLock() {
return autoVersioning;
}
+
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettings.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettings.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettings.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -1,605 +0,0 @@
-/*
- * 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.launch;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogPage;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySheetEntry;
-import org.eclipse.ui.views.properties.IPropertySheetEntryListener;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.ui.views.properties.PropertySheetEntry;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.hibernate.console.ImageConstants;
-import org.hibernate.eclipse.console.ExtensionManager;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.eclipse.console.model.impl.ExporterDefinition;
-import org.hibernate.eclipse.console.model.impl.ExporterFactory;
-import org.hibernate.eclipse.console.utils.EclipseImages;
-
-public class ExporterSettings extends AbstractLaunchConfigurationTab {
- private Button enableEJB3annotations;
-
- private Button enableJDK5;
-
- private List selectedExporters;
-
- private CheckboxTableViewer exporterTable;
-
- private Button selectAll;
-
- private Button deselectAll;
-
- private PropertySheetPage propertySheet;
-
- private Button add;
-
- private Button remove;
-
- /**
- * Constructor for SampleNewWizardPage.
- *
- * @param pageName
- */
- public ExporterSettings() {
- super();
- }
-
- /**
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- selectedExporters = new ArrayList();
-
- // ScrolledComposite scrolled = new ScrolledComposite(parent,
- // SWT.V_SCROLL | SWT.H_SCROLL);
-
- Composite container = new Composite( parent, SWT.NONE );
- GridData controlData = new GridData( GridData.FILL_BOTH );
- container.setLayoutData( controlData );
-
- GridLayout layout = new GridLayout();
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- layout.verticalSpacing = 1;
- container.setLayout( layout );
-
- createGeneralSettings( container );
-
- createExporterTable( container );
-
- createExporterProperties( container );
-
- dialogChanged();
- setControl( container );
- }
-
- private void createExporterProperties(Composite parent) {
- Composite exportersComposite = createComposite( parent, "Properties:" );
-
- exportersComposite.setLayout( new GridLayout( 2, false ) );
-
- GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
- gd.minimumHeight = 100;
- exportersComposite.setLayoutData( gd );
-
- Group gr = new Group(exportersComposite, SWT.NONE);
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
-
- gr.setLayout( gridLayout );
- gd = new GridData( SWT.FILL, SWT.FILL, true, true );
- gd.verticalSpan = 2;
- gr.setLayoutData( gd );
-
- Control sheet = createPropertySheet( gr );
- gd = new GridData( SWT.FILL, SWT.FILL, true, true );
- sheet.setLayoutData( gd );
-
- add = new Button( exportersComposite, SWT.PUSH );
- add.setEnabled( false );
- add.setText( "Add..." );
- gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING );
- gd.horizontalIndent = 5;
- add.setLayoutData( gd );
- add.addSelectionListener( new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- IStructuredSelection ss = (IStructuredSelection) exporterTable.getSelection();
- ExporterFactory ef = (ExporterFactory) ss.getFirstElement();
-
- if(ef!=null) {
- AddPropertyDialog dialog = new AddPropertyDialog(getShell(), ef);
- if(dialog.open()==Dialog.OK) {
- ef.setProperty( dialog.getPropertyName(), dialog.getPropertyValue() );
- dialogChanged();
- refreshPropertySheet();
- }
- }
- }
-
- } );
-
- remove = new Button( exportersComposite, SWT.PUSH );
- remove.setText( "Remove..." );
- remove.setEnabled( false );
- remove.addSelectionListener( new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- if(currentDescriptor!=null) {
- IStructuredSelection ss = (IStructuredSelection) exporterTable.getSelection();
- ExporterFactory ef = (ExporterFactory) ss.getFirstElement();
- ef.removeProperty( (String) currentDescriptor.getId() );
- dialogChanged();
- refreshPropertySheet();
- }
- }
-
- } );
-
- gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING );
- gd.horizontalIndent = 5;
- remove.setLayoutData( gd );
-
- }
-
- public class MyPropertySheetEntry extends PropertySheetEntry {
-
- public IPropertyDescriptor getMyDescriptor() {
- return super.getDescriptor();
- }
-
- protected PropertySheetEntry createChildEntry() {
- return new MyPropertySheetEntry();
- }
- }
-
- // currently selected in the propertysheet
- private IPropertyDescriptor currentDescriptor;
-
- private Control createPropertySheet(Composite exportersComposite) {
- propertySheet = new PropertySheetPage() {
-
-
- public void handleEntrySelection(ISelection selection) {
- super.handleEntrySelection( selection );
- IStructuredSelection iss = (IStructuredSelection) selection;
- if(iss.isEmpty()) {
- currentDescriptor = null;
- } else {
- MyPropertySheetEntry mse = (MyPropertySheetEntry)iss.getFirstElement();
- currentDescriptor = mse.getMyDescriptor();
- }
- }
- };
-
- propertySheet.createControl( exportersComposite );
-
- final PropertySheetEntry propertySheetEntry = new MyPropertySheetEntry();
-
- propertySheetEntry
- .setPropertySourceProvider( new IPropertySourceProvider() {
-
- public IPropertySource getPropertySource(Object object) {
- if ( object instanceof ExporterFactory ) {
- return new ExporterFactoryPropertySource(
- (ExporterFactory) object ) {
- public void setPropertyValue(Object id, Object value) {
- super.setPropertyValue( id, value );
- dialogChanged();
- }
- };
- }
- else {
- return null;
- }
- }
- } );
- propertySheet.setRootEntry( propertySheetEntry );
- // propertySheetEntry.setValues( new Object[] { this });
-
- exporterTable
- .addSelectionChangedListener( new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection s = (IStructuredSelection) event
- .getSelection();
- if(s.isEmpty()) {
- if(add!=null) add.setEnabled( false );
- if(remove!=null) remove.setEnabled( false );
-
- } else {
- if(add!=null) add.setEnabled( true );
- if(remove!=null) remove.setEnabled( true );
-
- ExporterFactory ep = (ExporterFactory) s
- .getFirstElement();
- propertySheetEntry.setValues( new Object[] { ep } );
- // if(ep.isEnabled( configuration ))
- }
- }
-
- } );
-
- return propertySheet.getControl();
- }
-
- private void createExporterTable(Composite parent) {
- Composite exporterOptions = createComposite( parent, "Exporters:" );
-
- GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
- gd.minimumHeight = 100;
- exporterOptions.setLayoutData( gd );
-
- exporterOptions.setLayout( new GridLayout( 2, false ) );
-
- Table table = new Table( exporterOptions, SWT.CHECK | SWT.BORDER
- | SWT.V_SCROLL );
- exporterTable = new CheckboxTableViewer( table );
- exporterTable.setContentProvider( new ExporterContentProvider() );
- exporterTable.setLabelProvider( new ExporterLabelProvider() );
-
- // exporterTable.getControl().setLayoutData(
- // new GridData( SWT.FILL, SWT.FILL, true, true ) );
- exporterTable.setColumnProperties( new String[] { "", "Description" } );
- exporterTable.addCheckStateListener( new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
-
- ExporterFactory factory = (ExporterFactory) event.getElement();
-
- if ( !event.getChecked()
- && selectedExporters.contains( factory ) ) {
- selectedExporters.remove( factory );
- }
- else if ( event.getChecked()
- && !selectedExporters.contains( factory ) ) {
- selectedExporters.add( factory );
- }
-
- dialogChanged();
- }
- } );
-
- gd = new GridData( SWT.FILL, SWT.FILL, true, true );
- gd.verticalSpan = 2;
- gd.horizontalSpan = 1;
- table.setLayoutData( gd );
-
- selectAll = new Button( exporterOptions, SWT.PUSH );
- selectAll.setText( "Select All" );
- selectAll.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- exporterTable.setAllChecked( true );
- dialogChanged();
- }
- } );
- gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING );
- gd.horizontalIndent = 5;
- selectAll.setLayoutData( gd );
-
- deselectAll = new Button( exporterOptions, SWT.PUSH );
- deselectAll.setText( "Deselect All" );
- deselectAll.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- exporterTable.setAllChecked( false );
- dialogChanged();
- }
- } );
-
- gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING );
- gd.horizontalIndent = 5;
- deselectAll.setLayoutData( gd );
-
- }
-
- private void createGeneralSettings(Composite parent) {
-
- SelectionListener fieldlistener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected( e );
- }
-
- public void widgetSelected(SelectionEvent e) {
- dialogChanged();
- }
- };
- Composite generalSettingsComposite = createComposite( parent,
- "General settings:" );
- generalSettingsComposite.setLayoutData( new GridData( SWT.BEGINNING,
- SWT.BEGINNING, false, false ) );
-
- enableJDK5 = new Button( generalSettingsComposite, SWT.CHECK );
- enableJDK5.setText( "Use Java 5 syntax" );
- enableJDK5.addSelectionListener( fieldlistener );
-
- enableEJB3annotations = new Button( generalSettingsComposite, SWT.CHECK );
- enableEJB3annotations.setText( "Generate EJB3 annotations" );
- enableEJB3annotations.addSelectionListener( fieldlistener );
- }
-
- private class ExporterContentProvider implements IStructuredContentProvider {
-
- public Object[] getElements(Object inputElement) {
- return ((List) inputElement ).toArray();
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- }
-
- private class ExporterLabelProvider implements ITableLabelProvider {
- Map exp2img = new HashMap(); // not the most optimized but better
-
- // than having a finalize method.
-
- public Image getColumnImage(Object element, int columnIndex) {
- ExporterFactory ef = (ExporterFactory) element;
- ExporterDefinition definition = ef.getExporterDefinition();
- Image image = (Image) exp2img.get( definition.getId() );
- if ( image == null ) {
- image = definition.getIconDescriptor().createImage();
- exp2img.put( definition.getId(), image );
- }
- return image;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- ExporterFactory ef = (ExporterFactory) element;
- ExporterDefinition definition = ef.getExporterDefinition();
- return definition.getDescription();
- }
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
-
- Iterator iterator = exp2img.values().iterator();
- while ( iterator.hasNext() ) {
- Image img = (Image) iterator.next();
- if ( img != null ) {
- img.dispose();
- }
- }
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return true;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
-
- }
-
- private Composite createComposite(Composite parent, String name) {
-
- new Label( parent, SWT.NONE ).setText( name );
- Composite client = new Composite( parent, SWT.NONE );
- client.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
- client.setLayout( new GridLayout() );
- // client.setBackground( ColorConstants.cyan );
- return client;
- }
-
- private void dialogChanged() {
- boolean configSelected = true; // TODO: only active if configname in
- // settings
- // ...getConfigurationName().length()==0;
-
- if ( !configSelected ) {
- updateStatus( "Console configuration must be specified" );
- return;
- }
-
- if ( selectedExporters.size() == 0 ) {
- updateStatus( "At least one exporter option must be selected" );
- return;
- }
- updateStatus( null );
- }
-
- protected String checkDirectory(IPath path, String name) {
- IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(
- path );
- if ( res != null ) {
- int resType = res.getType();
- if ( resType == IResource.PROJECT || resType == IResource.FOLDER ) {
- IProject proj = res.getProject();
- if ( !proj.isOpen() ) {
- return "Project for " + name + " is closed";
- }
- }
- else {
- return name + " has to be a folder or project";
- }
- }
- else {
- return name + " does not exist";
- }
- return null;
- }
-
- protected String checkFile(IPath path, String name) {
- IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(
- path );
- if ( res != null ) {
- int resType = res.getType();
- if ( resType == IResource.FILE ) {
- return null;
- }
- else {
- return name + " must be a file";
- }
- }
- else {
- return name + " does not exist";
- }
- }
-
- private void updateStatus(String message) {
- setErrorMessage( message );
- updateLaunchConfigurationDialog();
- }
-
- private Path pathOrNull(String p) {
- if ( p == null || p.trim().length() == 0 ) {
- return null;
- }
- else {
- return new Path( p );
- }
- }
-
- public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- // ExporterAttributes tmpAttrs = new ExporterAttributes();
- // tmpAttrs.setEnableAllExporters(true);
- // tmpAttrs.save(configuration);
- }
-
- public void initializeFrom(ILaunchConfiguration configuration) {
- try {
- ExporterAttributes attributes = new ExporterAttributes(
- configuration );
- selectedExporters.clear();
-
- enableEJB3annotations.setSelection( attributes.isEJB3Enabled() );
- enableJDK5.setSelection( attributes.isJDK5Enabled() );
-
- List exporterFactories = attributes.getExporterFactories();
- exporterTable.setInput( exporterFactories );
- for (Iterator iter = exporterFactories.iterator(); iter.hasNext();) {
- ExporterFactory exporterFactory = (ExporterFactory) iter.next();
- if ( exporterFactory.isEnabled() ) {
- exporterTable.setChecked( exporterFactory, true );
- selectedExporters.add( exporterFactory );
- }
- else {
- exporterTable.setChecked( exporterFactory, false );
- }
- }
-
- refreshPropertySheet();
-
- dialogChanged();
-
- }
- catch (CoreException ce) {
- HibernateConsolePlugin
- .getDefault()
- .logErrorMessage(
- "Problem when reading hibernate tools launch configuration",
- ce );
- }
- }
-
- private void refreshPropertySheet() {
- exporterTable.setSelection( exporterTable.getSelection() ); // here to make sure the dependent propertysheet actually will reread what ever the selection is.
- }
-
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(
- HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS,
- enableEJB3annotations.getSelection() );
- configuration.setAttribute( HibernateLaunchConstants.ATTR_ENABLE_JDK5,
- enableJDK5.getSelection() );
-
- List exporterFactories = (List) exporterTable.getInput();
- for (Iterator iter = exporterFactories.iterator(); iter.hasNext();) {
- ExporterFactory ef = (ExporterFactory) iter.next();
- boolean enabled = selectedExporters.contains( ef );
-
- String propertiesId = ef.getId() + ".properties";
-
- ef.setEnabled( configuration, enabled );
-
-
- HashMap map = new HashMap(ef.getProperties());
-
- if(map.isEmpty()) {
- configuration.setAttribute( propertiesId, (Map)null );
- } else {
- configuration.setAttribute( propertiesId, map );
- }
- }
-
- }
-
- public String getName() {
- return "Exporters";
- }
-
- public Image getImage() {
- return EclipseImages.getImage( ImageConstants.MINI_HIBERNATE );
- }
-
-}
Copied: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java (from rev 3703, trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettings.java)
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -0,0 +1,883 @@
+/*
+ * 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.launch;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.AbstractTableViewer;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.IPropertySourceProvider;
+import org.eclipse.ui.views.properties.PropertySheetEntry;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.ExtensionManager;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.model.impl.ExporterDefinition;
+import org.hibernate.eclipse.console.model.impl.ExporterFactory;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.console.wizards.UpDownListComposite;
+
+public class ExporterSettingsTab extends AbstractLaunchConfigurationTab {
+ private Button enableEJB3annotations;
+
+ private Button enableJDK5;
+
+ private List selectedExporters;
+
+ private Set deletedExporterIds;
+
+ //private CheckboxTableViewer exporterTable;
+
+ private Button selectAll;
+
+ private Button deselectAll;
+
+ private PropertySheetPage propertySheet;
+
+ private Button add;
+
+ private Button remove;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param pageName
+ */
+ public ExporterSettingsTab() {
+ super();
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ selectedExporters = new ArrayList();
+ deletedExporterIds = new HashSet();
+ // ScrolledComposite scrolled = new ScrolledComposite(parent,
+ // SWT.V_SCROLL | SWT.H_SCROLL);
+
+ Composite container = new Composite( parent, SWT.NONE );
+ GridData controlData = new GridData( GridData.FILL_BOTH );
+ container.setLayoutData( controlData );
+
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 5;
+ layout.marginWidth = 5;
+ layout.verticalSpacing = 1;
+ container.setLayout( layout );
+
+ createGeneralSettings( container );
+
+ createExporterTable( container );
+
+ createExporterProperties( container );
+
+ dialogChanged();
+ setControl( container );
+ }
+
+ private void createExporterProperties(Composite parent) {
+ Composite exportersComposite = createComposite( parent, "Properties:" );
+
+ exportersComposite.setLayout( new GridLayout( 2, false ) );
+
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.minimumHeight = 100;
+ exportersComposite.setLayoutData( gd );
+
+ Group gr = new Group(exportersComposite, SWT.NONE);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.marginHeight = 0;
+ gridLayout.marginWidth = 0;
+
+ gr.setLayout( gridLayout );
+ gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.verticalSpan = 2;
+ gr.setLayoutData( gd );
+
+ Control sheet = createPropertySheet( gr );
+ gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ sheet.setLayoutData( gd );
+
+ add = new Button( exportersComposite, SWT.PUSH );
+ add.setEnabled( false );
+ add.setText( "Add..." );
+ gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING );
+ gd.horizontalIndent = 5;
+ add.setLayoutData( gd );
+ add.addSelectionListener( new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection ss = (IStructuredSelection) getExporterTable().getSelection();
+ ExporterFactory ef = (ExporterFactory) ss.getFirstElement();
+
+ if(ef!=null) {
+ AddPropertyDialog dialog = new AddPropertyDialog(getShell(), ef);
+ if(dialog.open()==Dialog.OK) {
+ ef.setProperty( dialog.getPropertyName(), dialog.getPropertyValue() );
+ dialogChanged();
+ refreshPropertySheet();
+ }
+ }
+ }
+
+ } );
+
+ remove = new Button( exportersComposite, SWT.PUSH );
+ remove.setText( "Remove..." );
+ remove.setEnabled( false );
+ remove.addSelectionListener( new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if(currentDescriptor!=null) {
+ IStructuredSelection ss = (IStructuredSelection) getExporterTable().getSelection();
+ ExporterFactory ef = (ExporterFactory) ss.getFirstElement();
+ ef.removeProperty( (String) currentDescriptor.getId() );
+ dialogChanged();
+ refreshPropertySheet();
+ }
+ }
+
+ } );
+
+ gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING );
+ gd.horizontalIndent = 5;
+ remove.setLayoutData( gd );
+
+ }
+
+ public class MyPropertySheetEntry extends PropertySheetEntry {
+
+ public IPropertyDescriptor getMyDescriptor() {
+ return super.getDescriptor();
+ }
+
+ protected PropertySheetEntry createChildEntry() {
+ return new MyPropertySheetEntry();
+ }
+ }
+
+ // currently selected in the propertysheet
+ private IPropertyDescriptor currentDescriptor;
+
+ private UpDownListComposite exporterUpDown;
+
+ private ObservableFactoryList observableFactoryList;
+
+
+
+ private Control createPropertySheet(Composite exportersComposite) {
+ propertySheet = new PropertySheetPage() {
+
+
+ public void handleEntrySelection(ISelection selection) {
+ super.handleEntrySelection( selection );
+ IStructuredSelection iss = (IStructuredSelection) selection;
+ if(iss.isEmpty()) {
+ currentDescriptor = null;
+ } else {
+ MyPropertySheetEntry mse = (MyPropertySheetEntry)iss.getFirstElement();
+ currentDescriptor = mse.getMyDescriptor();
+ }
+ }
+ };
+
+ propertySheet.createControl( exportersComposite );
+
+ final PropertySheetEntry propertySheetEntry = new MyPropertySheetEntry();
+
+ propertySheetEntry
+ .setPropertySourceProvider( new IPropertySourceProvider() {
+
+ public IPropertySource getPropertySource(Object object) {
+ if ( object instanceof ExporterFactory ) {
+ return new ExporterFactoryPropertySource(
+ (ExporterFactory) object ) {
+ public void setPropertyValue(Object id, Object value) {
+ super.setPropertyValue( id, value );
+ dialogChanged();
+ }
+ };
+ }
+ else {
+ return null;
+ }
+ }
+ } );
+ propertySheet.setRootEntry( propertySheetEntry );
+ // propertySheetEntry.setValues( new Object[] { this });
+
+ getExporterTable()
+ .addSelectionChangedListener( new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection s = (IStructuredSelection) event
+ .getSelection();
+ if(s.isEmpty()) {
+ if(add!=null) add.setEnabled( false );
+ if(remove!=null) remove.setEnabled( false );
+
+ propertySheetEntry.setValues(new Object[0]);
+
+ } else {
+ if(add!=null) add.setEnabled( true );
+ if(remove!=null) remove.setEnabled( true );
+
+ ExporterFactory ep = (ExporterFactory) s
+ .getFirstElement();
+ propertySheetEntry.setValues( new Object[] { ep } );
+ // if(ep.isEnabled( configuration ))
+ }
+ }
+
+ } );
+
+ return propertySheet.getControl();
+ }
+
+ private void createExporterTable(Composite parent) {
+ exporterUpDown = new UpDownListComposite(parent, SWT.NONE, "Exporters:", true, new ExporterLabelProvider(), new ExporterContentProvider()) {
+
+ protected Object[] handleAdd(int idx) {
+
+ switch (idx) {
+ case 0:
+ Object[] selectExporters = selectExporters(getShell(), "Add exporter", "Select the exporter(s) you want to add");
+ for (int i = 0; i < selectExporters.length; i++) {
+ ExporterDefinition exporterDefinition = (ExporterDefinition) selectExporters[i];
+ addDef(exporterDefinition);
+ }
+ return new Object[0];// { exporterFactory };
+ case 1:
+ getExporterTable().setAllChecked( true );
+ break;
+ case 2:
+ getExporterTable().setAllChecked( false );
+ break;
+ default:
+ break;
+ }
+ return null;
+ }
+
+ private void addDef(ExporterDefinition expDef) {
+ int initialCount = getTable().getItemCount();
+ boolean duplicate = false;
+ do {
+ duplicate = false;
+ initialCount++;
+ Iterator iterator = observableFactoryList.getList().iterator();
+ while(iterator.hasNext()) {
+ ExporterFactory def = (ExporterFactory) iterator.next();
+ if(def.getId().equals(""+initialCount)) {
+ duplicate = true;
+ }
+ }
+ } while(duplicate);
+
+ String initialName = "" + initialCount;
+
+ ExporterFactory exporterFactory = new ExporterFactory( expDef, initialName );
+ observableFactoryList.add(exporterFactory);
+ ((CheckboxTableViewer)getTableViewer()).setChecked(exporterFactory, true);
+ }
+
+ protected void handleRemove() {
+ IStructuredSelection selection = (IStructuredSelection) getTableViewer().getSelection();
+ if (selection != null) {
+ int numSelected= selection.size();
+
+ Iterator iterator= selection.iterator();
+ while (iterator.hasNext() ) {
+ Object item= iterator.next();
+ observableFactoryList.remove((ExporterFactory)item);
+ deletedExporterIds.add(((ExporterFactory)item).getId());
+ }
+ //getTableViewer().setSelection(StructuredSelection.EMPTY);
+ listChanged();
+ }
+ }
+
+ protected void moveSelectionDown() {
+ Table table = getTableViewer().getTable();
+ int indices[]= table.getSelectionIndices();
+ if (indices.length < 1) {
+ return;
+ }
+ int newSelection[]= new int[indices.length];
+ int max= table.getItemCount() - 1;
+ for (int i = indices.length - 1; i >= 0; i--) {
+ int index= indices[i];
+ if (index < max) {
+ ExporterFactory data = (ExporterFactory) getTableViewer().getElementAt(index);
+ observableFactoryList.moveTo(index + 1, (ExporterFactory)data);
+ newSelection[i]= index + 1;
+ }
+ }
+ table.setSelection(newSelection);
+ listChanged();
+ }
+
+ protected void moveSelectionUp() {
+ Table table = getTableViewer().getTable();
+ int indices[]= table.getSelectionIndices();
+ int newSelection[]= new int[indices.length];
+ for (int i = 0; i < indices.length; i++) {
+ int index= indices[i];
+ if (index > 0) {
+ ExporterFactory data = (ExporterFactory) getTableViewer().getElementAt(index);
+ observableFactoryList.moveTo(index - 1, (ExporterFactory)data);
+ newSelection[i]= index - 1;
+ }
+ }
+ table.setSelection(newSelection);
+ listChanged();
+ }
+
+ protected String[] getAddButtonLabels() {
+ return new String[] { "Add...", "Select all", "Deselect all" };
+ }
+ protected void listChanged() {
+ dialogChanged();
+ }
+ };
+
+ getExporterTable().addCheckStateListener( new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+
+ ExporterFactory factory = (ExporterFactory) event.getElement();
+
+ if ( !event.getChecked()
+ && selectedExporters.contains( factory ) ) {
+ selectedExporters.remove( factory );
+ }
+ else if ( event.getChecked()
+ && !selectedExporters.contains( factory ) ) {
+ selectedExporters.add( factory );
+ }
+
+ dialogChanged();
+ }
+ } );
+
+ GridData gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ gd.verticalAlignment = GridData.FILL;
+ gd.horizontalAlignment = GridData.FILL;
+ exporterUpDown.setLayoutData( gd );
+ }
+
+ private void createOldExporterTable(Composite parent) {
+ Composite exporterOptions = createComposite( parent, "Exporters:" );
+
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.minimumHeight = 100;
+ exporterOptions.setLayoutData( gd );
+
+ exporterOptions.setLayout( new GridLayout( 2, false ) );
+
+ Table table = new Table( exporterOptions, SWT.CHECK | SWT.BORDER
+ | SWT.V_SCROLL );
+ //setExporterTable(new CheckboxTableViewer( table ));
+ getExporterTable().setContentProvider( new ExporterContentProvider() );
+ getExporterTable().setLabelProvider( new ExporterLabelProvider() );
+
+ // exporterTable.getControl().setLayoutData(
+ // new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ getExporterTable().setColumnProperties( new String[] { "", "Description" } );
+ getExporterTable().addCheckStateListener( new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+
+ ExporterFactory factory = (ExporterFactory) event.getElement();
+
+ if ( !event.getChecked()
+ && selectedExporters.contains( factory ) ) {
+ selectedExporters.remove( factory );
+ }
+ else if ( event.getChecked()
+ && !selectedExporters.contains( factory ) ) {
+ selectedExporters.add( factory );
+ }
+
+ dialogChanged();
+ }
+ } );
+
+ gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.verticalSpan = 2;
+ gd.horizontalSpan = 1;
+ table.setLayoutData( gd );
+
+ selectAll = new Button( exporterOptions, SWT.PUSH );
+ selectAll.setText( "Select All" );
+ selectAll.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ getExporterTable().setAllChecked( true );
+ dialogChanged();
+ }
+ } );
+ gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING );
+ gd.horizontalIndent = 5;
+ selectAll.setLayoutData( gd );
+
+ deselectAll = new Button( exporterOptions, SWT.PUSH );
+ deselectAll.setText( "Deselect All" );
+ deselectAll.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ getExporterTable().setAllChecked( false );
+ dialogChanged();
+ }
+ } );
+
+ gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING );
+ gd.horizontalIndent = 5;
+ deselectAll.setLayoutData( gd );
+
+ }
+
+ private void createGeneralSettings(Composite parent) {
+
+ SelectionListener fieldlistener = new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected( e );
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ dialogChanged();
+ }
+ };
+ Composite generalSettingsComposite = createComposite( parent,
+ "General settings:" );
+ generalSettingsComposite.setLayoutData( new GridData( SWT.BEGINNING,
+ SWT.BEGINNING, false, false ) );
+
+ enableJDK5 = new Button( generalSettingsComposite, SWT.CHECK );
+ enableJDK5.setText( "Use Java 5 syntax" );
+ enableJDK5.addSelectionListener( fieldlistener );
+
+ enableEJB3annotations = new Button( generalSettingsComposite, SWT.CHECK );
+ enableEJB3annotations.setText( "Generate EJB3 annotations" );
+ enableEJB3annotations.addSelectionListener( fieldlistener );
+ }
+
+ private class ExporterContentProvider implements IStructuredContentProvider, PropertyChangeListener {
+
+ private AbstractTableViewer viewer;
+
+ public Object[] getElements(Object inputElement) {
+ return ((ObservableFactoryList) inputElement ).getList().toArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = (AbstractTableViewer) viewer;
+ ObservableFactoryList ol = (ObservableFactoryList) oldInput;
+ ObservableFactoryList newList = (ObservableFactoryList) newInput;
+
+ if(ol!=null) {
+ ol.removePropertyChangeListener(this);
+ }
+
+ if(newList!=null) {
+ newList.addPropertyChangeListener(this);
+ }
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ if("addElement".equals(evt.getPropertyName())) {
+ viewer.add(evt.getNewValue());
+ }
+
+ if("removeElement".equals(evt.getPropertyName())) {
+ viewer.remove(evt.getOldValue());
+ }
+
+ if("insertElement".equals(evt.getPropertyName())) {
+ viewer.insert(evt.getNewValue(), ((Integer)evt.getOldValue()).intValue());
+ }
+ }
+
+ }
+
+ // Complete hack to get table to work with arbitrary exporters quickly.
+ private class ObservableFactoryList {
+
+ List underlyingList = new ArrayList();
+
+ PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ public ObservableFactoryList(List exporterFactories) {
+ underlyingList = exporterFactories;
+ }
+
+ public void moveTo(int i, ExporterFactory data) {
+ underlyingList.remove((ExporterFactory) data);
+ remove(data);
+ underlyingList.add(i, data);
+ pcs.firePropertyChange("insertElement", new Integer(i), data);
+
+ }
+
+ void addPropertyChangeListener(PropertyChangeListener pcl) {
+ pcs.addPropertyChangeListener(pcl);
+ }
+
+ public List getList() {
+ return Collections.unmodifiableList(underlyingList);
+ }
+
+ void removePropertyChangeListener(PropertyChangeListener pcl) {
+ pcs.removePropertyChangeListener(pcl);
+ }
+
+ boolean add(ExporterFactory o) {
+ boolean changed = underlyingList.add(o);
+ pcs.firePropertyChange("addElement", null, o);
+ return changed;
+ }
+
+ boolean remove(ExporterFactory o) {
+ boolean changed = underlyingList.remove(o);
+ pcs.firePropertyChange("removeElement", o, null);
+ return changed;
+ }
+
+
+ }
+
+ static private class ExporterLabelProvider implements ITableLabelProvider, ILabelProvider {
+ Map exp2img = new HashMap(); // not the most optimized but better
+ // than having a finalize method.
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ ExporterDefinition definition = getExporterDefinition(element);
+ Image image = (Image) exp2img.get( definition.getId() );
+ if ( image == null ) {
+ image = definition.getIconDescriptor().createImage();
+ exp2img.put( definition.getId(), image );
+ }
+ return image;
+ }
+
+ private ExporterDefinition getExporterDefinition(Object element) {
+ if(element instanceof ExporterFactory) {
+ ExporterFactory ef = (ExporterFactory) element;
+ return ef.getExporterDefinition();
+ } else {
+ return (ExporterDefinition) element;
+ }
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ ExporterDefinition definition = getExporterDefinition(element);
+ return definition.getDescription();
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+
+ Iterator iterator = exp2img.values().iterator();
+ while ( iterator.hasNext() ) {
+ Image img = (Image) iterator.next();
+ if ( img != null ) {
+ img.dispose();
+ }
+ }
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getImage(Object element) {
+ return getColumnImage(element, 0);
+ }
+
+ public String getText(Object element) {
+ return getColumnText(element, 0);
+ }
+
+ }
+
+ private Composite createComposite(Composite parent, String name) {
+
+ new Label( parent, SWT.NONE ).setText( name );
+ Composite client = new Composite( parent, SWT.NONE );
+ client.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ client.setLayout( new GridLayout() );
+ // client.setBackground( ColorConstants.cyan );
+ return client;
+ }
+
+ private void dialogChanged() {
+ boolean configSelected = true; // TODO: only active if configname in
+ // settings
+ // ...getConfigurationName().length()==0;
+
+ if ( !configSelected ) {
+ updateStatus( "Console configuration must be specified" );
+ return;
+ }
+
+ if ( selectedExporters.size() == 0 ) {
+ updateStatus( "At least one exporter option must be selected" );
+ return;
+ }
+
+
+ // hard-coded checks: this should be delegated to extension point that knows about the different exporters.
+ Iterator iterator = observableFactoryList.getList().iterator();
+ while (iterator.hasNext()) {
+ ExporterFactory ef = (ExporterFactory) iterator.next();
+ String str = (String) ef.getProperties().get("outputdir");
+ String msg = null;
+ if(str!=null) {
+ msg = PathHelper.checkDirectory(PathHelper.pathOrNull(str), "Output directory for " + ef.getExporterDefinition().getDescription(), false);
+ if(msg!=null) {
+ updateStatus(msg);
+ return;
+ }
+ }
+
+ str = (String) ef.getProperties().get("template_path");
+ if(str!=null) {
+ msg = PathHelper.checkDirectory(PathHelper.pathOrNull(str), "Template directory for " + ef.getExporterDefinition().getDescription(), true);
+ if(msg!=null) {
+ updateStatus(msg);
+ return;
+ }
+ }
+
+ }
+ updateStatus( null );
+ }
+
+ protected String checkDirectory(IPath path, String name) {
+ IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(
+ path );
+ if ( res != null ) {
+ int resType = res.getType();
+ if ( resType == IResource.PROJECT || resType == IResource.FOLDER ) {
+ IProject proj = res.getProject();
+ if ( !proj.isOpen() ) {
+ return "Project for " + name + " is closed";
+ }
+ }
+ else {
+ return name + " has to be a folder or project";
+ }
+ }
+ else {
+ return name + " does not exist";
+ }
+ return null;
+ }
+
+ protected String checkFile(IPath path, String name) {
+ IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(
+ path );
+ if ( res != null ) {
+ int resType = res.getType();
+ if ( resType == IResource.FILE ) {
+ return null;
+ }
+ else {
+ return name + " must be a file";
+ }
+ }
+ else {
+ return name + " does not exist";
+ }
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage( message );
+ updateLaunchConfigurationDialog();
+ }
+
+ private Path pathOrNull(String p) {
+ if ( p == null || p.trim().length() == 0 ) {
+ return null;
+ }
+ else {
+ return new Path( p );
+ }
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ // ExporterAttributes tmpAttrs = new ExporterAttributes();
+ // tmpAttrs.setEnableAllExporters(true);
+ // tmpAttrs.save(configuration);
+ }
+
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ ExporterAttributes attributes = new ExporterAttributes(
+ configuration );
+ selectedExporters.clear();
+
+ enableEJB3annotations.setSelection( attributes.isEJB3Enabled() );
+ enableJDK5.setSelection( attributes.isJDK5Enabled() );
+
+ List exporterFactories = attributes.getExporterFactories();
+ observableFactoryList = new ObservableFactoryList(exporterFactories);
+ getExporterTable().setInput( observableFactoryList );
+ for (Iterator iter = exporterFactories.iterator(); iter.hasNext();) {
+ ExporterFactory exporterFactory = (ExporterFactory) iter.next();
+ if ( exporterFactory.isEnabled() ) {
+ getExporterTable().setChecked( exporterFactory, true );
+ selectedExporters.add( exporterFactory );
+ }
+ else {
+ getExporterTable().setChecked( exporterFactory, false );
+ }
+ }
+
+ refreshPropertySheet();
+
+ dialogChanged();
+
+ }
+ catch (CoreException ce) {
+ HibernateConsolePlugin
+ .getDefault()
+ .logErrorMessage(
+ "Problem when reading hibernate tools launch configuration",
+ ce );
+ }
+ }
+
+ private void refreshPropertySheet() {
+ getExporterTable().setSelection( getExporterTable().getSelection() ); // here to make sure the dependent propertysheet actually will reread what ever the selection is.
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(
+ HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS,
+ enableEJB3annotations.getSelection() );
+ configuration.setAttribute( HibernateLaunchConstants.ATTR_ENABLE_JDK5,
+ enableJDK5.getSelection() );
+
+ List exporterFactories = ((ObservableFactoryList)getExporterTable().getInput()).getList();
+ ExporterAttributes.saveExporterFactories(configuration, exporterFactories, selectedExporters, deletedExporterIds);
+
+ deletedExporterIds.clear();
+ }
+
+
+
+ public String getName() {
+ return "Exporters";
+ }
+
+ public Image getImage() {
+ return EclipseImages.getImage( ImageConstants.MINI_HIBERNATE );
+ }
+
+ private CheckboxTableViewer getExporterTable() {
+ return (CheckboxTableViewer) exporterUpDown.getTableViewer();
+ }
+
+ public static Object[] selectExporters(Shell shell, String title, String description) {
+ ILabelProvider labelProvider= new ExporterLabelProvider();
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, labelProvider);
+ dialog.setTitle(title);
+ dialog.setMessage(description);
+ dialog.setElements(ExtensionManager.findExporterDefinitionsAsMap().values().toArray());
+ dialog.setMultipleSelection(true);
+
+ if (dialog.open() == Window.OK) {
+ return dialog.getResult();
+ } else {
+ return new ExporterDefinition[0];
+ }
+ }
+}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -44,6 +44,9 @@
{
public static final String ATTR_PREFIX = "org.hibernate.tools.";
+ // attribute to list of id for exporters configured in a specific launchconfig.
+ public static final String ATTR_EXPORTERS = ATTR_PREFIX + "exporters";
+
public static final String ATTR_CONSOLE_CONFIGURATION_NAME = ATTR_PREFIX + "configurationname";
public static final String ATTR_OUTPUT_DIR = ATTR_PREFIX + "outputdir";
public static final String ATTR_REVERSE_ENGINEER = ATTR_PREFIX + "schema2hbm";
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/LaunchConfigurationTabGroup.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/LaunchConfigurationTabGroup.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/LaunchConfigurationTabGroup.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -36,8 +36,8 @@
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
- new CodeGenerationSettings(),
- new ExporterSettings(),
+ new CodeGenerationSettingsTab(),
+ new ExporterSettingsTab(),
new RefreshTab(),
new CommonTab()
};
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ExporterTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ExporterTest.java 2007-09-25 07:16:29 UTC (rev 3782)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ExporterTest.java 2007-09-25 07:27:00 UTC (rev 3783)
@@ -30,12 +30,12 @@
null);
- factory = new ExporterFactory(definition);
+ factory = new ExporterFactory(definition, definition.getId());
}
public void testExporters() {
- Map properties = definition.getProperties();
+ Map properties = definition.getExporterProperties();
assertEquals(properties, map);
17 years, 3 months