Author: snjeza
Date: 2011-05-25 14:44:30 -0400 (Wed, 25 May 2011)
New Revision: 31485
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/JBossRuntimeLocator.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
Log:
JBIDE-8502 Cancel button doesn't work while searching via JBoss Tools Runtime
Detection
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java 2011-05-25
18:37:46 UTC (rev 31484)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java 2011-05-25
18:44:30 UTC (rev 31485)
@@ -28,7 +28,10 @@
public ServerBean loadFromLocation(File location) {
JBossServerType type = getServerType(location);
- String version = getServerVersion(getFullServerVersion(new
File(location,type.getSystemJarPath())));
+ String version = null;
+ if (!JBossServerType.UNKNOWN.equals(type)) {
+ version = getServerVersion(getFullServerVersion(new
File(location,type.getSystemJarPath())));
+ }
ServerBean server = new ServerBean(location.getPath(),getName(location),type,version);
return server;
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2011-05-25
18:37:46 UTC (rev 31484)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2011-05-25
18:44:30 UTC (rev 31485)
@@ -140,7 +140,7 @@
@Override
public boolean isValid() {
if (super.isValid()) {
- Bundle droolsBundle = Platform.getBundle("org.eclipse.drools");
+ Bundle droolsBundle = Platform.getBundle("org.drools.eclipse");
//$NON-NLS-1$
return droolsBundle != null;
}
return false;
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2011-05-25
18:37:46 UTC (rev 31484)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2011-05-25
18:44:30 UTC (rev 31485)
@@ -57,6 +57,7 @@
import org.jboss.tools.runtime.Messages;
import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
import org.jboss.tools.runtime.core.model.ServerDefinition;
+import org.osgi.framework.Bundle;
public class JBossASHandler extends AbstractRuntimeDetector implements
IJBossRuntimePluginConstants {
@@ -395,7 +396,10 @@
}
if (SOA_P.equals(type)) {
- DroolsHandler.calculateIncludedServerDefinition(serverDefinition);
+ Bundle droolsBundle = Platform.getBundle("org.drools.eclipse");
//$NON-NLS-1$
+ if (droolsBundle != null) {
+ DroolsHandler.calculateIncludedServerDefinition(serverDefinition);
+ }
JbpmHandler.calculateIncludedServerDefinition(serverDefinition);
}
}
@@ -413,8 +417,11 @@
append(builder, includeSeam);
}
if (SOA_P.equals(type)) {
- String includeDrools = DroolsHandler.included(serverDefinition);
- append(builder, includeDrools);
+ Bundle droolsBundle = Platform.getBundle("org.drools.eclipse");
//$NON-NLS-1$
+ if (droolsBundle != null) {
+ String includeDrools = DroolsHandler.included(serverDefinition);
+ append(builder, includeDrools);
+ }
String includeJbpm = JbpmHandler.included(serverDefinition);
append(builder, includeJbpm);
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/JBossRuntimeLocator.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/JBossRuntimeLocator.java 2011-05-25
18:37:46 UTC (rev 31484)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/JBossRuntimeLocator.java 2011-05-25
18:44:30 UTC (rev 31485)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
+ * 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,
@@ -11,6 +11,7 @@
package org.jboss.tools.runtime.core;
import java.io.File;
+import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -38,61 +39,76 @@
public List<ServerDefinition> searchForRuntimes(IPath path, IProgressMonitor
monitor) {
List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
- Set<IRuntimeDetector> runtimeDetectors =
RuntimeCoreActivator.getRuntimeDetectors();
- return searchForRuntimes(serverDefinitions, path, DEPTH, runtimeDetectors, monitor);
+ searchForRuntimes(serverDefinitions, path, monitor);
+ return serverDefinitions;
}
- private List<ServerDefinition> searchForRuntimes(List<ServerDefinition>
serverDefinitions, IPath path,
- int depth, Set<IRuntimeDetector> runtimeDetectors, IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- return serverDefinitions;
- }
- File[] children = null;
+ private void searchForRuntimes(List<ServerDefinition> serverDefinitions, IPath
path,
+ IProgressMonitor monitor) {
+ File[] files = null;
if (path != null) {
File root = path.toFile();
- monitor.setTaskName("Searching " + path.toOSString());
- ServerDefinition serverDefinition = null;
- for (IRuntimeDetector detector:runtimeDetectors) {
- if (monitor.isCanceled()) {
- return serverDefinitions;
- }
- if (!detector.isEnabled()) {
- continue;
- }
- serverDefinition = detector.getServerDefinition(root, monitor);
- if (serverDefinition != null) {
- serverDefinitions.add(serverDefinition);
- break;
- }
+ if (root.isDirectory())
+ files = new File[] { root };
+ else
+ return;
+ } else
+ files = File.listRoots();
+
+ if (files != null) {
+ int size = files.length;
+ int work = 100 / size;
+ int workLeft = 100 - (work * size);
+ for (int i = 0; i < size; i++) {
+ if (monitor.isCanceled())
+ return;
+ if (files[i] != null && files[i].isDirectory())
+ searchDirectory(files[i], serverDefinitions, DEPTH, monitor);
+ monitor.worked(work);
}
- if (serverDefinition == null) {
- children = root.listFiles();
- }
+ monitor.worked(workLeft);
} else {
- children = File.listRoots();
+ monitor.worked(100);
}
- if (monitor.isCanceled()) {
- return serverDefinitions;
+ }
+
+ private void searchDirectory(File directory, List<ServerDefinition>
serverDefinitions,
+ int depth, IProgressMonitor monitor) {
+ if (depth == 0 || monitor.isCanceled() || directory == null ||
!directory.isDirectory()) {
+ return;
}
- if (depth == 0) {
- return serverDefinitions;
+
+ monitor.setTaskName("Searching " + directory.getAbsolutePath());
+
+ Set<IRuntimeDetector> runtimeDetectors =
RuntimeCoreActivator.getRuntimeDetectors();
+ for (IRuntimeDetector detector:runtimeDetectors) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+ if (!detector.isEnabled()) {
+ continue;
+ }
+ ServerDefinition serverDefinition = detector.getServerDefinition(directory, monitor);
+ if (serverDefinition != null) {
+ serverDefinitions.add(serverDefinition);
+ return;
+ }
}
- if( children != null ) {
- for( int i = 0; i < children.length; i++ ) {
- if (monitor.isCanceled()) {
- return serverDefinitions;
- }
- if( children[i].isDirectory()) {
- if (monitor.isCanceled()) {
- return serverDefinitions;
- }
- searchForRuntimes(serverDefinitions, new Path(children[i].getAbsolutePath()),
- --depth, runtimeDetectors, monitor);
- }
+
+ File[] files = directory.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ return file.isDirectory();
}
+ });
+ if (files != null) {
+ int size = files.length;
+ for (int i = 0; i < size; i++) {
+ if (monitor.isCanceled())
+ return;
+ searchDirectory(files[i], serverDefinitions, depth - 1, monitor);
+ }
}
- return serverDefinitions;
}
}