Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 150009 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/workingsets/SimpleWorkingSetSelectionDialog.java (+2 lines)
Lines 122-127 Link Here
122
	public SimpleWorkingSetSelectionDialog(Shell shell, IWorkingSet[] workingSet, String[] workingSetIDs) {
122
	public SimpleWorkingSetSelectionDialog(Shell shell, IWorkingSet[] workingSet, String[] workingSetIDs) {
123
		super(shell);
123
		super(shell);
124
		setTitle(WorkingSetMessages.SimpleWorkingSetSelectionDialog_SimpleSelectWorkingSetDialog_title);
124
		setTitle(WorkingSetMessages.SimpleWorkingSetSelectionDialog_SimpleSelectWorkingSetDialog_title);
125
		setHelpAvailable(false);
126
		setShellStyle(getShellStyle() | SWT.RESIZE);
125
		fWorkingSet= workingSet;
127
		fWorkingSet= workingSet;
126
		fWorkingSetIDs= workingSetIDs;
128
		fWorkingSetIDs= workingSetIDs;
127
	}
129
	}
(-)ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.java (-44 / +62 lines)
Lines 19-24 Link Here
19
import org.eclipse.core.runtime.IExecutableExtension;
19
import org.eclipse.core.runtime.IExecutableExtension;
20
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
21
22
import org.eclipse.swt.widgets.Display;
22
import org.eclipse.swt.widgets.Shell;
23
import org.eclipse.swt.widgets.Shell;
23
24
24
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.jface.viewers.IStructuredSelection;
Lines 77-101 Link Here
77
	public boolean performFinish() {
78
	public boolean performFinish() {
78
		boolean res= super.performFinish();
79
		boolean res= super.performFinish();
79
		if (res) {
80
		if (res) {
80
			IJavaElement newElement= getCreatedElement();
81
			final IJavaElement newElement= getCreatedElement();
81
			
82
			
82
			IWorkingSet[] workingSets= fFirstPage.getWorkingSets();
83
			IWorkingSet[] workingSets= fFirstPage.getWorkingSets();
83
			for (int i= 0; i < workingSets.length; i++) {
84
			for (int i= 0; i < workingSets.length; i++) {
84
				IWorkingSet workingSet= workingSets[i];
85
				IWorkingSet workingSet= workingSets[i];
85
				IAdaptable[] elements= workingSet.getElements();
86
				IAdaptable[] adaptedNewElements= workingSet.adaptElements(new IAdaptable[] {newElement});
86
				IAdaptable[] newElements= new IAdaptable[elements.length + 1];
87
				if (adaptedNewElements.length == 1) {
87
				System.arraycopy(elements, 0, newElements, 0, elements.length);
88
					IAdaptable[] elements= workingSet.getElements();
88
				newElements[newElements.length - 1]= newElement;
89
					IAdaptable[] newElements= new IAdaptable[elements.length + 1];
89
				workingSet.setElements(workingSet.adaptElements(newElements));
90
					System.arraycopy(elements, 0, newElements, 0, elements.length);
91
					newElements[newElements.length - 1]= adaptedNewElements[0];
92
					workingSet.setElements(newElements);
93
				}
90
			}
94
			}
91
			
95
			
92
			BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
96
			BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
93
			PackageExplorerPart activePackageExplorer= getActivePackageExplorer();
97
			selectAndReveal(fSecondPage.getJavaProject().getProject());				
94
			if (activePackageExplorer == null) {
98
			
95
				selectAndReveal(fSecondPage.getJavaProject().getProject());				
99
			Display.getDefault().asyncExec(new Runnable() {
96
			} else {
100
				public void run() {
97
				activePackageExplorer.tryToReveal(newElement);
101
					PackageExplorerPart activePackageExplorer= getActivePackageExplorer();
98
			}
102
					if (activePackageExplorer != null) {
103
						activePackageExplorer.tryToReveal(newElement);
104
					}
105
				}
106
			});
99
		}
107
		}
100
		return res;
108
		return res;
101
	}
109
	}
