Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 126589 Details for
Bug 162102
[Workbench] User configurability for MAX_RECENT_WORKSPACES
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch that implements reading and writing of the workspaces data.
162102-patch.txt (text/plain), 16.25 KB, created by
Eric Rizzo
on 2009-02-24 14:05:21 EST
(
hide
)
Description:
Patch that implements reading and writing of the workspaces data.
Filename:
MIME Type:
Creator:
Eric Rizzo
Created:
2009-02-24 14:05:21 EST
Size:
16.25 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/plugin.properties,v >retrieving revision 1.144 >diff -u -r1.144 plugin.properties >--- plugin.properties 23 Feb 2009 23:55:43 -0000 1.144 >+++ plugin.properties 24 Feb 2009 19:01:15 -0000 >@@ -219,6 +219,7 @@ > PreferenceKeywords.Restore = restore > PreferenceKeywords.State = state > PreferenceKeywords.Encoding = encoding >+PreferenceKeywords.RecentWorkspaces = workspaces prompt recent startup > > # TODO This stuff is just to help me work on the parsing of the menus extension > # point. It is likely not in its final form yet. >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/plugin.xml,v >retrieving revision 1.285 >diff -u -r1.285 plugin.xml >--- plugin.xml 23 Feb 2009 23:55:43 -0000 1.285 >+++ plugin.xml 24 Feb 2009 19:01:16 -0000 >@@ -411,6 +411,9 @@ > id="org.eclipse.ui.ide.startupAndShutdown" > label="%PreferenceKeywords.StartupAndShutdown"/> > <keyword >+ id="org.eclipse.ui.ide.recentWorkspaces" >+ label="%PreferenceKeywords.RecentWorkspaces"/> >+ <keyword > id="org.eclipse.ui.ide.workspace" > label="%PreferenceKeywords.Workspace"/> > <keyword >@@ -2234,7 +2237,7 @@ > type="org.eclipse.core.resources.IMarker"> > </propertyTester> > </extension> >- <extension >+ <extension > point="org.eclipse.ui.installationPages"> > <page > name="%installationPage.feature.name" >Index: src/org/eclipse/ui/internal/ide/ChooseWorkspaceData.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceData.java,v >retrieving revision 1.21 >diff -u -r1.21 ChooseWorkspaceData.java >--- src/org/eclipse/ui/internal/ide/ChooseWorkspaceData.java 24 Mar 2008 19:13:35 -0000 1.21 >+++ src/org/eclipse/ui/internal/ide/ChooseWorkspaceData.java 24 Feb 2009 19:01:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2007 IBM Corporation and others. >+ * Copyright (c) 2004, 2009 IBM Corporation 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Eric Rizzo - added API to set the list of recent workspaces. > *******************************************************************************/ > package org.eclipse.ui.internal.ide; > >@@ -192,6 +193,17 @@ > } > > /** >+ * Sets the list of recent workspaces. >+ */ >+ public void setRecentWorkspaces(String[] workspaces) { >+ if (workspaces == null) { >+ recentWorkspaces = new String[0]; >+ } else { >+ recentWorkspaces = workspaces; >+ } >+ } >+ >+ /** > * Update the persistent store. Call this function after the currently > * selected value has been found to be ok. > */ >#P org.eclipse.ui.ide.application >Index: src/org/eclipse/ui/internal/ide/application/dialogs/IDEStartupPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/dialogs/IDEStartupPreferencePage.java,v >retrieving revision 1.2 >diff -u -r1.2 IDEStartupPreferencePage.java >--- src/org/eclipse/ui/internal/ide/application/dialogs/IDEStartupPreferencePage.java 16 Mar 2007 18:00:16 -0000 1.2 >+++ src/org/eclipse/ui/internal/ide/application/dialogs/IDEStartupPreferencePage.java 24 Feb 2009 19:01:17 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2007 IBM Corporation and others. >+ * Copyright (c) 2004, 2009 IBM Corporation 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Eric Rizzo - removed "prompt for workspace on startup" checkbox > *******************************************************************************/ > package org.eclipse.ui.internal.ide.application.dialogs; > >@@ -21,7 +22,6 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.IWorkbenchHelpContextIds; > import org.eclipse.ui.internal.dialogs.StartupPreferencePage; >-import org.eclipse.ui.internal.ide.ChooseWorkspaceData; > import org.eclipse.ui.internal.ide.IDEInternalPreferences; > import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; > import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; >@@ -38,8 +38,6 @@ > > private Button refreshButton; > >- private Button launchPromptButton; >- > private Button exitPromptButton; > > /* >@@ -54,7 +52,6 @@ > > Composite composite = createComposite(parent); > >- createLaunchPromptPref(composite); > createRefreshWorkspaceOnStartupPref(composite); > createExitPromptPref(composite); > >@@ -72,8 +69,6 @@ > protected void performDefaults() { > IPreferenceStore store = getIDEPreferenceStore(); > >- launchPromptButton.setSelection(true); >- > refreshButton > .setSelection(store > .getDefaultBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP)); >@@ -94,14 +89,6 @@ > store.setValue(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP, > refreshButton.getSelection()); > >- // TODO: This should get the value from the configuration preference >- // area, but dj said we shouldn't use it yet; some final details are >- // being worked out. Hopefully it will be available soon, at which time >- // the entire recentWorkspaces.xml file can be removed. But until then, >- // this preference reads/writes the file each time. >- ChooseWorkspaceData.setShowDialogValue(launchPromptButton >- .getSelection()); >- > // store the exit prompt on last window close setting > store.setValue(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, > exitPromptButton.getSelection()); >@@ -119,20 +106,6 @@ > IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP)); > } > >- protected void createLaunchPromptPref(Composite composite) { >- launchPromptButton = new Button(composite, SWT.CHECK); >- launchPromptButton.setText(IDEWorkbenchMessages.StartupPreferencePage_launchPromptButton); >- launchPromptButton.setFont(composite.getFont()); >- >- // TODO: This should get the value from the configuration preference >- // area, but dj said we shouldn't use it yet; some final details are >- // being worked out. Hopefully it will be available soon, at which time >- // the entire recentWorkspaces.xml file can be removed. But until then, >- // this preference reads/writes the file each time. >- launchPromptButton.setSelection(ChooseWorkspaceData >- .getShowDialogValue()); >- } >- > protected void createExitPromptPref(Composite composite) { > exitPromptButton = new Button(composite, SWT.CHECK); > exitPromptButton.setText(IDEWorkbenchMessages.StartupPreferencePage_exitPromptButton); >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide.application/plugin.xml,v >retrieving revision 1.9 >diff -u -r1.9 plugin.xml >--- plugin.xml 19 Jan 2009 13:42:13 -0000 1.9 >+++ plugin.xml 24 Feb 2009 19:01:17 -0000 >@@ -19,6 +19,13 @@ > id="org.eclipse.ui.preferencePages.Startup"> > <keywordReference id="org.eclipse.ui.ide.startupAndShutdown"/> > </page> >+ <page >+ name="%PreferencePages.Startup.Workspaces" >+ category="org.eclipse.ui.preferencePages.Startup" >+ class="org.eclipse.ui.internal.ide.application.dialogs.RecentWorkspacesPreferencePage" >+ id="org.eclipse.ui.preferencePages.Startup.Workspaces"> >+ <keywordReference id="org.eclipse.ui.ide.recentWorkspaces"/> >+ </page> > </extension> > <extension > point="org.eclipse.ui.perspectives"> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide.application/plugin.properties,v >retrieving revision 1.9 >diff -u -r1.9 plugin.properties >--- plugin.properties 19 Jan 2009 13:42:13 -0000 1.9 >+++ plugin.properties 24 Feb 2009 19:01:17 -0000 >@@ -12,6 +12,7 @@ > Plugin.providerName = Eclipse.org > > PreferencePages.Startup = Startup and Shutdown >+PreferencePages.Startup.Workspaces = Workspaces > > Perspective.resourcePerspective = Resource > Perspective.resourceDescription = This perspective is designed to provide general resource viewing and navigation. >Index: src/org/eclipse/ui/internal/ide/application/dialogs/RecentWorkspacesPreferencePage.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/ide/application/dialogs/RecentWorkspacesPreferencePage.java >diff -N src/org/eclipse/ui/internal/ide/application/dialogs/RecentWorkspacesPreferencePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/ide/application/dialogs/RecentWorkspacesPreferencePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,182 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Eric Rizzo 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: >+ * Eric Rizzo - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.ide.application.dialogs; >+ >+import java.util.ArrayList; >+import java.util.Arrays; >+ >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.preference.PreferencePage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.List; >+import org.eclipse.swt.widgets.Spinner; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPreferencePage; >+import org.eclipse.ui.internal.ide.ChooseWorkspaceData; >+ >+ >+/** >+ * Preference page for editing the list of recent workspaces and whether or not >+ * the user is prompted at startup. >+ * >+ * @since 3.5 >+ */ >+public class RecentWorkspacesPreferencePage extends PreferencePage >+ implements IWorkbenchPreferencePage { >+ >+ private static final int MIN_WORKSPACS = 5; >+ private static final int MAX_WORKSPACES = 99; >+ private static final int MAX_WORKSPACES_DIGIT_COUNT = 2; >+ >+ private ChooseWorkspaceData workspacesData; >+ >+ private Button promptOption; >+ private Spinner maxWorkspacesField; >+ private List workspacesList; >+ private Button removeButton; >+ >+ >+ public void init(IWorkbench workbench) { >+ workspacesData = new ChooseWorkspaceData(Platform.getInstanceLocation().getURL()); >+ } >+ >+ public Control createContents(Composite parent) { >+ Composite container = new Composite(parent, SWT.NULL); >+ final GridLayout gridLayout = new GridLayout(); >+ gridLayout.numColumns = 2; >+ gridLayout.marginHeight = 0; >+ gridLayout.marginWidth = 0; >+ container.setLayout(gridLayout); >+ >+ createPromptOption(container); >+ createMaxWorkspacesField(container); >+ createWorkspacesList(container); >+ >+ return container; >+ } >+ >+ >+ protected void createPromptOption(Composite parent) { >+ promptOption = new Button(parent, SWT.CHECK); >+ promptOption.setText("Prompt for &workspace on startup"); //$NON-NLS-1$ >+ promptOption.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); >+ >+ promptOption.setSelection(workspacesData.getShowDialog()); >+ promptOption.addSelectionListener(new SelectionAdapter(){ >+ public void widgetSelected(SelectionEvent event) { >+ workspacesData.toggleShowDialog(); >+ } >+ }); >+ } >+ >+ >+ protected void createMaxWorkspacesField(Composite parent) { >+ final Label maxWorkspacesLabel = new Label(parent, SWT.NONE); >+ maxWorkspacesLabel.setText("&Number of recent workspaces to remember:"); //$NON-NLS-1$ >+ maxWorkspacesField = new Spinner(parent, SWT.BORDER); >+ maxWorkspacesField.setTextLimit(MAX_WORKSPACES_DIGIT_COUNT); >+ maxWorkspacesField.setMinimum(MIN_WORKSPACS); >+ maxWorkspacesField.setMaximum(MAX_WORKSPACES); >+ >+ maxWorkspacesField.setSelection(workspacesData.getRecentWorkspaces().length); >+ } >+ >+ >+ protected void createWorkspacesList(Composite parent) { >+ final Group recentWorkspacesGroup = new Group(parent, SWT.NONE); >+ recentWorkspacesGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); >+ recentWorkspacesGroup.setText("Recent workspaces"); //$NON-NLS-1$ >+ final GridLayout gridLayout_1 = new GridLayout(); >+ gridLayout_1.numColumns = 2; >+ recentWorkspacesGroup.setLayout(gridLayout_1); >+ >+ workspacesList = new List(recentWorkspacesGroup, SWT.BORDER | SWT.MULTI); >+ final GridData gd_workspacesList = new GridData(SWT.FILL, SWT.FILL, true, true); >+ workspacesList.setLayoutData(gd_workspacesList); >+ >+ removeButton = new Button(recentWorkspacesGroup, SWT.NONE); >+ final GridData gd_removeButton = new GridData(SWT.CENTER, SWT.TOP, false, false); >+ removeButton.setLayoutData(gd_removeButton); >+ removeButton.setText("&Remove"); //$NON-NLS-1$ >+ removeButton.setEnabled(false); >+ >+ removeButton.addSelectionListener(new SelectionAdapter(){ >+ public void widgetSelected(SelectionEvent event) { >+ removeSelectedWorkspaces(); >+ } >+ }); >+ >+ workspacesList.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ removeButton.setEnabled(workspacesList.getSelectionCount() > 0); >+ } >+ }); >+ >+ String[] recentWorkspaces = workspacesData.getRecentWorkspaces(); >+ for (int i = 0; i < recentWorkspaces.length; i++) { >+ String aWorkspace = recentWorkspaces[i]; >+ if (aWorkspace != null) { >+ workspacesList.add(aWorkspace); >+ } >+ } >+ } >+ >+ >+ protected void removeSelectedWorkspaces() { >+ // This would be a lot less code if we could use Jakarta CollectionUtils and/or ArrayUtils >+ >+ int[] selected = workspacesList.getSelectionIndices(); >+ java.util.List workspaces = new ArrayList(Arrays.asList(workspacesList.getItems())); >+ >+ // Iterate bottom-up because removal changes indices in the list >+ for (int i = selected.length-1; i >= 0; i--) { >+ workspaces.remove(selected[i]); >+ } >+ >+ String[] newItems = new String[workspaces.size()]; >+ workspaces.toArray(newItems); >+ workspacesList.setItems(newItems); >+ } >+ >+ >+ protected void performDefaults() { >+ promptOption.setSelection(true); >+ super.performDefaults(); >+ } >+ >+ >+ public boolean performOk() { >+ int maxWorkspaces = maxWorkspacesField.getSelection(); >+ String[] workspaces = new String[maxWorkspaces]; >+ String[] listItems = workspacesList.getItems(); >+ >+ if (maxWorkspaces < listItems.length) { >+ // TODO: maybe alert the user that the list will be truncated? >+ System.arraycopy(listItems, 0, workspaces, 0, maxWorkspaces); >+ } else { >+ System.arraycopy(listItems, 0, workspaces, 0, listItems.length); >+ } >+ >+ workspacesData.setRecentWorkspaces(workspaces); >+ workspacesData.writePersistedData(); >+ return true; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 162102
:
126254
|
126255
|
126589
|
127480