### Eclipse Workspace Patch 1.0 #P org.jboss.tools.flow.jpdl4.multipage Index: src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java =================================================================== --- src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java (revision 19919) +++ src/org/jboss/tools/flow/jpdl4/multipage/validator/Jpdl4Validator.java (working copy) @@ -36,7 +36,7 @@ clearMarkers((IFile)resource); ValidationResult validationResult = super.validate(resource, kind, state, monitor); if (!(resource instanceof IFile) || resource == null) return validationResult; - PreferencesManager manager = PreferencesManager.INSTANCE; + PreferencesManager manager = PreferencesManager.getInstance(); if (manager == null) return validationResult; String jbpmName = Activator.getDefault().getPluginPreferences().getString(Constants.JBPM_NAME); if (jbpmName == null) return validationResult; #P org.jboss.tools.jbpm.common Index: src/org/jboss/tools/jbpm/Activator.java =================================================================== --- src/org/jboss/tools/jbpm/Activator.java (revision 19917) +++ src/org/jboss/tools/jbpm/Activator.java (working copy) @@ -30,7 +30,7 @@ } public PreferencesManager getPreferencesManager() { - return PreferencesManager.INSTANCE; + return PreferencesManager.getInstance(); } public void start(BundleContext context) throws Exception { Index: src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java =================================================================== --- src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java (revision 19917) +++ src/org/jboss/tools/jbpm/preferences/AddJbpmInstallationDialog.java (working copy) @@ -185,7 +185,7 @@ } private boolean isNameAlreadyUsed() { - return PreferencesManager.INSTANCE.getJbpmInstallation(nameText.getText()) != null; + return PreferencesManager.getInstance().getJbpmInstallation(nameText.getText()) != null; } private boolean isLocationExisting() { Index: src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java =================================================================== --- src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java (revision 19917) +++ src/org/jboss/tools/jbpm/preferences/JbpmLocationsPage.java (working copy) @@ -178,7 +178,7 @@ } private void initializeInput(TableViewer viewer) { - viewer.setInput(PreferencesManager.INSTANCE); + viewer.setInput(PreferencesManager.getInstance()); checkItemToCheck(viewer); } Index: src/org/jboss/tools/jbpm/preferences/PreferencesManager.java =================================================================== --- src/org/jboss/tools/jbpm/preferences/PreferencesManager.java (revision 20652) +++ src/org/jboss/tools/jbpm/preferences/PreferencesManager.java (working copy) @@ -43,9 +43,16 @@ private Map jbpmInstallations = null; private File installationsFile = null; - public static final PreferencesManager INSTANCE = new PreferencesManager(); + private static PreferencesManager INSTANCE; - private PreferencesManager() { + public static PreferencesManager getInstance() { + if (INSTANCE == null) { + INSTANCE = new PreferencesManager(); + } + return INSTANCE; + } + + protected PreferencesManager() { initializeInstallations(); } @@ -63,7 +70,7 @@ return jbpmInstallations; } - private Preferences getPreferences() { + protected Preferences getPreferences() { return Activator.getDefault().getPluginPreferences(); } @@ -86,10 +93,10 @@ } } - private void loadInstallations() { + protected void loadInstallations(File installationsFile) { Reader reader = null; try { - reader = new FileReader(getInstallationFile()); + reader = new FileReader(installationsFile); XMLMemento memento = XMLMemento.createReadRoot(reader); IMemento[] children = memento.getChildren("installation"); for (int i = 0; i < children.length; i++) { @@ -114,6 +121,10 @@ } } + protected void loadInstallations() { + loadInstallations(getInstallationFile()); + } + public void saveInstallations() { XMLMemento memento = XMLMemento.createWriteRoot("installations"); Iterator iterator = getJbpmInstallations().keySet().iterator(); #P org.jbpm.gd.jpdl Index: plugin.xml =================================================================== --- plugin.xml (revision 19961) +++ plugin.xml (working copy) @@ -355,8 +355,9 @@ class="org.jbpm.gd.jpdl.util.JbpmClasspathContainerInitializer" id="JBPM"/> - - - - - installations = PreferencesManager.INSTANCE.getJbpmInstallationMap(); + Map installations = Jbpm3PreferencesManager.INSTANCE.getJbpmInstallationMap(); Iterator iterator = installations.keySet().iterator(); int counter = 0; while (iterator.hasNext()) { @@ -100,7 +100,7 @@ if ("jBPM3".equals(installation.version)) { counter++; combo.add(next); - if (PreferencesManager.INSTANCE.getPreferredJbpmName().equals(next)) { + if (Jbpm3PreferencesManager.INSTANCE.getPreferredJbpmName().equals(next)) { combo.select(counter - 1); } } Index: src/org/jbpm/gd/jpdl/wizard/NewProcessProjectWizard.java =================================================================== --- src/org/jbpm/gd/jpdl/wizard/NewProcessProjectWizard.java (revision 19918) +++ src/org/jbpm/gd/jpdl/wizard/NewProcessProjectWizard.java (working copy) @@ -84,8 +84,8 @@ import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; import org.eclipse.ui.part.ISetSelectionTarget; import org.jboss.tools.jbpm.preferences.JbpmInstallation; -import org.jboss.tools.jbpm.preferences.PreferencesManager; import org.jbpm.gd.jpdl.Logger; +import org.jbpm.gd.jpdl.prefs.Jbpm3PreferencesManager; import org.jbpm.gd.jpdl.util.JbpmClasspathContainer; public class NewProcessProjectWizard extends Wizard implements INewWizard { @@ -115,7 +115,7 @@ } private boolean isJbpm3RuntimeAvailable() { - Map installations = PreferencesManager.INSTANCE.getJbpmInstallationMap(); + Map installations = Jbpm3PreferencesManager.INSTANCE.getJbpmInstallationMap(); Iterator iterator = installations.keySet().iterator(); while (iterator.hasNext()) { JbpmInstallation installation = installations.get(iterator.next()); @@ -191,7 +191,7 @@ } private JbpmInstallation getJbpmInstallation() { - return PreferencesManager.INSTANCE.getJbpmInstallation(getCoreJbpmName()); + return Jbpm3PreferencesManager.INSTANCE.getJbpmInstallation(getCoreJbpmName()); } private void createJbpmLibraryContainer(IJavaProject javaProject) throws JavaModelException { @@ -258,7 +258,7 @@ } private void createSimpleProcessDefinition(IJavaProject javaProject) throws CoreException, JavaModelException, IOException { - JbpmInstallation jbpmInstallation = PreferencesManager.INSTANCE.getJbpmInstallation(getCoreJbpmName()); + JbpmInstallation jbpmInstallation = Jbpm3PreferencesManager.INSTANCE.getJbpmInstallation(getCoreJbpmName()); if (jbpmInstallation == null) return; // IFolder processesFolder = javaProject.getProject().getFolder("processes"); // if (!processesFolder.exists()) { @@ -305,7 +305,7 @@ } private void copyJbpmResources(IJavaProject javaProject) throws CoreException { - JbpmInstallation jbpmInstallation = PreferencesManager.INSTANCE.getJbpmInstallation(getCoreJbpmName()); + JbpmInstallation jbpmInstallation = Jbpm3PreferencesManager.INSTANCE.getJbpmInstallation(getCoreJbpmName()); if (jbpmInstallation == null) return; String location = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(jbpmInstallation.location); IFolder folder = javaProject.getProject().getFolder("src/main/config"); @@ -440,7 +440,7 @@ String name = configureRuntimePage.nameText.getText(); String location = configureRuntimePage.locationText.getText(); String version = "jBPM3"; - PreferencesManager.INSTANCE.initializeDefaultJbpmInstallation(name, location, version); + Jbpm3PreferencesManager.INSTANCE.initializeDefaultJbpmInstallation(name, location, version); } getContainer().updateButtons(); createJavaProject(); Index: src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizard.java =================================================================== --- src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizard.java (revision 19918) +++ src/org/jbpm/gd/jpdl/wizard/NewProcessDefinitionWizard.java (working copy) @@ -48,9 +48,9 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; import org.jboss.tools.jbpm.preferences.JbpmInstallation; -import org.jboss.tools.jbpm.preferences.PreferencesManager; import org.jbpm.gd.jpdl.Logger; import org.jbpm.gd.jpdl.Plugin; +import org.jbpm.gd.jpdl.prefs.Jbpm3PreferencesManager; public class NewProcessDefinitionWizard extends Wizard implements INewWizard { @@ -141,7 +141,7 @@ IProject project = page.getProcessFolder().getProject(); String jbpmName = project.getPersistentProperty(new QualifiedName("", "jbpmName")); if (jbpmName == null) return ""; - JbpmInstallation jbpmInstallation = PreferencesManager.INSTANCE.getJbpmInstallation(jbpmName); + JbpmInstallation jbpmInstallation = Jbpm3PreferencesManager.INSTANCE.getJbpmInstallation(jbpmName); if (jbpmInstallation == null) return ""; String location = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(jbpmInstallation.location); if (location == null) return ""; Index: src/org/jbpm/gd/jpdl/prefs/Jbpm3PreferencesManager.java =================================================================== --- src/org/jbpm/gd/jpdl/prefs/Jbpm3PreferencesManager.java (revision 0) +++ src/org/jbpm/gd/jpdl/prefs/Jbpm3PreferencesManager.java (revision 0) @@ -0,0 +1,62 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jbpm.gd.jpdl.prefs; + +import java.io.File; + +import org.jboss.tools.jbpm.Constants; +import org.jboss.tools.jbpm.preferences.PreferencesManager; +import org.jbpm.gd.jpdl.Plugin; + +public class Jbpm3PreferencesManager extends PreferencesManager { + + public static final Jbpm3PreferencesManager INSTANCE = new Jbpm3PreferencesManager(); + + protected Jbpm3PreferencesManager() { + super(); + initialize(); + } + + void initialize() { + initializeInstallations(); + initializePreferredJbpmName(); + } + + private void initializeInstallations() { + File installationsFile = + Plugin.getDefault().getStateLocation().append("jbpm-installations.xml").toFile(); + if (installationsFile.exists()) { + loadInstallations(installationsFile); + saveInstallations(); + loadInstallations(); + } + installationsFile.delete(); + } + + private void initializePreferredJbpmName() { + String preferredJbpmName = Plugin.getDefault().getPluginPreferences().getString(Constants.JBPM_NAME); + if (preferredJbpmName != null) { + setPreferredJbpmName(preferredJbpmName); + } + } + +} #P org.jboss.tools.flow.jpdl4 Index: src/org/jboss/tools/flow/jpdl4/Activator.java =================================================================== --- src/org/jboss/tools/flow/jpdl4/Activator.java (revision 19916) +++ src/org/jboss/tools/flow/jpdl4/Activator.java (working copy) @@ -30,7 +30,7 @@ } public PreferencesManager getPreferencesManager() { - return PreferencesManager.INSTANCE; + return PreferencesManager.getInstance(); } public void start(BundleContext context) throws Exception {