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 9271 Details for
Bug 56431
[ViewMgmt] Placeholder is lost when a multi-view instanced view is opened
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]
Just a preview of pattern matching placeholder support
preview-patch.txt (text/plain), 8.88 KB, created by
Matthew Hatem
on 2004-04-06 19:15:07 EDT
(
hide
)
Description:
Just a preview of pattern matching placeholder support
Filename:
MIME Type:
Creator:
Matthew Hatem
Created:
2004-04-06 19:15:07 EDT
Size:
8.88 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/PerspectivePresentation.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PerspectivePresentation.java,v >retrieving revision 1.28 >diff -u -r1.28 PerspectivePresentation.java >--- Eclipse UI/org/eclipse/ui/internal/PerspectivePresentation.java 25 Mar 2004 21:41:29 -0000 1.28 >+++ Eclipse UI/org/eclipse/ui/internal/PerspectivePresentation.java 6 Apr 2004 23:03:12 -0000 >@@ -14,6 +14,7 @@ > import java.util.ArrayList; > import java.util.Enumeration; > import java.util.List; >+import java.util.StringTokenizer; > import java.util.Vector; > > import org.eclipse.core.runtime.IStatus; >@@ -31,6 +32,7 @@ > import org.eclipse.ui.internal.dnd.DragUtil; > import org.eclipse.ui.internal.dnd.IDragOverListener; > import org.eclipse.ui.internal.dnd.IDropTarget; >+import org.eclipse.ui.internal.misc.StringMatcher; > > /** > * A perspective presentation is a collection of parts with a layout. Each part >@@ -51,13 +53,15 @@ > private ArrayList detachedWindowList = new ArrayList(1); > private ArrayList detachedPlaceHolderList = new ArrayList(1); > private boolean detachable = false; >- >+ > private boolean active = false; > // key is the LayoutPart object, value is the PartDragDrop object > //private IPartDropListener partDropListener; > > private static final int MIN_DETACH_WIDTH = 150; > private static final int MIN_DETACH_HEIGHT = 250; >+ private static final String singleWildCard= new String(new char[] {'*'}); >+ > private IDragOverListener dragTarget = new IDragOverListener() { > > public IDropTarget drag(Control currentControl, Object draggedObject, Point position, final Rectangle dragRectangle) { >@@ -171,13 +175,31 @@ > // If part added / removed always zoom out. > if (isZoomed()) > zoomOut(); >- >+ > // Look for a placeholder. > PartPlaceholder placeholder = null; >- LayoutPart testPart = findPart(part.getID()); >+ LayoutPart testPart = null; >+ String primaryId = part.getID(); >+ String secondaryId = null; >+ >+ // @issue - do we need this check >+ if (part instanceof ViewPane) { >+ ViewPane pane = (ViewPane) part; >+ IViewReference ref = (IViewReference)pane.getPartReference(); >+ secondaryId = ref.getSecondaryId(); >+ if (secondaryId != null) >+ testPart = findPart(ref.getId(), secondaryId); >+ else >+ testPart = findPart(part.getID()); >+ } >+ else { >+ testPart = findPart(part.getID()); >+ } >+ >+ // validate the testPart > if (testPart != null && testPart instanceof PartPlaceholder) > placeholder = (PartPlaceholder) testPart; >- >+ > // If there is no placeholder do a simple add. Otherwise, replace the > // placeholder. > if (placeholder == null) { >@@ -240,8 +262,24 @@ > part.reparent(mainLayout.getParent()); > } > >- // replace placeholder with real part >- container.replace(placeholder, part); >+ // see if we should replace the placeholder >+ // TODO: need to restore placeholders with secondaryIDs >+ // TODO: XXX.* is not working >+ // TODO: duplicate test for xxx.*:xxx >+ if (placeholder != null) { >+ System.out.println("found placeholder - "+placeholder.getID()); >+ if (placeholder.getID().indexOf(singleWildCard)!=-1) { >+ if (container instanceof PartSashContainer) >+ ((PartSashContainer)container).addEnhanced(part, SWT.RIGHT, 0.0f, placeholder); >+ else >+ container.add(part); >+ } >+ else >+ container.replace(placeholder, part); >+ } >+ else >+ container.add(part); >+ > } > } > } >@@ -710,6 +748,7 @@ > // } > /** > * Find the first part with a given ID in the presentation. >+ * Wild cards now supported. > */ > private LayoutPart findPart(String id) { > // Check main window. >@@ -731,7 +770,46 @@ > if (part != null) > return part; > } >+ >+ // check for a wild card placeholder >+ part = findPart(singleWildCard, mainLayout.getChildren()); >+ if (part != null) >+ return part; >+ >+ // Not found. >+ return null; >+ } >+ /** >+ * Find the first part that matches the specified >+ * primary and secondary id pair. Wild cards >+ * are supported. >+ */ >+ private LayoutPart findPart(String primaryId, String secondaryId) { >+ // check main window. >+ LayoutPart part = findPart(primaryId, secondaryId, mainLayout.getChildren()); >+ if (part != null) >+ return part; > >+ // check each detached windows. >+ for (int i = 0, length = detachedWindowList.size(); i < length; i++) { >+ DetachedWindow window = (DetachedWindow) detachedWindowList.get(i); >+ part = findPart(primaryId, secondaryId, window.getChildren()); >+ if (part != null) >+ return part; >+ } >+ for (int i = 0; i < detachedPlaceHolderList.size(); i++) { >+ DetachedPlaceHolder holder = >+ (DetachedPlaceHolder) detachedPlaceHolderList.get(i); >+ part = findPart(primaryId, secondaryId, holder.getChildren()); >+ if (part != null) >+ return part; >+ } >+ >+ // check for a wild card placeholder >+ part = findPart(singleWildCard, mainLayout.getChildren()); >+ if (part != null) >+ return part; >+ > // Not found. > return null; > } >@@ -739,19 +817,104 @@ > * Find the first part with a given ID in the presentation. > */ > private LayoutPart findPart(String id, LayoutPart[] parts) { >+ LayoutPart wildCard = null; >+ MatchingPart currentMatchingPart = null; > for (int i = 0, length = parts.length; i < length; i++) { > LayoutPart part = parts[i]; > if (part.getID().equals(id)) { > return part; >- } else if (part instanceof EditorArea) { >+ } >+ else if (part.getID().equals(singleWildCard)) >+ wildCard = part; >+ else if (part.getID().indexOf(singleWildCard) != -1) { >+ StringMatcher sm = new StringMatcher(part.getID(), true, false); >+ MatchingPart matchingPart; >+ if (sm.match(id)) { >+ matchingPart = new MatchingPart(part.getID(), null, part); >+ if (currentMatchingPart != null && >+ matchingPart.pid.length() > currentMatchingPart.pid.length()) >+ currentMatchingPart = matchingPart; >+ else >+ currentMatchingPart = matchingPart; >+ } >+ } >+ else if (part instanceof EditorArea) { > // Skip. > } else if (part instanceof ILayoutContainer) { > part = findPart(id, ((ILayoutContainer) part).getChildren()); > if (part != null) > return part; >- } >+ } > } >- return null; >+ if (currentMatchingPart != null) >+ return currentMatchingPart.part; >+ return wildCard; >+ } >+ /** >+ * Find the first part that matches the specified >+ * primary and secondary id pair. Wild cards >+ * are supported. >+ */ >+ private class MatchingPart { >+ String pid; >+ String sid; >+ LayoutPart part; >+ MatchingPart (String pid, String sid, LayoutPart part) { >+ this.pid = pid; this.sid = sid; this.part = part; >+ } >+ } >+ private LayoutPart findPart(String primaryId, String secondaryId, LayoutPart[] parts) { >+ LayoutPart wildCard = null; >+ MatchingPart currentMatchingPart = null; >+ for (int i = 0, length = parts.length; i < length; i++) { >+ LayoutPart part = parts[i]; >+ if ((parts[i] instanceof PartPlaceholder)) { >+ String id = part.getID(); >+ if (id.indexOf(":") == -1) continue; >+ >+ StringTokenizer st = new StringTokenizer(part.getID(), ":"); >+ String phPrimaryId = st.nextToken(); >+ String phSecondaryId = st.nextToken(); >+ >+ // perfect matching pair >+ if (phPrimaryId.equals(primaryId) && >+ phSecondaryId.equals(secondaryId)) { >+ return part; >+ } >+ >+ // check for partial matching pair >+ MatchingPart matchingPart; >+ StringMatcher sm = new StringMatcher(phPrimaryId, true, false); >+ if (sm.match(primaryId)) { >+ sm = new StringMatcher(phSecondaryId, true, false); >+ if (sm.match(secondaryId)) { >+ matchingPart = new MatchingPart(phPrimaryId, phSecondaryId, part); >+ // check for most specific >+ if (currentMatchingPart != null) { >+ if (matchingPart.pid.length() > currentMatchingPart.pid.length()) >+ currentMatchingPart = matchingPart; >+ else if (matchingPart.pid.length() == currentMatchingPart.pid.length()) { >+ if (matchingPart.sid.length() > currentMatchingPart.sid.length()) >+ currentMatchingPart = matchingPart; >+ } >+ } >+ else >+ currentMatchingPart = matchingPart; >+ } >+ } >+ >+ } else if (part instanceof EditorArea) { >+ // Skip. >+ } else if (part instanceof ILayoutContainer) { >+ part = findPart(primaryId, secondaryId, ((ILayoutContainer) part).getChildren()); >+ if (part != null) >+ return part; >+ } else if (part.getID().equals(singleWildCard)) >+ wildCard = part; >+ } >+ if (currentMatchingPart != null) >+ return currentMatchingPart.part; >+ return wildCard; > } > /** > * Returns true if a placeholder exists for a given ID.
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 56431
:
9271
|
9272
|
9339
|
9340
|
9355
|
9446
|
9713