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 64028 Details for
Bug 150009
[build path] allow selecting a working set for new Java project
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]
fix 10
fix_150009.txt (text/plain), 24.26 KB, created by
Benno Baumgartner
on 2007-04-17 09:40:11 EDT
(
hide
)
Description:
fix 10
Filename:
MIME Type:
Creator:
Benno Baumgartner
Created:
2007-04-17 09:40:11 EDT
Size:
24.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java,v >retrieving revision 1.56 >diff -u -r1.56 NewWizardMessages.java >--- ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java 16 Apr 2007 13:24:10 -0000 1.56 >+++ ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java 17 Apr 2007 13:40:11 -0000 >@@ -56,6 +56,7 @@ > > public static String IncludeToBuildpathAction_ErrorTitle; > public static String JavaProjectWizardFirstPage_DetectGroup_differendWorkspaceCC_message; >+ public static String JavaProjectWizardFirstPage_EnableWorkingSet_button; > public static String JavaProjectWizardFirstPage_JREGroup_specific_EE; > public static String JavaProjectWizardFirstPage_WorkingSets_group; > public static String JavaProjectWizardFirstPage_WorkingSetSelection_message; >Index: ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties,v >retrieving revision 1.247 >diff -u -r1.247 NewWizardMessages.properties >--- ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties 16 Apr 2007 13:24:10 -0000 1.247 >+++ ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties 17 Apr 2007 13:40:13 -0000 >@@ -675,7 +675,7 @@ > JavaProjectWizardFirstPage_LocationGroup_title=Contents > JavaProjectWizardFirstPage_LocationGroup_external_desc=Create project from e&xisting source > JavaProjectWizardFirstPage_JREGroup_default_compliance=Use def&ault JRE (Currently ''{0}'') >-JavaProjectWizardFirstPage_WorkingSetSelection_message=The selected Working Sets will contain the new project >+JavaProjectWizardFirstPage_WorkingSetSelection_message=The new project will be added to the selected working sets: > JavaProjectWizardFirstPage_LocationGroup_workspace_desc=Create new project in &workspace > JavaProjectWizardFirstPage_LocationGroup_locationLabel_desc=&Directory: > JavaProjectWizardFirstPage_LocationGroup_browseButton_desc=B&rowse... >@@ -686,6 +686,7 @@ > JavaProjectWizardFirstPage_LayoutGroup_configure=C&onfigure Defaults... > JavaProjectWizardFirstPage_DetectGroup_message=The wizard will automatically configure the JRE and the project layout based on the specified existing source.<a></a> > JavaProjectWizardFirstPage_DetectGroup_jre_message=The current workspace uses a {1} JRE with compiler compliance level {0}. This is not recommended and either the JRE or the compiler compliance level should be changed. <a>Configure...</a> >+JavaProjectWizardFirstPage_EnableWorkingSet_button=Add project to the following working sets: > JavaProjectWizardFirstPage_DetectGroup_differendWorkspaceCC_message=The default compiler compliance level for the current workspace is {0}. The new project will use a project specific compiler compliance level of {1}.<a></a> > JavaProjectWizardFirstPage_Message_enterProjectName=Enter a project name. > JavaProjectWizardFirstPage_Message_projectAlreadyExists=A project with this name already exists. >Index: ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.java,v >retrieving revision 1.20 >diff -u -r1.20 JavaProjectWizard.java >--- ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.java 17 Apr 2007 11:12:40 -0000 1.20 >+++ ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.java 17 Apr 2007 13:40:08 -0000 >@@ -11,14 +11,24 @@ > package org.eclipse.jdt.internal.ui.wizards; > > import java.lang.reflect.InvocationTargetException; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.HashSet; >+import java.util.List; > > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExecutableExtension; > import org.eclipse.core.runtime.IProgressMonitor; > > import org.eclipse.swt.widgets.Shell; > >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.ITreeSelection; >+import org.eclipse.jface.viewers.TreePath; >+ >+import org.eclipse.ui.IWorkingSet; > import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; > > import org.eclipse.jdt.core.IJavaElement; >@@ -26,7 +36,10 @@ > > import org.eclipse.jdt.internal.ui.JavaPlugin; > import org.eclipse.jdt.internal.ui.JavaPluginImages; >+import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart; > import org.eclipse.jdt.internal.ui.util.ExceptionHandler; >+import org.eclipse.jdt.internal.ui.workingsets.OthersWorkingSetUpdater; >+import org.eclipse.jdt.internal.ui.workingsets.WorkingSetModel; > > public class JavaProjectWizard extends NewElementWizard implements IExecutableExtension { > >@@ -47,7 +60,7 @@ > public void addPages() { > super.addPages(); > fFirstPage= new JavaProjectWizardFirstPage(); >-// fFirstPage.setWorkingSets(getWorkingSets(getSelection())); >+ fFirstPage.setWorkingSets(getWorkingSets(getSelection())); > addPage(fFirstPage); > fSecondPage= new JavaProjectWizardSecondPage(fFirstPage); > addPage(fSecondPage); >@@ -66,35 +79,35 @@ > public boolean performFinish() { > boolean res= super.performFinish(); > if (res) { >-// IWorkingSet[] workingSets= fFirstPage.getWorkingSets(); >-// for (int i= 0; i < workingSets.length; i++) { >-// IWorkingSet workingSet= workingSets[i]; >-// IAdaptable[] elements= workingSet.getElements(); >-// IAdaptable[] newElements= new IAdaptable[elements.length + 1]; >-// System.arraycopy(elements, 0, newElements, 0, elements.length); >-// IJavaElement element= getCreatedElement(); >-// newElements[newElements.length - 1]= element; >-// workingSet.setElements(newElements); >-// } >-// >-// PackageExplorerPart explorerPart= PackageExplorerPart.getFromActivePerspective(); >-// if (explorerPart != null && workingSets.length > 0) { >-// WorkingSetModel workingSetModel= explorerPart.getWorkingSetModel(); >-// HashSet active= new HashSet(Arrays.asList(workingSetModel.getActiveWorkingSets())); >-// >-// boolean hasChange= false; >-// for (int j= 0; j < workingSets.length; j++) { >-// IWorkingSet workingSet= workingSets[j]; >-// if (!active.contains(workingSet)) { >-// active.add(workingSet); >-// hasChange= true; >-// } >-// } >-// >-// if (hasChange) { >-// workingSetModel.setActiveWorkingSets((IWorkingSet[])active.toArray(new IWorkingSet[active.size()])); >-// } >-// } >+ IWorkingSet[] workingSets= fFirstPage.getWorkingSets(); >+ for (int i= 0; i < workingSets.length; i++) { >+ IWorkingSet workingSet= workingSets[i]; >+ IAdaptable[] elements= workingSet.getElements(); >+ IAdaptable[] newElements= new IAdaptable[elements.length + 1]; >+ System.arraycopy(elements, 0, newElements, 0, elements.length); >+ IJavaElement element= getCreatedElement(); >+ newElements[newElements.length - 1]= element; >+ workingSet.setElements(newElements); >+ } >+ >+ PackageExplorerPart explorerPart= PackageExplorerPart.getFromActivePerspective(); >+ if (explorerPart != null && workingSets.length > 0) { >+ WorkingSetModel workingSetModel= explorerPart.getWorkingSetModel(); >+ HashSet active= new HashSet(Arrays.asList(workingSetModel.getActiveWorkingSets())); >+ >+ boolean hasChange= false; >+ for (int j= 0; j < workingSets.length; j++) { >+ IWorkingSet workingSet= workingSets[j]; >+ if (!active.contains(workingSet)) { >+ active.add(workingSet); >+ hasChange= true; >+ } >+ } >+ >+ if (hasChange) { >+ workingSetModel.setActiveWorkingSets((IWorkingSet[])active.toArray(new IWorkingSet[active.size()])); >+ } >+ } > > BasicNewProjectResourceWizard.updatePerspective(fConfigElement); > selectAndReveal(fSecondPage.getJavaProject().getProject()); >@@ -131,67 +144,70 @@ > return JavaCore.create(fFirstPage.getProjectHandle()); > } > >-// private IWorkingSet[] getWorkingSets(IStructuredSelection selection) { >-// if (!(selection instanceof ITreeSelection)) >-// return null; >-// >-// ITreeSelection treeSelection= (ITreeSelection)selection; >-// List elements= treeSelection.toList(); >-// if (elements.size() != 1) >-// return null; >-// >-// Object element= elements.get(0); >-// TreePath[] paths= treeSelection.getPathsFor(element); >-// if (paths.length != 1) >-// return null; >-// >-// TreePath path= paths[0]; >-// if (path.getSegmentCount() == 0) >-// return null; >-// >-// Object candidate= path.getSegment(0); >-// if (candidate instanceof IWorkingSet) { >-// if (isValidWorkingSet((IWorkingSet)candidate)) >-// return new IWorkingSet[] {(IWorkingSet)candidate}; >-// } else { >-// PackageExplorerPart explorerPart= PackageExplorerPart.getFromActivePerspective(); >-// if (explorerPart == null) >-// return null; >-// >-// WorkingSetModel workingSetModel= explorerPart.getWorkingSetModel(); >-// IWorkingSet[] activeWorkingSets= workingSetModel.getActiveWorkingSets(); >-// >-// ArrayList result= new ArrayList(); >-// for (int i= 0; i < activeWorkingSets.length; i++) { >-// IWorkingSet workingSet= activeWorkingSets[i]; >-// if (contains(workingSet, candidate)) { >-// if (isValidWorkingSet(workingSet)) >-// result.add(workingSet); >-// } >-// } >-// if (result.size() == 0) >-// return null; >-// >-// return (IWorkingSet[])result.toArray(new IWorkingSet[result.size()]); >-// } >-// >-// return null; >-// } >-// >-// private boolean isValidWorkingSet(IWorkingSet workingSet) { >-// if (OthersWorkingSetUpdater.ID.equals(workingSet.getId())) >-// return false; >-// >-// return true; >-// } >-// >-// private boolean contains(IWorkingSet workingSet, Object candidate) { >-// IAdaptable[] elements= workingSet.getElements(); >-// for (int i= 0; i < elements.length; i++) { >-// if (candidate.equals(elements[i])) >-// return true; >-// } >-// return false; >-// } >+ private IWorkingSet[] getWorkingSets(IStructuredSelection selection) { >+ if (!(selection instanceof ITreeSelection)) >+ return null; >+ >+ ITreeSelection treeSelection= (ITreeSelection)selection; >+ List elements= treeSelection.toList(); >+ if (elements.size() != 1) >+ return null; >+ >+ Object element= elements.get(0); >+ TreePath[] paths= treeSelection.getPathsFor(element); >+ if (paths.length != 1) >+ return null; >+ >+ TreePath path= paths[0]; >+ if (path.getSegmentCount() == 0) >+ return null; >+ >+ Object candidate= path.getSegment(0); >+ if (candidate instanceof IWorkingSet) { >+ if (isValidWorkingSet((IWorkingSet)candidate)) >+ return new IWorkingSet[] {(IWorkingSet)candidate}; >+ } else { >+ PackageExplorerPart explorerPart= PackageExplorerPart.getFromActivePerspective(); >+ if (explorerPart == null) >+ return null; >+ >+ WorkingSetModel workingSetModel= explorerPart.getWorkingSetModel(); >+ if (workingSetModel == null) >+ return null; >+ >+ IWorkingSet[] activeWorkingSets= workingSetModel.getActiveWorkingSets(); >+ >+ ArrayList result= new ArrayList(); >+ for (int i= 0; i < activeWorkingSets.length; i++) { >+ IWorkingSet workingSet= activeWorkingSets[i]; >+ if (contains(workingSet, candidate)) { >+ if (isValidWorkingSet(workingSet)) >+ result.add(workingSet); >+ } >+ } >+ if (result.size() == 0) >+ return null; >+ >+ return (IWorkingSet[])result.toArray(new IWorkingSet[result.size()]); >+ } >+ >+ return null; >+ } >+ >+ private boolean isValidWorkingSet(IWorkingSet workingSet) { >+ if (OthersWorkingSetUpdater.ID.equals(workingSet.getId())) >+ return false; >+ >+ return true; >+ } >+ >+ private boolean contains(IWorkingSet workingSet, Object candidate) { >+ IAdaptable[] elements= workingSet.getElements(); >+ for (int i= 0; i < elements.length; i++) { >+ if (candidate.equals(elements[i])) >+ return true; >+ } >+ return false; >+ } > > } >Index: ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardFirstPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardFirstPage.java,v >retrieving revision 1.48 >diff -u -r1.48 JavaProjectWizardFirstPage.java >--- ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardFirstPage.java 17 Apr 2007 11:12:40 -0000 1.48 >+++ ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardFirstPage.java 17 Apr 2007 13:40:10 -0000 >@@ -614,7 +614,7 @@ > workingSetGroup.setLayout(new GridLayout(1, false)); > > String[] workingSetIds= new String[] {JavaWorkingSetUpdater.ID, "org.eclipse.ui.resourceWorkingSetPage"}; //$NON-NLS-1$ >- fWorkingSetBlock= new WorkingSetConfigurationBlock(initialWorkingSets, workingSetIds); >+ fWorkingSetBlock= new WorkingSetConfigurationBlock(initialWorkingSets, workingSetIds, NewWizardMessages.JavaProjectWizardFirstPage_EnableWorkingSet_button, JavaPlugin.getDefault().getDialogSettings()); > fWorkingSetBlock.setDialogMessage(NewWizardMessages.JavaProjectWizardFirstPage_WorkingSetSelection_message); > fWorkingSetBlock.createContent(workingSetGroup); > } >@@ -845,8 +845,8 @@ > private String fInitialName; > > private static final String PAGE_NAME= NewWizardMessages.JavaProjectWizardFirstPage_page_pageName; >-// private WorkingSetGroup fWorkingSetGroup; >-// private IWorkingSet[] fInitWorkingSets; >+ private WorkingSetGroup fWorkingSetGroup; >+ private IWorkingSet[] fInitWorkingSets; > > /** > * Create a new <code>SimpleProjectFirstPage</code>. >@@ -884,7 +884,7 @@ > fLocationGroup= new LocationGroup(composite); > fJREGroup= new JREGroup(composite); > fLayoutGroup= new LayoutGroup(composite); >-// fWorkingSetGroup= new WorkingSetGroup(composite, fInitWorkingSets); >+ fWorkingSetGroup= new WorkingSetGroup(composite, fInitWorkingSets); > fDetectGroup= new DetectGroup(composite); > > // establish connections >@@ -999,21 +999,21 @@ > return layout; > } > >-// /** >-// * @param workingSets the initialy selected working sets or <b>null</b> >-// */ >-// public void setWorkingSets(IWorkingSet[] workingSets) { >-// if (workingSets == null) { >-// fInitWorkingSets= new IWorkingSet[0]; >-// } else { >-// fInitWorkingSets= workingSets; >-// } >-// } >-// >-// /** >-// * @return the selected working sets, not <b>null</b> >-// */ >-// public IWorkingSet[] getWorkingSets() { >-// return fWorkingSetGroup.getSelectedWorkingSets(); >-// } >+ /** >+ * @param workingSets the initialy selected working sets or <b>null</b> >+ */ >+ public void setWorkingSets(IWorkingSet[] workingSets) { >+ if (workingSets == null) { >+ fInitWorkingSets= new IWorkingSet[0]; >+ } else { >+ fInitWorkingSets= workingSets; >+ } >+ } >+ >+ /** >+ * @return the selected working sets, not <b>null</b> >+ */ >+ public IWorkingSet[] getWorkingSets() { >+ return fWorkingSetGroup.getSelectedWorkingSets(); >+ } > } >Index: ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java,v >retrieving revision 1.1 >diff -u -r1.1 WorkingSetConfigurationBlock.java >--- ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java 16 Apr 2007 13:24:10 -0000 1.1 >+++ ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java 17 Apr 2007 13:40:13 -0000 >@@ -10,6 +10,13 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.workingsets; > >+import com.ibm.icu.text.Collator; >+ >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Comparator; >+import java.util.List; >+ > import org.eclipse.core.runtime.Assert; > > import org.eclipse.swt.SWT; >@@ -20,12 +27,13 @@ > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Text; > > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.IDialogSettings; > import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.jface.window.Window; > >@@ -36,25 +44,39 @@ > > public class WorkingSetConfigurationBlock { > >+ private static final String WORKINGSET_SELECTION_HISTORY= "workingset_selection_history"; //$NON-NLS-1$ >+ private static final int MAX_HISTORY_SIZE= 5; >+ > private Label fLabel; >- private Text fText; >+ private Combo fWorkingSetCombo; > private Button fConfigure; > private IWorkingSet[] fSelectedWorkingSets; > private String[] fWorkingSetIDs; > private String fMessage; >+ private Button fEnableButton; >+ private ArrayList fSelectionHistory; >+ private final IDialogSettings fSettings; >+ private final String fEnableButtonText; > > /** > * @param preSelectedWorkingSets the working sets which are selected when showning the block, not <b>null</b> > * @param compatibleWorkingSetIds only working sets with an id in compatibleWorkingSetIds can be selected, not <b>null</b> >+ * @param enableButtonText the text shown for the enable button, not <b>null</b> >+ * @param settings to store/load the selection history, not <b>null</b> > */ >- public WorkingSetConfigurationBlock(IWorkingSet[] preSelectedWorkingSets, String[] compatibleWorkingSetIds) { >+ public WorkingSetConfigurationBlock(IWorkingSet[] preSelectedWorkingSets, String[] compatibleWorkingSetIds, String enableButtonText, IDialogSettings settings) { > Assert.isNotNull(preSelectedWorkingSets); > Assert.isNotNull(compatibleWorkingSetIds); >+ Assert.isNotNull(enableButtonText); >+ Assert.isNotNull(settings); > >+ fEnableButtonText= enableButtonText; > fSelectedWorkingSets= preSelectedWorkingSets; > fWorkingSetIDs= compatibleWorkingSetIds; >+ fSettings= settings; >+ fSelectionHistory= loadSelectionHistory(settings, compatibleWorkingSetIds); > } >- >+ > /** > * @param message the message to show to the user in the working set selection dialog > */ >@@ -66,7 +88,11 @@ > * @return the selected working sets, not <b>null</b> > */ > public IWorkingSet[] getSelectedWorkingSets() { >- return fSelectedWorkingSets; >+ if (fEnableButton.getSelection()) { >+ return fSelectedWorkingSets; >+ } else { >+ return new IWorkingSet[0]; >+ } > } > > /** >@@ -79,15 +105,22 @@ > Composite composite= new Composite(parent, SWT.NONE); > composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); > composite.setLayout(new GridLayout(numColumn, false)); >+ >+ fEnableButton= new Button(composite, SWT.CHECK); >+ fEnableButton.setText(fEnableButtonText); >+ GridData enableData= new GridData(SWT.FILL, SWT.CENTER, true, false); >+ enableData.horizontalSpan= numColumn; >+ fEnableButton.setLayoutData(enableData); >+ fEnableButton.setSelection(fSelectedWorkingSets.length > 0); > > fLabel= new Label(composite, SWT.NONE); > fLabel.setText(WorkingSetMessages.WorkingSetConfigurationBlock_WorkingSetText_name); > >- fText= new Text(composite, SWT.READ_ONLY | SWT.BORDER); >+ fWorkingSetCombo= new Combo(composite, SWT.READ_ONLY | SWT.BORDER); > GridData textData= new GridData(SWT.FILL, SWT.CENTER, true, false); > textData.horizontalSpan= numColumn - 2; > textData.horizontalIndent= 0; >- fText.setLayoutData(textData); >+ fWorkingSetCombo.setLayoutData(textData); > > fConfigure= new Button(composite, SWT.PUSH); > fConfigure.setText(WorkingSetMessages.WorkingSetConfigurationBlock_SelectWorkingSet_button); >@@ -117,7 +150,32 @@ > } > }); > >- updateWorkingSetSelection(); >+ fEnableButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateEnableState(fEnableButton.getSelection()); >+ } >+ }); >+ updateEnableState(fEnableButton.getSelection()); >+ >+ fWorkingSetCombo.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateSelectedWorkingSets(); >+ } >+ }); >+ >+ fWorkingSetCombo.setItems(getHistoryEntries()); >+ if (fSelectedWorkingSets.length == 0 && fSelectionHistory.size() > 0) { >+ fWorkingSetCombo.select(historyIndex((String)fSelectionHistory.get(0))); >+ updateSelectedWorkingSets(); >+ } else { >+ updateWorkingSetSelection(); >+ } >+ } >+ >+ private void updateEnableState(boolean enabled) { >+ fLabel.setEnabled(enabled); >+ fWorkingSetCombo.setEnabled(enabled); >+ fConfigure.setEnabled(enabled); > } > > private void updateWorkingSetSelection() { >@@ -131,8 +189,103 @@ > buf.append(ws.getLabel()); > } > } >+ >+ String currentSelection= buf.toString(); >+ int index= historyIndex(currentSelection); >+ if (index >= 0) { >+ historyInsert(currentSelection); >+ fWorkingSetCombo.select(index); >+ } else { >+ historyInsert(currentSelection); >+ fWorkingSetCombo.setItems(getHistoryEntries()); >+ fWorkingSetCombo.select(historyIndex(currentSelection)); >+ } >+ } >+ >+ private String[] getHistoryEntries() { >+ String[] history= (String[])fSelectionHistory.toArray(new String[fSelectionHistory.size()]); >+ Arrays.sort(history, new Comparator() { >+ public int compare(Object o1, Object o2) { >+ return Collator.getInstance().compare(o1, o2); >+ } >+ }); >+ return history; >+ } >+ >+ private void historyInsert(String entry) { >+ fSelectionHistory.remove(entry); >+ fSelectionHistory.add(0, entry); >+ storeSelectionHistory(fSettings); >+ } >+ >+ private int historyIndex(String entry) { >+ for (int i= 0; i < fWorkingSetCombo.getItemCount(); i++) { >+ if (fWorkingSetCombo.getItem(i).equals(entry)) >+ return i; >+ } >+ >+ return -1; >+ } >+ >+ private void updateSelectedWorkingSets() { >+ String item= fWorkingSetCombo.getItem(fWorkingSetCombo.getSelectionIndex()); >+ String[] workingSetNames= item.split(", "); //$NON-NLS-1$ >+ >+ IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager(); >+ fSelectedWorkingSets= new IWorkingSet[workingSetNames.length]; >+ for (int i= 0; i < workingSetNames.length; i++) { >+ IWorkingSet set= workingSetManager.getWorkingSet(workingSetNames[i]); >+ Assert.isNotNull(set); >+ fSelectedWorkingSets[i]= set; >+ } >+ } >+ >+ private void storeSelectionHistory(IDialogSettings settings) { >+ String[] history; >+ if (fSelectionHistory.size() > MAX_HISTORY_SIZE) { >+ List subList= fSelectionHistory.subList(0, MAX_HISTORY_SIZE); >+ history= (String[])subList.toArray(new String[subList.size()]); >+ } else { >+ history= (String[])fSelectionHistory.toArray(new String[fSelectionHistory.size()]); >+ } >+ settings.put(WORKINGSET_SELECTION_HISTORY, history); >+ } >+ >+ private ArrayList loadSelectionHistory(IDialogSettings settings, String[] compatibleWorkingSetIds) { >+ String[] strings= settings.getArray(WORKINGSET_SELECTION_HISTORY); >+ if (strings == null || strings.length == 0) >+ return new ArrayList(); >+ >+ ArrayList result= new ArrayList(); >+ >+ IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager(); >+ for (int i= 0; i < strings.length; i++) { >+ String[] workingSetNames= strings[i].split(", "); //$NON-NLS-1$ >+ boolean valid= true; >+ for (int j= 0; j < workingSetNames.length && valid; j++) { >+ IWorkingSet workingSet= workingSetManager.getWorkingSet(workingSetNames[j]); >+ if (workingSet == null) { >+ valid= false; >+ } else { >+ if (!contains(compatibleWorkingSetIds, workingSet.getId())) >+ valid= false; >+ } >+ } >+ if (valid) { >+ result.add(strings[i]); >+ } >+ } >+ >+ return result; >+ } >+ >+ private boolean contains(String[] compatibleWorkingSetIds, String id) { >+ for (int i= 0; i < compatibleWorkingSetIds.length; i++) { >+ if (compatibleWorkingSetIds[i].equals(id)) >+ return true; >+ } > >- fText.setText(buf.toString()); >+ return false; > } > > private static int getButtonWidthHint(Button button) {
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 150009
:
63899
| 64028 |
64151
|
64177