Author: koen.aers(a)jboss.com
Date: 2009-05-29 21:35:08 -0400 (Fri, 29 May 2009)
New Revision: 15613
Removed:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java
Log:
- allow for configurations of jbpm 4 runtimes (GPD-346)
Modified: trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF 2009-05-30
01:34:31 UTC (rev 15612)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.common/META-INF/MANIFEST.MF 2009-05-30
01:35:08 UTC (rev 15613)
@@ -10,5 +10,3 @@
org.eclipse.core.runtime;bundle-version="3.4.0"
Export-Package: org.jboss.tools.jbpm.preferences,
org.jboss.tools.jbpm.util
-Bundle-Activator: org.jboss.tools.jbpm.Activator
-Bundle-ActivationPolicy: lazy
Deleted:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java 2009-05-30
01:34:31 UTC (rev 15612)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/Activator.java 2009-05-30
01:35:08 UTC (rev 15613)
@@ -1,18 +0,0 @@
-package org.jboss.tools.jbpm;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-public class Activator extends AbstractUIPlugin {
-
- private static Activator activator;
-
- public static Activator getDefault() {
- return activator;
- }
-
- public Activator() {
- super();
- activator = this;
- }
-
-}
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java 2009-05-30
01:34:31 UTC (rev 15612)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java 2009-05-30
01:35:08 UTC (rev 15613)
@@ -22,10 +22,9 @@
package org.jboss.tools.jbpm.preferences;
-import java.io.File;
-
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.StatusDialog;
@@ -43,34 +42,29 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.jbpm.Activator;
public abstract class AddJbpmInstallationDialog extends StatusDialog {
- private static final String pluginId =
Activator.getDefault().getBundle().getSymbolicName();
+ private static final String ENTER_NAME = "Enter the name of the jBPM
installation.";
+ private static final String ENTER_LOCATION = "Enter the location of the jBPM
installation.";
+ private static final String UNEXISTING_LOCATION = "The location does not
exist.";
+ private static final String NAME_ALREADY_USED = "The name is already used.";
+ private static final String INVALID_JBPM_INSTALLATION = "This is not a valid jBPM
installation.";
- private static final IStatus enterNameStatus = new Status(
- Status.INFO, pluginId, 0, "Enter the name of the jBPM installation.",
null);
- private static final IStatus enterLocationStatus = new Status(
- Status.INFO, pluginId, 0, "Enter the location of the jBPM installation.",
null);
- private static final IStatus unExistingLocationStatus = new Status(
- Status.ERROR, pluginId, 0, "The location does not exist.", null);
- private static final IStatus nameAlreadyUsedStatus = new Status(
- Status.ERROR, pluginId, 0, "The name is already used.", null);
- private static final IStatus inValidJbpmInstallationStatus = new Status(
- Status.ERROR, pluginId, 0, "This is not a valid jBPM installation.", null);
+ private Plugin plugin;
String title;
Text nameText, locationText;
Button locationButton;
- IStatus currentStatus = enterNameStatus;
+ IStatus currentStatus; ;
String name, location;
IStatus status;
- public AddJbpmInstallationDialog(Shell parentShell) {
+ public AddJbpmInstallationDialog(Shell parentShell, Plugin plugin) {
super(parentShell);
+ this.plugin = plugin;
}
public void initialize(String t, String n, String l) {
@@ -97,7 +91,7 @@
protected Control createContents(Composite parent) {
Control result = super.createContents(parent);
- updateStatus(currentStatus);
+ updateCurrentStatus();
return result;
}
@@ -117,7 +111,6 @@
private void handleLocationChanged() {
location = locationText.getText();
updateCurrentStatus();
- updateStatus(currentStatus);
}
private void createLocationButton(Composite area) {
@@ -166,29 +159,33 @@
private void handleNameChanged() {
name = nameText.getText();
updateCurrentStatus();
- updateStatus(currentStatus);
}
+ private IStatus getStatus(int severity, String str) {
+ return new Status(severity, plugin.getBundle().getSymbolicName(), str, null);
+ }
+
private void updateCurrentStatus() {
if (isNameEmpty() && isLocationEmpty()) {
- currentStatus = enterNameStatus;
+ currentStatus = getStatus(Status.INFO, ENTER_NAME);
} else if (isNameAlreadyUsed() && !"Edit Location".equals(title)) {
- currentStatus = nameAlreadyUsedStatus;
+ currentStatus = getStatus(Status.ERROR, NAME_ALREADY_USED);
} else if (isLocationEmpty()) {
- currentStatus = enterLocationStatus;
+ currentStatus = getStatus(Status.INFO, ENTER_LOCATION);
} else if (!isLocationExisting()) {
- currentStatus = unExistingLocationStatus;
+ currentStatus = getStatus(Status.ERROR, UNEXISTING_LOCATION);
} else if (!isValidJbpmInstallation()) {
- currentStatus = inValidJbpmInstallationStatus;
+ currentStatus = getStatus(Status.ERROR, INVALID_JBPM_INSTALLATION);
} else if (isNameEmpty()) {
- currentStatus = enterNameStatus;
+ currentStatus = getStatus(Status.INFO, ENTER_NAME);
} else {
currentStatus = Status.OK_STATUS;
}
+ updateStatus(currentStatus);
}
private boolean isNameAlreadyUsed() {
- return PreferencesManager.INSTANCE.getJbpmInstallation(nameText.getText()) != null;
+ return
PreferencesManager.getPreferencesManager(plugin).getJbpmInstallation(nameText.getText())
!= null;
}
private boolean isLocationExisting() {
@@ -202,15 +199,7 @@
private boolean isLocationEmpty() {
return location == null || "".equals(location);
}
-
- private boolean isValidJbpmInstallation() {
- return getJbpmVersionInfoFile().exists();
- }
-
- private File getJbpmVersionInfoFile() {
- return new
Path(location).append("/src/resources/gpd/version.info.xml").toFile();
- }
-
+
protected void updateButtonsEnableState(IStatus status) {
Button ok = getButton(IDialogConstants.OK_ID);
if (ok != null && !ok.isDisposed())
@@ -223,7 +212,7 @@
label.setLayoutData(gridData);
label.setText("Name :");
}
-
+
public String getName() {
return name;
}
@@ -232,6 +221,7 @@
return location;
}
- public abstract String getVersion();
+ protected abstract String getVersion();
+ protected abstract boolean isValidJbpmInstallation();
}
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java 2009-05-30
01:34:31 UTC (rev 15612)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java 2009-05-30
01:35:08 UTC (rev 15613)
@@ -21,7 +21,6 @@
*/
package org.jboss.tools.jbpm.preferences;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.viewers.ColumnWeightData;
@@ -41,7 +40,7 @@
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.jboss.tools.jbpm.Activator;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.tools.jbpm.Constants;
import org.jboss.tools.jbpm.util.AutoResizeTableLayout;
@@ -49,10 +48,13 @@
private TableViewer tableViewer;
private Button addButton, editButton, removeButton;
+
+ private AbstractUIPlugin plugin;
- public JbpmLocationsPage() {
+ public JbpmLocationsPage(AbstractUIPlugin plugin) {
super();
- setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ this.plugin = plugin;
+ setPreferenceStore(plugin.getPreferenceStore());
}
protected abstract AddJbpmInstallationDialog createAddJbpmInstallationDialog(Shell
shell);
@@ -177,12 +179,12 @@
}
private void initializeInput(TableViewer viewer) {
- viewer.setInput(PreferencesManager.INSTANCE);
+ viewer.setInput(PreferencesManager.getPreferencesManager(plugin));
checkItemToCheck(viewer);
}
private void checkItemToCheck(TableViewer viewer) {
- String name = getPreferences().getString(Constants.JBPM_NAME);
+ String name = plugin.getPreferenceStore().getString(Constants.JBPM_NAME);
if (name != null) {
TableItem tableItem = getItemToCheck(viewer, name);
if (tableItem != null) {
@@ -299,7 +301,7 @@
if (item != null) {
name = item.getText(0);
}
- getPreferences().setValue(Constants.JBPM_NAME, name);
+ plugin.getPluginPreferences().setValue(Constants.JBPM_NAME, name);
return true;
}
@@ -312,7 +314,7 @@
}
public void performDefaults() {
- getPreferences().setToDefault(Constants.JBPM_NAME);
+ plugin.getPluginPreferences().setToDefault(Constants.JBPM_NAME);
PreferencesManager inputManager =
(PreferencesManager)tableViewer.getInput();
inputManager.getJbpmInstallationMap().clear();
@@ -322,9 +324,5 @@
updateButtons();
setValid(true);
}
-
- private Preferences getPreferences() {
- return Activator.getDefault().getPluginPreferences();
- }
}
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java 2009-05-30
01:34:31 UTC (rev 15612)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.common/src/org/jboss/tools/jbpm/preferences/PreferencesManager.java 2009-05-30
01:35:08 UTC (rev 15613)
@@ -31,21 +31,32 @@
import java.util.Iterator;
import java.util.Map;
+import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.XMLMemento;
-import org.jboss.tools.jbpm.Activator;
import org.jboss.tools.jbpm.Constants;
public class PreferencesManager {
- public static final PreferencesManager INSTANCE = new PreferencesManager();
+ private static Map<Plugin, PreferencesManager> managerMap = new HashMap<Plugin,
PreferencesManager>();
private Map<String, JbpmInstallation> jbpmInstallations = null;
private File installationsFile = null;
+ private Plugin plugin;
+
+ public static PreferencesManager getPreferencesManager(Plugin key) {
+ PreferencesManager preferencesManager = managerMap.get(key);
+ if (preferencesManager == null) {
+ preferencesManager = new PreferencesManager(key);
+ managerMap.put(key, preferencesManager);
+ }
+ return preferencesManager;
+ }
- private PreferencesManager() {
+ private PreferencesManager(Plugin plugin) {
+ this.plugin = plugin;
initializeInstallations();
}
@@ -63,13 +74,13 @@
return jbpmInstallations;
}
- private static Preferences getPreferences() {
- return Activator.getDefault().getPluginPreferences();
+ private Preferences getPreferences() {
+ return plugin.getPluginPreferences();
}
private void initializeInstallations() {
installationsFile =
- Activator.getDefault().getStateLocation().append("jbpm-installations.xml").toFile();
+ plugin.getStateLocation().append("jbpm-installations.xml").toFile();
if (!installationsFile.exists()) {
createInstallationsFile();
} else {