JBoss Tools SVN: r36304 - trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2011-11-11 11:21:46 -0500 (Fri, 11 Nov 2011)
New Revision: 36304
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
Log:
JBIDE-9910 Proposal info for message bundles in code completion for EL
Fix CA for java element/bean proposals in Java files (Fixed issue causing JUnit Test org.jboss.tools.seam.ui.test.ca.SeamELContentAssistJbide1676Test to fail)
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2011-11-11 14:51:41 UTC (rev 36303)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2011-11-11 16:21:46 UTC (rev 36304)
@@ -581,7 +581,7 @@
elEndPosition = limit;
}
limit = documentContent.indexOf('}', offset - ref.getStartPosition());
- if (limit != -1 && elEndPosition != -1 && limit < elEndPosition) {
+ if (limit != -1 && (elEndPosition == -1 || (elEndPosition != -1 && limit < elEndPosition))) {
elEndPosition = limit+1;
}
String restOfEL = elEndPosition == -1 ? "" : documentContent.substring(offset - ref.getStartPosition(), elEndPosition); //$NON-NLS-1$
13 years, 1 month
JBoss Tools SVN: r36303 - trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2011-11-11 09:51:41 -0500 (Fri, 11 Nov 2011)
New Revision: 36303
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
Log:
JBIDE-9910 Proposal info for message bundles in code completion for EL
Fix CA for java element/bean proposals in Java files
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2011-11-11 14:48:19 UTC (rev 36302)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2011-11-11 14:51:41 UTC (rev 36303)
@@ -629,7 +629,7 @@
if (string.indexOf('\'') != -1 && restOfEL.indexOf('\'') != -1) // Exclude last quote if this char already exists
string = string.substring(0, string.lastIndexOf('\''));
- if (string.indexOf(']') == -1 && restOfEL.indexOf(']') == -1) // Add closing square bracket if needed
+ if ((string.indexOf('[') != -1 || prefix.indexOf('[') != -1) && string.indexOf(']') == -1 && restOfEL.indexOf(']') == -1) // Add closing square bracket if needed
string += ']';
string += proposalSufix;
13 years, 1 month
JBoss Tools SVN: r36302 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-11-11 09:48:19 -0500 (Fri, 11 Nov 2011)
New Revision: 36302
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
Log:
[JBIDE-10133] checked in new client jar
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-11-11 14:47:57 UTC (rev 36301)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-11-11 14:48:19 UTC (rev 36302)
@@ -10,16 +10,20 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
+import java.io.IOException;
+
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.common.ui.preferencevalue.StringPreferenceValue;
-import org.jboss.tools.openshift.express.client.IOpenShiftService;
import org.jboss.tools.openshift.express.client.IUser;
import org.jboss.tools.openshift.express.client.NotFoundOpenShiftException;
import org.jboss.tools.openshift.express.client.OpenShiftException;
import org.jboss.tools.openshift.express.client.User;
-import org.jboss.tools.openshift.express.client.UserConfiguration;
+import org.jboss.tools.openshift.express.client.configuration.DefaultConfiguration;
+import org.jboss.tools.openshift.express.client.configuration.SystemConfiguration;
+import org.jboss.tools.openshift.express.client.configuration.SystemProperties;
+import org.jboss.tools.openshift.express.client.configuration.UserConfiguration;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
/**
@@ -37,7 +41,6 @@
public static final String PROPERTY_PASSWORD = "password";
public static final String PROPERTY_CREDENTIALS_VALIDITY = "credentialsValidity";
- private String serverUrl;
private String rhLogin;
private String password;
private IStatus credentialsValidity;
@@ -48,7 +51,6 @@
public CredentialsWizardPageModel(ImportProjectWizardModel model) {
this.wizardModel = model;
- this.serverUrl = IOpenShiftService.BASE_URL;
this.rhLoginPreferenceValue = new StringPreferenceValue(RHLOGIN_PREFS_KEY, OpenShiftUIActivator.PLUGIN_ID);
this.rhLogin = initRhLogin();
resetCredentialsStatus();
@@ -67,21 +69,16 @@
protected String getUserConfiguration() {
String configuredUsername = null;
try {
- configuredUsername = new UserConfiguration().getRhlogin();
+ configuredUsername = new SystemProperties(
+ new UserConfiguration(
+ new SystemConfiguration(
+ new DefaultConfiguration()))).getRhlogin();
} catch (Exception e) {
// do nothing
}
return configuredUsername;
}
- public String getServerUrl() {
- return serverUrl;
- }
-
- public void setServerUrl(String serverUrl) {
- firePropertyChange(PROPERTY_SERVER_URL, this.serverUrl, this.serverUrl = serverUrl);
- }
-
public String getRhLogin() {
return rhLogin;
}
@@ -119,7 +116,7 @@
public IStatus getCredentialsValidity() {
return credentialsValidity;
}
-
+
public boolean areCredentialsValid() {
IStatus validationStatus = getCredentialsValidity();
return validationStatus != null
@@ -142,6 +139,8 @@
status = Status.OK_STATUS;
} catch (OpenShiftException e) {
this.user = null;
+ } catch (IOException e) {
+ this.user = null;
}
wizardModel.setUser(user);
setCredentialsStatus(status);
13 years, 1 month
JBoss Tools SVN: r36301 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.client: META-INF and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-11-11 09:47:57 -0500 (Fri, 11 Nov 2011)
New Revision: 36301
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/META-INF/MANIFEST.MF
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar
Log:
[JBIDE-10133] checked in new client jar
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath 2011-11-11 14:13:50 UTC (rev 36300)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath 2011-11-11 14:47:57 UTC (rev 36301)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar" sourcepath="/home/adietish/jboss-workspaces/openshift-java-client/org.jboss.tools.openshift.express.client"/>
<classpathentry exported="true" kind="lib" path="jboss-dmr-1.0.0.Final.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/META-INF/MANIFEST.MF
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.client/META-INF/MANIFEST.MF 2011-11-11 14:13:50 UTC (rev 36300)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.client/META-INF/MANIFEST.MF 2011-11-11 14:47:57 UTC (rev 36301)
@@ -9,5 +9,6 @@
jboss-dmr-1.0.0.Final.jar,
org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar
Export-Package: org.jboss.tools.openshift.express.client,
+ org.jboss.tools.openshift.express.client.configuration,
org.jboss.tools.openshift.express.client.utils
Require-Bundle: com.jcraft.jsch;bundle-version="0.1.44"
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
13 years, 1 month
JBoss Tools SVN: r36300 - trunk/openshift/plugins/org.jboss.tools.openshift.express.client.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-11-11 09:13:50 -0500 (Fri, 11 Nov 2011)
New Revision: 36300
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar
Log:
[JBIDE-10133] added functionality to client and built a new jar for our plugin
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.client
___________________________________________________________________
Added: svn:ignore
+ target
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/org.jboss.tools.openshift.express.client-2.3.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
13 years, 1 month
JBoss Tools SVN: r36299 - branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-11-11 07:44:54 -0500 (Fri, 11 Nov 2011)
New Revision: 36299
Added:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/IArtifactCollector.java
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/IExporter.java
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java
Log:
Move exporters call to extenders plugins
Modified: branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java 2011-11-11 12:44:47 UTC (rev 36298)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java 2011-11-11 12:44:54 UTC (rev 36299)
@@ -10,6 +10,10 @@
******************************************************************************/
package org.hibernate.eclipse.console.ext;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.hibernate.console.ext.HibernateExtension;
/**
@@ -22,7 +26,7 @@
public void setHibernateException(HibernateExtension hibernateExtension);
- /*public void launchExporters(ILaunchConfiguration configuration, String mode,
- ILaunch launch, IProgressMonitor monitor) throws CoreException;*/
+ public void launchExporters(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException;
}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/IArtifactCollector.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/IArtifactCollector.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/IArtifactCollector.java 2011-11-11 12:44:54 UTC (rev 36299)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.ext;
+
+import java.io.File;
+import java.util.Set;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface IArtifactCollector {
+
+ public File[] getFiles(String type);
+
+ public Set getFileTypes();
+
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/IExporter.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/IExporter.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/IExporter.java 2011-11-11 12:44:54 UTC (rev 36299)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.ext;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface IExporter {
+
+
+ /**
+ * @param file basedirectory to be used for generated files.
+ */
+ public void setOutputDirectory(File file);
+
+ public File getOutputDirectory();
+
+ /**
+ * @param templatePath array of directories used sequentially to lookup templates
+ */
+ public void setTemplatePath(String[] templatePath);
+
+ public String[] getTemplatePath();
+
+ /**
+ *
+ * @param properties set of properties to be used by exporter.
+ */
+ public void setProperties(Properties properties);
+
+ public Properties getProperties();
+
+ /**
+ *
+ * @param collector Instance to be consulted when adding a new file.
+ */
+ public void setArtifactCollector(IArtifactCollector collector);
+
+ /**
+ *
+ * @return artifact collector
+ */
+ public IArtifactCollector getArtifactCollector();
+
+ /**
+ * Called when exporter should start generating its output
+ */
+ public void start();
+
+}
13 years, 1 month
JBoss Tools SVN: r36298 - in branches/dead/hibernatetools-multiversion2/plugins: org.jboss.tools.hibernate3_5/META-INF and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-11-11 07:44:47 -0500 (Fri, 11 Nov 2011)
New Revision: 36298
Added:
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/CompletionProposal.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/EclipseHQLCompletionRequestor.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterAttributes.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterDefinition.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterFactory.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExtensionManager.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/CompletionProposal.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ConsoleExtension4_0.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/EclipseHQLCompletionRequestor.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterAttributes.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterDefinition.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterFactory.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExtensionManager.java
Removed:
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/CompletionProposal.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/ConsoleExtension3_5.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/EclipseHQLCompletionRequestor.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/CompletionProposal.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConsoleExtension4_0.java
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/EclipseHQLCompletionRequestor.java
Modified:
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/META-INF/MANIFEST.MF
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/plugin.xml
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/META-INF/MANIFEST.MF
branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/plugin.xml
Log:
Move exporters call to extenders plugins
Modified: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/META-INF/MANIFEST.MF
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/META-INF/MANIFEST.MF 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/META-INF/MANIFEST.MF 2011-11-11 12:44:47 UTC (rev 36298)
@@ -10,6 +10,10 @@
org.hibernate.eclipse;bundle-version="3.4.0",
org.hibernate.eclipse.libs;bundle-version="1.0.0",
org.eclipse.jface.text;bundle-version="3.7.0",
- org.hibernate.eclipse.console;bundle-version="3.4.0"
+ org.hibernate.eclipse.console;bundle-version="3.4.0",
+ org.eclipse.debug.core;bundle-version="3.7.0",
+ org.eclipse.core.variables;bundle-version="3.2.500",
+ org.eclipse.jdt.core;bundle-version="3.7.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.eclipse.debug.core
Modified: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/plugin.xml
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/plugin.xml 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/plugin.xml 2011-11-11 12:44:47 UTC (rev 36298)
@@ -11,7 +11,7 @@
<extension
point="org.hibernate.eclipse.console.consoleextension">
<consoleextension
- classname="org.jboss.tools.hibernate3_5.ConsoleExtension3_5"
+ classname="org.jboss.tools.hibernate3_5.console.ConsoleExtension3_5"
version="%hibernate.version">
</consoleextension>
</extension>
Deleted: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/CompletionProposal.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/CompletionProposal.java 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/CompletionProposal.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -1,279 +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.jboss.tools.hibernate3_5;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
-
-/**
- * Generic completion proposal to be used as is, or as base for other completion proposals.
- *
- * @author Max Rydahl Andersen
- *
- */
-public class CompletionProposal implements ICompletionProposal, ICompletionProposalExtension {
-
- private String displayString;
- private String replacementString;
- private int replacementOffset;
- private int documentOffset = -1;
- private int replacementLength;
- private int cursorPosition;
- private Image image;
- private IContextInformation contextInformation;
- private int contextInformationPosition;
- private char[] triggerCharacters;
- private String additionalProposalInfo;
-
- /**
- * Creates a new completion proposal. All fields are initialized based on
- * the provided information.
- *
- * @param additionalInfo additional information about the completion proposal
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset offset of the text to be replaced
- * @param documentOffset offset of the document
- * @param replacementLength length of the text to be replaced
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal If set
- * to <code>null</code>, the replacement string will be taken
- * as display string.
- */
- public CompletionProposal( String additionalInfo, String replacementString, int replacementOffset,
- int documentOffset, int replacementLength, Image image, String displayString,
- IContextInformation contextInformation ) {
-
- this.replacementString = replacementString;
- this.replacementOffset = replacementOffset;
- this.documentOffset = documentOffset;
- this.replacementLength = replacementLength;
- this.image = image;
- this.displayString = displayString != null ? displayString : replacementString;
-
- this.cursorPosition = replacementString.length();
-
- this.contextInformation = contextInformation;
-
- this.triggerCharacters = null;
- this.additionalProposalInfo = additionalInfo;
- }
-
- /**
- * Creates a new completion proposal. All fields are initialized based on
- * the provided information.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param cursorPosition the position of the cursor following the insert
- * relative to replacementOffset
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal
- * @param contentInformation the context information associated with this proposal
- * @param additionalProposalInfo the additional information associated with
- * this proposal
- */
- public CompletionProposal( String replacementString, int replacementOffset, int replacementLength,
- int cursorPosition, Image image, String displayString, IContextInformation contextInformation,
- String additionalProposalInfo ) {
-
- this.replacementString = replacementString;
- this.replacementOffset = replacementOffset;
- this.documentOffset = replacementOffset;
- this.replacementLength = replacementLength;
- this.cursorPosition = cursorPosition;
- this.image = image;
- this.displayString = displayString;
- this.contextInformation = contextInformation;
- this.additionalProposalInfo = additionalProposalInfo;
-
- }
-
- public void setContextInformation( IContextInformation contextInformation ) {
- this.contextInformation = contextInformation;
- contextInformationPosition = (contextInformation != null ? cursorPosition : -1);
- }
-
- /**
- * Sets the trigger characters.
- *
- * @param triggerCharacters The set of characters which can trigger the
- * application of this completion proposal
- */
- public void setTriggerCharacters( char[] triggerCharacters ) {
- this.triggerCharacters = triggerCharacters;
- }
-
- /**
- * Sets the cursor position relative to the insertion offset. By default
- * this is the length of the completion string (Cursor positioned after the
- * completion)
- *
- * @param cursorPosition The cursorPosition to set
- */
- public void setCursorPosition( int cursorPosition ) {
-
- if (cursorPosition >= 0) {
- this.cursorPosition = cursorPosition;
- this.contextInformationPosition = (contextInformation != null ? cursorPosition : -1);
- }
- }
-
- public void apply( IDocument document, char trigger, int offset ) {
- try {
- // patch replacement length
-
- int delta = offset - (documentOffset + replacementLength);
- if (delta > 0)
- replacementLength += delta;
-
- if (trigger == (char) 0) {
- replace( document, documentOffset, replacementLength, replacementString );
- }
- else {
- StringBuffer buffer = new StringBuffer( replacementString );
-
- if ((replacementLength < buffer.length() && buffer.charAt( replacementLength ) != trigger)) {
- buffer.insert( cursorPosition, trigger );
- ++cursorPosition;
- }
-
- replace( document, documentOffset, replacementLength, buffer.toString() );
- }
-
- int oldLen = document.getLength();
- documentOffset += document.getLength() - oldLen;
- }
- catch (BadLocationException e) {
- HibernateConsolePlugin.getDefault().log( e );
- }
- }
-
- /**
- * Replaces the document content at the specified offset and length with the
- * specified string.
- *
- * @param document the document opened in the editor
- * @param offset offset to the document content to be replaced
- * @param length length of text to be replaced
- * @param string replacement string
- * @throws BadLocationException
- */
- private void replace( IDocument document, int offset, int length, String string ) throws BadLocationException {
- if (document != null && string != null && offset >= 0 && length >= 0) {
- if (!document.get( offset, length ).equals( string ))
- document.replace( offset, length, string );
- }
- }
-
- public void apply( IDocument document ) {
- apply( document, (char) 0, documentOffset + replacementLength );
- }
-
- public Point getSelection( IDocument document ) {
- return new Point( documentOffset + cursorPosition, 0 );
- }
-
- public IContextInformation getContextInformation() {
- return contextInformation;
- }
-
- public Image getImage() {
- return image;
- }
-
- public String getDisplayString() {
- return displayString;
- }
-
- public String getAdditionalProposalInfo() {
- return additionalProposalInfo;
- }
-
- public char[] getTriggerCharacters() {
- return triggerCharacters;
- }
-
- public int getContextInformationPosition() {
- return replacementOffset + contextInformationPosition;
- }
-
- public int getReplacementOffset() {
- return replacementOffset;
- }
-
- public void setReplacementOffset( int replacementOffset ) {
-
- if (replacementOffset >= 0) {
- this.replacementOffset = replacementOffset;
- }
- }
-
- public int getReplacementLength() {
- return replacementLength;
- }
-
- public void setReplacementLength( int replacementLength ) {
-
- if (replacementLength >= 0) {
- this.replacementLength = replacementLength;
- }
- }
-
- public String getReplacementString() {
- return replacementString;
- }
-
- public void setReplacementString( String replacementString ) {
- this.replacementString = replacementString;
- }
-
- public void setImage( Image image ) {
- this.image = image;
- }
-
- public boolean isValidFor( IDocument document, int offset ) {
- if (offset < replacementOffset)
- return false;
-
- int replacementLength = replacementString == null ? 0 : replacementString.length();
- if (offset >= replacementOffset + replacementLength)
- return false;
-
- try {
- int length = offset - replacementOffset;
- String start = document.get( replacementOffset, length );
- return replacementString.substring( 0, length ).equalsIgnoreCase( start );
- }
- catch (BadLocationException x) {
- }
-
- return false;
- }
-
-}
\ No newline at end of file
Deleted: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/ConsoleExtension3_5.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/ConsoleExtension3_5.java 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/ConsoleExtension3_5.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate3_5;
-
-import org.hibernate.console.execution.ExecutionContext;
-import org.hibernate.console.ext.HibernateException;
-import org.hibernate.console.ext.HibernateExtension;
-import org.hibernate.eclipse.console.ext.CompletionProposalsResult;
-import org.hibernate.eclipse.console.ext.ConsoleExtension;
-import org.hibernate.tool.ide.completion.HQLCodeAssist;
-import org.hibernate.tool.ide.completion.IHQLCodeAssist;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class ConsoleExtension3_5 implements ConsoleExtension {
-
- private HibernateExtension3_5 hibernateExtension;
-
- public ConsoleExtension3_5(){}
-
- public void setHibernateException(HibernateExtension hibernateExtension){
- this.hibernateExtension = (HibernateExtension3_5) hibernateExtension;
- }
-
- @Override
- public CompletionProposalsResult hqlCodeComplete(String query, int currentOffset) {
- EclipseHQLCompletionRequestor requestor = new EclipseHQLCompletionRequestor();
- if (!hibernateExtension.hasConfiguration()){
- try {
- hibernateExtension.build();
- hibernateExtension.execute( new ExecutionContext.Command() {
- public Object execute() {
- if(hibernateExtension.hasConfiguration()) {
- hibernateExtension.getConfiguration().buildMappings();
- }
- return null;
- }
- });
- } catch (HibernateException e){
- //FIXME
- //String mess = NLS.bind(HibernateConsoleMessages.CompletionHelper_error_could_not_build_cc, consoleConfiguration.getName());
- //HibernateConsolePlugin.getDefault().logErrorMessage(mess, e);
- }
- }
- IHQLCodeAssist hqlEval = new HQLCodeAssist(hibernateExtension.getConfiguration());
- query = query.replace('\t', ' ');
- hqlEval.codeComplete(query, currentOffset, requestor);
- return new CompletionProposalsResult(requestor.getCompletionProposals(), requestor.getLastErrorMessage());
- }
-
-
-
-}
Deleted: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/EclipseHQLCompletionRequestor.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/EclipseHQLCompletionRequestor.java 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/EclipseHQLCompletionRequestor.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -1,151 +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.jboss.tools.hibernate3_5;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.swt.graphics.Image;
-import org.hibernate.console.ImageConstants;
-import org.hibernate.eclipse.console.utils.EclipseImages;
-import org.hibernate.eclipse.console.workbench.HibernateWorkbenchHelper;
-import org.hibernate.tool.ide.completion.HQLCompletionProposal;
-import org.hibernate.tool.ide.completion.IHQLCompletionRequestor;
-import org.hibernate.util.StringHelper;
-
-public class EclipseHQLCompletionRequestor implements IHQLCompletionRequestor {
-
- private final List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
- private String lastErrorMessage;
- private final int virtualOffset;
-
- public EclipseHQLCompletionRequestor() {
- virtualOffset = 0;
- }
-
- public EclipseHQLCompletionRequestor(int virtualOffset) {
- this.virtualOffset = virtualOffset;
- }
-
- public List<ICompletionProposal> getCompletionProposals() {
- return result;
- }
-
- public boolean accept(HQLCompletionProposal proposal) {
- result.add(new CompletionProposal(proposal.getCompletion(), // replacementString
- proposal.getReplaceStart()+virtualOffset, // replacementOffset
- proposal.getReplaceEnd()-proposal.getReplaceStart(), // replacementLength
- proposal.getCompletion().length(), // cursorPosition (relativeTo replacementStart)
- getImage(proposal),
- getDisplayString(proposal),
- null,
- null));
- return true;
- }
-
- private String getDisplayString(HQLCompletionProposal proposal) {
- StringBuffer buf = new StringBuffer(proposal.getSimpleName());
-
- switch(proposal.getCompletionKind()) {
- case HQLCompletionProposal.ENTITY_NAME:
- if(proposal.getEntityName()!=null &&
- !(proposal.getSimpleName().equals( proposal.getEntityName()))) {
- buf.append(" - "); //$NON-NLS-1$
- buf.append(StringHelper.qualifier( proposal.getEntityName() ));
- } else if(proposal.getShortEntityName()!=null &&
- !(proposal.getSimpleName().equals( proposal.getEntityName()))) {
- buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
- }
- break;
- case HQLCompletionProposal.ALIAS_REF:
- if(proposal.getShortEntityName()!=null) {
- buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
- } else if(proposal.getEntityName()!=null) {
- buf.append( " - " + proposal.getEntityName() ); //$NON-NLS-1$
- }
- break;
- case HQLCompletionProposal.PROPERTY:
- if(proposal.getShortEntityName()!=null) {
- buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
- } else if(proposal.getEntityName()!=null) {
- if(proposal.getEntityName().indexOf( "." )>=0) { //$NON-NLS-1$
- buf.append( " - " + StringHelper.unqualify( proposal.getEntityName() )); //$NON-NLS-1$
- } else {
- buf.append( " - " + proposal.getEntityName() ); //$NON-NLS-1$
- }
- }
- break;
- case HQLCompletionProposal.KEYWORD:
- break;
- case HQLCompletionProposal.FUNCTION:
- break;
- default:
-
- }
-
-
- return buf.toString();
- }
-
- private Image getImage(HQLCompletionProposal proposal) {
- String key = null;
-
- switch(proposal.getCompletionKind()) {
- case HQLCompletionProposal.ENTITY_NAME:
- case HQLCompletionProposal.ALIAS_REF:
- key = ImageConstants.MAPPEDCLASS;
- break;
- case HQLCompletionProposal.PROPERTY:
- if(proposal.getProperty()!=null) {
- return HibernateWorkbenchHelper.getImage( proposal.getProperty() );
- } else {
- key = ImageConstants.PROPERTY;
- }
- break;
- case HQLCompletionProposal.KEYWORD:
- key = null;
- break;
- case HQLCompletionProposal.FUNCTION:
- key = ImageConstants.FUNCTION;
- break;
- default:
- key = null;
- }
-
- return key==null?null:EclipseImages.getImage( key );
- }
-
- public void completionFailure(String errorMessage) {
- lastErrorMessage = errorMessage;
- }
-
- public String getLastErrorMessage() {
- return lastErrorMessage;
- }
-
- public void clear() {
- result.clear();
- lastErrorMessage = null;
- }
-
-}
Copied: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/CompletionProposal.java (from rev 36273, branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/CompletionProposal.java)
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/CompletionProposal.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/CompletionProposal.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,279 @@
+/*
+ * 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.jboss.tools.hibernate3_5.console;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+
+/**
+ * Generic completion proposal to be used as is, or as base for other completion proposals.
+ *
+ * @author Max Rydahl Andersen
+ *
+ */
+public class CompletionProposal implements ICompletionProposal, ICompletionProposalExtension {
+
+ private String displayString;
+ private String replacementString;
+ private int replacementOffset;
+ private int documentOffset = -1;
+ private int replacementLength;
+ private int cursorPosition;
+ private Image image;
+ private IContextInformation contextInformation;
+ private int contextInformationPosition;
+ private char[] triggerCharacters;
+ private String additionalProposalInfo;
+
+ /**
+ * Creates a new completion proposal. All fields are initialized based on
+ * the provided information.
+ *
+ * @param additionalInfo additional information about the completion proposal
+ * @param replacementString the actual string to be inserted into the document
+ * @param replacementOffset offset of the text to be replaced
+ * @param documentOffset offset of the document
+ * @param replacementLength length of the text to be replaced
+ * @param image the image to display for this proposal
+ * @param displayString the string to be displayed for the proposal If set
+ * to <code>null</code>, the replacement string will be taken
+ * as display string.
+ */
+ public CompletionProposal( String additionalInfo, String replacementString, int replacementOffset,
+ int documentOffset, int replacementLength, Image image, String displayString,
+ IContextInformation contextInformation ) {
+
+ this.replacementString = replacementString;
+ this.replacementOffset = replacementOffset;
+ this.documentOffset = documentOffset;
+ this.replacementLength = replacementLength;
+ this.image = image;
+ this.displayString = displayString != null ? displayString : replacementString;
+
+ this.cursorPosition = replacementString.length();
+
+ this.contextInformation = contextInformation;
+
+ this.triggerCharacters = null;
+ this.additionalProposalInfo = additionalInfo;
+ }
+
+ /**
+ * Creates a new completion proposal. All fields are initialized based on
+ * the provided information.
+ *
+ * @param replacementString the actual string to be inserted into the document
+ * @param replacementOffset the offset of the text to be replaced
+ * @param replacementLength the length of the text to be replaced
+ * @param cursorPosition the position of the cursor following the insert
+ * relative to replacementOffset
+ * @param image the image to display for this proposal
+ * @param displayString the string to be displayed for the proposal
+ * @param contentInformation the context information associated with this proposal
+ * @param additionalProposalInfo the additional information associated with
+ * this proposal
+ */
+ public CompletionProposal( String replacementString, int replacementOffset, int replacementLength,
+ int cursorPosition, Image image, String displayString, IContextInformation contextInformation,
+ String additionalProposalInfo ) {
+
+ this.replacementString = replacementString;
+ this.replacementOffset = replacementOffset;
+ this.documentOffset = replacementOffset;
+ this.replacementLength = replacementLength;
+ this.cursorPosition = cursorPosition;
+ this.image = image;
+ this.displayString = displayString;
+ this.contextInformation = contextInformation;
+ this.additionalProposalInfo = additionalProposalInfo;
+
+ }
+
+ public void setContextInformation( IContextInformation contextInformation ) {
+ this.contextInformation = contextInformation;
+ contextInformationPosition = (contextInformation != null ? cursorPosition : -1);
+ }
+
+ /**
+ * Sets the trigger characters.
+ *
+ * @param triggerCharacters The set of characters which can trigger the
+ * application of this completion proposal
+ */
+ public void setTriggerCharacters( char[] triggerCharacters ) {
+ this.triggerCharacters = triggerCharacters;
+ }
+
+ /**
+ * Sets the cursor position relative to the insertion offset. By default
+ * this is the length of the completion string (Cursor positioned after the
+ * completion)
+ *
+ * @param cursorPosition The cursorPosition to set
+ */
+ public void setCursorPosition( int cursorPosition ) {
+
+ if (cursorPosition >= 0) {
+ this.cursorPosition = cursorPosition;
+ this.contextInformationPosition = (contextInformation != null ? cursorPosition : -1);
+ }
+ }
+
+ public void apply( IDocument document, char trigger, int offset ) {
+ try {
+ // patch replacement length
+
+ int delta = offset - (documentOffset + replacementLength);
+ if (delta > 0)
+ replacementLength += delta;
+
+ if (trigger == (char) 0) {
+ replace( document, documentOffset, replacementLength, replacementString );
+ }
+ else {
+ StringBuffer buffer = new StringBuffer( replacementString );
+
+ if ((replacementLength < buffer.length() && buffer.charAt( replacementLength ) != trigger)) {
+ buffer.insert( cursorPosition, trigger );
+ ++cursorPosition;
+ }
+
+ replace( document, documentOffset, replacementLength, buffer.toString() );
+ }
+
+ int oldLen = document.getLength();
+ documentOffset += document.getLength() - oldLen;
+ }
+ catch (BadLocationException e) {
+ HibernateConsolePlugin.getDefault().log( e );
+ }
+ }
+
+ /**
+ * Replaces the document content at the specified offset and length with the
+ * specified string.
+ *
+ * @param document the document opened in the editor
+ * @param offset offset to the document content to be replaced
+ * @param length length of text to be replaced
+ * @param string replacement string
+ * @throws BadLocationException
+ */
+ private void replace( IDocument document, int offset, int length, String string ) throws BadLocationException {
+ if (document != null && string != null && offset >= 0 && length >= 0) {
+ if (!document.get( offset, length ).equals( string ))
+ document.replace( offset, length, string );
+ }
+ }
+
+ public void apply( IDocument document ) {
+ apply( document, (char) 0, documentOffset + replacementLength );
+ }
+
+ public Point getSelection( IDocument document ) {
+ return new Point( documentOffset + cursorPosition, 0 );
+ }
+
+ public IContextInformation getContextInformation() {
+ return contextInformation;
+ }
+
+ public Image getImage() {
+ return image;
+ }
+
+ public String getDisplayString() {
+ return displayString;
+ }
+
+ public String getAdditionalProposalInfo() {
+ return additionalProposalInfo;
+ }
+
+ public char[] getTriggerCharacters() {
+ return triggerCharacters;
+ }
+
+ public int getContextInformationPosition() {
+ return replacementOffset + contextInformationPosition;
+ }
+
+ public int getReplacementOffset() {
+ return replacementOffset;
+ }
+
+ public void setReplacementOffset( int replacementOffset ) {
+
+ if (replacementOffset >= 0) {
+ this.replacementOffset = replacementOffset;
+ }
+ }
+
+ public int getReplacementLength() {
+ return replacementLength;
+ }
+
+ public void setReplacementLength( int replacementLength ) {
+
+ if (replacementLength >= 0) {
+ this.replacementLength = replacementLength;
+ }
+ }
+
+ public String getReplacementString() {
+ return replacementString;
+ }
+
+ public void setReplacementString( String replacementString ) {
+ this.replacementString = replacementString;
+ }
+
+ public void setImage( Image image ) {
+ this.image = image;
+ }
+
+ public boolean isValidFor( IDocument document, int offset ) {
+ if (offset < replacementOffset)
+ return false;
+
+ int replacementLength = replacementString == null ? 0 : replacementString.length();
+ if (offset >= replacementOffset + replacementLength)
+ return false;
+
+ try {
+ int length = offset - replacementOffset;
+ String start = document.get( replacementOffset, length );
+ return replacementString.substring( 0, length ).equalsIgnoreCase( start );
+ }
+ catch (BadLocationException x) {
+ }
+
+ return false;
+ }
+
+}
\ No newline at end of file
Copied: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java (from rev 36275, branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/ConsoleExtension3_5.java)
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate3_5.console;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.JDBCMetaDataConfiguration;
+import org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy;
+import org.hibernate.cfg.reveng.OverrideRepository;
+import org.hibernate.cfg.reveng.ReverseEngineeringSettings;
+import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.console.execution.ExecutionContext;
+import org.hibernate.console.execution.ExecutionContext.Command;
+import org.hibernate.console.ext.HibernateException;
+import org.hibernate.console.ext.HibernateExtension;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.ext.CompletionProposalsResult;
+import org.hibernate.eclipse.console.ext.ConsoleExtension;
+import org.hibernate.eclipse.launch.CodeGenerationStrings;
+import org.hibernate.eclipse.launch.CodeGenerationUtils;
+import org.hibernate.eclipse.launch.PathHelper;
+import org.hibernate.tool.hbm2x.ArtifactCollector;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.ide.completion.HQLCodeAssist;
+import org.hibernate.tool.ide.completion.IHQLCodeAssist;
+import org.hibernate.util.ReflectHelper;
+import org.jboss.tools.hibernate3_5.HibernateExtension3_5;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ConsoleExtension3_5 implements ConsoleExtension {
+
+ private HibernateExtension3_5 hibernateExtension;
+
+ public ConsoleExtension3_5(){}
+
+ public void setHibernateException(HibernateExtension hibernateExtension){
+ this.hibernateExtension = (HibernateExtension3_5) hibernateExtension;
+ }
+
+ @Override
+ public CompletionProposalsResult hqlCodeComplete(String query, int currentOffset) {
+ EclipseHQLCompletionRequestor requestor = new EclipseHQLCompletionRequestor();
+ if (!hibernateExtension.hasConfiguration()){
+ try {
+ hibernateExtension.build();
+ hibernateExtension.execute( new ExecutionContext.Command() {
+ public Object execute() {
+ if(hibernateExtension.hasConfiguration()) {
+ hibernateExtension.getConfiguration().buildMappings();
+ }
+ return null;
+ }
+ });
+ } catch (HibernateException e){
+ //FIXME
+ //String mess = NLS.bind(HibernateConsoleMessages.CompletionHelper_error_could_not_build_cc, consoleConfiguration.getName());
+ //HibernateConsolePlugin.getDefault().logErrorMessage(mess, e);
+ }
+ }
+ IHQLCodeAssist hqlEval = new HQLCodeAssist(hibernateExtension.getConfiguration());
+ query = query.replace('\t', ' ');
+ hqlEval.codeComplete(query, currentOffset, requestor);
+ return new CompletionProposalsResult(requestor.getCompletionProposals(), requestor.getLastErrorMessage());
+ }
+
+ /* (non-Javadoc)
+ * @see org.hibernate.eclipse.console.ext.ConsoleExtension#launchExporters(org.hibernate.eclipse.console.ext.ILaunchConfiguration, java.lang.String, org.hibernate.eclipse.console.ext.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void launchExporters(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+ Assert.isNotNull(configuration);
+ Assert.isNotNull(monitor);
+ ExporterAttributes attributes = new ExporterAttributes(configuration);
+ List<ExporterFactory> exporterFactories = attributes.getExporterFactories();
+ for (Iterator<ExporterFactory> iter = exporterFactories.iterator(); iter.hasNext();) {
+ ExporterFactory exFactory = iter.next();
+ if (!exFactory.isEnabled(configuration)) {
+ iter.remove();
+ }
+ }
+
+ try {
+ Set<String> outputDirectories = new HashSet<String>();
+ ExporterFactory[] exporters = exporterFactories.toArray( new ExporterFactory[exporterFactories.size()] );
+ ArtifactCollector collector = runExporters(attributes, exporters, outputDirectories, monitor);
+
+ for (String path : outputDirectories) {
+ CodeGenerationUtils.refreshOutputDir(path);
+ }
+
+ //RefreshTab.refreshResources(configuration, monitor);
+
+ // code formatting needs to happen *after* refresh to make sure eclipse will format the uptodate files!
+ if(collector!=null) {
+ //formatGeneratedCode( monitor, collector );
+ }
+
+
+ } catch(Exception e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
+ } catch(NoClassDefFoundError e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_received_noclassdeffounderror,e), 666));
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private ArtifactCollector runExporters (final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final IProgressMonitor monitor)
+ throws CoreException
+ {
+
+ monitor.beginTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_generating_code_for + attributes.getConsoleConfigurationName(), exporterFactories.length + 1);
+
+ if (monitor.isCanceled())
+ return null;
+
+ ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
+ if (attributes.isReverseEngineer()) {
+ monitor.subTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_reading_jdbc_metadata);
+ }
+ final Configuration cfg = buildConfiguration(attributes, cc, ResourcesPlugin.getWorkspace().getRoot());
+
+ monitor.worked(1);
+
+ if (monitor.isCanceled())
+ return null;
+
+ return (ArtifactCollector) cc.execute(new Command() {
+
+ public Object execute() {
+ ArtifactCollector artifactCollector = new ArtifactCollector();
+
+ // Global properties
+ Properties props = new Properties();
+ props.put(CodeGenerationStrings.EJB3, "" + attributes.isEJB3Enabled()); //$NON-NLS-1$
+ props.put(CodeGenerationStrings.JDK5, "" + attributes.isJDK5Enabled()); //$NON-NLS-1$
+
+ for (int i = 0; i < exporterFactories.length; i++)
+ {
+ monitor.subTask(exporterFactories[i].getExporterDefinition().getDescription());
+
+ Properties globalProperties = new Properties();
+ globalProperties.putAll(props);
+
+ Exporter exporter;
+ try {
+ exporter = exporterFactories[i].createConfiguredExporter(cfg, attributes.getOutputPath(), attributes.getTemplatePath(), globalProperties, outputDirectories, artifactCollector);
+ } catch (CoreException e) {
+ throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_setting_up + exporterFactories[i].getExporterDefinition(), e);
+ }
+
+ try {
+ exporter.start();
+ } catch(HibernateException he) {
+ throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_running + exporterFactories[i].getExporterDefinition().getDescription(), he);
+ }
+ monitor.worked(1);
+ }
+ return artifactCollector;
+ }
+
+ });
+
+
+ }
+
+
+ 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 = PathHelper.findMember( root, attributes.getRevengSettings());
+
+ if(reveng) {
+ Configuration configuration = null;
+ if(cc.hasConfiguration()) {
+ configuration = cc.getConfiguration();
+ } else {
+ configuration = cc.buildWith( null, false );
+ }
+
+ final JDBCMetaDataConfiguration cfg = new JDBCMetaDataConfiguration();
+ Properties properties = configuration.getProperties();
+ cfg.setProperties( properties );
+ cc.buildWith(cfg,false);
+
+ cfg.setPreferBasicCompositeIds(preferBasicCompositeids);
+
+ cc.execute(new Command() { // need to execute in the consoleconfiguration to let it handle classpath stuff!
+
+ public Object execute() {
+ //todo: factor this setup of revengstrategy to core
+ ReverseEngineeringStrategy res = new DefaultReverseEngineeringStrategy();
+
+ OverrideRepository repository = null;
+
+ if(revengres!=null) {
+ File file = PathHelper.getLocation( revengres ).toFile();
+ repository = new OverrideRepository();
+ repository.addFile(file);
+ }
+
+ if (repository != null){
+ res = repository.getReverseEngineeringStrategy(res);
+ }
+
+ if(reverseEngineeringStrategy!=null && reverseEngineeringStrategy.trim().length()>0) {
+ res = loadreverseEngineeringStrategy(reverseEngineeringStrategy, res);
+ }
+
+ ReverseEngineeringSettings qqsettings = new ReverseEngineeringSettings(res)
+ .setDefaultPackageName(attributes.getPackageName())
+ .setDetectManyToMany( attributes.detectManyToMany() )
+ .setDetectOneToOne( attributes.detectOneToOne() )
+ .setDetectOptimisticLock( attributes.detectOptimisticLock() );
+
+ res.setSettings(qqsettings);
+
+ cfg.setReverseEngineeringStrategy( res );
+
+ cfg.readFromJDBC();
+ cfg.buildMappings();
+ return null;
+ }
+ });
+
+ return cfg;
+ } else {
+ cc.build();
+ final Configuration configuration = cc.getConfiguration();
+
+ cc.execute(new Command() {
+ public Object execute() {
+
+ configuration.buildMappings();
+ return configuration;
+ }
+ });
+ return configuration;
+ }
+ }
+
+ // TODO: merge with revstrategy load in JDBCConfigurationTask
+ @SuppressWarnings("unchecked")
+ private ReverseEngineeringStrategy loadreverseEngineeringStrategy(final String className, ReverseEngineeringStrategy delegate) {
+ try {
+ Class<ReverseEngineeringStrategy> clazz = ReflectHelper.classForName(className);
+ Constructor<ReverseEngineeringStrategy> constructor = clazz.getConstructor(new Class[] { ReverseEngineeringStrategy.class });
+ return constructor.newInstance(new Object[] { delegate });
+ }
+ catch (NoSuchMethodException e) {
+ try {
+ Class<?> clazz = ReflectHelper.classForName(className);
+ ReverseEngineeringStrategy rev = (ReverseEngineeringStrategy) clazz.newInstance();
+ return rev;
+ }
+ catch (Exception eq) {
+ String out = NLS.bind(HibernateConsoleMessages.CodeGenerationLaunchDelegate_could_not_create_or_find_with_default_noarg_constructor, className);
+ throw new HibernateConsoleRuntimeException(out, eq);
+ }
+ }
+ catch (Exception e) {
+ String out = NLS.bind(HibernateConsoleMessages.CodeGenerationLaunchDelegate_could_not_create_or_find_with_one_argument_delegate_constructor, className);
+ throw new HibernateConsoleRuntimeException(out, e);
+ }
+ }
+
+}
Copied: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/EclipseHQLCompletionRequestor.java (from rev 36273, branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/EclipseHQLCompletionRequestor.java)
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/EclipseHQLCompletionRequestor.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/EclipseHQLCompletionRequestor.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,151 @@
+/*
+ * 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.jboss.tools.hibernate3_5.console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.console.workbench.HibernateWorkbenchHelper;
+import org.hibernate.tool.ide.completion.HQLCompletionProposal;
+import org.hibernate.tool.ide.completion.IHQLCompletionRequestor;
+import org.hibernate.util.StringHelper;
+
+public class EclipseHQLCompletionRequestor implements IHQLCompletionRequestor {
+
+ private final List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
+ private String lastErrorMessage;
+ private final int virtualOffset;
+
+ public EclipseHQLCompletionRequestor() {
+ virtualOffset = 0;
+ }
+
+ public EclipseHQLCompletionRequestor(int virtualOffset) {
+ this.virtualOffset = virtualOffset;
+ }
+
+ public List<ICompletionProposal> getCompletionProposals() {
+ return result;
+ }
+
+ public boolean accept(HQLCompletionProposal proposal) {
+ result.add(new CompletionProposal(proposal.getCompletion(), // replacementString
+ proposal.getReplaceStart()+virtualOffset, // replacementOffset
+ proposal.getReplaceEnd()-proposal.getReplaceStart(), // replacementLength
+ proposal.getCompletion().length(), // cursorPosition (relativeTo replacementStart)
+ getImage(proposal),
+ getDisplayString(proposal),
+ null,
+ null));
+ return true;
+ }
+
+ private String getDisplayString(HQLCompletionProposal proposal) {
+ StringBuffer buf = new StringBuffer(proposal.getSimpleName());
+
+ switch(proposal.getCompletionKind()) {
+ case HQLCompletionProposal.ENTITY_NAME:
+ if(proposal.getEntityName()!=null &&
+ !(proposal.getSimpleName().equals( proposal.getEntityName()))) {
+ buf.append(" - "); //$NON-NLS-1$
+ buf.append(StringHelper.qualifier( proposal.getEntityName() ));
+ } else if(proposal.getShortEntityName()!=null &&
+ !(proposal.getSimpleName().equals( proposal.getEntityName()))) {
+ buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
+ }
+ break;
+ case HQLCompletionProposal.ALIAS_REF:
+ if(proposal.getShortEntityName()!=null) {
+ buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
+ } else if(proposal.getEntityName()!=null) {
+ buf.append( " - " + proposal.getEntityName() ); //$NON-NLS-1$
+ }
+ break;
+ case HQLCompletionProposal.PROPERTY:
+ if(proposal.getShortEntityName()!=null) {
+ buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
+ } else if(proposal.getEntityName()!=null) {
+ if(proposal.getEntityName().indexOf( "." )>=0) { //$NON-NLS-1$
+ buf.append( " - " + StringHelper.unqualify( proposal.getEntityName() )); //$NON-NLS-1$
+ } else {
+ buf.append( " - " + proposal.getEntityName() ); //$NON-NLS-1$
+ }
+ }
+ break;
+ case HQLCompletionProposal.KEYWORD:
+ break;
+ case HQLCompletionProposal.FUNCTION:
+ break;
+ default:
+
+ }
+
+
+ return buf.toString();
+ }
+
+ private Image getImage(HQLCompletionProposal proposal) {
+ String key = null;
+
+ switch(proposal.getCompletionKind()) {
+ case HQLCompletionProposal.ENTITY_NAME:
+ case HQLCompletionProposal.ALIAS_REF:
+ key = ImageConstants.MAPPEDCLASS;
+ break;
+ case HQLCompletionProposal.PROPERTY:
+ if(proposal.getProperty()!=null) {
+ return HibernateWorkbenchHelper.getImage( proposal.getProperty() );
+ } else {
+ key = ImageConstants.PROPERTY;
+ }
+ break;
+ case HQLCompletionProposal.KEYWORD:
+ key = null;
+ break;
+ case HQLCompletionProposal.FUNCTION:
+ key = ImageConstants.FUNCTION;
+ break;
+ default:
+ key = null;
+ }
+
+ return key==null?null:EclipseImages.getImage( key );
+ }
+
+ public void completionFailure(String errorMessage) {
+ lastErrorMessage = errorMessage;
+ }
+
+ public String getLastErrorMessage() {
+ return lastErrorMessage;
+ }
+
+ public void clear() {
+ result.clear();
+ lastErrorMessage = null;
+ }
+
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterAttributes.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterAttributes.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterAttributes.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,406 @@
+/*
+ * 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:/*
+ * 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.jboss.tools.hibernate3_5.console;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+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.jdt.core.JavaConventions;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.hibernate.eclipse.launch.PathHelper;
+
+// This class was created to centralize launch configuration attribute loading/saving
+// (and also to clean up CodeGenerationLaunchDelegate considerably)
+public class ExporterAttributes
+{
+ private boolean reverseEngineer, useOwnTemplates, enableJDK5, enableEJB3, preferBasicCompositeIds;
+ private boolean useExternalProcess;
+ private String consoleConfigurationName;
+ private String revengSettings;
+ private String revengStrategy;
+ private String packageName;
+ private String outputPath;
+ private String templatePath;
+ private List<ExporterFactory> exporterFactories;
+
+ private boolean autoManyToManyDetection;
+ private boolean autoOneToOneDetection;
+ private boolean autoVersioning;
+
+ public ExporterAttributes () { }
+
+ public ExporterAttributes (ILaunchConfiguration configuration)
+ throws CoreException
+ {
+ initialize(configuration);
+ }
+
+ public void initialize (ILaunchConfiguration configuration)
+ throws CoreException
+ {
+ try {
+ consoleConfigurationName = configuration.getAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,""); //$NON-NLS-1$
+ outputPath = configuration.getAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR,""); //$NON-NLS-1$
+ reverseEngineer = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, false);
+ revengSettings = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_SETTINGS, ""); //$NON-NLS-1$
+ revengStrategy = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_STRATEGY, ""); //$NON-NLS-1$
+ useOwnTemplates = configuration.getAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES,false);
+ useExternalProcess = configuration.getAttribute(HibernateLaunchConstants.ATTR_USE_EXTERNAL_PROCESS, false);
+ enableJDK5 = configuration.getAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5,false);
+ enableEJB3 = configuration.getAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS,false);
+ packageName = configuration.getAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME,""); //$NON-NLS-1$
+ templatePath = configuration.getAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR,""); //$NON-NLS-1$
+ preferBasicCompositeIds = configuration.getAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, true);
+ autoManyToManyDetection = configuration.getAttribute( HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
+ autoOneToOneDetection = configuration.getAttribute( HibernateLaunchConstants.ATTR_AUTOMATIC_ONE_TO_ONE, true);
+ autoVersioning = configuration.getAttribute( HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
+
+
+ if (!useOwnTemplates) {
+ templatePath = null;
+ }
+
+ exporterFactories = readExporterFactories(configuration);
+ } catch (CoreException e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
+ }
+ }
+
+ public static String getLaunchAttributePrefix(String exporterId) {
+ return HibernateLaunchConstants.ATTR_EXPORTERS + "." + exporterId; //$NON-NLS-1$
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<ExporterFactory> readExporterFactories(ILaunchConfiguration configuration) throws CoreException {
+
+ List<String> exporterNames = configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List<String>)null);
+
+ if(exporterNames!=null) {
+ Map<String, ExporterDefinition> exDefinitions = ExtensionManager.findExporterDefinitionsAsMap();
+ List<ExporterFactory> factories = new ArrayList<ExporterFactory>();
+
+ for (String exporterId : exporterNames) {
+ String extensionId = configuration.getAttribute(getLaunchAttributePrefix(exporterId) + ".extension_id", (String)null); //$NON-NLS-1$
+
+ ExporterDefinition expDef = exDefinitions.get(extensionId);
+ if(expDef==null) {
+ String out = NLS.bind(HibernateConsoleMessages.ExporterAttributes_could_not_locate_exporter_for_in, extensionId, configuration.getName());
+ throw new HibernateConsoleRuntimeException(out);
+ } else {
+ ExporterFactory exporterFactory = new ExporterFactory( expDef, exporterId );
+ exporterFactory.isEnabled( configuration );
+ factories.add( exporterFactory );
+ Map<String, String> props = configuration.getAttribute( getLaunchAttributePrefix(exporterFactory.getId())
+ + ".properties", new HashMap<String, String>() ); //$NON-NLS-1$
+ 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<ExporterFactory> factories = new ArrayList<ExporterFactory>();
+
+ 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<String, String> props = configuration.getAttribute( getLaunchAttributePrefix(exporterFactory.getId())
+ + ".properties", new HashMap<String, String>() ); //$NON-NLS-1$
+ exporterFactory.setProperties( props );
+ }
+
+ return factories;
+ }
+ }
+
+ public static void saveExporterFactories(
+ ILaunchConfigurationWorkingCopy configuration,
+ List<ExporterFactory> exporterFactories, Set<ExporterFactory> enabledExporters, Set<String> deletedExporterIds) {
+
+
+ List<String> names = new ArrayList<String>();
+ for (ExporterFactory ef : exporterFactories) {
+ configuration.setAttribute(getLaunchAttributePrefix(ef.getId()) + ".extension_id", ef.getExporterDefinition().getId()); //$NON-NLS-1$
+ boolean enabled = enabledExporters.contains( ef );
+ String propertiesId = getLaunchAttributePrefix(ef.getId()) + ".properties"; //$NON-NLS-1$
+ names.add(ef.getId());
+ ef.setEnabled( configuration, enabled, false );
+
+ HashMap<String, String> map = new HashMap<String, String>(ef.getProperties());
+
+ if(map.isEmpty()) {
+ configuration.setAttribute( propertiesId, (Map<String, String>)null );
+ } else {
+ configuration.setAttribute( propertiesId, map );
+ }
+ }
+
+ deletedExporterIds.removeAll(names);
+
+ for (String deleted : deletedExporterIds) {
+ configuration.setAttribute( getLaunchAttributePrefix( deleted ), (String)null);
+ configuration.setAttribute(getLaunchAttributePrefix(deleted ) + ".extension_id", (String)null); //$NON-NLS-1$
+ configuration.setAttribute(getLaunchAttributePrefix(deleted) + ".properties", (String)null); //$NON-NLS-1$
+ }
+
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, names);
+ }
+
+ public static void oldSaveExporterFactories(
+ ILaunchConfigurationWorkingCopy configuration,
+ List<ExporterFactory> exporterFactories, List<ExporterFactory> enabledExporters) {
+
+ for (ExporterFactory ef : exporterFactories) {
+ boolean enabled = enabledExporters.contains( ef );
+ String propertiesId = ef.getId() + ".properties"; //$NON-NLS-1$
+
+ ef.setEnabled( configuration, enabled, true );
+
+ HashMap<String, String> map = new HashMap<String, String>(ef.getProperties());
+
+ if(map.isEmpty()) {
+ configuration.setAttribute( propertiesId, (Map<String, String>)null );
+ } else {
+ configuration.setAttribute( propertiesId, map );
+ }
+ }
+ }
+
+
+ private Path pathOrNull(String p) {
+ if(p==null || p.trim().length()==0) {
+ return null;
+ } else {
+ return new Path(p);
+ }
+ }
+
+ public String getOutputPath()
+ {
+ return outputPath;
+ }
+
+ public void setOutputPath(String outputPath)
+ {
+ this.outputPath = outputPath;
+ }
+
+ public String getPackageName()
+ {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName)
+ {
+ this.packageName = packageName;
+ }
+
+ public String getRevengSettings()
+ {
+ return revengSettings;
+ }
+
+ public void setRevengSettings(String revengSettings)
+ {
+ this.revengSettings = revengSettings;
+ }
+
+ public String getRevengStrategy()
+ {
+ return revengStrategy;
+ }
+
+ public void setRevengStrategy(String revengStrategy)
+ {
+ this.revengStrategy = revengStrategy;
+ }
+
+ public String getTemplatePath()
+ {
+ return templatePath;
+ }
+
+ public void setTemplatePath(String templatePath)
+ {
+ this.templatePath = templatePath;
+ }
+
+ public String getConsoleConfigurationName()
+ {
+ return consoleConfigurationName;
+ }
+
+ public void setConsoleConfigurationName(String consoleConfigurationName)
+ {
+ this.consoleConfigurationName = consoleConfigurationName;
+ }
+
+ public boolean isEJB3Enabled()
+ {
+ return enableEJB3;
+ }
+
+ public void setEnableEJB3(boolean enableEJB3)
+ {
+ this.enableEJB3 = enableEJB3;
+ }
+
+ public boolean isJDK5Enabled()
+ {
+ return enableJDK5;
+ }
+
+ public void setEnableJDK5(boolean enableJDK5)
+ {
+ this.enableJDK5 = enableJDK5;
+ }
+
+ public boolean isPreferBasicCompositeIds()
+ {
+ return preferBasicCompositeIds;
+ }
+
+ public void setPreferBasicCompositeIds(boolean preferBasicCompositeIds)
+ {
+ this.preferBasicCompositeIds = preferBasicCompositeIds;
+ }
+
+ public boolean isReverseEngineer()
+ {
+ return reverseEngineer;
+ }
+
+ public void setReverseEngineer(boolean reverseEngineer)
+ {
+ this.reverseEngineer = reverseEngineer;
+ }
+
+ public boolean isUseOwnTemplates()
+ {
+ return useOwnTemplates;
+ }
+
+ public void setUseOwnTemplates(boolean useOwnTemplates)
+ {
+ this.useOwnTemplates = useOwnTemplates;
+ }
+
+ public boolean isUseExternalProcess()
+ {
+ return useExternalProcess;
+ }
+
+ public void setUseExternalProcess(boolean useExternalProcess)
+ {
+ this.useExternalProcess = useExternalProcess;
+ }
+
+ public List<ExporterFactory> getExporterFactories() {
+ return exporterFactories;
+ }
+
+ public boolean detectManyToMany() {
+ return autoManyToManyDetection;
+ }
+
+ public boolean detectOptimisticLock() {
+ return autoVersioning;
+ }
+
+ public boolean detectOneToOne() {
+ return autoOneToOneDetection;
+ }
+
+ /**
+ * Check exporter attributes and return message with description what is wrong with attributes.
+ *
+ * @return message
+ */
+ public String checkExporterAttributes() {
+ String msg = null;
+ boolean notSelected = consoleConfigurationName == null || consoleConfigurationName.length() <= 0;
+ if (notSelected) {
+ msg = HibernateConsoleMessages.CodeGenerationSettingsTab_console_cfg_must_be_specified;
+ }
+ if (msg == null) {
+ msg = PathHelper.checkDirectory(outputPath, HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, true);
+ }
+ if (msg == null) {
+ if (reverseEngineer && packageName.length() > 0) {
+ IStatus val= JavaConventions.validatePackageName(packageName);
+ if (val.getSeverity() == IStatus.ERROR || val.getSeverity() == IStatus.WARNING) {
+ msg = val.getMessage();
+ }
+ }
+ }
+ if (msg == null) {
+ if (reverseEngineer && revengSettings.trim().length() > 0) {
+ msg = PathHelper.checkFile(revengSettings, HibernateConsoleMessages.CodeGenerationSettingsTab_reveng_xml_3, true);
+ }
+ }
+ if (msg == null) {
+ if (useOwnTemplates) {
+ msg = PathHelper.checkDirectory(templatePath, HibernateConsoleMessages.CodeGenerationSettingsTab_template_dir, true);
+ }
+ }
+ if (msg == null) {
+ if (reverseEngineer && !preferBasicCompositeIds) {
+ msg = HibernateConsoleMessages.CodeGenerationSettingsTab_script_can_not_be_generated_correctly_without;
+ }
+ }
+ return msg;
+ }
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterDefinition.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterDefinition.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterDefinition.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,181 @@
+/*
+ * 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:/*
+ * 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.jboss.tools.hibernate3_5.console;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.hibernate.annotations.common.util.ReflectHelper;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.model.impl.ExporterProperty;
+import org.hibernate.tool.hbm2x.Exporter;
+
+/**
+ * Represents what is specified in plugin.xml about possible exporters.
+ *
+ */
+public class ExporterDefinition {
+
+ private String classname;
+
+ private String description;
+
+ private String id;
+
+ private ImageDescriptor iconDescriptor;
+
+ private Map<String, ExporterProperty> properties;
+
+ private IConfigurationElement element;
+
+ public ExporterDefinition(IConfigurationElement element) {
+ init(element.getAttribute( "classname" ), //$NON-NLS-1$
+ element.getAttribute( "description" ), //$NON-NLS-1$
+ element.getAttribute( "id" ), //$NON-NLS-1$
+ createProperties( element ),
+ createIcon( element ));
+ this.element = element;
+ }
+
+ protected void init(String className, String description, String id, Map<String, ExporterProperty> properties, ImageDescriptor icon) {
+ this.classname = className;
+ this.description = description;
+ this.id = id;
+ this.properties = properties;
+ this.iconDescriptor = icon;
+ }
+
+ static private ImageDescriptor createIcon(IConfigurationElement element) {
+ if ( element.getAttribute( "icon" ) != null ) { //$NON-NLS-1$
+ return AbstractUIPlugin.imageDescriptorFromPlugin(
+ element.getNamespace(), element.getAttribute( "icon" ) ); //$NON-NLS-1$
+ } else {
+ return null;
+ }
+ }
+
+ static private Map<String, ExporterProperty> createProperties(IConfigurationElement element) {
+ Map<String, ExporterProperty> properties = new HashMap<String, ExporterProperty>();
+
+ IConfigurationElement propertyElements[] = element
+ .getChildren( "property" ); //$NON-NLS-1$
+ for (int i = 0; i < propertyElements.length; i++) {
+ ExporterProperty property = new ExporterProperty(
+ propertyElements[i].getAttribute("name"), //$NON-NLS-1$
+ propertyElements[i].getAttribute("description"), //$NON-NLS-1$
+ propertyElements[i].getAttribute("value"), //$NON-NLS-1$
+ Boolean.valueOf(propertyElements[i].getAttribute("required")).booleanValue()); //$NON-NLS-1$
+ String type = propertyElements[i].getAttribute("type"); //$NON-NLS-1$
+ if (type != null){
+ property.setType(type);
+ }
+ properties.put(property.getName(),property);
+ }
+ return properties;
+ }
+
+
+ public Exporter createExporterInstance() {
+ Exporter exporter = null;
+
+ try {
+ exporter = (Exporter) ReflectHelper.classForName( classname ).newInstance();
+ }
+ catch (InstantiationException e) {
+ throw new HibernateConsoleRuntimeException(NLS.bind(
+ HibernateConsoleMessages.ExporterDefinition_problem_creating_exporter_class, classname));
+ }
+ catch (IllegalAccessException e) {
+ throw new HibernateConsoleRuntimeException(NLS.bind(
+ HibernateConsoleMessages.ExporterDefinition_problem_creating_exporter_class, classname)); }
+ catch (ClassNotFoundException e) {
+ throw new HibernateConsoleRuntimeException(NLS.bind(
+ HibernateConsoleMessages.ExporterDefinition_problem_creating_exporter_class, classname));
+ }
+
+ return exporter;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public ImageDescriptor getIconDescriptor() {
+ return iconDescriptor;
+ }
+
+ public Map<String, ExporterProperty> getExporterProperties() {
+ return properties;
+ }
+
+ 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( id, false );
+ }
+ catch (CoreException e) {
+ // log and assume false
+ HibernateConsolePlugin.getDefault().log(e);
+ return false;
+ }
+
+ return enabled;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getExporterTag() {
+ return getId().substring(getId().lastIndexOf(".") + 1); //$NON-NLS-1$
+ }
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterFactory.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterFactory.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExporterFactory.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,363 @@
+package org.jboss.tools.hibernate3_5.console;
+
+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 java.util.Set;
+import java.util.StringTokenizer;
+
+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.eclipse.osgi.util.NLS;
+import org.hibernate.annotations.common.util.StringHelper;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.model.impl.ExporterFactoryStrings;
+import org.hibernate.eclipse.console.model.impl.ExporterProperty;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.hibernate.eclipse.launch.PathHelper;
+import org.hibernate.tool.hbm2x.ArtifactCollector;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.GenericExporter;
+import org.hibernate.tool.hbm2x.Hbm2DDLExporter;
+import org.hibernate.tool.hbm2x.QueryExporter;
+
+/**
+ * ExporterFactory is used in UI to hold additional configuration for Exporter definitions
+ * @author max
+ *
+ */
+public class ExporterFactory {
+
+ private ExporterDefinition definition;
+
+ final Map<String, String> inputProperties;
+
+ private boolean enabled = true;
+
+ private final String exporterId;
+
+ public ExporterFactory(ExporterDefinition definition, String exporterId) {
+ this.definition = definition;
+ this.exporterId = exporterId;
+ inputProperties = new HashMap<String, String>();
+ }
+
+ public Map<String, ExporterProperty> getDefaultExporterProperties() {
+ return definition.getExporterProperties();
+ }
+
+ public String setProperty(String key, String value) {
+ return inputProperties.put( key, value );
+ }
+
+ public void removeProperty(String propertyName) {
+ inputProperties.remove( propertyName );
+ }
+
+ public String getPropertyValue(String key) {
+ if(inputProperties.containsKey( key )) {
+ return inputProperties.get( key );
+ } else {
+ ExporterProperty ep = definition.getExporterProperties().get( key );
+ if(ep!=null) {
+ return ep.getDefaultValue();
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public boolean isEnabled() {
+ return enabled ;
+ }
+
+ public void setEnabled(boolean b) {
+ enabled = b;
+ }
+
+ public ExporterDefinition getExporterDefinition() {
+ return definition;
+ }
+
+ public boolean isEnabled(ILaunchConfiguration configuration) {
+ boolean enabled = false;
+
+ try {
+ if(configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List<String>)null)==null) {
+ enabled = configuration.getAttribute( getId(), false );
+ } else {
+ enabled = configuration.getAttribute(ExporterAttributes.getLaunchAttributePrefix(getId()), false);
+ }
+ } catch(CoreException ce) {
+ // ignore; assume false
+ enabled=false;
+ }
+
+ setEnabled( enabled );
+ return isEnabled();
+ }
+
+ public void setEnabled(ILaunchConfigurationWorkingCopy configuration, boolean enabled, boolean oldSettings) {
+ setEnabled( enabled );
+ if(oldSettings) {
+ configuration.setAttribute( getId(), isEnabled() );
+ } else {
+ configuration.setAttribute(ExporterAttributes.getLaunchAttributePrefix(getId()), isEnabled());
+ }
+ }
+
+ public void setEnabled(ILaunchConfigurationWorkingCopy configuration, boolean enabled) {
+
+ boolean oldSettings = true;
+ try {
+ if(configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List<String>)null)==null) {
+ oldSettings = true;
+ } else {
+ oldSettings = false;
+ }
+ } catch(CoreException ce) {
+ // ignore and assume settings are old
+ }
+
+ setEnabled(configuration, enabled, oldSettings);
+ }
+
+ public Map<String, String> getProperties() {
+ return inputProperties;
+ }
+
+ public String getId() {
+ return exporterId;
+ }
+
+ public String getExporterTag() {
+ return definition.getExporterTag();
+ }
+
+ public String getExporterDefinitionId() {
+ return definition.getId();
+ }
+
+ public void setProperties(Map<String, String> props) {
+ inputProperties.clear();
+ inputProperties.putAll( props );
+ }
+
+ public ExporterProperty getExporterProperty(String key) {
+ return definition.getExporterProperties().get( key );
+ }
+
+ public boolean hasLocalValueFor(String string) {
+ return inputProperties.containsKey( string );
+ }
+
+ /** Method that resolves an expression through eclipses built-in variable manager.
+ * @throws CoreException if expression could not be evaluated. */
+ public static String resolve(String expression) throws CoreException {
+ if (expression == null) {
+ return null;
+ }
+ IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
+ return variableManager.performStringSubstitution(expression, false);
+ }
+
+ /**
+ * ExporterFactory update a collection of output directories,
+ * true if new output directory was added into the set of outputDirs.
+ *
+ * @param defOutDir
+ * @param globalProps
+ * @param outputDirs
+ * @return true if new output directory added
+ * @throws CoreException
+ */
+ public boolean collectOutputDirectories(String defOutDir, final Properties globalProps,
+ Set<String> outputDirs) throws CoreException {
+ Properties extract = new Properties();
+ Properties props = new Properties();
+ props.putAll(globalProps);
+ props.putAll(getProperties());
+ extractExporterProperties(getExporterDefinitionId(), props, extract);
+ String outputPath = defOutDir;
+ if (extract.containsKey(ExporterFactoryStrings.OUTPUTDIR)) {
+ outputPath = extract.getProperty(ExporterFactoryStrings.OUTPUTDIR);
+ }
+ String resolvedOutputDir = resolve(outputPath);
+ String loc = PathHelper.getLocationAsStringPath(resolvedOutputDir);
+ boolean res = false;
+ if (StringHelper.isNotEmpty(loc)) { // only set if something valid found
+ res = outputDirs.add(loc);
+ }
+ return res;
+ }
+
+ /**
+ * Creates exporter with the specified settings; also resolves any relevant properties via Eclipse VariablesPlugin.
+ * @param collector
+ * @throws CoreException in case of resolve variables issues.
+ */
+ public Exporter createConfiguredExporter(Configuration cfg, String defaultOutputDirectory,
+ String customTemplatePath, Properties globalProperties, Set<String> outputDirectories, ArtifactCollector collector) throws CoreException {
+
+ Exporter exporter = getExporterDefinition().createExporterInstance();
+
+ Properties extract = new Properties();
+ Properties props = new Properties();
+ props.putAll(globalProperties);
+ props.putAll(getProperties());
+
+ exporter.setProperties(props);
+ exporter.setArtifactCollector(collector);
+
+ extractExporterProperties(getExporterDefinitionId(), props, extract);
+
+ String outputPath = defaultOutputDirectory;
+ if (extract.containsKey(ExporterFactoryStrings.OUTPUTDIR)) {
+ outputPath = extract.getProperty(ExporterFactoryStrings.OUTPUTDIR);
+ }
+
+ String resolvedOutputDir = resolve(outputPath);
+ String loc = PathHelper.getLocationAsStringPath(resolvedOutputDir);
+ if (outputPath != null && loc == null) {
+ String out = NLS.bind(HibernateConsoleMessages.ExporterFactory_output_dir_in_does_not_exist,
+ resolvedOutputDir, getExporterDefinition().getDescription());
+ throw new HibernateConsoleRuntimeException(out);
+ }
+
+ if (StringHelper.isNotEmpty(loc)) { // only set if something valid found
+ outputDirectories.add(loc);
+ exporter.setOutputDirectory(new File(loc));
+ }
+
+ exporter.setConfiguration(cfg);
+
+ List<String> templatePathList = new ArrayList<String>();
+ if (extract.containsKey(ExporterFactoryStrings.TEMPLATE_PATH)) {
+ String resolveTemplatePath = resolve(extract.getProperty(ExporterFactoryStrings.TEMPLATE_PATH));
+ StringTokenizer st = new StringTokenizer(resolveTemplatePath, ";"); //$NON-NLS-1$
+ String out = ""; //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String locationAsStringPath = PathHelper.getLocationAsStringPath(st.nextToken());
+ if (locationAsStringPath == null) {
+ out += NLS.bind(HibernateConsoleMessages.ExporterFactory_template_dir_in_does_not_exist,
+ resolveTemplatePath, getExporterDefinition().getDescription()) + '\n';
+ } else {
+ templatePathList.add(locationAsStringPath);
+ }
+ }
+ if (out.length() > 0 ){
+ out = out.substring(0, out.length() - 1);
+ throw new HibernateConsoleRuntimeException(out);
+ }
+ }
+
+ if (StringHelper.isNotEmpty(customTemplatePath)) {
+ String resolvedCustomTemplatePath = resolve(customTemplatePath);
+ StringTokenizer st = new StringTokenizer(resolvedCustomTemplatePath, ";"); //$NON-NLS-1$
+ String out = ""; //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String locationAsStringPath = PathHelper.getLocationAsStringPath(st.nextToken());
+ if (locationAsStringPath != null) {
+ templatePathList.add(locationAsStringPath);
+ } else {
+ out = NLS.bind(HibernateConsoleMessages.ExporterFactory_template_dir_in_does_not_exist,
+ resolvedCustomTemplatePath, getExporterDefinition().getDescription());
+ }
+ }
+ if (!("".equals(out))) { //$NON-NLS-1$
+ out = out.substring(0, out.length() - 1);
+ throw new HibernateConsoleRuntimeException(out);
+ }
+ }
+ exporter.setTemplatePath(templatePathList.toArray(new String[templatePathList.size()]));
+ // special handling for GenericExporter (TODO: be delegated via plugin.xml)
+ if (getExporterDefinitionId().equals("org.hibernate.tools.hbmtemplate")) { //$NON-NLS-1$
+ GenericExporter ge = (GenericExporter) exporter;
+ ge.setFilePattern(extract.getProperty(ExporterFactoryStrings.FILE_PATTERN));
+ ge.setTemplateName(extract.getProperty(ExporterFactoryStrings.TEMPLATE_NAME));
+ ge.setForEach(extract.getProperty(ExporterFactoryStrings.FOR_EACH));
+ }
+ // special handling for Hbm2DDLExporter
+ if (getExporterDefinitionId().equals("org.hibernate.tools.hbm2ddl")) { //$NON-NLS-1$
+ Hbm2DDLExporter ddlExporter = (Hbm2DDLExporter) exporter;
+ //avoid users to delete their databases with a single click
+ ddlExporter.setExport(Boolean.parseBoolean(extract.getProperty(ExporterFactoryStrings.EXPORTTODATABASE)));
+ }
+ // special handling for QueryExporter
+ if (getExporterDefinitionId().equals("org.hibernate.tools.query")) { //$NON-NLS-1$
+ QueryExporter queryExporter = (QueryExporter) exporter;
+ List<String> queryStrings = new ArrayList<String>();
+ queryStrings.add(extract.getProperty(ExporterFactoryStrings.QUERY_STRING, "")); //$NON-NLS-1$
+ queryExporter.setQueries(queryStrings);
+ queryExporter.setFilename(extract.getProperty(ExporterFactoryStrings.OUTPUTFILENAME));
+ }
+ return exporter;
+ }
+
+ /**
+ * Extract and update GUI specific exporter properties
+ *
+ * @param exporterId
+ * @param props - properties which values remain
+ * @param extract - separated updated properties
+ * @throws CoreException
+ */
+ public static void extractExporterProperties(
+ String exporterId, Properties props, Properties extract) throws CoreException {
+ if (props.containsKey(ExporterFactoryStrings.OUTPUTDIR)) {
+ extract.put(ExporterFactoryStrings.OUTPUTDIR, resolve(props.getProperty(ExporterFactoryStrings.OUTPUTDIR)));
+ // done to avoid validation check in hibernate tools templates
+ props.remove(ExporterFactoryStrings.OUTPUTDIR);
+ }
+ if (props.containsKey(ExporterFactoryStrings.TEMPLATE_PATH)) {
+ extract.put(ExporterFactoryStrings.TEMPLATE_PATH, resolve(props.getProperty(ExporterFactoryStrings.TEMPLATE_PATH)));
+ // done to avoid validation check in hibernate tools templates
+ props.remove(ExporterFactoryStrings.TEMPLATE_PATH);
+ }
+ if (exporterId.equals("org.hibernate.tools.hbmtemplate")) { //$NON-NLS-1$
+ String tmp;
+ if (props.containsKey(ExporterFactoryStrings.FILE_PATTERN)) {
+ tmp = props.getProperty(ExporterFactoryStrings.FILE_PATTERN, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.FILE_PATTERN, tmp);
+ props.remove(ExporterFactoryStrings.FILE_PATTERN);
+ }
+ if (props.containsKey(ExporterFactoryStrings.TEMPLATE_NAME)) {
+ tmp = props.getProperty(ExporterFactoryStrings.TEMPLATE_NAME, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.TEMPLATE_NAME, tmp);
+ props.remove(ExporterFactoryStrings.TEMPLATE_NAME);
+ }
+ if (props.containsKey(ExporterFactoryStrings.FOR_EACH)) {
+ tmp = props.getProperty(ExporterFactoryStrings.FOR_EACH, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.FOR_EACH, tmp);
+ props.remove(ExporterFactoryStrings.FOR_EACH);
+ }
+ }
+ // special handling for Hbm2DDLExporter
+ if (exporterId.equals("org.hibernate.tools.hbm2ddl")) { //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.EXPORTTODATABASE, props.getProperty(ExporterFactoryStrings.EXPORTTODATABASE, Boolean.toString(false)));
+ props.remove(ExporterFactoryStrings.EXPORTTODATABASE);
+ }
+ // special handling for QueryExporter
+ if (exporterId.equals("org.hibernate.tools.query")) { //$NON-NLS-1$
+ String tmp;
+ if (props.containsKey(ExporterFactoryStrings.QUERY_STRING)) {
+ tmp = props.getProperty(ExporterFactoryStrings.QUERY_STRING, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.QUERY_STRING, tmp);
+ props.remove(ExporterFactoryStrings.QUERY_STRING);
+ }
+ if (props.containsKey(ExporterFactoryStrings.OUTPUTFILENAME)) {
+ tmp = props.getProperty(ExporterFactoryStrings.OUTPUTFILENAME, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.OUTPUTFILENAME, tmp);
+ props.remove(ExporterFactoryStrings.OUTPUTFILENAME);
+ }
+ }
+ }
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExtensionManager.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExtensionManager.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ExtensionManager.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,97 @@
+/*
+ * 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:/*
+ * 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.jboss.tools.hibernate3_5.console;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+public class ExtensionManager
+{
+ public static final String EXPORTERS_EXTENSION_ID = "org.hibernate.eclipse.console.exporters"; //$NON-NLS-1$
+
+ private static IExtension[] findExtensions (String extensionId)
+ {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(extensionId);
+ return extensionPoint.getExtensions();
+ }
+
+ public static ExporterDefinition[] findExporterDefinitions ()
+ {
+ List<ExporterDefinition> exporters = new ArrayList<ExporterDefinition>();
+
+ IExtension[] extensions = findExtensions(EXPORTERS_EXTENSION_ID);
+ for (int i = 0; i < extensions.length; i++)
+ {
+ IConfigurationElement elements[] = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++)
+ {
+ ExporterDefinition exporter = new ExporterDefinition(elements[j]);
+ exporters.add(exporter);
+ }
+ }
+
+ return exporters.toArray(new ExporterDefinition[exporters.size()]);
+ }
+
+ /**
+ * return map of ExporterDefinitions keyed by id
+ */
+ public static Map<String, ExporterDefinition> findExporterDefinitionsAsMap() {
+ Map<String, ExporterDefinition> result = new HashMap<String, ExporterDefinition>();
+
+ ExporterDefinition[] findExporterDefinitions = findExporterDefinitions();
+ for (int i = 0; i < findExporterDefinitions.length; i++) {
+ ExporterDefinition exporterDefinition = findExporterDefinitions[i];
+ result.put(exporterDefinition.getId(), exporterDefinition);
+ }
+
+ return result;
+ }
+}
Modified: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/META-INF/MANIFEST.MF
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/META-INF/MANIFEST.MF 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/META-INF/MANIFEST.MF 2011-11-11 12:44:47 UTC (rev 36298)
@@ -10,7 +10,10 @@
org.hibernate.eclipse;bundle-version="3.4.0",
org.eclipse.datatools.connectivity;bundle-version="1.2.2",
org.hibernate.eclipse.console;bundle-version="3.4.0",
- org.eclipse.jface.text;bundle-version="3.7.0"
+ org.eclipse.jface.text;bundle-version="3.7.0",
+ org.eclipse.debug.core;bundle-version="3.7.0",
+ org.eclipse.core.variables;bundle-version="3.2.500",
+ org.eclipse.jdt.core;bundle-version="3.7.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: lib/required/jboss-logging-3.0.0.GA.jar,
Modified: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/plugin.xml
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/plugin.xml 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/plugin.xml 2011-11-11 12:44:47 UTC (rev 36298)
@@ -11,7 +11,7 @@
<extension
point="org.hibernate.eclipse.console.consoleextension">
<consoleextension
- classname="org.jboss.tools.hibernate4_0.ConsoleExtension4_0"
+ classname="org.jboss.tools.hibernate4_0.console.ConsoleExtension4_0"
version="%hibernate.version">
</consoleextension>
</extension>
Deleted: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/CompletionProposal.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/CompletionProposal.java 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/CompletionProposal.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -1,279 +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.jboss.tools.hibernate4_0;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
-
-/**
- * Generic completion proposal to be used as is, or as base for other completion proposals.
- *
- * @author Max Rydahl Andersen
- *
- */
-public class CompletionProposal implements ICompletionProposal, ICompletionProposalExtension {
-
- private String displayString;
- private String replacementString;
- private int replacementOffset;
- private int documentOffset = -1;
- private int replacementLength;
- private int cursorPosition;
- private Image image;
- private IContextInformation contextInformation;
- private int contextInformationPosition;
- private char[] triggerCharacters;
- private String additionalProposalInfo;
-
- /**
- * Creates a new completion proposal. All fields are initialized based on
- * the provided information.
- *
- * @param additionalInfo additional information about the completion proposal
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset offset of the text to be replaced
- * @param documentOffset offset of the document
- * @param replacementLength length of the text to be replaced
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal If set
- * to <code>null</code>, the replacement string will be taken
- * as display string.
- */
- public CompletionProposal( String additionalInfo, String replacementString, int replacementOffset,
- int documentOffset, int replacementLength, Image image, String displayString,
- IContextInformation contextInformation ) {
-
- this.replacementString = replacementString;
- this.replacementOffset = replacementOffset;
- this.documentOffset = documentOffset;
- this.replacementLength = replacementLength;
- this.image = image;
- this.displayString = displayString != null ? displayString : replacementString;
-
- this.cursorPosition = replacementString.length();
-
- this.contextInformation = contextInformation;
-
- this.triggerCharacters = null;
- this.additionalProposalInfo = additionalInfo;
- }
-
- /**
- * Creates a new completion proposal. All fields are initialized based on
- * the provided information.
- *
- * @param replacementString the actual string to be inserted into the document
- * @param replacementOffset the offset of the text to be replaced
- * @param replacementLength the length of the text to be replaced
- * @param cursorPosition the position of the cursor following the insert
- * relative to replacementOffset
- * @param image the image to display for this proposal
- * @param displayString the string to be displayed for the proposal
- * @param contentInformation the context information associated with this proposal
- * @param additionalProposalInfo the additional information associated with
- * this proposal
- */
- public CompletionProposal( String replacementString, int replacementOffset, int replacementLength,
- int cursorPosition, Image image, String displayString, IContextInformation contextInformation,
- String additionalProposalInfo ) {
-
- this.replacementString = replacementString;
- this.replacementOffset = replacementOffset;
- this.documentOffset = replacementOffset;
- this.replacementLength = replacementLength;
- this.cursorPosition = cursorPosition;
- this.image = image;
- this.displayString = displayString;
- this.contextInformation = contextInformation;
- this.additionalProposalInfo = additionalProposalInfo;
-
- }
-
- public void setContextInformation( IContextInformation contextInformation ) {
- this.contextInformation = contextInformation;
- contextInformationPosition = (contextInformation != null ? cursorPosition : -1);
- }
-
- /**
- * Sets the trigger characters.
- *
- * @param triggerCharacters The set of characters which can trigger the
- * application of this completion proposal
- */
- public void setTriggerCharacters( char[] triggerCharacters ) {
- this.triggerCharacters = triggerCharacters;
- }
-
- /**
- * Sets the cursor position relative to the insertion offset. By default
- * this is the length of the completion string (Cursor positioned after the
- * completion)
- *
- * @param cursorPosition The cursorPosition to set
- */
- public void setCursorPosition( int cursorPosition ) {
-
- if (cursorPosition >= 0) {
- this.cursorPosition = cursorPosition;
- this.contextInformationPosition = (contextInformation != null ? cursorPosition : -1);
- }
- }
-
- public void apply( IDocument document, char trigger, int offset ) {
- try {
- // patch replacement length
-
- int delta = offset - (documentOffset + replacementLength);
- if (delta > 0)
- replacementLength += delta;
-
- if (trigger == (char) 0) {
- replace( document, documentOffset, replacementLength, replacementString );
- }
- else {
- StringBuffer buffer = new StringBuffer( replacementString );
-
- if ((replacementLength < buffer.length() && buffer.charAt( replacementLength ) != trigger)) {
- buffer.insert( cursorPosition, trigger );
- ++cursorPosition;
- }
-
- replace( document, documentOffset, replacementLength, buffer.toString() );
- }
-
- int oldLen = document.getLength();
- documentOffset += document.getLength() - oldLen;
- }
- catch (BadLocationException e) {
- HibernateConsolePlugin.getDefault().log( e );
- }
- }
-
- /**
- * Replaces the document content at the specified offset and length with the
- * specified string.
- *
- * @param document the document opened in the editor
- * @param offset offset to the document content to be replaced
- * @param length length of text to be replaced
- * @param string replacement string
- * @throws BadLocationException
- */
- private void replace( IDocument document, int offset, int length, String string ) throws BadLocationException {
- if (document != null && string != null && offset >= 0 && length >= 0) {
- if (!document.get( offset, length ).equals( string ))
- document.replace( offset, length, string );
- }
- }
-
- public void apply( IDocument document ) {
- apply( document, (char) 0, documentOffset + replacementLength );
- }
-
- public Point getSelection( IDocument document ) {
- return new Point( documentOffset + cursorPosition, 0 );
- }
-
- public IContextInformation getContextInformation() {
- return contextInformation;
- }
-
- public Image getImage() {
- return image;
- }
-
- public String getDisplayString() {
- return displayString;
- }
-
- public String getAdditionalProposalInfo() {
- return additionalProposalInfo;
- }
-
- public char[] getTriggerCharacters() {
- return triggerCharacters;
- }
-
- public int getContextInformationPosition() {
- return replacementOffset + contextInformationPosition;
- }
-
- public int getReplacementOffset() {
- return replacementOffset;
- }
-
- public void setReplacementOffset( int replacementOffset ) {
-
- if (replacementOffset >= 0) {
- this.replacementOffset = replacementOffset;
- }
- }
-
- public int getReplacementLength() {
- return replacementLength;
- }
-
- public void setReplacementLength( int replacementLength ) {
-
- if (replacementLength >= 0) {
- this.replacementLength = replacementLength;
- }
- }
-
- public String getReplacementString() {
- return replacementString;
- }
-
- public void setReplacementString( String replacementString ) {
- this.replacementString = replacementString;
- }
-
- public void setImage( Image image ) {
- this.image = image;
- }
-
- public boolean isValidFor( IDocument document, int offset ) {
- if (offset < replacementOffset)
- return false;
-
- int replacementLength = replacementString == null ? 0 : replacementString.length();
- if (offset >= replacementOffset + replacementLength)
- return false;
-
- try {
- int length = offset - replacementOffset;
- String start = document.get( replacementOffset, length );
- return replacementString.substring( 0, length ).equalsIgnoreCase( start );
- }
- catch (BadLocationException x) {
- }
-
- return false;
- }
-
-}
\ No newline at end of file
Deleted: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConsoleExtension4_0.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConsoleExtension4_0.java 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConsoleExtension4_0.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate4_0;
-
-import org.hibernate.console.execution.ExecutionContext;
-import org.hibernate.console.ext.HibernateException;
-import org.hibernate.console.ext.HibernateExtension;
-import org.hibernate.eclipse.console.ext.CompletionProposalsResult;
-import org.hibernate.eclipse.console.ext.ConsoleExtension;
-import org.hibernate.tool.ide.completion.HQLCodeAssist;
-import org.hibernate.tool.ide.completion.IHQLCodeAssist;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class ConsoleExtension4_0 implements ConsoleExtension {
-
- private HibernateExtension4_0 hibernateExtension;
-
- public ConsoleExtension4_0(){}
-
- public void setHibernateException(HibernateExtension hibernateExtension){
- this.hibernateExtension = (HibernateExtension4_0) hibernateExtension;
- }
-
- @Override
- public CompletionProposalsResult hqlCodeComplete(String query, int currentOffset) {
- EclipseHQLCompletionRequestor requestor = new EclipseHQLCompletionRequestor();
- if (!hibernateExtension.hasConfiguration()){
- try {
- hibernateExtension.build();
- hibernateExtension.execute( new ExecutionContext.Command() {
- public Object execute() {
- if(hibernateExtension.hasConfiguration()) {
- hibernateExtension.getConfiguration().buildMappings();
- }
- return null;
- }
- });
- } catch (HibernateException e){
- //FIXME
- //String mess = NLS.bind(HibernateConsoleMessages.CompletionHelper_error_could_not_build_cc, consoleConfiguration.getName());
- //HibernateConsolePlugin.getDefault().logErrorMessage(mess, e);
- }
- }
- IHQLCodeAssist hqlEval = new HQLCodeAssist(hibernateExtension.getConfiguration());
- query = query.replace('\t', ' ');
- hqlEval.codeComplete(query, currentOffset, requestor);
- return new CompletionProposalsResult(requestor.getCompletionProposals(), requestor.getLastErrorMessage());
- }
-
-
-
-}
Deleted: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/EclipseHQLCompletionRequestor.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/EclipseHQLCompletionRequestor.java 2011-11-11 12:13:18 UTC (rev 36297)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/EclipseHQLCompletionRequestor.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -1,151 +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.jboss.tools.hibernate4_0;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.swt.graphics.Image;
-import org.hibernate.console.ImageConstants;
-import org.hibernate.eclipse.console.utils.EclipseImages;
-import org.hibernate.eclipse.console.workbench.HibernateWorkbenchHelper;
-import org.hibernate.internal.util.StringHelper;
-import org.hibernate.tool.ide.completion.HQLCompletionProposal;
-import org.hibernate.tool.ide.completion.IHQLCompletionRequestor;
-
-public class EclipseHQLCompletionRequestor implements IHQLCompletionRequestor {
-
- private final List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
- private String lastErrorMessage;
- private final int virtualOffset;
-
- public EclipseHQLCompletionRequestor() {
- virtualOffset = 0;
- }
-
- public EclipseHQLCompletionRequestor(int virtualOffset) {
- this.virtualOffset = virtualOffset;
- }
-
- public List<ICompletionProposal> getCompletionProposals() {
- return result;
- }
-
- public boolean accept(HQLCompletionProposal proposal) {
- result.add(new CompletionProposal(proposal.getCompletion(), // replacementString
- proposal.getReplaceStart()+virtualOffset, // replacementOffset
- proposal.getReplaceEnd()-proposal.getReplaceStart(), // replacementLength
- proposal.getCompletion().length(), // cursorPosition (relativeTo replacementStart)
- getImage(proposal),
- getDisplayString(proposal),
- null,
- null));
- return true;
- }
-
- private String getDisplayString(HQLCompletionProposal proposal) {
- StringBuffer buf = new StringBuffer(proposal.getSimpleName());
-
- switch(proposal.getCompletionKind()) {
- case HQLCompletionProposal.ENTITY_NAME:
- if(proposal.getEntityName()!=null &&
- !(proposal.getSimpleName().equals( proposal.getEntityName()))) {
- buf.append(" - "); //$NON-NLS-1$
- buf.append(StringHelper.qualifier( proposal.getEntityName() ));
- } else if(proposal.getShortEntityName()!=null &&
- !(proposal.getSimpleName().equals( proposal.getEntityName()))) {
- buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
- }
- break;
- case HQLCompletionProposal.ALIAS_REF:
- if(proposal.getShortEntityName()!=null) {
- buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
- } else if(proposal.getEntityName()!=null) {
- buf.append( " - " + proposal.getEntityName() ); //$NON-NLS-1$
- }
- break;
- case HQLCompletionProposal.PROPERTY:
- if(proposal.getShortEntityName()!=null) {
- buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
- } else if(proposal.getEntityName()!=null) {
- if(proposal.getEntityName().indexOf( "." )>=0) { //$NON-NLS-1$
- buf.append( " - " + StringHelper.unqualify( proposal.getEntityName() )); //$NON-NLS-1$
- } else {
- buf.append( " - " + proposal.getEntityName() ); //$NON-NLS-1$
- }
- }
- break;
- case HQLCompletionProposal.KEYWORD:
- break;
- case HQLCompletionProposal.FUNCTION:
- break;
- default:
-
- }
-
-
- return buf.toString();
- }
-
- private Image getImage(HQLCompletionProposal proposal) {
- String key = null;
-
- switch(proposal.getCompletionKind()) {
- case HQLCompletionProposal.ENTITY_NAME:
- case HQLCompletionProposal.ALIAS_REF:
- key = ImageConstants.MAPPEDCLASS;
- break;
- case HQLCompletionProposal.PROPERTY:
- if(proposal.getProperty()!=null) {
- return HibernateWorkbenchHelper.getImage( proposal.getProperty() );
- } else {
- key = ImageConstants.PROPERTY;
- }
- break;
- case HQLCompletionProposal.KEYWORD:
- key = null;
- break;
- case HQLCompletionProposal.FUNCTION:
- key = ImageConstants.FUNCTION;
- break;
- default:
- key = null;
- }
-
- return key==null?null:EclipseImages.getImage( key );
- }
-
- public void completionFailure(String errorMessage) {
- lastErrorMessage = errorMessage;
- }
-
- public String getLastErrorMessage() {
- return lastErrorMessage;
- }
-
- public void clear() {
- result.clear();
- lastErrorMessage = null;
- }
-
-}
Copied: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/CompletionProposal.java (from rev 36159, branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/CompletionProposal.java)
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/CompletionProposal.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/CompletionProposal.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,279 @@
+/*
+ * 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.jboss.tools.hibernate4_0.console;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+
+/**
+ * Generic completion proposal to be used as is, or as base for other completion proposals.
+ *
+ * @author Max Rydahl Andersen
+ *
+ */
+public class CompletionProposal implements ICompletionProposal, ICompletionProposalExtension {
+
+ private String displayString;
+ private String replacementString;
+ private int replacementOffset;
+ private int documentOffset = -1;
+ private int replacementLength;
+ private int cursorPosition;
+ private Image image;
+ private IContextInformation contextInformation;
+ private int contextInformationPosition;
+ private char[] triggerCharacters;
+ private String additionalProposalInfo;
+
+ /**
+ * Creates a new completion proposal. All fields are initialized based on
+ * the provided information.
+ *
+ * @param additionalInfo additional information about the completion proposal
+ * @param replacementString the actual string to be inserted into the document
+ * @param replacementOffset offset of the text to be replaced
+ * @param documentOffset offset of the document
+ * @param replacementLength length of the text to be replaced
+ * @param image the image to display for this proposal
+ * @param displayString the string to be displayed for the proposal If set
+ * to <code>null</code>, the replacement string will be taken
+ * as display string.
+ */
+ public CompletionProposal( String additionalInfo, String replacementString, int replacementOffset,
+ int documentOffset, int replacementLength, Image image, String displayString,
+ IContextInformation contextInformation ) {
+
+ this.replacementString = replacementString;
+ this.replacementOffset = replacementOffset;
+ this.documentOffset = documentOffset;
+ this.replacementLength = replacementLength;
+ this.image = image;
+ this.displayString = displayString != null ? displayString : replacementString;
+
+ this.cursorPosition = replacementString.length();
+
+ this.contextInformation = contextInformation;
+
+ this.triggerCharacters = null;
+ this.additionalProposalInfo = additionalInfo;
+ }
+
+ /**
+ * Creates a new completion proposal. All fields are initialized based on
+ * the provided information.
+ *
+ * @param replacementString the actual string to be inserted into the document
+ * @param replacementOffset the offset of the text to be replaced
+ * @param replacementLength the length of the text to be replaced
+ * @param cursorPosition the position of the cursor following the insert
+ * relative to replacementOffset
+ * @param image the image to display for this proposal
+ * @param displayString the string to be displayed for the proposal
+ * @param contentInformation the context information associated with this proposal
+ * @param additionalProposalInfo the additional information associated with
+ * this proposal
+ */
+ public CompletionProposal( String replacementString, int replacementOffset, int replacementLength,
+ int cursorPosition, Image image, String displayString, IContextInformation contextInformation,
+ String additionalProposalInfo ) {
+
+ this.replacementString = replacementString;
+ this.replacementOffset = replacementOffset;
+ this.documentOffset = replacementOffset;
+ this.replacementLength = replacementLength;
+ this.cursorPosition = cursorPosition;
+ this.image = image;
+ this.displayString = displayString;
+ this.contextInformation = contextInformation;
+ this.additionalProposalInfo = additionalProposalInfo;
+
+ }
+
+ public void setContextInformation( IContextInformation contextInformation ) {
+ this.contextInformation = contextInformation;
+ contextInformationPosition = (contextInformation != null ? cursorPosition : -1);
+ }
+
+ /**
+ * Sets the trigger characters.
+ *
+ * @param triggerCharacters The set of characters which can trigger the
+ * application of this completion proposal
+ */
+ public void setTriggerCharacters( char[] triggerCharacters ) {
+ this.triggerCharacters = triggerCharacters;
+ }
+
+ /**
+ * Sets the cursor position relative to the insertion offset. By default
+ * this is the length of the completion string (Cursor positioned after the
+ * completion)
+ *
+ * @param cursorPosition The cursorPosition to set
+ */
+ public void setCursorPosition( int cursorPosition ) {
+
+ if (cursorPosition >= 0) {
+ this.cursorPosition = cursorPosition;
+ this.contextInformationPosition = (contextInformation != null ? cursorPosition : -1);
+ }
+ }
+
+ public void apply( IDocument document, char trigger, int offset ) {
+ try {
+ // patch replacement length
+
+ int delta = offset - (documentOffset + replacementLength);
+ if (delta > 0)
+ replacementLength += delta;
+
+ if (trigger == (char) 0) {
+ replace( document, documentOffset, replacementLength, replacementString );
+ }
+ else {
+ StringBuffer buffer = new StringBuffer( replacementString );
+
+ if ((replacementLength < buffer.length() && buffer.charAt( replacementLength ) != trigger)) {
+ buffer.insert( cursorPosition, trigger );
+ ++cursorPosition;
+ }
+
+ replace( document, documentOffset, replacementLength, buffer.toString() );
+ }
+
+ int oldLen = document.getLength();
+ documentOffset += document.getLength() - oldLen;
+ }
+ catch (BadLocationException e) {
+ HibernateConsolePlugin.getDefault().log( e );
+ }
+ }
+
+ /**
+ * Replaces the document content at the specified offset and length with the
+ * specified string.
+ *
+ * @param document the document opened in the editor
+ * @param offset offset to the document content to be replaced
+ * @param length length of text to be replaced
+ * @param string replacement string
+ * @throws BadLocationException
+ */
+ private void replace( IDocument document, int offset, int length, String string ) throws BadLocationException {
+ if (document != null && string != null && offset >= 0 && length >= 0) {
+ if (!document.get( offset, length ).equals( string ))
+ document.replace( offset, length, string );
+ }
+ }
+
+ public void apply( IDocument document ) {
+ apply( document, (char) 0, documentOffset + replacementLength );
+ }
+
+ public Point getSelection( IDocument document ) {
+ return new Point( documentOffset + cursorPosition, 0 );
+ }
+
+ public IContextInformation getContextInformation() {
+ return contextInformation;
+ }
+
+ public Image getImage() {
+ return image;
+ }
+
+ public String getDisplayString() {
+ return displayString;
+ }
+
+ public String getAdditionalProposalInfo() {
+ return additionalProposalInfo;
+ }
+
+ public char[] getTriggerCharacters() {
+ return triggerCharacters;
+ }
+
+ public int getContextInformationPosition() {
+ return replacementOffset + contextInformationPosition;
+ }
+
+ public int getReplacementOffset() {
+ return replacementOffset;
+ }
+
+ public void setReplacementOffset( int replacementOffset ) {
+
+ if (replacementOffset >= 0) {
+ this.replacementOffset = replacementOffset;
+ }
+ }
+
+ public int getReplacementLength() {
+ return replacementLength;
+ }
+
+ public void setReplacementLength( int replacementLength ) {
+
+ if (replacementLength >= 0) {
+ this.replacementLength = replacementLength;
+ }
+ }
+
+ public String getReplacementString() {
+ return replacementString;
+ }
+
+ public void setReplacementString( String replacementString ) {
+ this.replacementString = replacementString;
+ }
+
+ public void setImage( Image image ) {
+ this.image = image;
+ }
+
+ public boolean isValidFor( IDocument document, int offset ) {
+ if (offset < replacementOffset)
+ return false;
+
+ int replacementLength = replacementString == null ? 0 : replacementString.length();
+ if (offset >= replacementOffset + replacementLength)
+ return false;
+
+ try {
+ int length = offset - replacementOffset;
+ String start = document.get( replacementOffset, length );
+ return replacementString.substring( 0, length ).equalsIgnoreCase( start );
+ }
+ catch (BadLocationException x) {
+ }
+
+ return false;
+ }
+
+}
\ No newline at end of file
Copied: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ConsoleExtension4_0.java (from rev 36275, branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/ConsoleExtension4_0.java)
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ConsoleExtension4_0.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ConsoleExtension4_0.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,303 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate4_0.console;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.annotations.common.util.ReflectHelper;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.JDBCMetaDataConfiguration;
+import org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy;
+import org.hibernate.cfg.reveng.OverrideRepository;
+import org.hibernate.cfg.reveng.ReverseEngineeringSettings;
+import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.console.execution.ExecutionContext;
+import org.hibernate.console.execution.ExecutionContext.Command;
+import org.hibernate.console.ext.HibernateException;
+import org.hibernate.console.ext.HibernateExtension;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.ext.CompletionProposalsResult;
+import org.hibernate.eclipse.console.ext.ConsoleExtension;
+import org.hibernate.eclipse.launch.CodeGenerationStrings;
+import org.hibernate.eclipse.launch.CodeGenerationUtils;
+import org.hibernate.eclipse.launch.PathHelper;
+import org.hibernate.tool.hbm2x.ArtifactCollector;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.ide.completion.HQLCodeAssist;
+import org.hibernate.tool.ide.completion.IHQLCodeAssist;
+import org.jboss.tools.hibernate4_0.HibernateExtension4_0;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ConsoleExtension4_0 implements ConsoleExtension {
+
+ private HibernateExtension4_0 hibernateExtension;
+
+ public ConsoleExtension4_0(){}
+
+ public void setHibernateException(HibernateExtension hibernateExtension){
+ this.hibernateExtension = (HibernateExtension4_0) hibernateExtension;
+ }
+
+ @Override
+ public CompletionProposalsResult hqlCodeComplete(String query, int currentOffset) {
+ EclipseHQLCompletionRequestor requestor = new EclipseHQLCompletionRequestor();
+ if (!hibernateExtension.hasConfiguration()){
+ try {
+ hibernateExtension.build();
+ hibernateExtension.execute( new ExecutionContext.Command() {
+ public Object execute() {
+ if(hibernateExtension.hasConfiguration()) {
+ hibernateExtension.getConfiguration().buildMappings();
+ }
+ return null;
+ }
+ });
+ } catch (HibernateException e){
+ //FIXME
+ //String mess = NLS.bind(HibernateConsoleMessages.CompletionHelper_error_could_not_build_cc, consoleConfiguration.getName());
+ //HibernateConsolePlugin.getDefault().logErrorMessage(mess, e);
+ }
+ }
+ IHQLCodeAssist hqlEval = new HQLCodeAssist(hibernateExtension.getConfiguration());
+ query = query.replace('\t', ' ');
+ hqlEval.codeComplete(query, currentOffset, requestor);
+ return new CompletionProposalsResult(requestor.getCompletionProposals(), requestor.getLastErrorMessage());
+ }
+
+ /* (non-Javadoc)
+ * @see org.hibernate.eclipse.console.ext.ConsoleExtension#launchExporters(org.hibernate.eclipse.console.ext.ILaunchConfiguration, java.lang.String, org.hibernate.eclipse.console.ext.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void launchExporters(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+ Assert.isNotNull(configuration);
+ Assert.isNotNull(monitor);
+ ExporterAttributes attributes = new ExporterAttributes(configuration);
+ List<ExporterFactory> exporterFactories = attributes.getExporterFactories();
+ for (Iterator<ExporterFactory> iter = exporterFactories.iterator(); iter.hasNext();) {
+ ExporterFactory exFactory = iter.next();
+ if (!exFactory.isEnabled(configuration)) {
+ iter.remove();
+ }
+ }
+
+ try {
+ Set<String> outputDirectories = new HashSet<String>();
+ ExporterFactory[] exporters = exporterFactories.toArray( new ExporterFactory[exporterFactories.size()] );
+ ArtifactCollector collector = runExporters(attributes, exporters, outputDirectories, monitor);
+
+ for (String path : outputDirectories) {
+ CodeGenerationUtils.refreshOutputDir(path);
+ }
+
+ //RefreshTab.refreshResources(configuration, monitor);
+
+ // code formatting needs to happen *after* refresh to make sure eclipse will format the uptodate files!
+ if(collector!=null) {
+ //formatGeneratedCode( monitor, collector );
+ }
+
+
+ } catch(Exception e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
+ } catch(NoClassDefFoundError e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_received_noclassdeffounderror,e), 666));
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private ArtifactCollector runExporters (final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final IProgressMonitor monitor)
+ throws CoreException
+ {
+
+ monitor.beginTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_generating_code_for + attributes.getConsoleConfigurationName(), exporterFactories.length + 1);
+
+ if (monitor.isCanceled())
+ return null;
+
+ ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
+ if (attributes.isReverseEngineer()) {
+ monitor.subTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_reading_jdbc_metadata);
+ }
+ final Configuration cfg = buildConfiguration(attributes, cc, ResourcesPlugin.getWorkspace().getRoot());
+
+ monitor.worked(1);
+
+ if (monitor.isCanceled())
+ return null;
+
+ return (ArtifactCollector) cc.execute(new Command() {
+
+ public Object execute() {
+ ArtifactCollector artifactCollector = new ArtifactCollector();
+
+ // Global properties
+ Properties props = new Properties();
+ props.put(CodeGenerationStrings.EJB3, "" + attributes.isEJB3Enabled()); //$NON-NLS-1$
+ props.put(CodeGenerationStrings.JDK5, "" + attributes.isJDK5Enabled()); //$NON-NLS-1$
+
+ for (int i = 0; i < exporterFactories.length; i++)
+ {
+ monitor.subTask(exporterFactories[i].getExporterDefinition().getDescription());
+
+ Properties globalProperties = new Properties();
+ globalProperties.putAll(props);
+
+ Exporter exporter;
+ try {
+ //FIXME - the exporters are not the same here!
+ //may be need to create it using the data from exporter definition???
+ exporter = exporterFactories[i].createConfiguredExporter(cfg, attributes.getOutputPath(), attributes.getTemplatePath(), globalProperties, outputDirectories, artifactCollector);
+ } catch (CoreException e) {
+ throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_setting_up + exporterFactories[i].getExporterDefinition(), e);
+ }
+
+ try {
+ exporter.start();
+ } catch(HibernateException he) {
+ throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_running + exporterFactories[i].getExporterDefinition().getDescription(), he);
+ }
+ monitor.worked(1);
+ }
+ return artifactCollector;
+ }
+
+ });
+
+
+ }
+
+
+ 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 = PathHelper.findMember( root, attributes.getRevengSettings());
+
+ if(reveng) {
+ Configuration configuration = null;
+ if(cc.hasConfiguration()) {
+ configuration = cc.getConfiguration();
+ } else {
+ configuration = cc.buildWith( null, false );
+ }
+
+ final JDBCMetaDataConfiguration cfg = new JDBCMetaDataConfiguration();
+ Properties properties = configuration.getProperties();
+ cfg.setProperties( properties );
+ cc.buildWith(cfg,false);
+
+ cfg.setPreferBasicCompositeIds(preferBasicCompositeids);
+
+ cc.execute(new Command() { // need to execute in the consoleconfiguration to let it handle classpath stuff!
+
+ public Object execute() {
+ //todo: factor this setup of revengstrategy to core
+ ReverseEngineeringStrategy res = new DefaultReverseEngineeringStrategy();
+
+ OverrideRepository repository = null;
+
+ if(revengres!=null) {
+ File file = PathHelper.getLocation( revengres ).toFile();
+ repository = new OverrideRepository();
+ repository.addFile(file);
+ }
+
+ if (repository != null){
+ res = repository.getReverseEngineeringStrategy(res);
+ }
+
+ if(reverseEngineeringStrategy!=null && reverseEngineeringStrategy.trim().length()>0) {
+ res = loadreverseEngineeringStrategy(reverseEngineeringStrategy, res);
+ }
+
+ ReverseEngineeringSettings qqsettings = new ReverseEngineeringSettings(res)
+ .setDefaultPackageName(attributes.getPackageName())
+ .setDetectManyToMany( attributes.detectManyToMany() )
+ .setDetectOneToOne( attributes.detectOneToOne() )
+ .setDetectOptimisticLock( attributes.detectOptimisticLock() );
+
+ res.setSettings(qqsettings);
+
+ cfg.setReverseEngineeringStrategy( res );
+
+ cfg.readFromJDBC();
+ cfg.buildMappings();
+ return null;
+ }
+ });
+
+ return cfg;
+ } else {
+ cc.build();
+ final Configuration configuration = ((HibernateExtension4_0)cc.getHibernateExtension()).getConfiguration();
+
+ cc.execute(new Command() {
+ public Object execute() {
+
+ configuration.buildMappings();
+ return configuration;
+ }
+ });
+ return configuration;
+ }
+ }
+
+ // TODO: merge with revstrategy load in JDBCConfigurationTask
+ @SuppressWarnings("unchecked")
+ private ReverseEngineeringStrategy loadreverseEngineeringStrategy(final String className, ReverseEngineeringStrategy delegate) {
+ try {
+ Class<ReverseEngineeringStrategy> clazz = ReflectHelper.classForName(className);
+ Constructor<ReverseEngineeringStrategy> constructor = clazz.getConstructor(new Class[] { ReverseEngineeringStrategy.class });
+ return constructor.newInstance(new Object[] { delegate });
+ }
+ catch (NoSuchMethodException e) {
+ try {
+ Class<?> clazz = ReflectHelper.classForName(className);
+ ReverseEngineeringStrategy rev = (ReverseEngineeringStrategy) clazz.newInstance();
+ return rev;
+ }
+ catch (Exception eq) {
+ String out = NLS.bind(HibernateConsoleMessages.CodeGenerationLaunchDelegate_could_not_create_or_find_with_default_noarg_constructor, className);
+ throw new HibernateConsoleRuntimeException(out, eq);
+ }
+ }
+ catch (Exception e) {
+ String out = NLS.bind(HibernateConsoleMessages.CodeGenerationLaunchDelegate_could_not_create_or_find_with_one_argument_delegate_constructor, className);
+ throw new HibernateConsoleRuntimeException(out, e);
+ }
+ }
+
+}
Copied: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/EclipseHQLCompletionRequestor.java (from rev 36159, branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/EclipseHQLCompletionRequestor.java)
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/EclipseHQLCompletionRequestor.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/EclipseHQLCompletionRequestor.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,151 @@
+/*
+ * 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.jboss.tools.hibernate4_0.console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.console.workbench.HibernateWorkbenchHelper;
+import org.hibernate.internal.util.StringHelper;
+import org.hibernate.tool.ide.completion.HQLCompletionProposal;
+import org.hibernate.tool.ide.completion.IHQLCompletionRequestor;
+
+public class EclipseHQLCompletionRequestor implements IHQLCompletionRequestor {
+
+ private final List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
+ private String lastErrorMessage;
+ private final int virtualOffset;
+
+ public EclipseHQLCompletionRequestor() {
+ virtualOffset = 0;
+ }
+
+ public EclipseHQLCompletionRequestor(int virtualOffset) {
+ this.virtualOffset = virtualOffset;
+ }
+
+ public List<ICompletionProposal> getCompletionProposals() {
+ return result;
+ }
+
+ public boolean accept(HQLCompletionProposal proposal) {
+ result.add(new CompletionProposal(proposal.getCompletion(), // replacementString
+ proposal.getReplaceStart()+virtualOffset, // replacementOffset
+ proposal.getReplaceEnd()-proposal.getReplaceStart(), // replacementLength
+ proposal.getCompletion().length(), // cursorPosition (relativeTo replacementStart)
+ getImage(proposal),
+ getDisplayString(proposal),
+ null,
+ null));
+ return true;
+ }
+
+ private String getDisplayString(HQLCompletionProposal proposal) {
+ StringBuffer buf = new StringBuffer(proposal.getSimpleName());
+
+ switch(proposal.getCompletionKind()) {
+ case HQLCompletionProposal.ENTITY_NAME:
+ if(proposal.getEntityName()!=null &&
+ !(proposal.getSimpleName().equals( proposal.getEntityName()))) {
+ buf.append(" - "); //$NON-NLS-1$
+ buf.append(StringHelper.qualifier( proposal.getEntityName() ));
+ } else if(proposal.getShortEntityName()!=null &&
+ !(proposal.getSimpleName().equals( proposal.getEntityName()))) {
+ buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
+ }
+ break;
+ case HQLCompletionProposal.ALIAS_REF:
+ if(proposal.getShortEntityName()!=null) {
+ buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
+ } else if(proposal.getEntityName()!=null) {
+ buf.append( " - " + proposal.getEntityName() ); //$NON-NLS-1$
+ }
+ break;
+ case HQLCompletionProposal.PROPERTY:
+ if(proposal.getShortEntityName()!=null) {
+ buf.append( " - " + proposal.getShortEntityName() ); //$NON-NLS-1$
+ } else if(proposal.getEntityName()!=null) {
+ if(proposal.getEntityName().indexOf( "." )>=0) { //$NON-NLS-1$
+ buf.append( " - " + StringHelper.unqualify( proposal.getEntityName() )); //$NON-NLS-1$
+ } else {
+ buf.append( " - " + proposal.getEntityName() ); //$NON-NLS-1$
+ }
+ }
+ break;
+ case HQLCompletionProposal.KEYWORD:
+ break;
+ case HQLCompletionProposal.FUNCTION:
+ break;
+ default:
+
+ }
+
+
+ return buf.toString();
+ }
+
+ private Image getImage(HQLCompletionProposal proposal) {
+ String key = null;
+
+ switch(proposal.getCompletionKind()) {
+ case HQLCompletionProposal.ENTITY_NAME:
+ case HQLCompletionProposal.ALIAS_REF:
+ key = ImageConstants.MAPPEDCLASS;
+ break;
+ case HQLCompletionProposal.PROPERTY:
+ if(proposal.getProperty()!=null) {
+ return HibernateWorkbenchHelper.getImage( proposal.getProperty() );
+ } else {
+ key = ImageConstants.PROPERTY;
+ }
+ break;
+ case HQLCompletionProposal.KEYWORD:
+ key = null;
+ break;
+ case HQLCompletionProposal.FUNCTION:
+ key = ImageConstants.FUNCTION;
+ break;
+ default:
+ key = null;
+ }
+
+ return key==null?null:EclipseImages.getImage( key );
+ }
+
+ public void completionFailure(String errorMessage) {
+ lastErrorMessage = errorMessage;
+ }
+
+ public String getLastErrorMessage() {
+ return lastErrorMessage;
+ }
+
+ public void clear() {
+ result.clear();
+ lastErrorMessage = null;
+ }
+
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterAttributes.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterAttributes.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterAttributes.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,406 @@
+/*
+ * 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:/*
+ * 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.jboss.tools.hibernate4_0.console;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+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.jdt.core.JavaConventions;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.hibernate.eclipse.launch.PathHelper;
+
+// This class was created to centralize launch configuration attribute loading/saving
+// (and also to clean up CodeGenerationLaunchDelegate considerably)
+public class ExporterAttributes
+{
+ private boolean reverseEngineer, useOwnTemplates, enableJDK5, enableEJB3, preferBasicCompositeIds;
+ private boolean useExternalProcess;
+ private String consoleConfigurationName;
+ private String revengSettings;
+ private String revengStrategy;
+ private String packageName;
+ private String outputPath;
+ private String templatePath;
+ private List<ExporterFactory> exporterFactories;
+
+ private boolean autoManyToManyDetection;
+ private boolean autoOneToOneDetection;
+ private boolean autoVersioning;
+
+ public ExporterAttributes () { }
+
+ public ExporterAttributes (ILaunchConfiguration configuration)
+ throws CoreException
+ {
+ initialize(configuration);
+ }
+
+ public void initialize (ILaunchConfiguration configuration)
+ throws CoreException
+ {
+ try {
+ consoleConfigurationName = configuration.getAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,""); //$NON-NLS-1$
+ outputPath = configuration.getAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR,""); //$NON-NLS-1$
+ reverseEngineer = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, false);
+ revengSettings = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_SETTINGS, ""); //$NON-NLS-1$
+ revengStrategy = configuration.getAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER_STRATEGY, ""); //$NON-NLS-1$
+ useOwnTemplates = configuration.getAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES,false);
+ useExternalProcess = configuration.getAttribute(HibernateLaunchConstants.ATTR_USE_EXTERNAL_PROCESS, false);
+ enableJDK5 = configuration.getAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5,false);
+ enableEJB3 = configuration.getAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS,false);
+ packageName = configuration.getAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME,""); //$NON-NLS-1$
+ templatePath = configuration.getAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR,""); //$NON-NLS-1$
+ preferBasicCompositeIds = configuration.getAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, true);
+ autoManyToManyDetection = configuration.getAttribute( HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
+ autoOneToOneDetection = configuration.getAttribute( HibernateLaunchConstants.ATTR_AUTOMATIC_ONE_TO_ONE, true);
+ autoVersioning = configuration.getAttribute( HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
+
+
+ if (!useOwnTemplates) {
+ templatePath = null;
+ }
+
+ exporterFactories = readExporterFactories(configuration);
+ } catch (CoreException e) {
+ throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
+ }
+ }
+
+ public static String getLaunchAttributePrefix(String exporterId) {
+ return HibernateLaunchConstants.ATTR_EXPORTERS + "." + exporterId; //$NON-NLS-1$
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<ExporterFactory> readExporterFactories(ILaunchConfiguration configuration) throws CoreException {
+
+ List<String> exporterNames = configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List<String>)null);
+
+ if(exporterNames!=null) {
+ Map<String, ExporterDefinition> exDefinitions = ExtensionManager.findExporterDefinitionsAsMap();
+ List<ExporterFactory> factories = new ArrayList<ExporterFactory>();
+
+ for (String exporterId : exporterNames) {
+ String extensionId = configuration.getAttribute(getLaunchAttributePrefix(exporterId) + ".extension_id", (String)null); //$NON-NLS-1$
+
+ ExporterDefinition expDef = exDefinitions.get(extensionId);
+ if(expDef==null) {
+ String out = NLS.bind(HibernateConsoleMessages.ExporterAttributes_could_not_locate_exporter_for_in, extensionId, configuration.getName());
+ throw new HibernateConsoleRuntimeException(out);
+ } else {
+ ExporterFactory exporterFactory = new ExporterFactory( expDef, exporterId );
+ exporterFactory.isEnabled( configuration );
+ factories.add( exporterFactory );
+ Map<String, String> props = configuration.getAttribute( getLaunchAttributePrefix(exporterFactory.getId())
+ + ".properties", new HashMap<String, String>() ); //$NON-NLS-1$
+ 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<ExporterFactory> factories = new ArrayList<ExporterFactory>();
+
+ 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<String, String> props = configuration.getAttribute( getLaunchAttributePrefix(exporterFactory.getId())
+ + ".properties", new HashMap<String, String>() ); //$NON-NLS-1$
+ exporterFactory.setProperties( props );
+ }
+
+ return factories;
+ }
+ }
+
+ public static void saveExporterFactories(
+ ILaunchConfigurationWorkingCopy configuration,
+ List<ExporterFactory> exporterFactories, Set<ExporterFactory> enabledExporters, Set<String> deletedExporterIds) {
+
+
+ List<String> names = new ArrayList<String>();
+ for (ExporterFactory ef : exporterFactories) {
+ configuration.setAttribute(getLaunchAttributePrefix(ef.getId()) + ".extension_id", ef.getExporterDefinition().getId()); //$NON-NLS-1$
+ boolean enabled = enabledExporters.contains( ef );
+ String propertiesId = getLaunchAttributePrefix(ef.getId()) + ".properties"; //$NON-NLS-1$
+ names.add(ef.getId());
+ ef.setEnabled( configuration, enabled, false );
+
+ HashMap<String, String> map = new HashMap<String, String>(ef.getProperties());
+
+ if(map.isEmpty()) {
+ configuration.setAttribute( propertiesId, (Map<String, String>)null );
+ } else {
+ configuration.setAttribute( propertiesId, map );
+ }
+ }
+
+ deletedExporterIds.removeAll(names);
+
+ for (String deleted : deletedExporterIds) {
+ configuration.setAttribute( getLaunchAttributePrefix( deleted ), (String)null);
+ configuration.setAttribute(getLaunchAttributePrefix(deleted ) + ".extension_id", (String)null); //$NON-NLS-1$
+ configuration.setAttribute(getLaunchAttributePrefix(deleted) + ".properties", (String)null); //$NON-NLS-1$
+ }
+
+ configuration.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, names);
+ }
+
+ public static void oldSaveExporterFactories(
+ ILaunchConfigurationWorkingCopy configuration,
+ List<ExporterFactory> exporterFactories, List<ExporterFactory> enabledExporters) {
+
+ for (ExporterFactory ef : exporterFactories) {
+ boolean enabled = enabledExporters.contains( ef );
+ String propertiesId = ef.getId() + ".properties"; //$NON-NLS-1$
+
+ ef.setEnabled( configuration, enabled, true );
+
+ HashMap<String, String> map = new HashMap<String, String>(ef.getProperties());
+
+ if(map.isEmpty()) {
+ configuration.setAttribute( propertiesId, (Map<String, String>)null );
+ } else {
+ configuration.setAttribute( propertiesId, map );
+ }
+ }
+ }
+
+
+ private Path pathOrNull(String p) {
+ if(p==null || p.trim().length()==0) {
+ return null;
+ } else {
+ return new Path(p);
+ }
+ }
+
+ public String getOutputPath()
+ {
+ return outputPath;
+ }
+
+ public void setOutputPath(String outputPath)
+ {
+ this.outputPath = outputPath;
+ }
+
+ public String getPackageName()
+ {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName)
+ {
+ this.packageName = packageName;
+ }
+
+ public String getRevengSettings()
+ {
+ return revengSettings;
+ }
+
+ public void setRevengSettings(String revengSettings)
+ {
+ this.revengSettings = revengSettings;
+ }
+
+ public String getRevengStrategy()
+ {
+ return revengStrategy;
+ }
+
+ public void setRevengStrategy(String revengStrategy)
+ {
+ this.revengStrategy = revengStrategy;
+ }
+
+ public String getTemplatePath()
+ {
+ return templatePath;
+ }
+
+ public void setTemplatePath(String templatePath)
+ {
+ this.templatePath = templatePath;
+ }
+
+ public String getConsoleConfigurationName()
+ {
+ return consoleConfigurationName;
+ }
+
+ public void setConsoleConfigurationName(String consoleConfigurationName)
+ {
+ this.consoleConfigurationName = consoleConfigurationName;
+ }
+
+ public boolean isEJB3Enabled()
+ {
+ return enableEJB3;
+ }
+
+ public void setEnableEJB3(boolean enableEJB3)
+ {
+ this.enableEJB3 = enableEJB3;
+ }
+
+ public boolean isJDK5Enabled()
+ {
+ return enableJDK5;
+ }
+
+ public void setEnableJDK5(boolean enableJDK5)
+ {
+ this.enableJDK5 = enableJDK5;
+ }
+
+ public boolean isPreferBasicCompositeIds()
+ {
+ return preferBasicCompositeIds;
+ }
+
+ public void setPreferBasicCompositeIds(boolean preferBasicCompositeIds)
+ {
+ this.preferBasicCompositeIds = preferBasicCompositeIds;
+ }
+
+ public boolean isReverseEngineer()
+ {
+ return reverseEngineer;
+ }
+
+ public void setReverseEngineer(boolean reverseEngineer)
+ {
+ this.reverseEngineer = reverseEngineer;
+ }
+
+ public boolean isUseOwnTemplates()
+ {
+ return useOwnTemplates;
+ }
+
+ public void setUseOwnTemplates(boolean useOwnTemplates)
+ {
+ this.useOwnTemplates = useOwnTemplates;
+ }
+
+ public boolean isUseExternalProcess()
+ {
+ return useExternalProcess;
+ }
+
+ public void setUseExternalProcess(boolean useExternalProcess)
+ {
+ this.useExternalProcess = useExternalProcess;
+ }
+
+ public List<ExporterFactory> getExporterFactories() {
+ return exporterFactories;
+ }
+
+ public boolean detectManyToMany() {
+ return autoManyToManyDetection;
+ }
+
+ public boolean detectOptimisticLock() {
+ return autoVersioning;
+ }
+
+ public boolean detectOneToOne() {
+ return autoOneToOneDetection;
+ }
+
+ /**
+ * Check exporter attributes and return message with description what is wrong with attributes.
+ *
+ * @return message
+ */
+ public String checkExporterAttributes() {
+ String msg = null;
+ boolean notSelected = consoleConfigurationName == null || consoleConfigurationName.length() <= 0;
+ if (notSelected) {
+ msg = HibernateConsoleMessages.CodeGenerationSettingsTab_console_cfg_must_be_specified;
+ }
+ if (msg == null) {
+ msg = PathHelper.checkDirectory(outputPath, HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, true);
+ }
+ if (msg == null) {
+ if (reverseEngineer && packageName.length() > 0) {
+ IStatus val= JavaConventions.validatePackageName(packageName);
+ if (val.getSeverity() == IStatus.ERROR || val.getSeverity() == IStatus.WARNING) {
+ msg = val.getMessage();
+ }
+ }
+ }
+ if (msg == null) {
+ if (reverseEngineer && revengSettings.trim().length() > 0) {
+ msg = PathHelper.checkFile(revengSettings, HibernateConsoleMessages.CodeGenerationSettingsTab_reveng_xml_3, true);
+ }
+ }
+ if (msg == null) {
+ if (useOwnTemplates) {
+ msg = PathHelper.checkDirectory(templatePath, HibernateConsoleMessages.CodeGenerationSettingsTab_template_dir, true);
+ }
+ }
+ if (msg == null) {
+ if (reverseEngineer && !preferBasicCompositeIds) {
+ msg = HibernateConsoleMessages.CodeGenerationSettingsTab_script_can_not_be_generated_correctly_without;
+ }
+ }
+ return msg;
+ }
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterDefinition.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterDefinition.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterDefinition.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,181 @@
+/*
+ * 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:/*
+ * 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.jboss.tools.hibernate4_0.console;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.hibernate.annotations.common.util.ReflectHelper;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.model.impl.ExporterProperty;
+import org.hibernate.tool.hbm2x.Exporter;
+
+/**
+ * Represents what is specified in plugin.xml about possible exporters.
+ *
+ */
+public class ExporterDefinition {
+
+ private String classname;
+
+ private String description;
+
+ private String id;
+
+ private ImageDescriptor iconDescriptor;
+
+ private Map<String, ExporterProperty> properties;
+
+ private IConfigurationElement element;
+
+ public ExporterDefinition(IConfigurationElement element) {
+ init(element.getAttribute( "classname" ), //$NON-NLS-1$
+ element.getAttribute( "description" ), //$NON-NLS-1$
+ element.getAttribute( "id" ), //$NON-NLS-1$
+ createProperties( element ),
+ createIcon( element ));
+ this.element = element;
+ }
+
+ protected void init(String className, String description, String id, Map<String, ExporterProperty> properties, ImageDescriptor icon) {
+ this.classname = className;
+ this.description = description;
+ this.id = id;
+ this.properties = properties;
+ this.iconDescriptor = icon;
+ }
+
+ static private ImageDescriptor createIcon(IConfigurationElement element) {
+ if ( element.getAttribute( "icon" ) != null ) { //$NON-NLS-1$
+ return AbstractUIPlugin.imageDescriptorFromPlugin(
+ element.getNamespace(), element.getAttribute( "icon" ) ); //$NON-NLS-1$
+ } else {
+ return null;
+ }
+ }
+
+ static private Map<String, ExporterProperty> createProperties(IConfigurationElement element) {
+ Map<String, ExporterProperty> properties = new HashMap<String, ExporterProperty>();
+
+ IConfigurationElement propertyElements[] = element
+ .getChildren( "property" ); //$NON-NLS-1$
+ for (int i = 0; i < propertyElements.length; i++) {
+ ExporterProperty property = new ExporterProperty(
+ propertyElements[i].getAttribute("name"), //$NON-NLS-1$
+ propertyElements[i].getAttribute("description"), //$NON-NLS-1$
+ propertyElements[i].getAttribute("value"), //$NON-NLS-1$
+ Boolean.valueOf(propertyElements[i].getAttribute("required")).booleanValue()); //$NON-NLS-1$
+ String type = propertyElements[i].getAttribute("type"); //$NON-NLS-1$
+ if (type != null){
+ property.setType(type);
+ }
+ properties.put(property.getName(),property);
+ }
+ return properties;
+ }
+
+
+ public Exporter createExporterInstance() {
+ Exporter exporter = null;
+
+ try {
+ exporter = (Exporter) ReflectHelper.classForName( classname ).newInstance();
+ }
+ catch (InstantiationException e) {
+ throw new HibernateConsoleRuntimeException(NLS.bind(
+ HibernateConsoleMessages.ExporterDefinition_problem_creating_exporter_class, classname));
+ }
+ catch (IllegalAccessException e) {
+ throw new HibernateConsoleRuntimeException(NLS.bind(
+ HibernateConsoleMessages.ExporterDefinition_problem_creating_exporter_class, classname)); }
+ catch (ClassNotFoundException e) {
+ throw new HibernateConsoleRuntimeException(NLS.bind(
+ HibernateConsoleMessages.ExporterDefinition_problem_creating_exporter_class, classname));
+ }
+
+ return exporter;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public ImageDescriptor getIconDescriptor() {
+ return iconDescriptor;
+ }
+
+ public Map<String, ExporterProperty> getExporterProperties() {
+ return properties;
+ }
+
+ 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( id, false );
+ }
+ catch (CoreException e) {
+ // log and assume false
+ HibernateConsolePlugin.getDefault().log(e);
+ return false;
+ }
+
+ return enabled;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getExporterTag() {
+ return getId().substring(getId().lastIndexOf(".") + 1); //$NON-NLS-1$
+ }
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterFactory.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterFactory.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExporterFactory.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,364 @@
+package org.jboss.tools.hibernate4_0.console;
+
+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 java.util.Set;
+import java.util.StringTokenizer;
+
+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.eclipse.osgi.util.NLS;
+import org.hibernate.annotations.common.util.StringHelper;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.model.impl.ExporterFactoryStrings;
+import org.hibernate.eclipse.console.model.impl.ExporterProperty;
+import org.hibernate.eclipse.launch.ExporterAttributes;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.hibernate.eclipse.launch.PathHelper;
+import org.hibernate.tool.hbm2x.ArtifactCollector;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.GenericExporter;
+import org.hibernate.tool.hbm2x.Hbm2DDLExporter;
+import org.hibernate.tool.hbm2x.QueryExporter;
+
+/**
+ * ExporterFactory is used in UI to hold additional configuration for Exporter definitions
+ * @author max
+ *
+ */
+public class ExporterFactory {
+
+ private ExporterDefinition definition;
+
+ final Map<String, String> inputProperties;
+
+ private boolean enabled = true;
+
+ private final String exporterId;
+
+ public ExporterFactory(ExporterDefinition definition, String exporterId) {
+ this.definition = definition;
+ this.exporterId = exporterId;
+ inputProperties = new HashMap<String, String>();
+ }
+
+ public Map<String, ExporterProperty> getDefaultExporterProperties() {
+ return definition.getExporterProperties();
+ }
+
+ public String setProperty(String key, String value) {
+ return inputProperties.put( key, value );
+ }
+
+ public void removeProperty(String propertyName) {
+ inputProperties.remove( propertyName );
+ }
+
+ public String getPropertyValue(String key) {
+ if(inputProperties.containsKey( key )) {
+ return inputProperties.get( key );
+ } else {
+ ExporterProperty ep = definition.getExporterProperties().get( key );
+ if(ep!=null) {
+ return ep.getDefaultValue();
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public boolean isEnabled() {
+ return enabled ;
+ }
+
+ public void setEnabled(boolean b) {
+ enabled = b;
+ }
+
+ public ExporterDefinition getExporterDefinition() {
+ return definition;
+ }
+
+ public boolean isEnabled(ILaunchConfiguration configuration) {
+ boolean enabled = false;
+
+ try {
+ if(configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List<String>)null)==null) {
+ enabled = configuration.getAttribute( getId(), false );
+ } else {
+ enabled = configuration.getAttribute(ExporterAttributes.getLaunchAttributePrefix(getId()), false);
+ }
+ } catch(CoreException ce) {
+ // ignore; assume false
+ enabled=false;
+ }
+
+ setEnabled( enabled );
+ return isEnabled();
+ }
+
+ public void setEnabled(ILaunchConfigurationWorkingCopy configuration, boolean enabled, boolean oldSettings) {
+ setEnabled( enabled );
+ if(oldSettings) {
+ configuration.setAttribute( getId(), isEnabled() );
+ } else {
+ configuration.setAttribute(ExporterAttributes.getLaunchAttributePrefix(getId()), isEnabled());
+ }
+ }
+
+ public void setEnabled(ILaunchConfigurationWorkingCopy configuration, boolean enabled) {
+
+ boolean oldSettings = true;
+ try {
+ if(configuration.getAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, (List<String>)null)==null) {
+ oldSettings = true;
+ } else {
+ oldSettings = false;
+ }
+ } catch(CoreException ce) {
+ // ignore and assume settings are old
+ }
+
+ setEnabled(configuration, enabled, oldSettings);
+ }
+
+ public Map<String, String> getProperties() {
+ return inputProperties;
+ }
+
+ public String getId() {
+ return exporterId;
+ }
+
+ public String getExporterTag() {
+ return definition.getExporterTag();
+ }
+
+ public String getExporterDefinitionId() {
+ return definition.getId();
+ }
+
+ public void setProperties(Map<String, String> props) {
+ inputProperties.clear();
+ inputProperties.putAll( props );
+ }
+
+ public ExporterProperty getExporterProperty(String key) {
+ return definition.getExporterProperties().get( key );
+ }
+
+ public boolean hasLocalValueFor(String string) {
+ return inputProperties.containsKey( string );
+ }
+
+ /** Method that resolves an expression through eclipses built-in variable manager.
+ * @throws CoreException if expression could not be evaluated. */
+ public static String resolve(String expression) throws CoreException {
+ if (expression == null) {
+ return null;
+ }
+ IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
+ return variableManager.performStringSubstitution(expression, false);
+ }
+
+ /**
+ * ExporterFactory update a collection of output directories,
+ * true if new output directory was added into the set of outputDirs.
+ *
+ * @param defOutDir
+ * @param globalProps
+ * @param outputDirs
+ * @return true if new output directory added
+ * @throws CoreException
+ */
+ public boolean collectOutputDirectories(String defOutDir, final Properties globalProps,
+ Set<String> outputDirs) throws CoreException {
+ Properties extract = new Properties();
+ Properties props = new Properties();
+ props.putAll(globalProps);
+ props.putAll(getProperties());
+ extractExporterProperties(getExporterDefinitionId(), props, extract);
+ String outputPath = defOutDir;
+ if (extract.containsKey(ExporterFactoryStrings.OUTPUTDIR)) {
+ outputPath = extract.getProperty(ExporterFactoryStrings.OUTPUTDIR);
+ }
+ String resolvedOutputDir = resolve(outputPath);
+ String loc = PathHelper.getLocationAsStringPath(resolvedOutputDir);
+ boolean res = false;
+ if (StringHelper.isNotEmpty(loc)) { // only set if something valid found
+ res = outputDirs.add(loc);
+ }
+ return res;
+ }
+
+ /**
+ * Creates exporter with the specified settings; also resolves any relevant properties via Eclipse VariablesPlugin.
+ * @param collector
+ * @throws CoreException in case of resolve variables issues.
+ */
+ public Exporter createConfiguredExporter(Configuration cfg, String defaultOutputDirectory,
+ String customTemplatePath, Properties globalProperties, Set<String> outputDirectories, ArtifactCollector collector) throws CoreException {
+
+ Exporter exporter = getExporterDefinition().createExporterInstance();
+
+ Properties extract = new Properties();
+ Properties props = new Properties();
+ props.putAll(globalProperties);
+ props.putAll(getProperties());
+
+ exporter.setProperties(props);
+ exporter.setArtifactCollector(collector);
+
+ extractExporterProperties(getExporterDefinitionId(), props, extract);
+
+ String outputPath = defaultOutputDirectory;
+ if (extract.containsKey(ExporterFactoryStrings.OUTPUTDIR)) {
+ outputPath = extract.getProperty(ExporterFactoryStrings.OUTPUTDIR);
+ }
+
+ String resolvedOutputDir = resolve(outputPath);
+ String loc = PathHelper.getLocationAsStringPath(resolvedOutputDir);
+ if (outputPath != null && loc == null) {
+ String out = NLS.bind(HibernateConsoleMessages.ExporterFactory_output_dir_in_does_not_exist,
+ resolvedOutputDir, getExporterDefinition().getDescription());
+ throw new HibernateConsoleRuntimeException(out);
+ }
+
+ if (StringHelper.isNotEmpty(loc)) { // only set if something valid found
+ outputDirectories.add(loc);
+ exporter.setOutputDirectory(new File(loc));
+ }
+
+ exporter.setConfiguration(cfg);
+
+ List<String> templatePathList = new ArrayList<String>();
+ if (extract.containsKey(ExporterFactoryStrings.TEMPLATE_PATH)) {
+ String resolveTemplatePath = resolve(extract.getProperty(ExporterFactoryStrings.TEMPLATE_PATH));
+ StringTokenizer st = new StringTokenizer(resolveTemplatePath, ";"); //$NON-NLS-1$
+ String out = ""; //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String locationAsStringPath = PathHelper.getLocationAsStringPath(st.nextToken());
+ if (locationAsStringPath == null) {
+ out += NLS.bind(HibernateConsoleMessages.ExporterFactory_template_dir_in_does_not_exist,
+ resolveTemplatePath, getExporterDefinition().getDescription()) + '\n';
+ } else {
+ templatePathList.add(locationAsStringPath);
+ }
+ }
+ if (out.length() > 0 ){
+ out = out.substring(0, out.length() - 1);
+ throw new HibernateConsoleRuntimeException(out);
+ }
+ }
+
+ if (StringHelper.isNotEmpty(customTemplatePath)) {
+ String resolvedCustomTemplatePath = resolve(customTemplatePath);
+ StringTokenizer st = new StringTokenizer(resolvedCustomTemplatePath, ";"); //$NON-NLS-1$
+ String out = ""; //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String locationAsStringPath = PathHelper.getLocationAsStringPath(st.nextToken());
+ if (locationAsStringPath != null) {
+ templatePathList.add(locationAsStringPath);
+ } else {
+ out = NLS.bind(HibernateConsoleMessages.ExporterFactory_template_dir_in_does_not_exist,
+ resolvedCustomTemplatePath, getExporterDefinition().getDescription());
+ }
+ }
+ if (!("".equals(out))) { //$NON-NLS-1$
+ out = out.substring(0, out.length() - 1);
+ throw new HibernateConsoleRuntimeException(out);
+ }
+ }
+ exporter.setTemplatePath(templatePathList.toArray(new String[templatePathList.size()]));
+ // special handling for GenericExporter (TODO: be delegated via plugin.xml)
+ if (getExporterDefinitionId().equals("org.hibernate.tools.hbmtemplate")) { //$NON-NLS-1$
+ GenericExporter ge = (GenericExporter) exporter;
+ ge.setFilePattern(extract.getProperty(ExporterFactoryStrings.FILE_PATTERN));
+ ge.setTemplateName(extract.getProperty(ExporterFactoryStrings.TEMPLATE_NAME));
+ ge.setForEach(extract.getProperty(ExporterFactoryStrings.FOR_EACH));
+ }
+ // special handling for Hbm2DDLExporter
+ if (getExporterDefinitionId().equals("org.hibernate.tools.hbm2ddl")) { //$NON-NLS-1$
+ Hbm2DDLExporter ddlExporter = (Hbm2DDLExporter) exporter;
+ //avoid users to delete their databases with a single click
+ ddlExporter.setExport(Boolean.parseBoolean(extract.getProperty(ExporterFactoryStrings.EXPORTTODATABASE)));
+ }
+ // special handling for QueryExporter
+ if (getExporterDefinitionId().equals("org.hibernate.tools.query")) { //$NON-NLS-1$
+ QueryExporter queryExporter = (QueryExporter) exporter;
+ List<String> queryStrings = new ArrayList<String>();
+ queryStrings.add(extract.getProperty(ExporterFactoryStrings.QUERY_STRING, "")); //$NON-NLS-1$
+ queryExporter.setQueries(queryStrings);
+ queryExporter.setFilename(extract.getProperty(ExporterFactoryStrings.OUTPUTFILENAME));
+ }
+ return exporter;
+ }
+
+ /**
+ * Extract and update GUI specific exporter properties
+ *
+ * @param exporterId
+ * @param props - properties which values remain
+ * @param extract - separated updated properties
+ * @throws CoreException
+ */
+ public static void extractExporterProperties(
+ String exporterId, Properties props, Properties extract) throws CoreException {
+ if (props.containsKey(ExporterFactoryStrings.OUTPUTDIR)) {
+ extract.put(ExporterFactoryStrings.OUTPUTDIR, resolve(props.getProperty(ExporterFactoryStrings.OUTPUTDIR)));
+ // done to avoid validation check in hibernate tools templates
+ props.remove(ExporterFactoryStrings.OUTPUTDIR);
+ }
+ if (props.containsKey(ExporterFactoryStrings.TEMPLATE_PATH)) {
+ extract.put(ExporterFactoryStrings.TEMPLATE_PATH, resolve(props.getProperty(ExporterFactoryStrings.TEMPLATE_PATH)));
+ // done to avoid validation check in hibernate tools templates
+ props.remove(ExporterFactoryStrings.TEMPLATE_PATH);
+ }
+ if (exporterId.equals("org.hibernate.tools.hbmtemplate")) { //$NON-NLS-1$
+ String tmp;
+ if (props.containsKey(ExporterFactoryStrings.FILE_PATTERN)) {
+ tmp = props.getProperty(ExporterFactoryStrings.FILE_PATTERN, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.FILE_PATTERN, tmp);
+ props.remove(ExporterFactoryStrings.FILE_PATTERN);
+ }
+ if (props.containsKey(ExporterFactoryStrings.TEMPLATE_NAME)) {
+ tmp = props.getProperty(ExporterFactoryStrings.TEMPLATE_NAME, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.TEMPLATE_NAME, tmp);
+ props.remove(ExporterFactoryStrings.TEMPLATE_NAME);
+ }
+ if (props.containsKey(ExporterFactoryStrings.FOR_EACH)) {
+ tmp = props.getProperty(ExporterFactoryStrings.FOR_EACH, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.FOR_EACH, tmp);
+ props.remove(ExporterFactoryStrings.FOR_EACH);
+ }
+ }
+ // special handling for Hbm2DDLExporter
+ if (exporterId.equals("org.hibernate.tools.hbm2ddl")) { //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.EXPORTTODATABASE, props.getProperty(ExporterFactoryStrings.EXPORTTODATABASE, Boolean.toString(false)));
+ props.remove(ExporterFactoryStrings.EXPORTTODATABASE);
+ }
+ // special handling for QueryExporter
+ if (exporterId.equals("org.hibernate.tools.query")) { //$NON-NLS-1$
+ String tmp;
+ if (props.containsKey(ExporterFactoryStrings.QUERY_STRING)) {
+ tmp = props.getProperty(ExporterFactoryStrings.QUERY_STRING, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.QUERY_STRING, tmp);
+ props.remove(ExporterFactoryStrings.QUERY_STRING);
+ }
+ if (props.containsKey(ExporterFactoryStrings.OUTPUTFILENAME)) {
+ tmp = props.getProperty(ExporterFactoryStrings.OUTPUTFILENAME, ""); //$NON-NLS-1$
+ extract.put(ExporterFactoryStrings.OUTPUTFILENAME, tmp);
+ props.remove(ExporterFactoryStrings.OUTPUTFILENAME);
+ }
+ }
+ }
+}
Added: branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExtensionManager.java
===================================================================
--- branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExtensionManager.java (rev 0)
+++ branches/dead/hibernatetools-multiversion2/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ExtensionManager.java 2011-11-11 12:44:47 UTC (rev 36298)
@@ -0,0 +1,97 @@
+/*
+ * 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:/*
+ * 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.jboss.tools.hibernate4_0.console;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+public class ExtensionManager
+{
+ public static final String EXPORTERS_EXTENSION_ID = "org.hibernate.eclipse.console.exporters"; //$NON-NLS-1$
+
+ private static IExtension[] findExtensions (String extensionId)
+ {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(extensionId);
+ return extensionPoint.getExtensions();
+ }
+
+ public static ExporterDefinition[] findExporterDefinitions ()
+ {
+ List<ExporterDefinition> exporters = new ArrayList<ExporterDefinition>();
+
+ IExtension[] extensions = findExtensions(EXPORTERS_EXTENSION_ID);
+ for (int i = 0; i < extensions.length; i++)
+ {
+ IConfigurationElement elements[] = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++)
+ {
+ ExporterDefinition exporter = new ExporterDefinition(elements[j]);
+ exporters.add(exporter);
+ }
+ }
+
+ return exporters.toArray(new ExporterDefinition[exporters.size()]);
+ }
+
+ /**
+ * return map of ExporterDefinitions keyed by id
+ */
+ public static Map<String, ExporterDefinition> findExporterDefinitionsAsMap() {
+ Map<String, ExporterDefinition> result = new HashMap<String, ExporterDefinition>();
+
+ ExporterDefinition[] findExporterDefinitions = findExporterDefinitions();
+ for (int i = 0; i < findExporterDefinitions.length; i++) {
+ ExporterDefinition exporterDefinition = findExporterDefinitions[i];
+ result.put(exporterDefinition.getId(), exporterDefinition);
+ }
+
+ return result;
+ }
+}
13 years, 1 month
JBoss Tools SVN: r36297 - in trunk: openshift/plugins/org.jboss.tools.openshift.express.ui and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-11-11 07:13:18 -0500 (Fri, 11 Nov 2011)
New Revision: 36297
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenShiftRuntime.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenshiftDelegatingStartLaunchConfiguration.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenshiftLaunchTabGroup.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.properties
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressLaunchDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
Log:
JBIDE-9935 - openshift server standalone
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.properties 2011-11-11 10:34:03 UTC (rev 36296)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.properties 2011-11-11 12:13:18 UTC (rev 36297)
@@ -1,3 +1,5 @@
+Bundle-Vendor.0 = JBoss by Red Hat
+Bundle-Name.0 = JBoss AS Core Plug-in
pluginName=JBoss WTP Server Tools Core Plugin
providerName=JBoss Community
enterpriseProviderName=JBoss Enterprise Middleware
@@ -50,9 +52,6 @@
deploy.server.name=Deploy Only
deploy.server.description=A server which only provides a deploy folder for publishing.
-Bundle-Vendor.0 = JBoss by Red Hat
-Bundle-Name.0 = JBoss AS Core Plug-in
-
AllJBossRuntimeTypes=org.jboss.ide.eclipse.as.runtime.32,org.jboss.ide.eclipse.as.runtime.40,org.jboss.ide.eclipse.as.runtime.42,org.jboss.ide.eclipse.as.runtime.50,org.jboss.ide.eclipse.as.runtime.51,org.jboss.ide.eclipse.as.runtime.60,org.jboss.ide.eclipse.as.runtime.70,org.jboss.ide.eclipse.as.runtime.eap.43,org.jboss.ide.eclipse.as.runtime.eap.50,org.jboss.ide.eclipse.as.runtime.eap.60
AllJBossServerTypes=org.jboss.ide.eclipse.as.32,org.jboss.ide.eclipse.as.40,org.jboss.ide.eclipse.as.42,org.jboss.ide.eclipse.as.50,org.jboss.ide.eclipse.as.51,org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.70,org.jboss.ide.eclipse.as.eap.43,org.jboss.ide.eclipse.as.eap.50,org.jboss.ide.eclipse.as.eap.60,
AllJBTServerTypes=org.jboss.ide.eclipse.as.32,org.jboss.ide.eclipse.as.40,org.jboss.ide.eclipse.as.42,org.jboss.ide.eclipse.as.50,org.jboss.ide.eclipse.as.51,org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.70,org.jboss.ide.eclipse.as.eap.43,org.jboss.ide.eclipse.as.eap.50,org.jboss.ide.eclipse.as.eap.60,org.jboss.ide.eclipse.as.systemCopyServer
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2011-11-11 10:34:03 UTC (rev 36296)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2011-11-11 12:13:18 UTC (rev 36297)
@@ -27,7 +27,9 @@
org.eclipse.m2e.core.ui;bundle-version="1.0.100",
org.eclipse.wst.common.modulecore;bundle-version="1.2.100",
org.eclipse.team.ui;bundle-version="3.6.100",
- org.jboss.tools.openshift.egit.core;bundle-version="2.3.0"
+ org.jboss.tools.openshift.egit.core;bundle-version="2.3.0",
+ org.eclipse.jdt.launching;bundle-version="3.6.0",
+ org.eclipse.debug.ui;bundle-version="3.7.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.jboss.tools.common.databinding,
@@ -35,5 +37,5 @@
org.jboss.tools.common.ui.databinding,
org.jboss.tools.common.ui.preferencevalue,
org.jboss.tools.common.ui.ssh
-Bundle-Vendor: JBoss by Red Hat
+Bundle-Vendor: %Bundle-Vendor.0
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties 2011-11-11 12:13:18 UTC (rev 36297)
@@ -0,0 +1,8 @@
+Bundle-Vendor.0 = JBoss by Red Hat
+Bundle-Name.0 = OpenShift UI
+providerName=JBoss Community
+
+# Version Delegates
+openshift.express.name=OpenShift Express Runtime
+openshift.express.description=A server adapter for use interfacing with the OpenShift Express Framework
+openshift.express.runtime.name=OpenShift Express Runtime
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2011-11-11 10:34:03 UTC (rev 36296)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2011-11-11 12:13:18 UTC (rev 36297)
@@ -2,6 +2,11 @@
<?eclipse version="3.4"?>
<plugin>
<extension
+ point="org.jboss.ide.eclipse.as.ui.DeployMethodUI">
+ <ui deployMethodId="openshift"
+ class="org.jboss.tools.openshift.express.internal.ui.behaviour.OpenShiftDeployUI"/>
+ </extension>
+ <extension
point="org.eclipse.ui.newWizards">
<category
id="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.category"
@@ -15,22 +20,118 @@
name="OpenShift Express Application">
</wizard>
</extension>
+
<extension
+ point="org.eclipse.wst.server.ui.serverImages">
+ <image
+ icon="$nl$/icons/openshift-logo-white-icon.png"
+ typeIds="org.jboss.tools.openshift.express.openshift.server.type,org.jboss.tools.openshift.express.internal.OpenShiftRuntime"
+ id="org.jboss.ide.eclipse.as.ui.jbossIcon"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ class="org.jboss.tools.openshift.express.internal.ui.behaviour.OpenshiftLaunchTabGroup"
+ description="OpenShift Launch"
+ id="org.jboss.tools.openshift.express.internal.ui.behaviour.OpenshiftLaunchTabGroup"
+ type="org.jboss.tools.openshift.express.internal.core.behaviour.launchType"/>
+ </extension>
+
+ <!-- Core Extensions, should be moved out one day -->
+ <extension
point="org.jboss.ide.eclipse.as.core.behaviourExtension">
<behaviour
behaviourDelegate="org.jboss.tools.openshift.express.internal.core.behaviour.ExpressBehaviourDelegate"
launchDelegate="org.jboss.tools.openshift.express.internal.core.behaviour.ExpressLaunchDelegate"
name="OpenShift Express"
publishMethod="org.jboss.tools.openshift.express.internal.core.behaviour.ExpressPublishMethod"
- serverTypes="org.jboss.ide.eclipse.as.70,org.jboss.ide.eclipse.as.eap.60"
+ serverTypes="org.jboss.tools.openshift.express.openshift.server.type"
typeId="openshift">
</behaviour>
</extension>
+
<extension
- point="org.jboss.ide.eclipse.as.ui.DeployMethodUI">
- <ui
- class="org.jboss.tools.openshift.express.internal.ui.behaviour.OpenShiftDeployUI"
- deployMethodId="openshift">
- </ui>
+ point="org.eclipse.wst.server.core.serverTypes">
+ <serverType
+ behaviourClass="org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior"
+ class="org.jboss.ide.eclipse.as.core.server.internal.JBossServer"
+ name="%openshift.express.name"
+ description="%openshift.express.description"
+ hasConfiguration="false"
+ id="org.jboss.tools.openshift.express.openshift.server.type"
+ initialState="started"
+ launchConfigId="org.jboss.tools.openshift.express.internal.core.behaviour.launchType"
+ launchModes="run,debug,profile"
+ runtime="false"
+ runtimeTypeId="org.jboss.tools.openshift.express.internal.OpenShiftRuntime"
+ startBeforePublish="false"
+ startTimeout="450000"
+ stopTimeout="450000"
+ supportsRemoteHosts="true"/>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.runtimeTypes">
+ <runtimeType
+ vendor="%providerName"
+ class="org.jboss.tools.openshift.express.internal.core.behaviour.OpenShiftRuntime"
+ description="%openshift.express.runtime.name"
+ name="%openshift.express.runtime.name"
+ id="org.jboss.tools.openshift.express.internal.OpenShiftRuntime"
+ version="1.0">
+ <moduleType types="jst.appclient" versions="5.0, 6.0"/>
+ <moduleType types="wst.web" versions="1.0,1.2,1.3,1.4"/>
+ <moduleType types="jst.web" versions="2.2, 2.3, 2.4, 2.5, 3.0"/>
+ <moduleType types="jst.ejb" versions="1.0, 1.1, 2.0, 2.1, 3.0, 3.1"/>
+ <moduleType types="jst.ear" versions="1.2, 1.3, 1.4, 5.0, 6.0"/>
+ <moduleType types="jst.connector" versions="1.0, 1.5, 1.6"/>
+ <moduleType types="jst.utility" versions="1.0"/>
+ <moduleType types="jboss.package" versions="1.0"/>
+ <moduleType types="jboss.singlefile" versions="1.0"/>
+ <moduleType types="jst.jboss.esb" versions="4.2,4.3,4.4,4.5,4.6,4.7,4.9"/>
+ <moduleType types="jst.jboss.sar" versions="1.0"/>
+ <moduleType types="jbt.bpel.module" versions="1.1, 2.0"/>
+ <moduleType types="bpel.module" versions="1.1, 2.0"/>
+ <moduleType types="jboss.osgi" versions="1.0"/>
+ </runtimeType>
+ </extension>
+ <extension
+ point="org.eclipse.jst.server.core.runtimeFacetMappings">
+ <runtimeFacetMapping
+ runtimeTypeId="org.jboss.tools.openshift.express.internal.OpenShiftRuntime"
+ runtime-component="org.jboss.tools.openshift.express.internal.OpenShiftRuntime.component"
+ version="1.0"/>
+ </extension>
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <runtime-component-type id="org.jboss.tools.openshift.express.internal.OpenShiftRuntime.component"/>
+ <runtime-component-version
+ type="org.jboss.tools.openshift.express.internal.OpenShiftRuntime.component"
+ version="1.0"/>
+ <supported>
+ <runtime-component
+ id="org.jboss.tools.openshift.express.internal.OpenShiftRuntime.component"
+ version="1.0"/>
+ <facet id="wst.web" version="1.0,1.2,1.3,1.4"/>
+ <facet id="jst.web" version="2.2,2.3,2.4,2.5,3.0"/>
+ <facet id="jst.java" version="5.0,6.0,1.7"/>
+ <facet id="jst.utility" version="1.0"/>
+ <facet id="jst.connector" version="1.0,1.5,1.6"/>
+ <facet id="jst.ejb" version="2.0,2.1,3.0,3.1"/>
+ <facet id="jst.ear" version="1.2,1.3,1.4,5.0,6.0"/>
+ <facet id="jst.appclient" version="1.2,1.3,1.4,5.0,6.0"/>
+ <facet id="jst.webfragment" version="3.0"/>
+ </supported>
</extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ category="JBoss"
+ delegate="org.jboss.tools.openshift.express.internal.core.behaviour.OpenshiftDelegatingStartLaunchConfiguration"
+ id="org.jboss.tools.openshift.express.internal.core.behaviour.launchType"
+ modes="run,debug,profile"
+ name="JBoss OpenShift Server Startup Configuration"
+ public="true"
+ sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"
+ sourcePathComputerId="org.eclipse.jst.server.generic.core.sourcePathComputer"/>
+ </extension>
</plugin>
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java 2011-11-11 10:34:03 UTC (rev 36296)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java 2011-11-11 12:13:18 UTC (rev 36297)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
package org.jboss.tools.openshift.express.internal.core.behaviour;
import org.eclipse.core.runtime.CoreException;
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressLaunchDelegate.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressLaunchDelegate.java 2011-11-11 10:34:03 UTC (rev 36296)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressLaunchDelegate.java 2011-11-11 12:13:18 UTC (rev 36297)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
package org.jboss.tools.openshift.express.internal.core.behaviour;
import org.eclipse.core.runtime.CoreException;
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2011-11-11 10:34:03 UTC (rev 36296)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2011-11-11 12:13:18 UTC (rev 36297)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
package org.jboss.tools.openshift.express.internal.core.behaviour;
import java.util.ArrayList;
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2011-11-11 10:34:03 UTC (rev 36296)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2011-11-11 12:13:18 UTC (rev 36297)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
package org.jboss.tools.openshift.express.internal.core.behaviour;
import org.eclipse.core.runtime.CoreException;
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenShiftRuntime.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenShiftRuntime.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenShiftRuntime.java 2011-11-11 12:13:18 UTC (rev 36297)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.core.behaviour;
+
+import org.eclipse.wst.server.core.model.RuntimeDelegate;
+
+public class OpenShiftRuntime extends RuntimeDelegate {
+
+ public OpenShiftRuntime() {
+ }
+}
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenshiftDelegatingStartLaunchConfiguration.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenshiftDelegatingStartLaunchConfiguration.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenshiftDelegatingStartLaunchConfiguration.java 2011-11-11 12:13:18 UTC (rev 36297)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.behaviour;
+
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration;
+
+public class OpenshiftDelegatingStartLaunchConfiguration extends
+ DelegatingStartLaunchConfiguration implements
+ ILaunchConfigurationDelegate {
+
+}
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenshiftLaunchTabGroup.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenshiftLaunchTabGroup.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenshiftLaunchTabGroup.java 2011-11-11 12:13:18 UTC (rev 36297)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.behaviour;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.SWTFactory;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+public class OpenshiftLaunchTabGroup extends
+ AbstractLaunchConfigurationTabGroup {
+
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ setTabs(createTabs2(dialog, mode));
+ }
+
+ public ILaunchConfigurationTab[] createTabs2(ILaunchConfigurationDialog dialog, String mode) {
+ return new ILaunchConfigurationTab[]{
+ new OpenshiftDefaultLaunchTab()
+ };
+ }
+
+
+ public class OpenshiftDefaultLaunchTab extends AbstractLaunchConfigurationTab {
+
+ public void createControl(Composite parent) {
+ Font font = parent.getFont();
+ Composite comp = SWTFactory.createComposite(parent, font, 1, 1, GridData.FILL_BOTH);
+ GridLayout layout = new GridLayout();
+ layout.verticalSpacing = 0;
+ comp.setLayout(layout);
+ Label l = new Label(comp, SWT.NONE);
+ l.setText("OpenShift launches are not currently supported");
+ setControl(comp);
+ }
+
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getName() {
+ return "OpenShift Launch";
+ }
+
+ }
+}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-11-11 10:34:03 UTC (rev 36296)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-11-11 12:13:18 UTC (rev 36297)
@@ -78,18 +78,12 @@
private Text gitUriValueText;
private AdapterWizardPageModel model;
- private Combo suitableRuntimesCombo;
private IServerType serverTypeToCreate;
- private IRuntime runtimeDelegate;
private Label domainValueLabel;
private Label modeValueLabel;
- private Link addRuntimeLink;
- private Label runtimeLabel;
private Button serverAdapterCheckbox;
private IObservableValue serverAdapterCheckboxObservable;
- private IObservableValue selectedRuntimeObservable;
- private IObservableList suitableRuntimesObservable;
public AdapterWizardPage(ImportProjectWizard wizard, ImportProjectWizardModel model) {
super(
@@ -128,7 +122,6 @@
gitUriValueText = new Text(cloneGroup, SWT.BORDER);
gitUriValueText.setEditable(false);
- // gitUriValueText.setBackground(cloneGroup.getBackground());
GridDataFactory
.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(gitUriValueText);
ValueBindingBuilder
@@ -289,9 +282,6 @@
}
protected void enableServerWidgets(boolean enabled) {
- suitableRuntimesCombo.setEnabled(enabled);
- runtimeLabel.setEnabled(enabled);
- addRuntimeLink.setEnabled(enabled);
domainValueLabel.setEnabled(enabled);
modeValueLabel.setEnabled(enabled);
}
@@ -313,13 +303,6 @@
}
});
- runtimeLabel = new Label(c, SWT.NONE);
- runtimeLabel.setText("Local Runtime");
-
- suitableRuntimesCombo = new Combo(c, SWT.READ_ONLY);
- addRuntimeLink = new Link(c, SWT.NONE);
- addRuntimeLink.setText("<a>" + Messages.addRuntime + "</a>");
-
Label domainLabel = new Label(c, SWT.NONE);
domainLabel.setText("Host");
domainValueLabel = new Label(c, SWT.NONE);
@@ -333,115 +316,34 @@
modeLabel.setText("Mode");
modeValueLabel = new Label(c, SWT.NONE);
- suitableRuntimesCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateSelectedRuntimeDelegate();
- }
- });
- addRuntimeLink.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- IRuntimeType type = getValidRuntimeType();
- if (type != null)
- showRuntimeWizard(type);
- }
- });
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(domainLabel);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(modeLabel);
+ GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER)
+ .grab(true, false).applyTo(domainValueLabel);
+ GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER)
+ .grab(true, false).applyTo(serverAdapterCheckbox);
+ GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER)
+ .grab(true, false).applyTo(modeValueLabel);
- GridDataFactory.fillDefaults()
- .span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(serverAdapterCheckbox);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(runtimeLabel);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(runtimeLabel);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(suitableRuntimesCombo);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(domainLabel);
- GridDataFactory.fillDefaults()
- .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(domainValueLabel);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(modeLabel);
- GridDataFactory.fillDefaults()
- .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(modeValueLabel);
-
model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
serverAdapterCheckbox.getSelection());
-
- this.selectedRuntimeObservable =
- WidgetProperties.singleSelectionIndex().observe(suitableRuntimesCombo);
- this.suitableRuntimesObservable =
- WidgetProperties.items().observe(suitableRuntimesCombo);
this.serverAdapterCheckboxObservable =
WidgetProperties.selection().observe(serverAdapterCheckbox);
SelectedRuntimeValidator selectedRuntimeValidator = new SelectedRuntimeValidator();
dbc.addValidationStatusProvider(selectedRuntimeValidator);
-
- // ControlDecorationSupport.create(selectedRuntimeValidator, SWT.TOP |
- // SWT.LEFT);
}
- private void updateSelectedRuntimeDelegate() {
- if (!(new Integer(-1).equals(selectedRuntimeObservable.getValue()))) {
- String selectedRuntimeName = (String) suitableRuntimesObservable.get((Integer) selectedRuntimeObservable
- .getValue());
- runtimeDelegate = ServerCore.findRuntime(selectedRuntimeName);
- } else {
- runtimeDelegate = null;
- }
- model.getParentModel().setProperty(AdapterWizardPageModel.RUNTIME_DELEGATE, runtimeDelegate);
- }
-
- private IRuntimeType getValidRuntimeType() {
- String cartridgeName = model.getParentModel().getApplicationCartridgeName();
- if (ICartridge.JBOSSAS_7.getName().equals(cartridgeName)) {
- return ServerCore.findRuntimeType(IJBossToolingConstants.AS_70);
- }
- return null;
- }
-
private IServerType getServerTypeToCreate() {
- String cartridgeName = model.getParentModel().getApplicationCartridgeName();
- if (ICartridge.JBOSSAS_7.getName().equals(cartridgeName)) {
- return ServerCore.findServerType(IJBossToolingConstants.SERVER_AS_70);
- }
- return null;
+ return ServerCore.findServerType("org.jboss.tools.openshift.express.openshift.server.type");
}
- private IRuntime[] getRuntimesOfType(String type) {
- ArrayList<IRuntime> validRuntimes = new ArrayList<IRuntime>();
- IRuntime[] allRuntimes = ServerCore.getRuntimes();
- for (int i = 0; i < allRuntimes.length; i++) {
- if (allRuntimes[i].getRuntimeType().getId().equals(type))
- validRuntimes.add(allRuntimes[i]);
- }
- return validRuntimes.toArray(new IRuntime[validRuntimes.size()]);
- }
-
- private void fillRuntimeCombo(IRuntime[] runtimes) {
- suitableRuntimesObservable.clear();
- String[] names = new String[runtimes.length];
- for (int i = 0; i < runtimes.length; i++) {
- names[i] = runtimes[i].getName();
- suitableRuntimesObservable.add(runtimes[i].getName());
- }
- }
-
protected void onPageActivated(DataBindingContext dbc) {
model.resetRepositoryPath();
-
serverTypeToCreate = getServerTypeToCreate();
model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
- refreshValidRuntimes();
- if (suitableRuntimesObservable.size() > 0) {
- selectedRuntimeObservable.setValue(0);
- updateSelectedRuntimeDelegate();
- }
-
- IRuntimeType type = getValidRuntimeType();
- addRuntimeLink.setEnabled(type != null);
modeValueLabel.setText("Source");
model.getParentModel().setProperty(AdapterWizardPageModel.MODE, AdapterWizardPageModel.MODE_SOURCE);
-
onPageActivatedBackground(dbc);
}
@@ -459,52 +361,6 @@
}.schedule();
}
- protected void refreshValidRuntimes() {
- IRuntimeType type = getValidRuntimeType();
- if (type != null) {
- IRuntime[] runtimes = getRuntimesOfType(type.getId());
- fillRuntimeCombo(runtimes);
- } else {
- // suitableRuntimesCombo.setItems(new String[0]);
- selectedRuntimeObservable.setValue(0);
- }
- }
-
- /* Stolen from NewManualServerComposite */
- protected int showRuntimeWizard(IRuntimeType runtimeType) {
- WizardFragment fragment = null;
- TaskModel taskModel = new TaskModel();
- final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeType.getId());
- if (fragment2 == null)
- return Window.CANCEL;
-
- try {
- IRuntimeWorkingCopy runtimeWorkingCopy = runtimeType.createRuntime(null, null);
- taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy);
- } catch (CoreException ce) {
- OpenShiftUIActivator.getDefault().getLog().log(ce.getStatus());
- return Window.CANCEL;
- }
- fragment = new WizardFragment() {
- protected void createChildFragments(List<WizardFragment> list) {
- list.add(fragment2);
- list.add(WizardTaskUtil.SaveRuntimeFragment);
- }
- };
- TaskWizard wizard2 = new TaskWizard(Messages.wizNewRuntimeWizardTitle, fragment, taskModel);
- wizard2.setForcePreviousAndNextButtons(true);
- WizardDialog dialog = new WizardDialog(getShell(), wizard2);
- int returnValue = dialog.open();
- refreshValidRuntimes();
- if (returnValue != Window.CANCEL) {
- IRuntime rt = (IRuntime) taskModel.getObject(TaskModel.TASK_RUNTIME);
- if (rt != null && rt.getName() != null && suitableRuntimesCombo.indexOf(rt.getName()) != -1) {
- suitableRuntimesCombo.select(suitableRuntimesCombo.indexOf(rt.getName()));
- }
- }
- return returnValue;
- }
-
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (ImportProjectWizardModel.APPLICATION.equals(evt.getPropertyName())) {
@@ -518,10 +374,8 @@
serverTypeToCreate = getServerTypeToCreate();
boolean canCreateServer = serverTypeToCreate != null;
serverAdapterCheckbox.setEnabled(canCreateServer);
- // serverAdapterCheckbox.setSelection(canCreateServer);
serverAdapterCheckboxObservable.setValue(canCreateServer);
enableServerWidgets(canCreateServer);
- refreshValidRuntimes();
model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER, canCreateServer);
}
@@ -539,12 +393,6 @@
if (Boolean.FALSE.equals(serverAdapterCheckboxObservable.getValue())) {
return ValidationStatus.ok();
}
- if (new Integer(-1).equals(selectedRuntimeObservable.getValue())) {
- if (suitableRuntimesObservable.size() == 0) {
- return ValidationStatus.error("Please add a new valid runtime.");
- }
- return ValidationStatus.error("Please select a runtime");
- }
return ValidationStatus.ok();
}
}
13 years, 1 month
JBoss Tools SVN: r36296 - in trunk: openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-11-11 05:34:03 -0500 (Fri, 11 Nov 2011)
New Revision: 36296
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenShiftDeployUI.java
Log:
Added copyright, and a *possible* fix for JBIDE-10117 ?? Either way, it's cleaner.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java 2011-11-11 01:32:40 UTC (rev 36295)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java 2011-11-11 10:34:03 UTC (rev 36296)
@@ -95,7 +95,8 @@
String current = null;
if( ds != null ) {
Behaviour b = BehaviourModel.getModel().getBehaviour(callback.getServer().getOriginal().getServerType().getId());
- String behaviourType = DeploymentPreferenceLoader.getCurrentDeploymentMethodTypeId(callback.getServer().getOriginal());
+ String behaviourType = DeploymentPreferenceLoader.getCurrentDeploymentMethodTypeId(
+ callback.getServer().getOriginal(), getDefaultServerMode());
current = b.getImpl(behaviourType).getName();
} else {
String host = callback.getServer().getHost();
@@ -103,10 +104,10 @@
BehaviourImpl impl = null;
String serverTypeId = callback.getServer().getServerType().getId();
if( SocketUtil.isLocalhost(host)) {
- impl = BehaviourModel.getModel().getBehaviour(serverTypeId).getImpl(LocalPublishMethod.LOCAL_PUBLISH_METHOD);
+ impl = BehaviourModel.getModel().getBehaviour(serverTypeId).getImpl(getDefaultLocalServerMode());
} else {
// socket is not localhost, hard code this for now
- impl = BehaviourModel.getModel().getBehaviour(serverTypeId).getImpl("rse");
+ impl = BehaviourModel.getModel().getBehaviour(serverTypeId).getImpl(getDefaultRemoteServerMode());
}
current = impl.getName();
callback.execute(new ChangeServerPropertyCommand(
@@ -125,6 +126,16 @@
deployTypeChanged(false);
}
+ protected String getDefaultServerMode() {
+ return LocalPublishMethod.LOCAL_PUBLISH_METHOD;
+ }
+ protected String getDefaultLocalServerMode() {
+ return LocalPublishMethod.LOCAL_PUBLISH_METHOD;
+ }
+ protected String getDefaultRemoteServerMode() {
+ return "rse"; //$NON-NLS-1$
+ }
+
protected boolean showExecuteShellCheckbox() {
return true;
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenShiftDeployUI.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenShiftDeployUI.java 2011-11-11 01:32:40 UTC (rev 36295)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenShiftDeployUI.java 2011-11-11 10:34:03 UTC (rev 36296)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.behaviour;
import org.eclipse.swt.SWT;
13 years, 1 month
JBoss Tools SVN: r36295 - trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-11-10 20:32:40 -0500 (Thu, 10 Nov 2011)
New Revision: 36295
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java
Log:
https://issues.jboss.org/browse/JBIDE-10142 Seam 2 Tools: Extend JBoss Perspective
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java 2011-11-11 01:32:12 UTC (rev 36294)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java 2011-11-11 01:32:40 UTC (rev 36295)
@@ -92,7 +92,7 @@
ValidatorManager.addProjectBuildValidationSupport(project);
project.build(IncrementalProjectBuilder.FULL_BUILD,
new NullProgressMonitor());
-
+
JobUtils.waitForIdle();
}
} );
13 years, 1 month