Lines 130-135 Link Here
130
	}
138
	}
131
	
139
	
132
	private IWorkingSet[] getWorkingSets(IStructuredSelection selection) {
140
	private IWorkingSet[] getWorkingSets(IStructuredSelection selection) {
141
		IWorkingSet selected= getSelectedWorkingSet(selection);
142
		if (selected != null)
143
			return new IWorkingSet[] {selected};
144
		
145
		PackageExplorerPart explorerPart= getActivePackageExplorer();
146
		if (explorerPart == null)
147
			return null;
148
		
149
		if (explorerPart.getRootMode() == ViewActionGroup.SHOW_PROJECTS) {				
150
			//Get active filter
151
			IWorkingSet filterWorkingSet= explorerPart.getFilterWorkingSet();
152
			if (filterWorkingSet == null)
153
				return null;
154
			
155
			if (!isValidWorkingSet(filterWorkingSet))
156
				return null;
157
			
158
			return new IWorkingSet[] {filterWorkingSet};
159
		} else if (explorerPart.getRootMode() == ViewActionGroup.SHOW_WORKING_SETS) {
160
			//If we have been gone into a working set return the working set
161
			Object input= explorerPart.getViewPartInput();
162
			if (!(input instanceof IWorkingSet))
163
				return null;
164
			
165
			IWorkingSet workingSet= (IWorkingSet)input;
166
			if (!isValidWorkingSet(workingSet))
167
				return null;
168
			
169
			return new IWorkingSet[] {workingSet};
170
		}
171
		
172
		return null;
173
	}
174
175
	private IWorkingSet getSelectedWorkingSet(IStructuredSelection selection) {
133
		if (!(selection instanceof ITreeSelection))
176
		if (!(selection instanceof ITreeSelection))
134
			return null;
177
			return null;
135
		
178
		
Lines 148-186 Link Here
148
			return null;
191
			return null;
149
192
150
		Object candidate= path.getSegment(0);
193
		Object candidate= path.getSegment(0);
151
		if (candidate instanceof IWorkingSet) {
194
		if (!(candidate instanceof IWorkingSet))
152
			if (isValidWorkingSet((IWorkingSet)candidate))
195
			return null;
153
				return new IWorkingSet[] {(IWorkingSet)candidate};
154
		} else {
155
			PackageExplorerPart explorerPart= getActivePackageExplorer();
156
			if (explorerPart == null)
157
				return null;
158
			
196
			
159
			if (explorerPart.getRootMode() == ViewActionGroup.SHOW_PROJECTS) {				
197
		IWorkingSet result= (IWorkingSet)candidate;
160
				//Get active filter
198
		if (!isValidWorkingSet(result))
161
				IWorkingSet filterWorkingSet= explorerPart.getFilterWorkingSet();
199
			return null;
162
				if (filterWorkingSet == null)
163
					return null;
164
				
165
				if (!isValidWorkingSet(filterWorkingSet))
166
					return null;
167
				
168
				return new IWorkingSet[] {filterWorkingSet};
169
			} else if (explorerPart.getRootMode() == ViewActionGroup.SHOW_WORKING_SETS) {
170
				//If we have been gone into a working set return the working set
171
				Object input= explorerPart.getViewPartInput();
172
				if (!(input instanceof IWorkingSet))
173
					return null;
174
				
175
				IWorkingSet workingSet= (IWorkingSet)input;
176
				if (!isValidWorkingSet(workingSet))
177
					return null;
178
				
179
				return new IWorkingSet[] {workingSet};
180
			}
181
		}
182
		
200
		
183
		return null;
201
		return result;
184
	}
202
	}
185
203
186
	private PackageExplorerPart getActivePackageExplorer() {
204
	private PackageExplorerPart getActivePackageExplorer() {
Lines 208-212 Link Here
208
		
226
		
209
		return true;
227
		return true;
210
	}
228
	}
211
        
229
	
212
}
230
}

Return to bug 150009