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/packageview/PackagesMessages.properties (+2 lines)
Lines 85-90 Link Here
85
85
86
PackageExplorerPart_workspace=Workspace
86
PackageExplorerPart_workspace=Workspace
87
PackageExplorerPart_workingSetModel=Working Sets
87
PackageExplorerPart_workingSetModel=Working Sets
88
PackageExplorerPart_notFoundSepcific=Cannot reveal ''{0}''. Do you want to deselect the current working set ''{1}''?
89
PackageExplorerPart_removeFiltersSpecific=Cannot reveal ''{0}''. Do you want to remove some filters to reveal the element?
88
90
89
SelectionTransferDropAdapter_error_title=Drag and drop
91
SelectionTransferDropAdapter_error_title=Drag and drop
90
SelectionTransferDropAdapter_error_message=Unexpected exception. See log for details
92
SelectionTransferDropAdapter_error_message=Unexpected exception. See log for details
(-)ui/org/eclipse/jdt/internal/ui/packageview/PackagesMessages.java (+2 lines)
Lines 57-62 Link Here
57
	public static String OpenResource_error_messageArgs;
57
	public static String OpenResource_error_messageArgs;
58
	public static String OpenResource_error_messageProblems;
58
	public static String OpenResource_error_messageProblems;
59
	public static String OpenResource_error_title;
59
	public static String OpenResource_error_title;
60
	public static String PackageExplorerPart_notFoundSepcific;
61
	public static String PackageExplorerPart_removeFiltersSpecific;
60
	public static String Sorter_expectPackage;
62
	public static String Sorter_expectPackage;
61
	public static String ShowLibraries_hideReferencedLibs;
63
	public static String ShowLibraries_hideReferencedLibs;
62
	public static String ShowLibraries_showReferencedLibs;
64
	public static String ShowLibraries_showReferencedLibs;
