[jbosstools-commits] JBoss Tools SVN: r31312 - in trunk/runtime: plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model and 3 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri May 13 19:26:18 EDT 2011


Author: snjeza
Date: 2011-05-13 19:26:18 -0400 (Fri, 13 May 2011)
New Revision: 31312

Added:
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java
   trunk/runtime/tests/org.jboss.tools.runtime.test/plugin.xml
Modified:
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
   trunk/runtime/tests/org.jboss.tools.runtime.test/build.properties
   trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java
Log:
JBIDE-8730 JBoss Tools Runtime Detection doesn't work

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java	2011-05-13 23:17:27 UTC (rev 31311)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java	2011-05-13 23:26:18 UTC (rev 31312)
@@ -28,6 +28,7 @@
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.InvalidRuntimeDetector;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.prefs.BackingStoreException;
 
@@ -113,7 +114,8 @@
 						detector = (IRuntimeDetector) configurationElement.createExecutableExtension("class");
 					} catch (CoreException e) {
 						log(e);
-						continue;
+						detector = new InvalidRuntimeDetector();
+						detector.setValid(false);
 					}
 					String name = configurationElement.getAttribute(NAME);
 					String preferenceId = configurationElement.getAttribute(PREFERENCE_ID);

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java	2011-05-13 23:17:27 UTC (rev 31311)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java	2011-05-13 23:26:18 UTC (rev 31312)
@@ -24,6 +24,7 @@
 	private String name;
 	private String preferenceId;
 	private boolean enabled;
+	private boolean valid = true;
 	private int priority;
 
 	@Override
@@ -67,6 +68,9 @@
 	}
 
 	public boolean isEnabled() {
+		if (!isValid()) {
+			return false;
+		}
 		return enabled;
 	}
 
@@ -131,4 +135,11 @@
 		
 	}
 	
+	public boolean isValid() {
+		return valid;
+	}
+
+	public void setValid(boolean valid) {
+		this.valid = valid;
+	}
 }

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java	2011-05-13 23:17:27 UTC (rev 31311)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java	2011-05-13 23:26:18 UTC (rev 31312)
@@ -49,4 +49,8 @@
 	void setPriority(int priority);
 	
 	void computeIncludedServerDefinition(ServerDefinition serverDefinition);
+	
+	boolean isValid();
+	
+	void setValid(boolean valid);
 }

Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java	2011-05-13 23:26:18 UTC (rev 31312)
@@ -0,0 +1,41 @@
+/*************************************************************************************
+ * Copyright (c) 2011 JBoss by Red Hat and others.
+ * 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:
+ *     JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core.model;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * 
+ * @author snjeza
+ *
+ */
+public class InvalidRuntimeDetector extends AbstractRuntimeDetector {
+
+	@Override
+	public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
+		
+	}
+
+	@Override
+	public ServerDefinition getServerDefinition(File root,
+			IProgressMonitor monitor) {
+		return null;
+	}
+
+	@Override
+	public boolean exists(ServerDefinition serverDefinition) {
+		return false;
+	}
+
+}

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java	2011-05-13 23:17:27 UTC (rev 31311)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java	2011-05-13 23:26:18 UTC (rev 31312)
@@ -20,6 +20,7 @@
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.layout.PixelConverter;
 import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.jface.resource.JFaceResources;
@@ -214,7 +215,7 @@
 	}
 	
 	private TableViewer createDetectorViewer(Composite parent) {
-		CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER
+		final CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER
 				| SWT.V_SCROLL | SWT.SINGLE);
 		Table table = tableViewer.getTable();
 		GridData gd = new GridData(GridData.FILL_BOTH);
@@ -243,7 +244,13 @@
 			
 			public void checkStateChanged(CheckStateChangedEvent event) {
 				IRuntimeDetector detector = (IRuntimeDetector) event.getElement();
-				detector.setEnabled(!detector.isEnabled());
+				if (detector.isValid()) {
+					detector.setEnabled(!detector.isEnabled());
+				} else {
+					MessageDialog.openWarning(getShell(), "Information", "The '" + detector.getName() + "' detector is invalid.");
+					tableViewer.setChecked(detector, false);
+				}
+				
 			}
 		});
 		for (int i=0; i<runtimeDetectors.size(); i++) {
@@ -255,6 +262,7 @@
 				if (preferenceId != null && preferenceId.trim().length() > 0) {
 					Link link = new Link(table, SWT.NONE);
 					link.setText("     <a>Link</a>");
+					link.setEnabled(detector.isValid());
 					TableEditor editor = new TableEditor (table);
 					editor.grabHorizontal = editor.grabVertical = true;
 					editor.setEditor (link, item, 1);

Modified: trunk/runtime/tests/org.jboss.tools.runtime.test/build.properties
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/build.properties	2011-05-13 23:17:27 UTC (rev 31311)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/build.properties	2011-05-13 23:26:18 UTC (rev 31312)
@@ -2,4 +2,5 @@
 output.. = bin/
 bin.includes = META-INF/,\
                .,\
-               plugin.properties
+               plugin.properties,\
+               plugin.xml

Added: trunk/runtime/tests/org.jboss.tools.runtime.test/plugin.xml
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/plugin.xml	                        (rev 0)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/plugin.xml	2011-05-13 23:26:18 UTC (rev 31312)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+	<extension
+         point="org.jboss.tools.runtime.core.runtimeDetectors">
+    	<runtimeDetector
+    		id="org.jboss.tools.runtime.handlers.InvalidHandler"
+    		name="Invalid"
+       		class="org.jboss.tools.runtime.handlers.InvalidHandler"
+       		preferenceId="org.jboss.tools.runtime.handlers.InvalidHandler"
+       		priority="9999"/>
+	</extension>
+	
+</plugin>

Modified: trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java	2011-05-13 23:17:27 UTC (rev 31311)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java	2011-05-13 23:26:18 UTC (rev 31312)
@@ -10,6 +10,7 @@
  ************************************************************************************/
 package org.jboss.tools.runtime.test;
 
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -41,6 +42,7 @@
 import org.jboss.tools.runtime.core.JBossRuntimeLocator;
 import org.jboss.tools.runtime.core.RuntimeCoreActivator;
 import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.InvalidRuntimeDetector;
 import org.jboss.tools.runtime.core.model.RuntimePath;
 import org.jboss.tools.runtime.core.model.ServerDefinition;
 import org.jboss.tools.runtime.ui.RuntimeUIActivator;
@@ -376,6 +378,18 @@
 		}
 	}
 	
+	@Test
+	public void testInvalidDetectors() {
+		Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getDeclaredRuntimeDetectors();
+		IRuntimeDetector invalidDetector = null;
+		for (IRuntimeDetector detector:detectors) {
+			if (detector instanceof InvalidRuntimeDetector) {
+				invalidDetector = detector;
+			}
+		}
+		assertFalse("Invalid detector is enabled.", invalidDetector.isEnabled());
+	}
+	
 	private String serialize(Document doc) throws TransformerException {
 		StringWriter stringWriter = new StringWriter(); 
 		Transformer serializer = TransformerFactory.newInstance().newTransformer();



More information about the jbosstools-commits mailing list