JBoss Tools SVN: r40872 - in trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime: handlers and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2012-05-09 09:39:56 -0400 (Wed, 09 May 2012)
New Revision: 40872
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/DriverUtility.java
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/as/detector/IJBossRuntimePluginConstants.java
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
Log:
JBIDE-11799 - code cleanup for runtime as detector
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/as/detector/IJBossRuntimePluginConstants.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/as/detector/IJBossRuntimePluginConstants.java 2012-05-09 13:36:42 UTC (rev 40871)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/as/detector/IJBossRuntimePluginConstants.java 2012-05-09 13:39:56 UTC (rev 40872)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.runtime.as.detector;
+
public interface IJBossRuntimePluginConstants {
public static final String DEFAULT_DS = "DefaultDS";
public static final String RUNTIME = Messages.JBossRuntimeStartup_Runtime;
@@ -27,68 +28,12 @@
public static final String SERVERS_FILE_CONFIGURATION = "../../studio/" + SERVERS_FILE_NAME; //$NON-NLS-1$
public static String RUNTIME_CONFIG_FORMAT_VERSION = "1.0"; //$NON-NLS-1$
- // This constants are made to avoid dependency with org.jboss.ide.eclipse.as.core plugin
- public static final String JBOSS_AS_RUNTIME_TYPE_ID[] = {
- "org.jboss.ide.eclipse.as.runtime.32", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.40", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.42", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.50", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.51", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.60", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.eap.43", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.eap.50", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.70", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.71", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.runtime.eap.60" //$NON-NLS-1$
- // NEW_SERVER_ADAPTER add logic for new adapter here
- };
-
public static final String HSQLDB_DRIVER_JAR_NAME = "hsqldb.jar"; //$NON-NLS-1$
public static final String HSQLDB_DRIVER_3X_4X_LOCATION = "/server/default/lib/" + HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
public static final String HSQLDB_DRIVER_5X_LOCATION = "/common/lib/" + HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
-
- // This constants are made to avoid dependency with org.jboss.ide.eclipse.as.core plugin
- public static final String JBOSS_AS_HSQL_DRIVER_LOCATION[] = {
- HSQLDB_DRIVER_3X_4X_LOCATION,
- HSQLDB_DRIVER_3X_4X_LOCATION,
- HSQLDB_DRIVER_3X_4X_LOCATION,
- HSQLDB_DRIVER_5X_LOCATION,
- HSQLDB_DRIVER_5X_LOCATION,
- HSQLDB_DRIVER_5X_LOCATION,
- HSQLDB_DRIVER_3X_4X_LOCATION,
- HSQLDB_DRIVER_5X_LOCATION
- };
-
- public static final String JBOSS_AS_TYPE_ID[] = {
- "org.jboss.ide.eclipse.as.32", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.40", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.42", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.50", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.51", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.60", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.eap.43", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.eap.50", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.70", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.71", //$NON-NLS-1$
- "org.jboss.ide.eclipse.as.eap.60" //$NON-NLS-1$
- };
-
- public static final String JBOSS_AS_NAME[] = {
- Messages.JBossRuntimeStartup_JBoss_Application_Server_3_2,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_4_0,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_4_2,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_5_0,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_5_1,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_6_0,
- Messages.JBossRuntimeStartup_JBoss_EAP_Server_4_3,
- Messages.JBossRuntimeStartup_JBoss_EAP_Server_5_0,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_7_0,
- Messages.JBossRuntimeStartup_JBoss_Application_Server_7_1,
- Messages.JBossRuntimeStartup_JBoss_EAP_Server_6_0
- };
-
+
public static final String JBOSS_AS_HOST = "localhost"; //$NON-NLS-1$
public static final String JBOSS_AS_DEFAULT_CONFIGURATION_NAME = "default"; //$NON-NLS-1$
Added: trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/DriverUtility.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/DriverUtility.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/DriverUtility.java 2012-05-09 13:39:56 UTC (rev 40872)
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.runtime.handlers;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.ConnectionProfileException;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.drivers.DriverInstance;
+import org.eclipse.datatools.connectivity.drivers.DriverManager;
+import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants;
+import org.eclipse.datatools.connectivity.drivers.IPropertySet;
+import org.eclipse.datatools.connectivity.drivers.PropertySetImpl;
+import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
+import org.eclipse.wst.server.core.IServerType;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.tools.runtime.as.detector.IJBossRuntimePluginConstants;
+import org.jboss.tools.runtime.as.detector.Messages;
+import org.jboss.tools.runtime.as.detector.RuntimeAsActivator;
+
+public class DriverUtility implements IJBossRuntimePluginConstants {
+ public static final HashMap<String,String> SERVER_DRIVER_LOCATION = new HashMap<String, String>();
+ static {
+ SERVER_DRIVER_LOCATION.put(IJBossToolingConstants.SERVER_AS_32, HSQLDB_DRIVER_3X_4X_LOCATION);
+ SERVER_DRIVER_LOCATION.put(IJBossToolingConstants.SERVER_AS_40, HSQLDB_DRIVER_3X_4X_LOCATION);
+ SERVER_DRIVER_LOCATION.put(IJBossToolingConstants.SERVER_AS_42, HSQLDB_DRIVER_3X_4X_LOCATION);
+ SERVER_DRIVER_LOCATION.put(IJBossToolingConstants.SERVER_AS_50, HSQLDB_DRIVER_5X_LOCATION);
+ SERVER_DRIVER_LOCATION.put(IJBossToolingConstants.SERVER_AS_51, HSQLDB_DRIVER_5X_LOCATION);
+ SERVER_DRIVER_LOCATION.put(IJBossToolingConstants.SERVER_AS_60, HSQLDB_DRIVER_5X_LOCATION);
+ SERVER_DRIVER_LOCATION.put(IJBossToolingConstants.SERVER_EAP_43, HSQLDB_DRIVER_3X_4X_LOCATION);
+ SERVER_DRIVER_LOCATION.put(IJBossToolingConstants.SERVER_EAP_50, HSQLDB_DRIVER_5X_LOCATION);
+ }
+
+ /**
+ * Creates HSQL DB Driver
+ * @param jbossASLocation location of JBoss AS
+ * @param index
+ * @throws ConnectionProfileException
+ * @return driver instance
+ */
+ public void createDriver(String jbossASLocation, IServerType serverType) throws ConnectionProfileException {
+ if(ProfileManager.getInstance().getProfileByName(DEFAULT_DS) != null) {
+ // Don't create the driver a few times
+ return;
+ }
+ String driverPath;
+ try {
+ driverPath = getDriverPath(jbossASLocation, serverType);
+ } catch (IOException e) {
+ RuntimeAsActivator.getDefault().getLog().log(new Status(IStatus.ERROR,
+ RuntimeAsActivator.PLUGIN_ID, Messages.JBossRuntimeStartup_Cannott_create_new_HSQL_DB_Driver, e));
+ return;
+ }
+ if (driverPath == null) {
+ RuntimeAsActivator.getDefault().getLog().log(new Status(IStatus.ERROR,
+ RuntimeAsActivator.PLUGIN_ID, Messages.JBossRuntimeStartup_Cannot_create_new_DB_Driver));
+ }
+
+ DriverInstance driver = getDriver(serverType);
+ if (driver == null) {
+ TemplateDescriptor descr = getDriverTemplateDescriptor(serverType);
+ IPropertySet instance = new PropertySetImpl(getDriverName(serverType), getDriverDefinitionId(serverType));
+ instance.setName(getDriverName(serverType));
+ instance.setID(getDriverDefinitionId(serverType));
+ Properties props = new Properties();
+
+ IConfigurationElement[] template = descr.getProperties();
+ for (int i = 0; i < template.length; i++) {
+ IConfigurationElement prop = template[i];
+ String id = prop.getAttribute("id"); //$NON-NLS-1$
+
+ String value = prop.getAttribute("value"); //$NON-NLS-1$
+ props.setProperty(id, value == null ? "" : value); //$NON-NLS-1$
+ }
+ props.setProperty(DTP_DB_URL_PROPERTY_ID, getDriverUrl(serverType)); //$NON-NLS-1$
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, driverPath);
+ if( isAS7StyleServer(serverType)) {
+ props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, "org.h2.Driver");
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, "H2 driver");
+ props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID, "jdbc:h2:mem");
+ props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, "sa");
+ }
+
+ instance.setBaseProperties(props);
+ DriverManager.getInstance().removeDriverInstance(instance.getID());
+ System.gc();
+ DriverManager.getInstance().addDriverInstance(instance);
+ }
+
+ driver = DriverManager.getInstance().getDriverInstanceByName(getDriverName(serverType));
+ if (driver != null && ProfileManager.getInstance().getProfileByName(DEFAULT_DS) == null) { //$NON-NLS-1$
+ // create profile
+ Properties props = new Properties();
+ props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
+ getDriverDefinitionId(serverType));
+ props.setProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID, ""); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, "Default"); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, ""); //$NON-NLS-1$
+ props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, "false"); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
+
+ if( isAS7StyleServer(serverType)) {
+ ProfileManager.getInstance().createProfile(DEFAULT_DS, Messages.JBossRuntimeStartup_The_JBoss_AS_H2_embedded_database, H2_PROFILE_ID, props, "", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else {
+ ProfileManager.getInstance().createProfile(DEFAULT_DS, Messages.JBossRuntimeStartup_The_JBoss_AS_Hypersonic_embedded_database, HSQL_PROFILE_ID, props, "", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ }
+
+ protected static String getDriverUrl(IServerType serverType) {
+ if( isAS7StyleServer(serverType)) {
+ return "jdbc:h2:mem";
+ } else {
+ return "jdbc:hsqldb:.";
+ }
+ }
+
+ private static String getDriverDefinitionId(IServerType serverType) {
+ if( isAS7StyleServer(serverType)) {
+ return H2_DRIVER_DEFINITION_ID;
+ } else {
+ return HSQL_DRIVER_DEFINITION_ID;
+ }
+ }
+
+ private static String getDriverName(IServerType serverType) {
+ if( isAS7StyleServer(serverType)) {
+ return H2_DRIVER_NAME;
+ } else {
+ return HSQL_DRIVER_NAME;
+ }
+ }
+
+ protected static TemplateDescriptor getDriverTemplateDescriptor(IServerType serverType) {
+ if( isAS7StyleServer(serverType)) {
+ return TemplateDescriptor.getDriverTemplateDescriptor(H2_DRIVER_TEMPLATE_ID);
+ } else {
+ return TemplateDescriptor.getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
+ }
+ }
+
+ protected static DriverInstance getDriver(IServerType serverType) {
+ if( isAS7StyleServer(serverType)) {
+ return DriverManager.getInstance().getDriverInstanceByName(H2_DRIVER_NAME);
+ }
+ return DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ }
+
+ private static String getDriverPath(String jbossASLocation, IServerType serverType)
+ throws IOException {
+ String driverPath;
+ if (isAS7StyleServer(serverType)) {
+ File file = new File(jbossASLocation + "/modules/com/h2database/h2/main").getCanonicalFile();
+ File[] fileList = file.listFiles(new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ if (name.startsWith("h2") && name.endsWith(".jar")) {
+ return true;
+ }
+ return false;
+ }
+ });
+ if (fileList != null && fileList.length > 0) {
+ return fileList[0].getCanonicalPath();
+ }
+ return null;
+ } else {
+ String loc = SERVER_DRIVER_LOCATION.get(serverType.getId());
+ driverPath = new File(jbossASLocation + loc).getCanonicalPath(); //$NON-NLS-1$
+ }
+ return driverPath;
+ }
+
+ private static boolean isAS7StyleServer(IServerType type) {
+ if( type != null ) {
+ String id = type.getId();
+ return IJBossToolingConstants.SERVER_AS_70.equals(id) ||
+ IJBossToolingConstants.SERVER_AS_71.equals(id) ||
+ IJBossToolingConstants.SERVER_EAP_60.equals(id);
+ }
+ return false;
+ }
+
+}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2012-05-09 13:36:42 UTC (rev 40871)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2012-05-09 13:39:56 UTC (rev 40872)
@@ -15,6 +15,7 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Properties;
@@ -46,11 +47,13 @@
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.model.ServerDelegate;
import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBean;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.tools.runtime.as.detector.IJBossRuntimePluginConstants;
import org.jboss.tools.runtime.as.detector.Messages;
import org.jboss.tools.runtime.as.detector.RuntimeAsActivator;
@@ -63,12 +66,28 @@
public class JBossASHandler extends AbstractRuntimeDetector implements IJBossRuntimePluginConstants {
- private static final int JBOSS_AS70_INDEX = 8;
- private static final int JBOSS_AS71_INDEX = 9;
- private static final int JBOSS_EAP60_INDEX = 10;
private static String[] hasIncludedRuntimes = new String[] {SOA_P, EAP, EPP, EWP, SOA_P_STD};
private static final String DROOLS = "DROOLS"; // NON-NLS-1$
private static final String ESB = "ESB"; //$NON-NLS-1$
+
+ // This constants are made to avoid dependency with org.jboss.ide.eclipse.as.core plugin
+ public static final String RUNTIME_TYPES[] = IJBossToolingConstants.ALL_JBOSS_RUNTIMES;
+ public static final String SERVER_TYPES[] = IJBossToolingConstants.ALL_JBOSS_SERVERS;
+
+ public static final HashMap<String,String> SERVER_DEFAULT_NAME = new HashMap<String, String>();
+ static {
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_AS_32, Messages.JBossRuntimeStartup_JBoss_Application_Server_3_2);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_AS_40, Messages.JBossRuntimeStartup_JBoss_Application_Server_4_0);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_AS_42, Messages.JBossRuntimeStartup_JBoss_Application_Server_4_2);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_AS_50, Messages.JBossRuntimeStartup_JBoss_Application_Server_5_0);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_AS_51, Messages.JBossRuntimeStartup_JBoss_Application_Server_5_1);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_AS_60, Messages.JBossRuntimeStartup_JBoss_Application_Server_6_0);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_EAP_43, Messages.JBossRuntimeStartup_JBoss_EAP_Server_4_3);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_EAP_50, Messages.JBossRuntimeStartup_JBoss_EAP_Server_5_0);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_AS_70, Messages.JBossRuntimeStartup_JBoss_Application_Server_7_0);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_AS_71, Messages.JBossRuntimeStartup_JBoss_Application_Server_7_1);
+ SERVER_DEFAULT_NAME.put(IJBossToolingConstants.SERVER_EAP_60, Messages.JBossRuntimeStartup_JBoss_EAP_Server_6_0);
+ }
public void initializeRuntimes(List<RuntimeDefinition> serverDefinitions) {
createJBossServerFromDefinitions(serverDefinitions);
@@ -105,107 +124,66 @@
String type = serverDefinition.getType();
if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type)
|| SOA_P_STD.equals(type) || EWP.equals(type)
- || EAP_STD.equals(type)) {
+ || EAP_STD.equals(type) || AS.equals(type)) {
+ String typeId = new ServerBeanLoader(asLocation).getServerAdapterId();
String name = serverDefinition.getName();
String runtimeName = name + " " + RUNTIME; //$NON-NLS-1$
- int index = getJBossASVersion(asLocation, serverDefinition);
- createJBossServer(asLocation, index, name, runtimeName);
- } else if (AS.equals(type)) {
- String version = serverDefinition.getVersion();
- int index = 2;
- if ("3.2".equals(version)) { //$NON-NLS-1$
- index = 0;
- } else if ("4.0".equals(version)) { //$NON-NLS-1$
- index = 1;
- } else if ("4.2".equals(version)) { //$NON-NLS-1$
- index = 2;
- } else if ("5.0".equals(version)) { //$NON-NLS-1$
- index = 3;
- } else if ("5.1".equals(version)) { //$NON-NLS-1$
- index = 4;
- } else if ("6.0".equals(version) || "6.1".equals(version)) { //$NON-NLS-1$
- index = 5;
- } else if ("7.0".equals(version)) { //$NON-NLS-1$
- index = JBOSS_AS70_INDEX;
- } else if ("7.1".equals(version)) { //$NON-NLS-1$
- index = JBOSS_AS71_INDEX;
- }
- // NEW_SERVER_ADAPTER add logic for new adapter here
- createJBossServer(serverDefinition.getLocation(), index,
- serverDefinition.getName(),
- serverDefinition.getName() + " " + RUNTIME); //$NON-NLS-1$
+ createJBossServer(asLocation, typeId, name, runtimeName);
}
}
createJBossServerFromDefinitions(serverDefinition.getIncludedServerDefinitions());
}
}
- private static int getJBossASVersion(File asLocation, RuntimeDefinition serverDefinition) {
- int index = -1;
- String type = serverDefinition.getType();
- String ver = serverDefinition.getVersion();
- String fullVersion;
- if (EAP.equals(type) && "6.0".equals(ver)) {
- fullVersion = new ServerBeanLoader(asLocation).getFullServerVersion();
- } else {
- fullVersion = new ServerBeanLoader(asLocation).getFullServerVersion();
- }
- if(fullVersion != null ) {
- String version = fullVersion.substring(0, 3);
- if ("4.3".equals(version)) { //$NON-NLS-1$
- index = 6;
- } else if ("5.0".equals(version)) { //$NON-NLS-1$
- index = 7;
- } else if ("5.1".equals(version)) { //$NON-NLS-1$
- // FIXME - this needs to be changed when adding a new runtime type for JBoss EAP 5.1
- index = 7;
- } else if ("5.2".equals(version)) { //$NON-NLS-1$
- // SOA-P 5.2
- index = 7;
- } else if ("6.0".equals(version)) { //$NON-NLS-1$
- // EAP 6.0
- index = 10;
- }
- }
- return index;
- }
-
- private static void createJBossServer(File asLocation, int index, String name, String runtimeName) {
- if (asLocation == null || !asLocation.isDirectory() || index==-1) {
- return;
- }
- IPath jbossAsLocationPath = new Path(asLocation.getAbsolutePath());
-
+ private static boolean serverExistsForPath(IPath locPath) {
IServer[] servers = ServerCore.getServers();
for (int i = 0; i < servers.length; i++) {
IRuntime runtime = servers[i].getRuntime();
- if(runtime != null && runtime.getLocation() != null && runtime.getLocation().equals(jbossAsLocationPath)) {
- return;
+ if(runtime != null && runtime.getLocation() != null && runtime.getLocation().equals(locPath)) {
+ return true;
}
}
-
- IRuntime runtime = null;
+ return false;
+ }
+
+ private static IRuntime findRuntimeForPath(IPath locPath) {
IRuntime[] runtimes = ServerCore.getRuntimes();
for (int i = 0; i < runtimes.length; i++) {
if (runtimes[i] == null || runtimes[i].getLocation() == null) {
continue;
}
- if (runtimes[i].getLocation().equals(jbossAsLocationPath)) {
- runtime = runtimes[i].createWorkingCopy();
- break;
+ if (runtimes[i].getLocation().equals(locPath)) {
+ return runtimes[i];
}
}
-
+ return null;
+ }
+
+ private static void createJBossServer(File asLocation, String serverTypeId, String name, String runtimeName) {
+ if (asLocation == null || !asLocation.isDirectory() || serverTypeId == null)
+ return;
+ IServerType serverType = ServerCore.findServerType(serverTypeId);
+ if( serverType == null )
+ return;
+ IRuntimeType rtType = serverType.getRuntimeType();
+ if( rtType == null )
+ return;
+
+ IPath jbossAsLocationPath = new Path(asLocation.getAbsolutePath());
+ if( serverExistsForPath(jbossAsLocationPath))
+ return;
+
+ IRuntime runtime = findRuntimeForPath(jbossAsLocationPath);
IProgressMonitor progressMonitor = new NullProgressMonitor();
try {
if (runtime == null) {
- runtime = createRuntime(runtimeName, asLocation.getAbsolutePath(), progressMonitor, index);
+ runtime = createRuntime(runtimeName, asLocation.getAbsolutePath(), progressMonitor, rtType);
}
if (runtime != null) {
- createServer(progressMonitor, runtime, index, name);
+ createServer(progressMonitor, runtime, serverType, name);
}
- createDriver(asLocation.getAbsolutePath(), index);
+ new DriverUtility().createDriver(asLocation.getAbsolutePath(), serverType);
} catch (CoreException e) {
RuntimeAsActivator.log(e,Messages.JBossRuntimeStartup_Cannot_create_new_JBoss_Server);
} catch (ConnectionProfileException e) {
@@ -220,22 +198,16 @@
* @return runtime working copy
* @throws CoreException
*/
- private static IRuntime createRuntime(String runtimeName, String jbossASLocation, IProgressMonitor progressMonitor, int index) throws CoreException {
+ private static IRuntime createRuntime(String runtimeName, String jbossASLocation,
+ IProgressMonitor progressMonitor, IRuntimeType rtType) throws CoreException {
IRuntimeWorkingCopy runtime = null;
- String type = null;
- String version = null;
- String runtimeId = null;
IPath jbossAsLocationPath = new Path(jbossASLocation);
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, JBOSS_AS_RUNTIME_TYPE_ID[index]);
- if (runtimeTypes.length > 0) {
- runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
- runtime.setLocation(jbossAsLocationPath);
- if(runtimeName!=null) {
- runtime.setName(runtimeName);
- }
- return runtime.save(false, progressMonitor);
+ runtime = rtType.createRuntime(null, progressMonitor);
+ runtime.setLocation(jbossAsLocationPath);
+ if(runtimeName!=null) {
+ runtime.setName(runtimeName);
}
- return runtime;
+ return runtime.save(false, progressMonitor);
}
/**
@@ -245,18 +217,23 @@
* @return server working copy
* @throws CoreException
*/
- private static void createServer(IProgressMonitor progressMonitor, IRuntime runtime, int index, String name) throws CoreException {
- if (name == null) {
- name = JBOSS_AS_NAME[index];
+ private static void createServer(IProgressMonitor progressMonitor, IRuntime runtime,
+ IServerType serverType, String name) throws CoreException {
+ if (name == null)
+ name = SERVER_DEFAULT_NAME.get(serverType.getId());
+ if( !serverWithNameExists(name)) {
+ createServer2(runtime, serverType, name, LocalPublishMethod.LOCAL_PUBLISH_METHOD);
}
+ }
+
+ private static boolean serverWithNameExists(String name) {
IServer[] servers = ServerCore.getServers();
for (IServer server:servers) {
if (name.equals(server.getName()) ) {
- return;
+ return true;
}
}
- IServerType serverType = ServerCore.findServerType(JBOSS_AS_TYPE_ID[index]);
- createServer2(runtime, serverType, name, LocalPublishMethod.LOCAL_PUBLISH_METHOD);
+ return false;
}
public static IServer createServer2(IRuntime currentRuntime, IServerType serverType, String serverName, String mode) throws CoreException {
@@ -269,151 +246,6 @@
return serverWC.save(true, new NullProgressMonitor());
}
- /**
- * Creates HSQL DB Driver
- * @param jbossASLocation location of JBoss AS
- * @param index
- * @throws ConnectionProfileException
- * @return driver instance
- */
- private static void createDriver(String jbossASLocation, int index) throws ConnectionProfileException {
- if(ProfileManager.getInstance().getProfileByName(DEFAULT_DS) != null) {
- // Don't create the driver a few times
- return;
- }
- String driverPath;
- try {
- driverPath = getDriverPath(jbossASLocation, index);
- } catch (IOException e) {
- RuntimeAsActivator.getDefault().getLog().log(new Status(IStatus.ERROR,
- RuntimeAsActivator.PLUGIN_ID, Messages.JBossRuntimeStartup_Cannott_create_new_HSQL_DB_Driver, e));
- return;
- }
- if (driverPath == null) {
- RuntimeAsActivator.getDefault().getLog().log(new Status(IStatus.ERROR,
- RuntimeAsActivator.PLUGIN_ID, Messages.JBossRuntimeStartup_Cannot_create_new_DB_Driver));
- }
-
- DriverInstance driver = getDriver(index);
- if (driver == null) {
- TemplateDescriptor descr = getDriverTemplateDescriptor(index);
- IPropertySet instance = new PropertySetImpl(getDriverName(index), getDriverDefinitionId(index));
- instance.setName(getDriverName(index));
- instance.setID(getDriverDefinitionId(index));
- Properties props = new Properties();
-
- IConfigurationElement[] template = descr.getProperties();
- for (int i = 0; i < template.length; i++) {
- IConfigurationElement prop = template[i];
- String id = prop.getAttribute("id"); //$NON-NLS-1$
-
- String value = prop.getAttribute("value"); //$NON-NLS-1$
- props.setProperty(id, value == null ? "" : value); //$NON-NLS-1$
- }
- props.setProperty(DTP_DB_URL_PROPERTY_ID, getDriverUrl(index)); //$NON-NLS-1$
- props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
- props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, driverPath);
- if (index == JBOSS_AS70_INDEX || index == JBOSS_AS71_INDEX || index == JBOSS_EAP60_INDEX) {
- props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, "org.h2.Driver");
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, "H2 driver");
- props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID, "jdbc:h2:mem");
- props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, "sa");
- }
-
- instance.setBaseProperties(props);
- DriverManager.getInstance().removeDriverInstance(instance.getID());
- System.gc();
- DriverManager.getInstance().addDriverInstance(instance);
- }
-
- driver = DriverManager.getInstance().getDriverInstanceByName(getDriverName(index));
- if (driver != null && ProfileManager.getInstance().getProfileByName(DEFAULT_DS) == null) { //$NON-NLS-1$
- // create profile
- Properties props = new Properties();
- props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, getDriverDefinitionId(index));
- props.setProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID, ""); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, "Default"); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, ""); //$NON-NLS-1$
- props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, "false"); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
-
- if (index == JBOSS_AS70_INDEX || index == JBOSS_AS71_INDEX || index == JBOSS_EAP60_INDEX) {
- ProfileManager.getInstance().createProfile(DEFAULT_DS, Messages.JBossRuntimeStartup_The_JBoss_AS_H2_embedded_database, H2_PROFILE_ID, props, "", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- ProfileManager.getInstance().createProfile(DEFAULT_DS, Messages.JBossRuntimeStartup_The_JBoss_AS_Hypersonic_embedded_database, HSQL_PROFILE_ID, props, "", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- }
-
- protected static String getDriverUrl(int index) {
- if (index == JBOSS_AS70_INDEX || index == JBOSS_AS71_INDEX || index == JBOSS_EAP60_INDEX) {
- return "jdbc:h2:mem";
- } else {
- return "jdbc:hsqldb:.";
- }
- }
-
- private static String getDriverDefinitionId(int index) {
- if (index == JBOSS_AS70_INDEX || index == JBOSS_AS71_INDEX || index == JBOSS_EAP60_INDEX) {
- return H2_DRIVER_DEFINITION_ID;
- } else {
- return HSQL_DRIVER_DEFINITION_ID;
- }
- }
-
- private static String getDriverName(int index) {
- if (index == JBOSS_AS70_INDEX || index == JBOSS_AS71_INDEX || index == JBOSS_EAP60_INDEX) {
- return H2_DRIVER_NAME;
- } else {
- return HSQL_DRIVER_NAME;
- }
- }
-
- protected static TemplateDescriptor getDriverTemplateDescriptor(int index) {
- if (index == JBOSS_AS70_INDEX || index == JBOSS_AS71_INDEX || index == JBOSS_EAP60_INDEX) {
- return TemplateDescriptor.getDriverTemplateDescriptor(H2_DRIVER_TEMPLATE_ID);
- } else {
- return TemplateDescriptor.getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
- }
- }
-
- protected static DriverInstance getDriver(int index) {
- if (index == JBOSS_AS70_INDEX || index == JBOSS_AS71_INDEX || index == JBOSS_EAP60_INDEX) {
- return DriverManager.getInstance().getDriverInstanceByName(H2_DRIVER_NAME);
- }
- return DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
- }
-
- private static String getDriverPath(String jbossASLocation, int index)
- throws IOException {
- String driverPath;
- if (index == JBOSS_AS70_INDEX || index == JBOSS_AS71_INDEX || index == JBOSS_EAP60_INDEX) {
- File file = new File(jbossASLocation + "/modules/com/h2database/h2/main").getCanonicalFile();
- File[] fileList = file.listFiles(new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- if (name.startsWith("h2") && name.endsWith(".jar")) {
- return true;
- }
- return false;
- }
- });
- if (fileList != null && fileList.length > 0) {
- return fileList[0].getCanonicalPath();
- }
- return null;
- } else {
- driverPath = new File(jbossASLocation + JBOSS_AS_HSQL_DRIVER_LOCATION[index]).getCanonicalPath(); //$NON-NLS-1$
- }
- return driverPath;
- }
-
public RuntimeDefinition getServerDefinition(File root,
IProgressMonitor monitor) {
if (monitor.isCanceled() || root == null || !isEnabled()) {
12 years, 8 months
JBoss Tools SVN: r40871 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-05-09 09:36:42 -0400 (Wed, 09 May 2012)
New Revision: 40871
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java
Log:
Typo: removing extra '.' on second line of confirmation dialog box
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-05-09 13:31:36 UTC (rev 40870)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-05-09 13:36:42 UTC (rev 40871)
@@ -372,7 +372,7 @@
importLink.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
OpenShiftExpressApplicationWizard wizard =
- new ImportOpenShiftExpressApplicationWizard(fuser, null, fapplication, true);
+ new ImportOpenShiftExpressApplicationWizard(fuser, null, fapplication);
WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
int oldServerCount = ServerCore.getServers().length;
dialog.create();
12 years, 8 months
JBoss Tools SVN: r40870 - 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: 2012-05-09 09:31:36 -0400 (Wed, 09 May 2012)
New Revision: 40870
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java
Log:
[JBIDE-10399] commented embedd all/none buttons
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java 2012-05-09 12:46:44 UTC (rev 40869)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java 2012-05-09 13:31:36 UTC (rev 40870)
@@ -42,10 +42,6 @@
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
@@ -88,20 +84,21 @@
Composite tableContainer = new Composite(embedGroup, SWT.NONE);
this.viewer = createTable(tableContainer);
GridDataFactory.fillDefaults()
- .span(3, 1).hint(200, 150).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableContainer);
+ .span(3, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableContainer);
viewer.addCheckStateListener(onCartridgeChecked());
- Button checkAllButton = new Button(embedGroup, SWT.PUSH);
- checkAllButton.setText("Embed A&ll");
- GridDataFactory.fillDefaults()
- .hint(110, SWT.DEFAULT).align(SWT.FILL, SWT.CENTER).applyTo(checkAllButton);
- checkAllButton.addSelectionListener(onCheckAll());
+// hiding buttons for now: https://issues.jboss.org/browse/JBIDE-10399
+// Button checkAllButton = new Button(embedGroup, SWT.PUSH);
+// checkAllButton.setText("Embed A&ll");
+// GridDataFactory.fillDefaults()
+// .hint(110, SWT.DEFAULT).align(SWT.FILL, SWT.CENTER).applyTo(checkAllButton);
+// checkAllButton.addSelectionListener(onCheckAll());
- Button uncheckAllButton = new Button(embedGroup, SWT.PUSH);
- uncheckAllButton.setText("Embed N&one");
- GridDataFactory.fillDefaults()
- .hint(110, SWT.DEFAULT).align(SWT.FILL, SWT.CENTER).applyTo(uncheckAllButton);
- uncheckAllButton.addSelectionListener(onUncheckAll());
+// Button uncheckAllButton = new Button(embedGroup, SWT.PUSH);
+// uncheckAllButton.setText("Embed N&one");
+// GridDataFactory.fillDefaults()
+// .hint(110, SWT.DEFAULT).align(SWT.FILL, SWT.CENTER).applyTo(uncheckAllButton);
+// uncheckAllButton.addSelectionListener(onUncheckAll());
}
protected CheckboxTableViewer createTable(Composite tableContainer) {
@@ -248,35 +245,35 @@
model.getSelectedEmbeddableCartridges().remove(cartridge);
}
- private SelectionListener onCheckAll() {
- return new SelectionAdapter() {
+// private SelectionListener onCheckAll() {
+// return new SelectionAdapter() {
+//
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// viewer.setAllChecked(true);
+// try {
+// addJenkinsCartridge(IEmbeddedCartridge.JENKINS_14);
+// } catch (OpenShiftException ex) {
+// OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
+// } catch (SocketTimeoutException ex) {
+// OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
+// }
+// }
+//
+// };
+// }
- @Override
- public void widgetSelected(SelectionEvent e) {
- viewer.setAllChecked(true);
- try {
- addJenkinsCartridge(IEmbeddedCartridge.JENKINS_14);
- } catch (OpenShiftException ex) {
- OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
- } catch (SocketTimeoutException ex) {
- OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
- }
- }
+// private SelectionListener onUncheckAll() {
+// return new SelectionAdapter() {
+//
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// viewer.setAllChecked(false);
+// }
+//
+// };
+// }
- };
- }
-
- private SelectionListener onUncheckAll() {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- viewer.setAllChecked(false);
- }
-
- };
- }
-
@Override
protected void onPageActivated(DataBindingContext dbc) {
try {
12 years, 8 months
JBoss Tools SVN: r40869 - in trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test: src/org/jboss/tools/drools/ui/bot/test and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: jgargula
Date: 2012-05-09 08:46:44 -0400 (Wed, 09 May 2012)
New Revision: 40869
Modified:
trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/resources/project.properties
trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DomainSpecificLanguageEditorTest.java
trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java
Log:
Minor changes to tests (closing subclipse windows, checking DebugException)
Modified: trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/resources/project.properties
===================================================================
--- trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/resources/project.properties 2012-05-09 09:19:08 UTC (rev 40868)
+++ trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/resources/project.properties 2012-05-09 12:46:44 UTC (rev 40869)
@@ -1,3 +1,3 @@
use-external-drools-runtime=true
guvnor-repository-url=/jboss-brms/org.drools.guvnor.Guvnor/webdav
-external-drools-runtime-home=/home/vpakan/tmp/drools
+external-drools-runtime-home=/home/jgargula/Programs/drools-runtime
Modified: trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
===================================================================
--- trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2012-05-09 09:19:08 UTC (rev 40868)
+++ trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2012-05-09 12:46:44 UTC (rev 40869)
@@ -15,6 +15,7 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.jboss.tools.drools.ui.bot.test.smoke.DecisionTableTest;
import org.jboss.tools.drools.ui.bot.test.smoke.DomainSpecificLanguageEditorTest;
import org.jboss.tools.drools.ui.bot.test.smoke.DroolsRulesEditorTest;
@@ -163,6 +164,13 @@
break;
}
}
+ for (SWTBotShell shell : bot.shells()) {
+ if (IDELabel.Shell.SUBCLIPSE_USAGE.equals(shell.getText())) {
+ shell.bot().checkBox().deselect();
+ shell.bot().button(IDELabel.Button.OK).click();
+ break;
+ }
+ }
eclipse.openPerspective(PerspectiveType.JAVA);
eclipse.maximizeActiveShell();
Modified: trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DomainSpecificLanguageEditorTest.java
===================================================================
--- trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DomainSpecificLanguageEditorTest.java 2012-05-09 09:19:08 UTC (rev 40868)
+++ trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DomainSpecificLanguageEditorTest.java 2012-05-09 12:46:44 UTC (rev 40869)
@@ -124,9 +124,11 @@
drlDroolsEditor.insertText(lineNumber,0,">");
}
drlDroolsEditor.selectLine(18);
- bot.sleep(Timing.time1S());
- KeyboardHelper.pressKeyCode(bot.getDisplay(),(int)SWT.DEL);
- bot.sleep(Timing.time1S());
+ // pressing DELETE was malfunctioning
+ bot.menu(IDELabel.Menu.EDIT).menu(IDELabel.Menu.DELETE).click();
+ //bot.sleep(Timing.time1S());
+ //KeyboardHelper.pressKeyCode(bot.getDisplay(),(int)SWT.DEL);
+ //bot.sleep(Timing.time1S());
drlDroolsEditor.insertText(18, 0, " Message m of type Message.GOODBYE contains myMessage");
drlDroolsEditor.save();
util.waitForJobs(Timing.time10S(), JobName.BUILDING_WS);
Modified: trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java
===================================================================
--- trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java 2012-05-09 09:19:08 UTC (rev 40868)
+++ trunk/build/aggregate/soatests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java 2012-05-09 12:46:44 UTC (rev 40869)
@@ -2,6 +2,8 @@
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withLabel;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -130,7 +132,14 @@
public void agendaTest() {
bot.editorByTitle(RULES_FILE).show();
eclipse.stepOver();
+ // Some hacks to read output stream and check exception
+ PrintStream defaultOutputStream = System.out;
+ ByteArrayOutputStream pipeOut = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(pipeOut));
openView(IDELabel.View.AGENDA);
+ System.setOut(defaultOutputStream);
+ String output = new String(pipeOut.toByteArray());
+ System.out.print(output);
HashSet<Activation> expectedSet = new HashSet<Activation>(2);
// indicies are not compared
expectedSet.add(new Activation(0, "Bye Bye"));
@@ -150,6 +159,7 @@
eclipse.finishDebug();
assertTrue(CONSOLE_TEXT_MESSAGE_1 + EXPECTED_CONSOLE_TEXT_1 + EXPECTED_CONSOLE_TEXT_2 + CONSOLE_TEXT_MESSAGE_2
+ console.getConsoleText(), (EXPECTED_CONSOLE_TEXT_1 + EXPECTED_CONSOLE_TEXT_2).equals(console.getConsoleText()));
+ assertFalse("Opening agenda view throws DebugException", output.contains("DebugException"));
}
/**
@@ -230,6 +240,7 @@
auditView.toolbarButton("Clear Log").click();
assertEquals("Tree should be empty, but it was not.", 0, auditView.bot().tree().getAllItems().length);
+ packageExplorer.selectTreeItem(PROJECT_NAME, null).contextMenu(IDELabel.Menu.REFRESH).click();
}
/**
12 years, 8 months
JBoss Tools SVN: r40868 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-05-09 05:19:08 -0400 (Wed, 09 May 2012)
New Revision: 40868
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java
Log:
Fixed JBIDE-11804
OpenShift port forwarding typo
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java 2012-05-09 00:34:43 UTC (rev 40867)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java 2012-05-09 09:19:08 UTC (rev 40868)
@@ -162,7 +162,7 @@
@Override
public void widgetSelected(SelectionEvent e) {
try {
- WizardUtils.runInWizard(new Job("Refresh lis of ports...") {
+ WizardUtils.runInWizard(new Job("Refreshing list of ports...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
12 years, 8 months
JBoss Tools SVN: r40867 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-05-08 20:34:43 -0400 (Tue, 08 May 2012)
New Revision: 40867
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
Log:
JBIDE-11682
https://issues.jboss.org/browse/JBIDE-11682
Progress monitor is passed to the searcher.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2012-05-09 00:33:15 UTC (rev 40866)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2012-05-09 00:34:43 UTC (rev 40867)
@@ -391,7 +391,7 @@
pm.worked(1);
- getSearcher().findELReferences();
+ getSearcher().findELReferences(pm);
pm.done();
}
@@ -410,7 +410,7 @@
pm.worked(1);
- getSearcher().findELReferences();
+ getSearcher().findELReferences(pm);
pm.done();
}
12 years, 8 months
JBoss Tools SVN: r40866 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-05-08 20:33:15 -0400 (Tue, 08 May 2012)
New Revision: 40866
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/RenameNamedBeanProcessor.java
Log:
JBIDE-11682
https://issues.jboss.org/browse/JBIDE-11682
Progress monitor is passed to the searcher.
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/RenameNamedBeanProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/RenameNamedBeanProcessor.java 2012-05-09 00:32:31 UTC (rev 40865)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/RenameNamedBeanProcessor.java 2012-05-09 00:33:15 UTC (rev 40866)
@@ -58,7 +58,7 @@
pm.worked(1);
- getSearcher().findELReferences();
+ getSearcher().findELReferences(pm);
pm.done();
}
12 years, 8 months
JBoss Tools SVN: r40865 - trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-05-08 20:32:31 -0400 (Tue, 08 May 2012)
New Revision: 40865
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java
Log:
JBIDE-11682
https://issues.jboss.org/browse/JBIDE-11682
Progress monitor is passed to the searcher.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java 2012-05-09 00:31:35 UTC (rev 40864)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java 2012-05-09 00:32:31 UTC (rev 40865)
@@ -67,7 +67,7 @@
status.addWarning(JsfUIMessages.RENAME_METHOD_PARTICIPANT_SETTER_WARNING);
}
- searcher.findELReferences();
+ searcher.findELReferences(pm);
}
}
12 years, 8 months
JBoss Tools SVN: r40864 - trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-05-08 20:31:35 -0400 (Tue, 08 May 2012)
New Revision: 40864
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableProcessor.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameMessagePropertyProcessor.java
Log:
JBIDE-11682
https://issues.jboss.org/browse/JBIDE-11682
Progress monitor is passed to the searcher.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableProcessor.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableProcessor.java 2012-05-09 00:30:49 UTC (rev 40863)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableProcessor.java 2012-05-09 00:31:35 UTC (rev 40864)
@@ -138,7 +138,7 @@
if(managedBean != null){
Change managedBeanChange = RenameModelObjectChange.createChange(new XModelObject[]{managedBean}, getNewName(), MANAGED_BEAN_NAME_ATTRIBUTE);
rootChange.add(managedBeanChange);
- getSearcher().findELReferences();
+ getSearcher().findELReferences(pm);
}
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameMessagePropertyProcessor.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameMessagePropertyProcessor.java 2012-05-09 00:30:49 UTC (rev 40863)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameMessagePropertyProcessor.java 2012-05-09 00:31:35 UTC (rev 40864)
@@ -166,7 +166,7 @@
TextFileChange change = getChange((IFile)segment.getMessageBundleResource());
TextEdit edit = new ReplaceEdit(segment.getMessagePropertySourceReference().getStartPosition(), segment.getMessagePropertySourceReference().getLength(), getNewName());
change.addEdit(edit);
- getSearcher().findELReferences();
+ getSearcher().findELReferences(pm);
}
class MessagePropertySearcher extends ELSearcher{
12 years, 8 months
JBoss Tools SVN: r40863 - in trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb: refactoring and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-05-08 20:30:49 -0400 (Tue, 08 May 2012)
New Revision: 40863
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSearchPreferences.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELPreferenceInitializer.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/ELReferencesQueryParticipant.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
Log:
JBIDE-11682
https://issues.jboss.org/browse/JBIDE-11682
Progress monitor is passed to the searcher.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELPreferenceInitializer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELPreferenceInitializer.java 2012-05-08 23:41:06 UTC (rev 40862)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELPreferenceInitializer.java 2012-05-09 00:30:49 UTC (rev 40863)
@@ -47,5 +47,8 @@
//KB preferences
defaultPreferences.put(KBSeverityPreferences.REQUIRED_KB_CAPABILITIES_ARE_MISSING, SeverityPreferences.WARNING);
defaultPreferences.put(KBSeverityPreferences.KB_CAPABILITIES_ARE_NOT_ENABLED_IN_JAVA_MODULE, SeverityPreferences.WARNING);
+
+ //EL Search preferences
+ defaultPreferences.putInt(ELSearchPreferences.EL_SEARCH_TIME_LIMIT, 60); //60 sec
}
}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSearchPreferences.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSearchPreferences.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSearchPreferences.java 2012-05-09 00:30:49 UTC (rev 40863)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.jst.web.kb.preferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class ELSearchPreferences {
+ public static final String EL_SEARCH_TIME_LIMIT = "org.jboss.tools.jst.web.kb.preferences.elSearchTimeLimit"; //$NON-NLS-1$
+
+ public static long getElSearchTimeLimit(IProject project) {
+ IEclipsePreferences p = new ProjectScope(project).getNode(WebKbPlugin.PLUGIN_ID);
+ String result = (p == null) ? null : p.get(EL_SEARCH_TIME_LIMIT, null);
+ if(result == null) {
+ p = InstanceScope.INSTANCE.getNode(WebKbPlugin.PLUGIN_ID);
+ result = (p == null) ? null : p.get(EL_SEARCH_TIME_LIMIT, null);
+ }
+ if(result == null) {
+ result = DefaultScope.INSTANCE.getNode(WebKbPlugin.PLUGIN_ID).get(EL_SEARCH_TIME_LIMIT, "60"); //$NON-NLS-1$
+ }
+ try {
+ return Integer.parseInt(result) * 1000;
+ } catch (NumberFormatException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ return 60000;
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSearchPreferences.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/ELReferencesQueryParticipant.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/ELReferencesQueryParticipant.java 2012-05-08 23:41:06 UTC (rev 40862)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/ELReferencesQueryParticipant.java 2012-05-09 00:30:49 UTC (rev 40863)
@@ -56,7 +56,7 @@
String name = element.getElementName();
searcher = new ELSearcher(requestor, element, file, name);
searcher.setSearchScope(querySpecification.getScope());
- searcher.findELReferences();
+ searcher.findELReferences(monitor);
}
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2012-05-08 23:41:06 UTC (rev 40862)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2012-05-09 00:30:49 UTC (rev 40863)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
+ * Copyright (c) 2012 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,
@@ -22,11 +22,13 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.el.core.ELCorePlugin;
import org.jboss.tools.common.el.core.ELReference;
import org.jboss.tools.common.el.core.model.ELExpression;
@@ -34,7 +36,6 @@
import org.jboss.tools.common.el.core.model.ELMethodInvocation;
import org.jboss.tools.common.el.core.model.ELObject;
import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
-import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.el.core.resolver.ELResolution;
import org.jboss.tools.common.el.core.resolver.ELResolver;
@@ -44,11 +45,11 @@
import org.jboss.tools.common.el.core.resolver.IRelevanceCheck;
import org.jboss.tools.common.el.core.resolver.SimpleELContext;
import org.jboss.tools.common.el.core.resolver.Var;
-import org.jboss.tools.common.model.project.ProjectHome;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.BeanUtil;
import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.common.web.WebUtils;
import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.jst.web.kb.preferences.ELSearchPreferences;
public abstract class RefactorSearcher {
protected static final String JAVA_EXT = "java"; //$NON-NLS-1$
@@ -68,30 +69,40 @@
protected String propertyName;
protected IJavaElement javaElement;
protected IJavaSearchScope searchScope;
+
+ private long timeLimit = 60000; //ms use preference
+ private long timeUsed = 0;
public RefactorSearcher(IFile baseFile, String propertyName){
this.baseFile = baseFile;
this.propertyName = propertyName;
+ if(baseFile != null) {
+ timeLimit = ELSearchPreferences.getElSearchTimeLimit(baseFile.getProject());
+ }
}
public RefactorSearcher(IFile baseFile, String propertyName, IJavaElement javaElement){
this(baseFile, propertyName);
this.javaElement = javaElement;
+ if(baseFile != null) {
+ timeLimit = ELSearchPreferences.getElSearchTimeLimit(baseFile.getProject());
+ }
}
public void setSearchScope(IJavaSearchScope searchScope){
this.searchScope = searchScope;
}
- private void scanProject(IProject project){
+ private void scanProject(IProject project, IProgressMonitor monitor){
if(project == null || !project.exists()) return;
if(doneProjects.contains(project)) return;
+ if(monitor != null && monitor.isCanceled()) return;
doneProjects.add(project);
IProject[] referencingProject = project.getReferencingProjects();
for(IProject rProject: referencingProject){
- scanProject(rProject);
+ scanProject(rProject, monitor);
}
if(!containsInSearchScope(project))
@@ -99,18 +110,18 @@
updateEnvironment(project);
- IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
+ IJavaProject javaProject = EclipseUtil.getJavaProject(project);
// searching java, xml and property files in source folders
- if(javaProject != null){
- for(IResource resource : EclipseResourceUtil.getJavaSourceRoots(project)){
+ if(javaProject != null) {
+ for(IResource resource : EclipseUtil.getJavaSourceRoots(project)){
if(resource instanceof IFolder)
- if(!scanForJava((IFolder) resource)){
+ if(!scan(monitor, (IFolder) resource, true)){
outOfSynch(((IFolder) resource).getProject());
return;
}
else if(resource instanceof IFile)
- if(!scanForJava((IFile) resource)){
+ if(!scan(monitor, (IFile) resource, true)){
outOfSynch(((IFile) resource).getProject());
return;
}
@@ -120,12 +131,12 @@
// searching jsp, xhtml and xml files in WebContent folders
if(getViewFolder(project) != null){
- if(!scan(getViewFolder(project))){
+ if(!scan(monitor, getViewFolder(project), false)){
outOfSynch(project);
return;
}
}else{
- if(!scan(project)){
+ if(!scan(monitor, project, false)){
outOfSynch(project);
return;
}
@@ -134,7 +145,7 @@
private HashSet<IProject> doneProjects = new HashSet<IProject>();
- public final void findELReferences(){
+ public final void findELReferences(IProgressMonitor monitor){
if(baseFile == null)
return;
@@ -144,7 +155,7 @@
IProject[] projects = getProjects();
for (IProject project : projects) {
- scanProject(project);
+ scanProject(project, monitor);
}
//stopStatistic();
}
@@ -156,7 +167,7 @@
protected abstract IProject[] getProjects();
protected IContainer getViewFolder(IProject project) {
- IPath path = ProjectHome.getFirstWebContentPath(project);
+ IPath path = WebUtils.getFirstWebContentPath(project);
if(path != null)
return path.segmentCount() > 1 ? project.getFolder(path.removeFirstSegments(1)) : project;
@@ -164,37 +175,26 @@
return null;
}
- private boolean scanForJava(IContainer container){
- if(container.getName().startsWith(".")) //$NON-NLS-1$
+ private boolean scan(IProgressMonitor monitor, IContainer container, boolean addJava) {
+ if(monitor != null && monitor.isCanceled()) {
return true;
-
- try{
- for(IResource resource : container.members()){
- if(resource instanceof IFolder){
- if(!scanForJava((IFolder) resource))
- return false;
- }else if(resource instanceof IFile){
- if(!scanForJava((IFile) resource))
- return false;
- }
- }
- }catch(CoreException ex){
- ELCorePlugin.getDefault().logError(ex);
}
- return true;
- }
-
- private boolean scan(IContainer container){
+ if(timeUsed > timeLimit) {
+ return true;
+ }
+ if(container.isDerived()) {
+ return true;
+ }
if(container.getName().startsWith(".")) //$NON-NLS-1$
return true;
-
+
try{
for(IResource resource : container.members()){
if(resource instanceof IFolder){
- if(!scan((IFolder) resource))
+ if(!scan(monitor, (IFolder) resource, addJava))
return false;
}else if(resource instanceof IFile){
- if(!scan((IFile) resource))
+ if(!scan(monitor, (IFile) resource, addJava))
return false;
}
}
@@ -203,7 +203,7 @@
}
return true;
}
-
+
private String getFileContent(IFile file){
try {
return FileUtil.readStream(file);
@@ -221,53 +221,42 @@
* true - in order to continue searching
* false - in order to stop searching
*/
- private boolean scanForJava(IFile file){
+ private boolean scan(IProgressMonitor monitor, IFile file, boolean addJava){
if(isFilePhantom(file))
return true;
if(isFileOutOfSynch(file))
return false;
- if(PROPERTIES_EXT.equalsIgnoreCase(file.getFileExtension())){
+ if(timeUsed > timeLimit) {
+ return true;
+ }
+
+ if(monitor != null && monitor.isCanceled()) {
+ return true;
+ }
+
+ if(addJava && PROPERTIES_EXT.equalsIgnoreCase(file.getFileExtension())){
if(file.getName().equals(SEAM_PROPERTIES_FILE)){
String content = getFileContent(file);
scanProperties(file, content);
- }else
+ } else {
+ long t = System.currentTimeMillis();
searchInCach(file);
- } else if (JAVA_EXT.equalsIgnoreCase(file.getFileExtension())
+ timeUsed += System.currentTimeMillis() - t;
+ }
+ } else if ((addJava && JAVA_EXT.equalsIgnoreCase(file.getFileExtension()))
|| JSP_EXT.equalsIgnoreCase(file.getFileExtension())
|| JSPX_EXT.equalsIgnoreCase(file.getFileExtension())
|| XHTML_EXT.equalsIgnoreCase(file.getFileExtension())
|| XML_EXT.equalsIgnoreCase(file.getFileExtension())) {
+ long t = System.currentTimeMillis();
searchInCach(file);
+ timeUsed += System.currentTimeMillis() - t;
}
return true;
}
- /**
- *
- * @param file
- * @return
- * true - in order to continue searching
- * false - in order to stop searching
- */
- private boolean scan(IFile file){
- if(isFilePhantom(file))
- return true;
-
- if(isFileOutOfSynch(file))
- return false;
-
- String ext = file.getFileExtension();
- if(XML_EXT.equalsIgnoreCase(ext)
- || XHTML_EXT.equalsIgnoreCase(ext)
- || JSP_EXT.equalsIgnoreCase(ext)
- || JSPX_EXT.equalsIgnoreCase(ext)) {
- searchInCach(file);
- }
- return true;
- }
-
private void resolveByResolvers(ELExpression operand, ELResolver[] resolvers, ELContext context, IRelevanceCheck[] checks, int offset, List<MatchArea> areas, IFile file){
for (int i = 0; i < resolvers.length; i++) {
ELResolver resolver = resolvers[i];
12 years, 8 months