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 56431 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java (+1 lines)
Lines 80-85 Link Here
80
80
81
	// Persistance tags.
81
	// Persistance tags.
82
	public static final String TAG_ID = "id"; //$NON-NLS-1$
82
	public static final String TAG_ID = "id"; //$NON-NLS-1$
83
	public static final String TAG_SECONDARY_ID = "secondaryId"; //$NON-NLS-1$
83
	public static final String TAG_FOCUS = "focus"; //$NON-NLS-1$
84
	public static final String TAG_FOCUS = "focus"; //$NON-NLS-1$
84
	public static final String TAG_EDITOR = "editor"; //$NON-NLS-1$
85
	public static final String TAG_EDITOR = "editor"; //$NON-NLS-1$
85
	public static final String TAG_DELETED_EDITOR = "deletedEditor"; //$NON-NLS-1$
86
	public static final String TAG_DELETED_EDITOR = "deletedEditor"; //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java (+12 lines)
Lines 223-228 Link Here
223
223
224
}
224
}
225
/**
225
/**
226
 * Adds the child using ratio and position attributes
227
 * from the specified placeholder without replacing
228
 * the placeholder
229
 */
230
void addChildForPlaceholder(LayoutPart part, LayoutPart placeholder) {
231
	//FIXME we need to get the relation and ratio 
232
	// from the placholder
233
	add(part, SWT.RIGHT, 0.5f, placeholder);
234
	root.updateSashes(parent);
235
	resizeSashes(parent.getClientArea());
236
}
237
/**
226
 * See ILayoutContainer#allowBorder
238
 * See ILayoutContainer#allowBorder
227
 */
239
 */
