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/PartSashContainer.java (+10 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
	add(part, SWT.RIGHT, 0.5f, placeholder);
232
	root.updateSashes(parent);
233
	resizeSashes(parent.getClientArea());
234
}
235
/**
226
 * See ILayoutContainer#allowBorder
236
 * See ILayoutContainer#allowBorder
227
 */
237
 */
228
public boolean allowsBorder() {
238
public boolean allowsBorder() {
(-)Eclipse UI/org/eclipse/ui/internal/PerspectivePresentation.java (-8 / +174 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-183 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
		// @issue - do we need this check
186
		if (part instanceof ViewPane) {
187
			ViewPane pane = (ViewPane) part;
188
			IViewReference ref = (IViewReference)pane.getPartReference();
189
			secondaryId = ref.getSecondaryId();
190
			if (secondaryId != null)
191
				testPart = findPart(ref.getId(), secondaryId);
192
			else
193
				testPart = findPart(part.getID());
194
		}
195
		else {
196
			testPart = findPart(part.getID());
197
		}
198
		
199
		// validate the testPart
178
		if (testPart != null && testPart instanceof PartPlaceholder)
200
		if (testPart != null && testPart instanceof PartPlaceholder)
179
			placeholder = (PartPlaceholder) testPart;
201
			placeholder = (PartPlaceholder) testPart;
180
202
		
181
		// If there is no placeholder do a simple add. Otherwise, replace the
203
		// If there is no placeholder do a simple add. Otherwise, replace the
182
		// placeholder.
204
		// placeholder.
183
		if (placeholder == null) {
205
		if (placeholder == null) {
Lines 240-247 Link Here
240
						part.reparent(mainLayout.getParent());
262
						part.reparent(mainLayout.getParent());
241
					}
263
					}
242
264
243
					// replace placeholder with real part
265
					// see if we should replace the placeholder
244
					container.replace(placeholder, part);
266
					// TODO: need to restore placeholders with secondaryIDs
267
					if (placeholder != null) {
268
						System.out.println("found placeholder - "+placeholder.getID());
269
						if (placeholder.getID().indexOf(WILD_CARD)!=-1) {
270
							if (container instanceof PartSashContainer)
271
								((PartSashContainer)container).addChildForPlaceholder(part, placeholder);
272
							else
273
								container.add(part);
274
						}
275
						else
276
							container.replace(placeholder, part);
277
					}
278
					else 
279
						container.add(part);
280
					
245
				}
281
				}
246
			}
282
			}
247
		}
283
		}
Lines 710-715 Link Here
710
//	}
746
//	}
711
	/**
747
	/**
712
	 * Find the first part with a given ID in the presentation.
748
	 * Find the first part with a given ID in the presentation.
749
	 * Wild cards now supported.
713
	 */
750
	 */
714
	private LayoutPart findPart(String id) {
751
	private LayoutPart findPart(String id) {
715
		// Check main window.
752
		// Check main window.
Lines 731-756 Link Here
731
			if (part != null)
768
			if (part != null)
732
				return part;
769
				return part;
733
		}
770
		}
771
		
772
		// check for a wild card placeholder
773
		part = findPart(WILD_CARD, mainLayout.getChildren());
774
		if (part != null)
775
			return part;
734
776
735
		// Not found.
777
		// Not found.
736
		return null;
778
		return null;
737
	}
779
	}
738
	/**
780
	/**
781
	 * Find the first part that matches the specified 
782
	 * primary and secondary id pair.  Wild cards
783
	 * are supported.
784
	 */
785
	private LayoutPart findPart(String primaryId, String secondaryId) {
786
		// check main window.
787
		LayoutPart part = findPart(primaryId, secondaryId, mainLayout.getChildren());
788
		if (part != null)
789
			return part;
790
791
		// check each detached windows.
792
		for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
793
			DetachedWindow window = (DetachedWindow) detachedWindowList.get(i);
794
			part = findPart(primaryId, secondaryId, window.getChildren());
795
			if (part != null)
796
				return part;
797
		}
798
		for (int i = 0; i < detachedPlaceHolderList.size(); i++) {
799
			DetachedPlaceHolder holder =
800
				(DetachedPlaceHolder) detachedPlaceHolderList.get(i);
801
			part = findPart(primaryId, secondaryId, holder.getChildren());
802
			if (part != null)
803
				return part;
804
		}
805
		
806
		// check for a wild card placeholder
807
		part = findPart(WILD_CARD, mainLayout.getChildren());
808
		if (part != null)
809
			return part;
810
		
811
		// Not found.
812
		return null;
813
	}
814
	private class MatchingPart {
815
		String pid;
816
		String sid;
817
		LayoutPart part;
818
		MatchingPart (String pid, String sid, LayoutPart part) {
819
			this.pid = pid; this.sid = sid; this.part = part;
820
		}
821
	}
822
	/**
739
	 * Find the first part with a given ID in the presentation.
823
	 * Find the first part with a given ID in the presentation.
740
	 */
824
	 */