(-)ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java (-2 / +28 lines)
Lines 1407-1413 Link Here
1407
        if (workingSetGroup != null) {
1407
        if (workingSetGroup != null) {
1408
		    IWorkingSet workingSet= workingSetGroup.getWorkingSet();  	    
1408
		    IWorkingSet workingSet= workingSetGroup.getWorkingSet();  	    
1409
		    if (workingSetGroup.isFiltered(getVisibleParent(element), element)) {
1409
		    if (workingSetGroup.isFiltered(getVisibleParent(element), element)) {
1410
		        String message= Messages.format(PackagesMessages.PackageExplorer_notFound, workingSet.getLabel());  
1410
		    	String message;
1411
		    	if (element instanceof IJavaElement) {
1412
		    		String elementLabel= JavaElementLabels.getElementLabel((IJavaElement)element, JavaElementLabels.ALL_DEFAULT);
1413
		    		message= Messages.format(PackagesMessages.PackageExplorerPart_notFoundSepcific, new String[] {elementLabel, workingSet.getLabel()});
1414
		    	} else {
1415
		    		message= Messages.format(PackagesMessages.PackageExplorer_notFound, workingSet.getLabel());  		    		
1416
		    	}
1411
		        if (MessageDialog.openQuestion(getSite().getShell(), PackagesMessages.PackageExplorer_filteredDialog_title, message)) { 
1417
		        if (MessageDialog.openQuestion(getSite().getShell(), PackagesMessages.PackageExplorer_filteredDialog_title, message)) { 
1412
		            workingSetGroup.setWorkingSet(null, true);		
1418
		            workingSetGroup.setWorkingSet(null, true);		
1413
		            if (revealElementOrParent(element))
1419
		            if (revealElementOrParent(element))
Lines 1422-1428 Link Here
1422
        String[] currentFilters= filterGroup.internalGetEnabledFilterIds(); 
1428
        String[] currentFilters= filterGroup.internalGetEnabledFilterIds(); 
1423
        String[] newFilters= filterGroup.removeFiltersFor(getVisibleParent(element), element, getTreeViewer().getContentProvider()); 
1429
        String[] newFilters= filterGroup.removeFiltersFor(getVisibleParent(element), element, getTreeViewer().getContentProvider()); 
1424
        if (currentFilters.length > newFilters.length) {
1430
        if (currentFilters.length > newFilters.length) {
1425
            String message= PackagesMessages.PackageExplorer_removeFilters; 
1431
        	String message;
1432
        	if (element instanceof IJavaElement) {
1433
	    		String elementLabel= JavaElementLabels.getElementLabel((IJavaElement)element, JavaElementLabels.ALL_DEFAULT);
1434
	    		message= Messages.format(PackagesMessages.PackageExplorerPart_removeFiltersSpecific, elementLabel);
1435
	    	} else {
1436
	    		message= PackagesMessages.PackageExplorer_removeFilters;  		    		
1437
	    	}
1426
            if (MessageDialog.openQuestion(getSite().getShell(), PackagesMessages.PackageExplorer_filteredDialog_title, message)) { 
1438
            if (MessageDialog.openQuestion(getSite().getShell(), PackagesMessages.PackageExplorer_filteredDialog_title, message)) { 
1427
                filterGroup.setFilters(newFilters);		
1439
                filterGroup.setFilters(newFilters);		
1428
                if (revealElementOrParent(element))
1440
                if (revealElementOrParent(element))
Lines 1543-1548 Link Here
1543
			}
1555
			}
1544
		});
1556
		});
1545
	}
1557
	}
1558
	
1559
1560
	/**
1561
	 * @return the selected working set to filter if in root mode {@link ViewActionGroup#SHOW_PROJECTS}
1562
	 */
1563
	public IWorkingSet getFilterWorkingSet() {
1564
		if (!showProjects())
1565
			return null;
1566
		
1567
		if (fActionSet == null)
1568
			return null;
1569
		
1570
		return fActionSet.getWorkingSetActionGroup().getFilterGroup().getWorkingSet();
1571
	}
1546
1572
1547
	public WorkingSetModel getWorkingSetModel() {
1573
	public WorkingSetModel getWorkingSetModel() {
1548
		return fWorkingSetModel;
1574
		return fWorkingSetModel;
(-)ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.java (-56 / +55 lines)
Lines 11-19 Link Here
11
package org.eclipse.jdt.internal.ui.wizards;
11
package org.eclipse.jdt.internal.ui.wizards;
12
12
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
15
import java.util.Arrays;
16
import java.util.HashSet;
17
import java.util.List;
14
import java.util.List;
18
15
19
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
Lines 28-33 Link Here
28
import org.eclipse.jface.viewers.ITreeSelection;
25
import org.eclipse.jface.viewers.ITreeSelection;
29
import org.eclipse.jface.viewers.TreePath;
26
import org.eclipse.jface.viewers.TreePath;
30
27
28
import org.eclipse.ui.IWorkbenchPage;
31
import org.eclipse.ui.IWorkingSet;
29
import org.eclipse.ui.IWorkingSet;
32
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
30
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
33
31
Lines 38-45 Link Here
38
import org.eclipse.jdt.internal.ui.JavaPluginImages;
36
import org.eclipse.jdt.internal.ui.JavaPluginImages;
39
import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
37
import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
40
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
38
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
41
import org.eclipse.jdt.internal.ui.workingsets.OthersWorkingSetUpdater;
39
import org.eclipse.jdt.internal.ui.workingsets.JavaWorkingSetUpdater;
42
import org.eclipse.jdt.internal.ui.workingsets.WorkingSetModel;
40
import org.eclipse.jdt.internal.ui.workingsets.ViewActionGroup;
43
41
44
public class JavaProjectWizard extends NewElementWizard implements IExecutableExtension {
42
public class JavaProjectWizard extends NewElementWizard implements IExecutableExtension {
45
    
43
    
Lines 79-116 Link Here
79
	public boolean performFinish() {
77
	public boolean performFinish() {
80
		boolean res= super.performFinish();
78
		boolean res= super.performFinish();
81
		if (res) {
79
		if (res) {
80
			IJavaElement newElement= getCreatedElement();
81
			
82
			IWorkingSet[] workingSets= fFirstPage.getWorkingSets();
82
			IWorkingSet[] workingSets= fFirstPage.getWorkingSets();
83
			for (int i= 0; i < workingSets.length; i++) {
83
			for (int i= 0; i < workingSets.length; i++) {
84
				IWorkingSet workingSet= workingSets[i];
84
				IWorkingSet workingSet= workingSets[i];
85
				IAdaptable[] elements= workingSet.getElements();
85
				IAdaptable[] elements= workingSet.getElements();
86
				IAdaptable[] newElements= new IAdaptable[elements.length + 1];
86
				IAdaptable[] newElements= new IAdaptable[elements.length + 1];
87
				System.arraycopy(elements, 0, newElements, 0, elements.length);
87
				System.arraycopy(elements, 0, newElements, 0, elements.length);
88
				IJavaElement element= getCreatedElement();
88
				newElements[newElements.length - 1]= newElement;
89
				newElements[newElements.length - 1]= element;
89
				workingSet.setElements(workingSet.adaptElements(newElements));
90
				workingSet.setElements(newElements);
91
			}
92
			
93
			PackageExplorerPart explorerPart= PackageExplorerPart.getFromActivePerspective();
94
			if (explorerPart != null && workingSets.length > 0) {
95
				WorkingSetModel workingSetModel= explorerPart.getWorkingSetModel();
96
				HashSet active= new HashSet(Arrays.asList(workingSetModel.getActiveWorkingSets()));
97
				
98
				boolean hasChange= false;
99
				for (int j= 0; j < workingSets.length; j++) {
100
					IWorkingSet workingSet= workingSets[j];
101
					if (!active.contains(workingSet)) {
102
						active.add(workingSet);
103
						hasChange= true;
104
					}
105
				}
106
				
107
				if (hasChange) {
108
					workingSetModel.setActiveWorkingSets((IWorkingSet[])active.toArray(new IWorkingSet[active.size()]));
109
				}
110
			}
90
			}
111
			
91
			
112
			BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
92
			BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
113
	 		selectAndReveal(fSecondPage.getJavaProject().getProject());
93
			PackageExplorerPart activePackageExplorer= getActivePackageExplorer();
94
			if (activePackageExplorer == null) {
95
				selectAndReveal(fSecondPage.getJavaProject().getProject());				
96
			} else {
97
				activePackageExplorer.tryToReveal(newElement);
98
			}
114
		}
99
		}
115
		return res;
100
		return res;
116
	}
101
	}
Lines 167-213 Link Here
167
			if (isValidWorkingSet((IWorkingSet)candidate))
152
			if (isValidWorkingSet((IWorkingSet)candidate))
168
				return new IWorkingSet[] {(IWorkingSet)candidate};
153
				return new IWorkingSet[] {(IWorkingSet)candidate};
169
		} else {
154
		} else {
170
			PackageExplorerPart explorerPart= PackageExplorerPart.getFromActivePerspective();
155
			PackageExplorerPart explorerPart= getActivePackageExplorer();
171
			if (explorerPart == null)
156
			if (explorerPart == null)
172
				return null;
157
				return null;
173
			
158
			
174
			WorkingSetModel workingSetModel= explorerPart.getWorkingSetModel();
159
			if (explorerPart.getRootMode() == ViewActionGroup.SHOW_PROJECTS) {				
175
			if (workingSetModel == null)
160
				//Get active filter
176
				return null;
161
				IWorkingSet filterWorkingSet= explorerPart.getFilterWorkingSet();
177
			
162
				if (filterWorkingSet == null)
178
			IWorkingSet[] activeWorkingSets= workingSetModel.getActiveWorkingSets();
163
					return null;
179
164
				
180
			ArrayList result= new ArrayList();
165
				if (!isValidWorkingSet(filterWorkingSet))
181
			for (int i= 0; i < activeWorkingSets.length; i++) {
166
					return null;
182
				IWorkingSet workingSet= activeWorkingSets[i];
167
				
183
				if (contains(workingSet, candidate)) {
168
				return new IWorkingSet[] {filterWorkingSet};
184
					if (isValidWorkingSet(workingSet))
169
			} else if (explorerPart.getRootMode() == ViewActionGroup.SHOW_WORKING_SETS) {
185
						result.add(workingSet);
170
				//If we have been gone into a working set return the working set
186
				}
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};
187
			}
180
			}
188
			if (result.size() == 0)
189
				return null;
190
			
191
			return (IWorkingSet[])result.toArray(new IWorkingSet[result.size()]);
192
		}
181
		}
193
		
182
		
194
		return null;
183
		return null;
195
	}
184
	}
196
185
186
	private PackageExplorerPart getActivePackageExplorer() {
187
		PackageExplorerPart explorerPart= PackageExplorerPart.getFromActivePerspective();
188
		if (explorerPart == null)
189
			return null;
190
		
191
		IWorkbenchPage activePage= explorerPart.getViewSite().getWorkbenchWindow().getActivePage();
192
		if (activePage == null)
193
			return null;
194
		
195
		if (activePage.getActivePart() != explorerPart)
196
			return null;
197
		
198
		return explorerPart;
199
	}
200
197
	private boolean isValidWorkingSet(IWorkingSet workingSet) {
201
	private boolean isValidWorkingSet(IWorkingSet workingSet) {
198
		if (OthersWorkingSetUpdater.ID.equals(workingSet.getId()))
202
		String id= workingSet.getId();	
203
		if (!JavaWorkingSetUpdater.ID.equals(id) && !"org.eclipse.ui.resourceWorkingSetPage".equals(id)) //$NON-NLS-1$
204
			return false;
205
		
206
		if (workingSet.isAggregateWorkingSet())
199
			return false;
207
			return false;
200
		
208
		
201
		return true;
209
		return true;
202
	}
210
	}
203
204
	private boolean contains(IWorkingSet workingSet, Object candidate) {
205
		IAdaptable[] elements= workingSet.getElements();
206
		for (int i= 0; i < elements.length; i++) {
207
			if (candidate.equals(elements[i]))
208
				return true;
209
		}
210
		return false;
211
	}
212
        
211
        
213
}
212
}

Return to bug 150009