228
public boolean allowsBorder() {
240
public boolean allowsBorder() {
(-)Eclipse UI/org/eclipse/ui/internal/Perspective.java (-9 / +21 lines)
Lines 120-126 Link Here
120
	if (!isFastView(ref)) {
120
	if (!isFastView(ref)) {
121
		// Only remove the part from the presentation if it
121
		// Only remove the part from the presentation if it
122
		// is actually in the presentation.
122
		// is actually in the presentation.
123
		if (presentation.hasPlaceholder(pane.getID()) ||
123
		if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId()) ||
124
			pane.getContainer() != null)
124
			pane.getContainer() != null)
125
				presentation.removePart(pane);
125
				presentation.removePart(pane);
126
		// We are drag-enabling the pane because it has been disabled
126
		// We are drag-enabling the pane because it has been disabled
Lines 730-740 Link Here
730
	for (int x = 0; x < views.length; x ++) {
730
	for (int x = 0; x < views.length; x ++) {
731
		// Get the view details.
731
		// Get the view details.
732
		IMemento childMem = views[x];
732
		IMemento childMem = views[x];
733
		String viewID = childMem.getString(IWorkbenchConstants.TAG_ID);
733
		String primaryId = childMem.getString(IWorkbenchConstants.TAG_ID);
734
		String secondaryId = childMem.getString(IWorkbenchConstants.TAG_SECONDARY_ID);
734
		// Create and open the view.
735
		// Create and open the view.
735
		try {
736
		try {
736
			if(!"true".equals(childMem.getString(IWorkbenchConstants.TAG_REMOVED))) //$NON-NLS-1$
737
			if(!"true".equals(childMem.getString(IWorkbenchConstants.TAG_REMOVED))) { //$NON-NLS-1$
737
				viewFactory.createView(viewID);
738
				viewFactory.createView(primaryId, secondaryId);
739
			}
738
		} catch (PartInitException e) {
740
		} catch (PartInitException e) {
739
			childMem.putString(IWorkbenchConstants.TAG_REMOVED,"true"); //$NON-NLS-1$
741
			childMem.putString(IWorkbenchConstants.TAG_REMOVED,"true"); //$NON-NLS-1$
740
			result.add(new Status(IStatus.ERROR,PlatformUI.PLUGIN_ID,0,e.getMessage(),e));
742
			result.add(new Status(IStatus.ERROR,PlatformUI.PLUGIN_ID,0,e.getMessage(),e));
Lines 786-801 Link Here
786
	for (int x = 0; x < views.length; x ++) {
788
	for (int x = 0; x < views.length; x ++) {
787
		// Get the view details.
789
		// Get the view details.
788
		IMemento childMem = views[x];
790
		IMemento childMem = views[x];
789
		String viewID = childMem.getString(IWorkbenchConstants.TAG_ID);
791
		String primaryId = childMem.getString(IWorkbenchConstants.TAG_ID);
790
		if (viewID.equals(IIntroConstants.INTRO_VIEW_ID))
792
		String secondaryId = childMem.getString(IWorkbenchConstants.TAG_SECONDARY_ID);
793
		if (primaryId.equals(IIntroConstants.INTRO_VIEW_ID))
791
			continue;
794
			continue;
792
795
793
		// Create and open the view.
796
		// Create and open the view.
794
		WorkbenchPartReference ref = (WorkbenchPartReference)viewFactory.getView(viewID);
797
		WorkbenchPartReference ref = (WorkbenchPartReference)viewFactory.getView(primaryId, secondaryId);
798
		
799
		// report error
795
		if(ref == null) {
800
		if(ref == null) {
801
			String[] viewIds;
802
			if (secondaryId != null)
803
				viewIds = new String[]{primaryId};
804
			else
805
				viewIds = new String[]{primaryId+":"+secondaryId}; //$NON-NLS-1$		
796
			result.add(new Status(
806
			result.add(new Status(
797
				Status.ERROR,PlatformUI.PLUGIN_ID,0,
807
				Status.ERROR,PlatformUI.PLUGIN_ID,0,
798
				WorkbenchMessages.format("Perspective.couldNotFind", new String[]{viewID}), //$NON-NLS-1$
808
				WorkbenchMessages.format("Perspective.couldNotFind", viewIds), //$NON-NLS-1$
799
				null));
809
				null));
800
			continue;
810
			continue;
801
		}
811
		}
Lines 1137-1142 Link Here
1137
		IViewReference ref = pane.getViewReference();
1147
		IViewReference ref = pane.getViewReference();
1138
		IMemento viewMemento = memento.createChild(IWorkbenchConstants.TAG_VIEW);
1148
		IMemento viewMemento = memento.createChild(IWorkbenchConstants.TAG_VIEW);
1139
		viewMemento.putString(IWorkbenchConstants.TAG_ID, ref.getId());
1149
		viewMemento.putString(IWorkbenchConstants.TAG_ID, ref.getId());
1150
		if (ref.getSecondaryId() != null)
1151
			viewMemento.putString(IWorkbenchConstants.TAG_SECONDARY_ID, ref.getSecondaryId());
1140
	}
1152
	}
1141
1153
1142
	if(fastViews.size() > 0) {
1154
	if(fastViews.size() > 0) {
Lines 1417-1423 Link Here
1417
	
1429
	
1418
	IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
1430
	IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
1419
	int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
1431
	int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
1420
	if (presentation.hasPlaceholder(viewId)) {
1432
	if (presentation.hasPlaceholder(viewId, secondaryId)) {
1421
		presentation.addPart(pane);
1433
		presentation.addPart(pane);
1422
	} else if (openViewMode == IPreferenceConstants.OVM_EMBED) {
1434
	} else if (openViewMode == IPreferenceConstants.OVM_EMBED) {
1423
		presentation.addPart(pane);
1435
		presentation.addPart(pane);
(-)Eclipse UI/org/eclipse/ui/internal/PerspectivePresentation.java (-15 / +197 lines)
Lines 14-19 Link Here
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Enumeration;
15
import java.util.Enumeration;
16
import java.util.List;
16
import java.util.List;
17
import java.util.StringTokenizer;
17
import java.util.Vector;
18
import java.util.Vector;
18
19
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.IStatus;
Lines 31-36 Link Here
31
import org.eclipse.ui.internal.dnd.DragUtil;
32
import org.eclipse.ui.internal.dnd.DragUtil;
32
import org.eclipse.ui.internal.dnd.IDragOverListener;
33
import org.eclipse.ui.internal.dnd.IDragOverListener;
33
import org.eclipse.ui.internal.dnd.IDropTarget;
34
import org.eclipse.ui.internal.dnd.IDropTarget;
35
import org.eclipse.ui.internal.misc.StringMatcher;
34
36
35
/**
37
/**
36
 * A perspective presentation is a collection of parts with a layout. Each part
38
 * A perspective presentation is a collection of parts with a layout. Each part
Lines 51-63 Link Here
51
	private ArrayList detachedWindowList = new ArrayList(1);
53
	private ArrayList detachedWindowList = new ArrayList(1);
52
	private ArrayList detachedPlaceHolderList = new ArrayList(1);
54
	private ArrayList detachedPlaceHolderList = new ArrayList(1);
53
	private boolean detachable = false;
55
	private boolean detachable = false;
54
56
	
55
	private boolean active = false;
57
	private boolean active = false;
56
	// key is the LayoutPart object, value is the PartDragDrop object
58
	// key is the LayoutPart object, value is the PartDragDrop object
57
	//private IPartDropListener partDropListener;
59
	//private IPartDropListener partDropListener;
58
60
59
	private static final int MIN_DETACH_WIDTH = 150;
61
	private static final int MIN_DETACH_WIDTH = 150;
60
	private static final int MIN_DETACH_HEIGHT = 250;
62
	private static final int MIN_DETACH_HEIGHT = 250;
63
	private static final String WILD_CARD= new String(new char[] {'*'});
64
	
61
	private IDragOverListener dragTarget = new IDragOverListener() {
65
	private IDragOverListener dragTarget = new IDragOverListener() {
62
66
63
		public IDropTarget drag(Control currentControl, Object draggedObject, Point position, final Rectangle dragRectangle) {
67
		public IDropTarget drag(Control currentControl, Object draggedObject, Point position, final Rectangle dragRectangle) {
Lines 171-185 Link Here
171
		// If part added / removed always zoom out.
175
		// If part added / removed always zoom out.
172
		if (isZoomed())
176
		if (isZoomed())
173
			zoomOut();
177
			zoomOut();
174
178
		
175
		// Look for a placeholder.
179
		// Look for a placeholder.
176
		PartPlaceholder placeholder = null;
180
		PartPlaceholder placeholder = null;
177
		LayoutPart testPart = findPart(part.getID());
181
		LayoutPart testPart = null;
182
		String primaryId = part.getID();
183
		String secondaryId = null;
184
		
185
		if (part instanceof ViewPane) {
186
			ViewPane pane = (ViewPane) part;
187
			IViewReference ref = (IViewReference)pane.getPartReference();
188
			secondaryId = ref.getSecondaryId();
189
		}
190
		if (secondaryId != null)
191
			testPart = findPart(primaryId, secondaryId);
192
		else
193
			testPart = findPart(primaryId);
194
		
195
		// validate the testPart
178
		if (testPart != null && testPart instanceof PartPlaceholder)
196
		if (testPart != null && testPart instanceof PartPlaceholder)
179
			placeholder = (PartPlaceholder) testPart;
197
			placeholder = (PartPlaceholder) testPart;
180
198
		
181
		// If there is no placeholder do a simple add. Otherwise, replace the
199
		// If there is no placeholder do a simple add. Otherwise, replace the
182
		// placeholder.
200
		// placeholder if its not a pattern matching placholder
183
		if (placeholder == null) {
201
		if (placeholder == null) {
184
			part.reparent(mainLayout.getParent());
202
			part.reparent(mainLayout.getParent());
185
			LayoutPart relative = mainLayout.findBottomRight();
203
			LayoutPart relative = mainLayout.findBottomRight();
Lines 240-247 Link Here
240
						part.reparent(mainLayout.getParent());
258
						part.reparent(mainLayout.getParent());
241
					}
259
					}
242
260
243
					// replace placeholder with real part
261
					// see if we should replace the placeholder
244
					container.replace(placeholder, part);
262
					if (placeholder.getID().indexOf(WILD_CARD)!=-1) {
263
						if (container instanceof PartSashContainer)
264
							((PartSashContainer)container).addChildForPlaceholder(part, placeholder);
265
						else
266
							container.add(part);
267
					}
268
					else
269
						container.replace(placeholder, part);				
245
				}
270
				}
246
			}
271
			}
247
		}
272
		}
Lines 277-284 Link Here
277
	 * Returns true is not in a tab folder or if it is the top one in a tab
302
	 * Returns true is not in a tab folder or if it is the top one in a tab
278
	 * folder.
303
	 * folder.
279
	 */
304
	 */
280
	public boolean isPartVisible(String partId) {
305
	public boolean isPartVisible(String partId, String secondaryId) {
281
		LayoutPart part = findPart(partId);
306
		LayoutPart part;
307
		if (secondaryId != null)
308
			part = findPart(partId, secondaryId);
309
		else
310
			part = findPart(partId);
282
		if (part == null)
311
		if (part == null)
283
			return false;
312
			return false;
284
		if (part instanceof PartPlaceholder)
313
		if (part instanceof PartPlaceholder)
Lines 710-715 Link Here
710
//	}
739
//	}
711
	/**
740
	/**
712
	 * Find the first part with a given ID in the presentation.
741
	 * Find the first part with a given ID in the presentation.
742
	 * Wild cards now supported.
713
	 */
743
	 */
714
	private LayoutPart findPart(String id) {
744
	private LayoutPart findPart(String id) {
715
		// Check main window.
745
		// Check main window.
Lines 736-763 Link Here
736
		return null;
766
		return null;
737
	}
767
	}
738
	/**
768
	/**
769
	 * Find the first part that matches the specified 
770
	 * primary and secondary id pair.  Wild cards
771
	 * are supported.
772
	 */
773
	private LayoutPart findPart(String primaryId, String secondaryId) {
774
		// check main window.
775
		LayoutPart part = findPart(primaryId, secondaryId, mainLayout.getChildren());
776
		if (part != null)
777
			return part;
778
779
		// check each detached windows.
780
		for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
781
			DetachedWindow window = (DetachedWindow) detachedWindowList.get(i);
782
			part = findPart(primaryId, secondaryId, window.getChildren());
783
			if (part != null)
784
				return part;
785
		}
786
		for (int i = 0; i < detachedPlaceHolderList.size(); i++) {
787
			DetachedPlaceHolder holder =
788
				(DetachedPlaceHolder) detachedPlaceHolderList.get(i);
789
			part = findPart(primaryId, secondaryId, holder.getChildren());
790
			if (part != null)
791
				return part;
792
		}
793
		
794
		// Not found.
795
		return null;
796
	}
797
	private class MatchingPart {
798
		String pid;
799
		String sid;
800
		LayoutPart part;
801
		MatchingPart (String pid, String sid, LayoutPart part) {
802
			this.pid = pid; this.sid = sid; this.part = part;
803
		}
804
	}
805
	/**
739
	 * Find the first part with a given ID in the presentation.
806
	 * Find the first part with a given ID in the presentation.
740
	 */
807
	 */
741
	private LayoutPart findPart(String id, LayoutPart[] parts) {
808
	private LayoutPart findPart(String id, LayoutPart[] parts) {
809
		MatchingPart currentMatchingPart = null;
742
		for (int i = 0, length = parts.length; i < length; i++) {
810
		for (int i = 0, length = parts.length; i < length; i++) {
743
			LayoutPart part = parts[i];
811
			LayoutPart part = parts[i];
744
			if (part.getID().equals(id)) {
812
			if (part.getID().equals(id)) {
813
				// parts with a secondary id do not match in this case
814
				if (part instanceof ViewPane) {
815
					ViewPane pane = (ViewPane) part;
816
					IViewReference ref = (IViewReference)pane.getPartReference();
817
					if(ref.getSecondaryId() != null)
818
						continue;
819
				}
745
				return part;
820
				return part;
746
			} else if (part instanceof EditorArea) {
821
			} 
822
			else if (part.getID().indexOf(WILD_CARD) != -1) {
823
				StringMatcher sm = new StringMatcher(part.getID(), true, false);
824
				MatchingPart matchingPart;
825
				if (sm.match(id)) {
826
					matchingPart = new MatchingPart(part.getID(), null, part);
827
					if (currentMatchingPart != null && 
828
							matchingPart.pid.length() > currentMatchingPart.pid.length())
829
						currentMatchingPart = matchingPart;	
830
					else
831
						currentMatchingPart = matchingPart;
832
				}
833
			}
834
			else if (part instanceof EditorArea) {
747
				// Skip.
835
				// Skip.
748
			} else if (part instanceof ILayoutContainer) {
836
			} 
837
			else if (part instanceof ILayoutContainer) {
749
				part = findPart(id, ((ILayoutContainer) part).getChildren());
838
				part = findPart(id, ((ILayoutContainer) part).getChildren());
750
				if (part != null)
839
				if (part != null)
751
					return part;
840
					return part;
752
			}
841
			} 
753
		}
842
		}
843
		if (currentMatchingPart != null)
844
			return currentMatchingPart.part;
754
		return null;
845
		return null;
755
	}
846
	}
756
	/**
847
	/**
848
	 * Find the first part that matches the specified 
849
	 * primary and secondary id pair.  Wild cards
850
	 * are supported.
851
	 */
852
	private LayoutPart findPart(String primaryId, String secondaryId, LayoutPart[] parts) {
853
		MatchingPart currentMatchingPart = null;
854
		LayoutPart wildCard = null;
855
		for (int i = 0, length = parts.length; i < length; i++) {
856
			LayoutPart part = parts[i];
857
			// check containers first
858
			if (part instanceof ILayoutContainer) {
859
				LayoutPart testPart = findPart(primaryId, secondaryId, 
860
						((ILayoutContainer) part).getChildren());
861
				if (testPart != null)
862
					return testPart;
863
			} 
864
			// check for view part equality
865
			if (part instanceof ViewPane) {
866
				ViewPane pane = (ViewPane) part;
867
				IViewReference ref = (IViewReference)pane.getPartReference();
868
				if(ref.getId().equals(primaryId) && 
869
						ref.getSecondaryId() != null && 
870
						ref.getSecondaryId().equals(secondaryId))
871
					return part;				
872
			}
873
			// check placeholders
874
			else if ((parts[i] instanceof PartPlaceholder)) {
875
				String id = part.getID();
876
				if (id.indexOf(":") == -1) { //$NON-NLS-1$
877
					if (id.equals(WILD_CARD))
878
						wildCard = part;
879
					continue;
880
				}
881
				
882
				StringTokenizer st = new StringTokenizer(part.getID(), ":"); //$NON-NLS-1$
883
				String phPrimaryId = st.nextToken();
884
				String phSecondaryId = st.nextToken();
885
				// perfect matching pair
886
				if (phPrimaryId.equals(primaryId) && 
887
					phSecondaryId.equals(secondaryId)) {
888
					return part;
889
				}				
890
				// check for partial matching pair
891
				MatchingPart matchingPart;
892
				StringMatcher sm = new StringMatcher(phPrimaryId, true, false);
893
				if (sm.match(primaryId)) {
894
					sm = new StringMatcher(phSecondaryId, true, false);
895
					if (sm.match(secondaryId)) {
896
						matchingPart = new MatchingPart(phPrimaryId, phSecondaryId, part);						
897
						// check for most specific
898
						if (currentMatchingPart != null) {
899
							if (matchingPart.pid.length() > currentMatchingPart.pid.length())
900
								currentMatchingPart = matchingPart;							
901
							else if (matchingPart.pid.length() == currentMatchingPart.pid.length()) {
902
								if (matchingPart.sid.length() > currentMatchingPart.sid.length())
903
									currentMatchingPart = matchingPart;	
904
							}								
905
						}
906
						else
907
							currentMatchingPart = matchingPart;
908
					}
909
				}
910
									
911
			} 
912
			else if (part instanceof EditorArea) {
913
				// Skip.
914
			}
915
		}
916
		if (currentMatchingPart != null)
917
			return currentMatchingPart.part;
918
		return wildCard;
919
	}
920
	/**
757
	 * Returns true if a placeholder exists for a given ID.
921
	 * Returns true if a placeholder exists for a given ID.
758
	 */
922
	 */
759
	public boolean hasPlaceholder(String id) {
923
	public boolean hasPlaceholder(String id) {
760
		LayoutPart testPart = findPart(id);
924
		return hasPlaceholder(id, null);
925
	}
926
	/**
927
	 * Returns true if a placeholder exists for a given ID.
928
	 * @since 3.0
929
	 */
930
	public boolean hasPlaceholder(String primaryId, String secondaryId) {
931
		LayoutPart testPart;
932
		if (secondaryId == null)
933
			testPart = findPart(primaryId);
934
		else
935
			testPart = findPart(secondaryId);
761
		return (testPart != null && testPart instanceof PartPlaceholder);
936
		return (testPart != null && testPart instanceof PartPlaceholder);
762
	}
937
	}
763
	/**
938
	/**
Lines 879-885 Link Here
879
		// Replace part with a placeholder
1054
		// Replace part with a placeholder
880
		ILayoutContainer container = part.getContainer();
1055
		ILayoutContainer container = part.getContainer();
881
		if (container != null) {
1056
		if (container != null) {
882
			container.replace(part, new PartPlaceholder(part.getID()));
1057
			String placeHolderId = part.getID();
1058
			// check for a secondary id
1059
			if (part instanceof ViewPane) {
1060
				ViewPane pane = (ViewPane) part;
1061
				IViewReference ref = (IViewReference)pane.getPartReference();
1062
				if (ref.getSecondaryId() != null)
1063
					placeHolderId = ref.getId()+":"+ref.getSecondaryId(); //$NON-NLS-1$
1064
			}
1065
			container.replace(part, new PartPlaceholder(placeHolderId));
883
1066
884
			// If the parent is root we're done. Do not try to replace
1067
			// If the parent is root we're done. Do not try to replace
885
			// it with placeholder.
1068
			// it with placeholder.
Lines 967-973 Link Here
967
								(LayoutPart) container);
1150
								(LayoutPart) container);
968
						}
1151
						}
969
						containerPlaceholder.setRealContainer(null);
1152
						containerPlaceholder.setRealContainer(null);
970
971
					}
1153
					}
972
					container.replace(placeholders[i], part);
1154
					container.replace(placeholders[i], part);
973
					return;
1155
					return;
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java (-1 / +7 lines)
Lines 2760-2766 Link Here
2760
			PerspectivePresentation pres = newPersp.getPresentation();
2760
			PerspectivePresentation pres = newPersp.getPresentation();
2761
			for (Iterator iter = set.iterator(); iter.hasNext();) {
2761
			for (Iterator iter = set.iterator(); iter.hasNext();) {
2762
				PartPane pane = (PartPane) iter.next();
2762
				PartPane pane = (PartPane) iter.next();
2763
				boolean isVisible = pres.isPartVisible(pane.getID());
2763
				String secondaryId = null;
2764
				if (pane instanceof ViewPane) {
2765
					ViewPane vp = (ViewPane) pane;
2766
					IViewReference ref = (IViewReference)vp.getPartReference();
2767
					secondaryId = ref.getSecondaryId();
2768
				}
2769
				boolean isVisible = pres.isPartVisible(pane.getID(), secondaryId);
2764
				pane.setVisible(isVisible);
2770
				pane.setVisible(isVisible);
2765
			}
2771
			}
2766
		} else {
2772
		} else {

Return to bug 56431