741
	private LayoutPart findPart(String id, LayoutPart[] parts) {
825
	private LayoutPart findPart(String id, LayoutPart[] parts) {
826
		MatchingPart currentMatchingPart = null;
742
		for (int i = 0, length = parts.length; i < length; i++) {
827
		for (int i = 0, length = parts.length; i < length; i++) {
743
			LayoutPart part = parts[i];
828
			LayoutPart part = parts[i];
744
			if (part.getID().equals(id)) {
829
			if (part.getID().equals(id)) {
745
				return part;
830
				return part;
746
			} else if (part instanceof EditorArea) {
831
			} 
832
			else if (part.getID().indexOf(WILD_CARD) != -1) {
833
				StringMatcher sm = new StringMatcher(part.getID(), true, false);
834
				MatchingPart matchingPart;
835
				if (sm.match(id)) {
836
					matchingPart = new MatchingPart(part.getID(), null, part);
837
					if (currentMatchingPart != null && 
838
							matchingPart.pid.length() > currentMatchingPart.pid.length())
839
						currentMatchingPart = matchingPart;	
840
					else
841
						currentMatchingPart = matchingPart;
842
				}
843
			}
844
			else if (part instanceof EditorArea) {
747
				// Skip.
845
				// Skip.
748
			} else if (part instanceof ILayoutContainer) {
846
			} else if (part instanceof ILayoutContainer) {
749
				part = findPart(id, ((ILayoutContainer) part).getChildren());
847
				part = findPart(id, ((ILayoutContainer) part).getChildren());
750
				if (part != null)
848
				if (part != null)
751
					return part;
849
					return part;
850
			} 
851
		}
852
		if (currentMatchingPart != null)
853
			return currentMatchingPart.part;
854
		return null;
855
	}
856
	/**
857
	 * Find the first part that matches the specified 
858
	 * primary and secondary id pair.  Wild cards
859
	 * are supported.
860
	 */
861
	private LayoutPart findPart(String primaryId, String secondaryId, LayoutPart[] parts) {
862
		MatchingPart currentMatchingPart = null;
863
		for (int i = 0, length = parts.length; i < length; i++) {
864
			LayoutPart part = parts[i];
865
			// check containers first
866
			if (part instanceof ILayoutContainer) {
867
				part = findPart(primaryId, secondaryId, ((ILayoutContainer) part).getChildren());
868
				if (part != null)
869
					return part;
870
			} 
871
			// check placeholders
872
			else if ((parts[i] instanceof PartPlaceholder)) {
873
				String id = part.getID();
874
				if (id.indexOf(":") == -1) continue;
875
				
876
				StringTokenizer st = new StringTokenizer(part.getID(), ":");
877
				String phPrimaryId = st.nextToken();
878
				String phSecondaryId = st.nextToken();
879
				// perfect matching pair
880
				if (phPrimaryId.equals(primaryId) && 
881
					phSecondaryId.equals(secondaryId)) {
882
					return part;
883
				}				
884
				// check for partial matching pair
885
				MatchingPart matchingPart;
886
				StringMatcher sm = new StringMatcher(phPrimaryId, true, false);
887
				if (sm.match(primaryId)) {
888
					sm = new StringMatcher(phSecondaryId, true, false);
889
					if (sm.match(secondaryId)) {
890
						matchingPart = new MatchingPart(phPrimaryId, phSecondaryId, part);						
891
						// check for most specific
892
						if (currentMatchingPart != null) {
893
							if (matchingPart.pid.length() > currentMatchingPart.pid.length())
894
								currentMatchingPart = matchingPart;							
895
							else if (matchingPart.pid.length() == currentMatchingPart.pid.length()) {
896
								if (matchingPart.sid.length() > currentMatchingPart.sid.length())
897
									currentMatchingPart = matchingPart;	
898
							}								
899
						}
900
						else
901
							currentMatchingPart = matchingPart;
902
					}
903
				}
904
									
905
			} 
906
			else if (part instanceof EditorArea) {
907
				// Skip.
752
			}
908
			}
753
		}
909
		}
910
		if (currentMatchingPart != null)
911
			return currentMatchingPart.part;
754
		return null;
912
		return null;
755
	}
913
	}
756
	/**
914
	/**
Lines 879-885 Link Here
879
		// Replace part with a placeholder
1037
		// Replace part with a placeholder
880
		ILayoutContainer container = part.getContainer();
1038
		ILayoutContainer container = part.getContainer();
881
		if (container != null) {
1039
		if (container != null) {
882
			container.replace(part, new PartPlaceholder(part.getID()));
1040
			String placeHolderId = part.getID();
1041
			// check for a secondary id
1042
			if (part instanceof ViewPane) {
1043
				ViewPane pane = (ViewPane) part;
1044
				IViewReference ref = (IViewReference)pane.getPartReference();
1045
				if (ref.getSecondaryId() != null)
1046
					placeHolderId = ref.getId()+":"+ref.getSecondaryId();
1047
			}
1048
			container.replace(part, new PartPlaceholder(placeHolderId));
883
1049
884
			// If the parent is root we're done. Do not try to replace
1050
			// If the parent is root we're done. Do not try to replace
885
			// it with placeholder.
1051
			// it with placeholder.
(-)Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java (-1 / +1 lines)
Lines 392-398 Link Here
392
                    next.incrementBusy(event.getJob());
392
                    next.incrementBusy(event.getJob());
393
                }                
393
                }                
394
394
395
                if (event.getJob().isUser()) {
395
                if (!event.getJob().isSystem()) {
396
                    boolean inDialog = WorkbenchPlugin
396
                    boolean inDialog = WorkbenchPlugin
397
                            .getDefault()
397
                            .getDefault()
398
                            .getPreferenceStore()
398
                            .getPreferenceStore()

Return to bug 56431