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 63899 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
fix_150009.txt (text/plain), 30.39 KB, created by
Benno Baumgartner
on 2007-04-16 09:18:50 EDT
(
hide
)
Description:
fix
Filename:
MIME Type:
Creator:
Benno Baumgartner
Created:
2007-04-16 09:18:50 EDT
Size:
30.39 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.55 >diff -u -r1.55 NewWizardMessages.java >--- ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java 11 Apr 2007 14:18:59 -0000 1.55 >+++ ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java 16 Apr 2007 13:19:13 -0000 >@@ -57,6 +57,8 @@ > public static String IncludeToBuildpathAction_ErrorTitle; > public static String JavaProjectWizardFirstPage_DetectGroup_differendWorkspaceCC_message; > public static String JavaProjectWizardFirstPage_JREGroup_specific_EE; >+ public static String JavaProjectWizardFirstPage_WorkingSets_group; >+ public static String JavaProjectWizardFirstPage_WorkingSetSelection_message; > > public static String NewElementWizard_op_error_title; > public static String NewElementWizard_op_error_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.246 >diff -u -r1.246 NewWizardMessages.properties >--- ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties 13 Apr 2007 10:13:04 -0000 1.246 >+++ ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties 16 Apr 2007 13:19:13 -0000 >@@ -675,6 +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_LocationGroup_workspace_desc=Create new project in &workspace > JavaProjectWizardFirstPage_LocationGroup_locationLabel_desc=&Directory: > JavaProjectWizardFirstPage_LocationGroup_browseButton_desc=B&rowse... >@@ -962,6 +963,7 @@ > JavaProjectWizardSecondPage_problem_restore_project=Problem while restoring backup for .project > JavaProjectWizardSecondPage_problem_restore_classpath=Problem while restoring backup for .classpath > JavaProjectWizardFirstPage_directory_message=Choose a directory for the project contents: >+JavaProjectWizardFirstPage_WorkingSets_group=Working Sets > > > UserLibraryWizardPage_title=User Library >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.17 >diff -u -r1.17 JavaProjectWizard.java >--- ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.java 13 Apr 2007 09:52:14 -0000 1.17 >+++ ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.java 16 Apr 2007 13:19:12 -0000 >@@ -11,7 +11,9 @@ > package org.eclipse.jdt.internal.ui.wizards; > > import java.lang.reflect.InvocationTargetException; >-import java.util.Iterator; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.HashSet; > import java.util.List; > > import org.eclipse.core.runtime.CoreException; >@@ -34,8 +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.JavaWorkingSetUpdater; >+import org.eclipse.jdt.internal.ui.workingsets.OthersWorkingSetUpdater; >+import org.eclipse.jdt.internal.ui.workingsets.WorkingSetModel; > > public class JavaProjectWizard extends NewElementWizard implements IExecutableExtension { > >@@ -56,6 +60,7 @@ > public void addPages() { > super.addPages(); > fFirstPage= new JavaProjectWizardFirstPage(); >+ fFirstPage.setWorkingSets(getWorkingSets(getSelection())); > addPage(fFirstPage); > fSecondPage= new JavaProjectWizardSecondPage(fFirstPage); > addPage(fSecondPage); >@@ -74,8 +79,9 @@ > public boolean performFinish() { > boolean res= super.performFinish(); > if (res) { >- IWorkingSet workingSet= getWorkingSet(getSelection()); >- if (workingSet != null && JavaWorkingSetUpdater.ID.equals(workingSet.getId())) { >+ 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); >@@ -83,13 +89,33 @@ > 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()); > } > return res; > } >- >- protected void handleFinishException(Shell shell, InvocationTargetException e) { >+ >+ protected void handleFinishException(Shell shell, InvocationTargetException e) { > String title= NewWizardMessages.JavaProjectWizard_op_error_title; > String message= NewWizardMessages.JavaProjectWizard_op_error_create_message; > ExceptionHandler.handle(e, getShell(), title, message); >@@ -118,33 +144,64 @@ > return JavaCore.create(fFirstPage.getProjectHandle()); > } > >- private IWorkingSet getWorkingSet(IStructuredSelection selection) { >+ private IWorkingSet[] getWorkingSets(IStructuredSelection selection) { > if (!(selection instanceof ITreeSelection)) > return null; >+ > ITreeSelection treeSelection= (ITreeSelection)selection; > List elements= treeSelection.toList(); >- IWorkingSet result= null; >- for (Iterator iter= elements.iterator(); iter.hasNext();) { >- Object element= iter.next(); >- if (element instanceof IWorkingSet) >- return (IWorkingSet)element; >- TreePath[] paths= treeSelection.getPathsFor(element); >- if (paths.length != 1) >- return null; >- TreePath path= paths[0]; >- if (path.getSegmentCount() != 2) >- return null; >- Object candidate= path.getSegment(0); >- if (!(candidate instanceof IWorkingSet)) >- return null; >- if (result == null) { >- result= (IWorkingSet)candidate; >- } else { >- if (result != candidate) >- return null; >+ 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(); >+ 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 result; >+ 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.46 >diff -u -r1.46 JavaProjectWizardFirstPage.java >--- ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardFirstPage.java 11 Apr 2007 14:18:59 -0000 1.46 >+++ ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardFirstPage.java 16 Apr 2007 13:19:12 -0000 >@@ -47,6 +47,7 @@ > import org.eclipse.jface.util.Policy; > import org.eclipse.jface.wizard.WizardPage; > >+import org.eclipse.ui.IWorkingSet; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.dialogs.PreferencesUtil; > >@@ -79,12 +80,14 @@ > import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; > import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField; > import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField; >+import org.eclipse.jdt.internal.ui.workingsets.JavaWorkingSetUpdater; >+import org.eclipse.jdt.internal.ui.workingsets.WorkingSetConfigurationBlock; > > /** > * The first page of the <code>SimpleProjectWizard</code>. > */ > public class JavaProjectWizardFirstPage extends WizardPage { >- >+ > /** > * Request a project name. Fires an event whenever the text field is > * changed, regardless of its content. >@@ -598,8 +601,29 @@ > > > } >- > >+ private final class WorkingSetGroup { >+ >+ private WorkingSetConfigurationBlock fWorkingSetBlock; >+ >+ public WorkingSetGroup(Composite composite, IWorkingSet[] initialWorkingSets) { >+ Group workingSetGroup= new Group(composite, SWT.NONE); >+ workingSetGroup.setFont(composite.getFont()); >+ workingSetGroup.setText(NewWizardMessages.JavaProjectWizardFirstPage_WorkingSets_group); >+ workingSetGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); >+ 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.setDialogMessage(NewWizardMessages.JavaProjectWizardFirstPage_WorkingSetSelection_message); >+ fWorkingSetBlock.createContent(workingSetGroup); >+ } >+ >+ public IWorkingSet[] getSelectedWorkingSets() { >+ return fWorkingSetBlock.getSelectedWorkingSets(); >+ } >+ } >+ > /** > * Show a warning when the project location contains files. > */ >@@ -820,7 +844,9 @@ > > private String fInitialName; > >- private static final String PAGE_NAME= NewWizardMessages.JavaProjectWizardFirstPage_page_pageName; >+ private static final String PAGE_NAME= NewWizardMessages.JavaProjectWizardFirstPage_page_pageName; >+ private WorkingSetGroup fWorkingSetGroup; >+ private IWorkingSet[] fInitWorkingSets; > > /** > * Create a new <code>SimpleProjectFirstPage</code>. >@@ -858,6 +884,7 @@ > fLocationGroup= new LocationGroup(composite); > fJREGroup= new JREGroup(composite); > fLayoutGroup= new LayoutGroup(composite); >+ fWorkingSetGroup= new WorkingSetGroup(composite, fInitWorkingSets); > fDetectGroup= new DetectGroup(composite); > > // establish connections >@@ -971,4 +998,22 @@ > } > 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(); >+ } > } >Index: ui/org/eclipse/jdt/internal/ui/actions/NewWizardsActionGroup.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/NewWizardsActionGroup.java,v >retrieving revision 1.11 >diff -u -r1.11 NewWizardsActionGroup.java >--- ui/org/eclipse/jdt/internal/ui/actions/NewWizardsActionGroup.java 13 Apr 2007 09:52:14 -0000 1.11 >+++ ui/org/eclipse/jdt/internal/ui/actions/NewWizardsActionGroup.java 16 Apr 2007 13:19:12 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.jdt.ui.IContextMenuConstants; > > import org.eclipse.jdt.internal.ui.workingsets.JavaWorkingSetUpdater; >+import org.eclipse.jdt.internal.ui.workingsets.OthersWorkingSetUpdater; > > > /** >@@ -86,7 +87,11 @@ > type == IJavaElement.TYPE; > } > if (element instanceof IWorkingSet) { >- return JavaWorkingSetUpdater.ID.equals(((IWorkingSet)element).getId()); >+ String workingSetId= ((IWorkingSet)element).getId(); >+ return >+ JavaWorkingSetUpdater.ID.equals(workingSetId) || >+ "org.eclipse.ui.resourceWorkingSetPage".equals(workingSetId) || //$NON-NLS-1$ >+ OthersWorkingSetUpdater.ID.equals(workingSetId); > } > return false; > } >Index: ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMessages.java,v >retrieving revision 1.11 >diff -u -r1.11 WorkingSetMessages.java >--- ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMessages.java 15 Mar 2007 16:06:56 -0000 1.11 >+++ ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMessages.java 16 Apr 2007 13:19:13 -0000 >@@ -53,9 +53,14 @@ > public static String ClearWorkingSetAction_toolTip; > > public static String ConfigureWorkingSetAction_label; >+ public static String SimpleWorkingSetSelectionDialog_DeselectAll_button; >+ public static String SimpleWorkingSetSelectionDialog_SelectAll_button; >+ public static String SimpleWorkingSetSelectionDialog_SimpleSelectWorkingSetDialog_title; > public static String ViewActionGroup_show_label; > public static String ViewActionGroup_projects_label; > public static String ViewActionGroup_workingSets_label; >+ public static String WorkingSetConfigurationBlock_SelectWorkingSet_button; >+ public static String WorkingSetConfigurationBlock_WorkingSetText_name; > > public static String WorkingSetModel_histroy_name; > public static String WorkingSetModel_others_name; >Index: ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMessages.properties,v >retrieving revision 1.31 >diff -u -r1.31 WorkingSetMessages.properties >--- ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMessages.properties 13 Apr 2007 08:56:51 -0000 1.31 >+++ ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMessages.properties 16 Apr 2007 13:19:13 -0000 >@@ -62,6 +62,8 @@ > WorkingSetConfigurationDialog_down_label=&Down > WorkingSetConfigurationDialog_selectAll_label=Select &All > WorkingSetConfigurationDialog_deselectAll_label=Dese&lect All >+WorkingSetConfigurationBlock_WorkingSetText_name=Working Sets: >+WorkingSetConfigurationBlock_SelectWorkingSet_button=S&elect... > > #---- open close project action ------------------------------------------------------- > OpenCloseWorkingSetAction_close_label=Clo&se Projects >@@ -77,3 +79,6 @@ > > #---- Remove action ----------------------------------------------------------- > RemoveWorkingSetElementAction_label=Remo&ve from Working Set >+SimpleWorkingSetSelectionDialog_SimpleSelectWorkingSetDialog_title=Select Working Sets >+SimpleWorkingSetSelectionDialog_SelectAll_button=Select &All >+SimpleWorkingSetSelectionDialog_DeselectAll_button=&Deselect All >Index: ui/org/eclipse/jdt/internal/ui/workingsets/SimpleWorkingSetSelectionDialog.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/workingsets/SimpleWorkingSetSelectionDialog.java >diff -N ui/org/eclipse/jdt/internal/ui/workingsets/SimpleWorkingSetSelectionDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/workingsets/SimpleWorkingSetSelectionDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,229 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.ui.workingsets; >+ >+import java.util.Arrays; >+import java.util.Hashtable; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.Assert; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Image; >+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.Shell; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTableViewer; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerFilter; >+ >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.dialogs.SelectionDialog; >+ >+public class SimpleWorkingSetSelectionDialog extends SelectionDialog { >+ >+ private static class WorkingSetLabelProvider extends LabelProvider { >+ >+ private Map fIcons; >+ >+ public WorkingSetLabelProvider() { >+ fIcons= new Hashtable(); >+ } >+ >+ public void dispose() { >+ Iterator iterator= fIcons.values().iterator(); >+ while (iterator.hasNext()) { >+ Image icon= (Image)iterator.next(); >+ icon.dispose(); >+ } >+ super.dispose(); >+ } >+ >+ public Image getImage(Object object) { >+ Assert.isTrue(object instanceof IWorkingSet); >+ IWorkingSet workingSet= (IWorkingSet)object; >+ ImageDescriptor imageDescriptor= workingSet.getImageDescriptor(); >+ if (imageDescriptor == null) >+ return null; >+ >+ Image icon= (Image)fIcons.get(imageDescriptor); >+ if (icon == null) { >+ icon= imageDescriptor.createImage(); >+ fIcons.put(imageDescriptor, icon); >+ } >+ >+ return icon; >+ } >+ >+ public String getText(Object object) { >+ Assert.isTrue(object instanceof IWorkingSet); >+ IWorkingSet workingSet= (IWorkingSet)object; >+ return workingSet.getName(); >+ } >+ >+ } >+ >+ private class Filter extends ViewerFilter { >+ >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ IWorkingSet ws= (IWorkingSet)element; >+ return accept(ws, fWorkingSetIDs) && isCompatible(ws); >+ } >+ >+ private boolean accept(IWorkingSet set, String[] workingSetIDs) { >+ for (int i= 0; i < workingSetIDs.length; i++) { >+ if (workingSetIDs[i].equals(set.getId())) >+ return true; >+ } >+ >+ return false; >+ } >+ >+ private boolean isCompatible(IWorkingSet set) { >+ if (!set.isSelfUpdating() || set.isAggregateWorkingSet()) >+ return false; >+ >+ if (!set.isVisible()) >+ return false; >+ >+ return true; >+ } >+ >+ } >+ >+ private final IWorkingSet[] fWorkingSet; >+ private IWorkingSet[] fSelectedWorkingSets; >+ private CheckboxTableViewer fTableViewer; >+ private final String[] fWorkingSetIDs; >+ private Button fSelectAll; >+ private Button fDeselectAll; >+ >+ public SimpleWorkingSetSelectionDialog(Shell shell, IWorkingSet[] workingSet, String[] workingSetIDs) { >+ super(shell); >+ setTitle(WorkingSetMessages.SimpleWorkingSetSelectionDialog_SimpleSelectWorkingSetDialog_title); >+ fWorkingSet= workingSet; >+ fWorkingSetIDs= workingSetIDs; >+ } >+ >+ protected Control createDialogArea(Composite parent) { >+ Composite composite= (Composite)super.createDialogArea(parent); >+ composite.setFont(parent.getFont()); >+ >+ createMessageArea(composite); >+ Composite inner= new Composite(composite, SWT.NONE); >+ inner.setFont(composite.getFont()); >+ inner.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ GridLayout layout= new GridLayout(); >+ layout.numColumns= 2; >+ layout.marginHeight= 0; >+ layout.marginWidth= 0; >+ inner.setLayout(layout); >+ createTableViewer(inner); >+ createSelectionButtons(inner); >+ >+ return composite; >+ } >+ >+ public void setSelection(IWorkingSet[] selectedWorkingSets) { >+ fSelectedWorkingSets= selectedWorkingSets; >+ } >+ >+ public IWorkingSet[] getSelection() { >+ return fSelectedWorkingSets; >+ } >+ >+ private void createTableViewer(Composite parent) { >+ fTableViewer= CheckboxTableViewer.newCheckList(parent, SWT.BORDER | SWT.MULTI); >+ fTableViewer.addCheckStateListener(new ICheckStateListener() { >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ checkedStateChanged(); >+ } >+ }); >+ GridData data= new GridData(GridData.FILL_BOTH); >+ data.heightHint= convertHeightInCharsToPixels(20); >+ data.widthHint= convertWidthInCharsToPixels(50); >+ fTableViewer.getTable().setLayoutData(data); >+ fTableViewer.getTable().setFont(parent.getFont()); >+ >+ fTableViewer.addFilter(new Filter()); >+ fTableViewer.setLabelProvider(new WorkingSetLabelProvider()); >+ fTableViewer.setContentProvider(new IStructuredContentProvider() { >+ public Object[] getElements(Object element) { >+ return (Object[])element; >+ } >+ public void dispose() { >+ } >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ }); >+ >+ fTableViewer.setInput(fWorkingSet); >+ fTableViewer.setCheckedElements(fSelectedWorkingSets); >+ } >+ >+ private void createSelectionButtons(Composite parent) { >+ Composite buttons= new Composite(parent, SWT.NONE); >+ buttons.setFont(parent.getFont()); >+ buttons.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >+ GridLayout layout= new GridLayout(); >+ layout.marginHeight= 0; >+ layout.marginWidth= 0; >+ buttons.setLayout(layout); >+ >+ fSelectAll= new Button(buttons, SWT.PUSH); >+ fSelectAll.setText(WorkingSetMessages.SimpleWorkingSetSelectionDialog_SelectAll_button); >+ fSelectAll.setFont(parent.getFont()); >+ setButtonLayoutData(fSelectAll); >+ fSelectAll.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ selectAll(); >+ } >+ }); >+ >+ fDeselectAll= new Button(buttons, SWT.PUSH); >+ fDeselectAll.setText(WorkingSetMessages.SimpleWorkingSetSelectionDialog_DeselectAll_button); >+ fDeselectAll.setFont(parent.getFont()); >+ setButtonLayoutData(fDeselectAll); >+ fDeselectAll.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ deselectAll(); >+ } >+ }); >+ } >+ >+ private void checkedStateChanged() { >+ List elements= Arrays.asList(fTableViewer.getCheckedElements()); >+ fSelectedWorkingSets= (IWorkingSet[])elements.toArray(new IWorkingSet[elements.size()]); >+ } >+ >+ private void selectAll() { >+ fTableViewer.setAllChecked(true); >+ checkedStateChanged(); >+ } >+ >+ private void deselectAll() { >+ fTableViewer.setAllChecked(false); >+ checkedStateChanged(); >+ } >+} >Index: ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java >diff -N ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,149 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.ui.workingsets; >+ >+import org.eclipse.core.runtime.Assert; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; >+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.Label; >+import org.eclipse.swt.widgets.Text; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.jface.window.Window; >+ >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.IWorkingSetManager; >+import org.eclipse.ui.PlatformUI; >+ >+ >+public class WorkingSetConfigurationBlock { >+ >+ private Label fLabel; >+ private Text fText; >+ private Button fConfigure; >+ private IWorkingSet[] fSelectedWorkingSets; >+ private String[] fWorkingSetIDs; >+ private String fMessage; >+ >+ /** >+ * @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> >+ */ >+ public WorkingSetConfigurationBlock(IWorkingSet[] preSelectedWorkingSets, String[] compatibleWorkingSetIds) { >+ Assert.isNotNull(preSelectedWorkingSets); >+ Assert.isNotNull(compatibleWorkingSetIds); >+ >+ fSelectedWorkingSets= preSelectedWorkingSets; >+ fWorkingSetIDs= compatibleWorkingSetIds; >+ } >+ >+ /** >+ * @param message the message to show to the user in the working set selection dialog >+ */ >+ public void setDialogMessage(String message) { >+ fMessage= message; >+ } >+ >+ /** >+ * @return the selected working sets, not <b>null</b> >+ */ >+ public IWorkingSet[] getSelectedWorkingSets() { >+ return fSelectedWorkingSets; >+ } >+ >+ /** >+ * Add this block to the <code>parent</parent> >+ * @param parent the parent to add the block to, not <b>null</b> >+ */ >+ public void createContent(final Composite parent) { >+ int numColumn= 3; >+ >+ Composite composite= new Composite(parent, SWT.NONE); >+ composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); >+ composite.setLayout(new GridLayout(numColumn, false)); >+ >+ fLabel= new Label(composite, SWT.NONE); >+ fLabel.setText(WorkingSetMessages.WorkingSetConfigurationBlock_WorkingSetText_name); >+ >+ fText= new Text(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); >+ >+ fConfigure= new Button(composite, SWT.PUSH); >+ fConfigure.setText(WorkingSetMessages.WorkingSetConfigurationBlock_SelectWorkingSet_button); >+ GridData configureData= new GridData(SWT.LEFT, SWT.CENTER, false, false); >+ configureData.widthHint= getButtonWidthHint(fConfigure); >+ fConfigure.setLayoutData(configureData); >+ fConfigure.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager(); >+ IWorkingSet[] workingSets= manager.getWorkingSets(); >+ SimpleWorkingSetSelectionDialog dialog= new SimpleWorkingSetSelectionDialog(parent.getShell(), workingSets, fWorkingSetIDs); >+ dialog.setSelection(fSelectedWorkingSets); >+ if (fMessage != null) >+ dialog.setMessage(fMessage); >+ >+ if (dialog.open() == Window.OK) { >+ IWorkingSet[] result= dialog.getSelection(); >+ if (result != null && result.length > 0) { >+ fSelectedWorkingSets= result; >+ manager.addRecentWorkingSet(result[0]); >+ } else { >+ fSelectedWorkingSets= new IWorkingSet[0]; >+ } >+ updateWorkingSetSelection(); >+ } >+ } >+ }); >+ >+ updateWorkingSetSelection(); >+ } >+ >+ private void updateWorkingSetSelection() { >+ StringBuffer buf= new StringBuffer(); >+ >+ if (fSelectedWorkingSets.length > 0) { >+ buf.append(fSelectedWorkingSets[0].getLabel()); >+ for (int i= 1; i < fSelectedWorkingSets.length; i++) { >+ IWorkingSet ws= fSelectedWorkingSets[i]; >+ buf.append(',').append(' '); >+ buf.append(ws.getLabel()); >+ } >+ } >+ >+ fText.setText(buf.toString()); >+ } >+ >+ private static int getButtonWidthHint(Button button) { >+ button.setFont(JFaceResources.getDialogFont()); >+ >+ GC gc = new GC(button); >+ gc.setFont(button.getFont()); >+ FontMetrics fontMetrics= gc.getFontMetrics(); >+ gc.dispose(); >+ >+ int widthHint= Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); >+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); >+ } >+}
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