[jbosstools-commits] JBoss Tools SVN: r24586 - branches/jbosstools-3.2.0.M2/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Aug 31 18:40:47 EDT 2010


Author: snjeza
Date: 2010-08-31 18:40:47 -0400 (Tue, 31 Aug 2010)
New Revision: 24586

Modified:
   branches/jbosstools-3.2.0.M2/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java
Log:
https://jira.jboss.org/browse/JBDS-1302 Servers added during installation are not readded to a deleted workspace


Modified: branches/jbosstools-3.2.0.M2/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java
===================================================================
--- branches/jbosstools-3.2.0.M2/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java	2010-08-31 17:13:31 UTC (rev 24585)
+++ branches/jbosstools-3.2.0.M2/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java	2010-08-31 22:40:47 UTC (rev 24586)
@@ -210,19 +210,32 @@
 	}
 
 	private void saveWorkspacePreferences() {
+		Activator.getDefault().getPreferenceStore().setValue(Activator.FIRST_START, false);
 		String workspaces = getWorkspaces();
 		String newWorkspaces = "";
+		boolean addWorkspace = true;
 		if (workspaces == null || workspaces.trim().length() == 0) {
 			newWorkspaces = getWorkspace();
 		} else {
-			newWorkspaces = workspaces + "," + getWorkspace();
+			StringTokenizer tokenizer = new StringTokenizer(workspaces, ",");
+			while (tokenizer.hasMoreTokens()) {
+				String workspace = tokenizer.nextToken();
+				if (workspace.equals(getWorkspace())) {
+					addWorkspace = false;
+				}
+			}
+			if (addWorkspace) {
+				newWorkspaces = workspaces + "," + getWorkspace();
+			}
 		}
-		IEclipsePreferences prefs = getPreferences();
-		prefs.put(Activator.WORKSPACES, newWorkspaces);
-		try {
-			prefs.flush();
-		} catch (BackingStoreException e) {
-			Activator.log(e);
+		if (addWorkspace) {
+			IEclipsePreferences prefs = getPreferences();
+			prefs.put(Activator.WORKSPACES, newWorkspaces);
+			try {
+				prefs.flush();
+			} catch (BackingStoreException e) {
+				Activator.log(e);
+			}
 		}
 	}
 
@@ -230,6 +243,11 @@
 	 * @return
 	 */
 	private boolean willBeInitialized() {
+		boolean firstStart = Activator.getDefault().getPreferenceStore().getBoolean(Activator.FIRST_START);
+		if (firstStart) {
+			return true;
+		}
+	
 		String workspaces = getWorkspaces();
 		if (workspaces == null || workspaces.trim().length() == 0) {
 			return true;



More information about the jbosstools-commits mailing list