Author: snjeza
Date: 2011-05-13 18:18:50 -0400 (Fri, 13 May 2011)
New Revision: 31308
Added:
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java
Modified:
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
Log:
JBIDE-8730 JBoss Tools Runtime Detection doesn't work
Modified:
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
===================================================================
---
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java 2011-05-13
21:53:20 UTC (rev 31307)
+++
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java 2011-05-13
22:18:50 UTC (rev 31308)
@@ -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:
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
===================================================================
---
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java 2011-05-13
21:53:20 UTC (rev 31307)
+++
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java 2011-05-13
22:18:50 UTC (rev 31308)
@@ -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;
}
@@ -123,5 +127,13 @@
int p1 = this.getPriority();
int p2 = o.getPriority();
return p1 - p2;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
}
}
Modified:
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java
===================================================================
---
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java 2011-05-13
21:53:20 UTC (rev 31307)
+++
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java 2011-05-13
22:18:50 UTC (rev 31308)
@@ -47,4 +47,8 @@
int getPriority();
void setPriority(int priority);
+
+ boolean isValid();
+
+ void setValid(boolean valid);
}
Added:
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java
===================================================================
---
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java
(rev 0)
+++
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java 2011-05-13
22:18:50 UTC (rev 31308)
@@ -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:
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
===================================================================
---
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2011-05-13
21:53:20 UTC (rev 31307)
+++
branches/jbosstools-3.2.x/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2011-05-13
22:18:50 UTC (rev 31308)
@@ -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);