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 9355 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]
release quality patch, includes fix for multi view restore state bug
(text/plain), 17.37 KB, created by
Matthew Hatem
on 2004-04-09 11:03:19 EDT
(
hide
)
Description:
release quality patch, includes fix for multi view restore state bug
Filename:
MIME Type:
Creator:
Matthew Hatem
Created:
2004-04-09 11:03:19 EDT
Size:
17.37 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java,v >retrieving revision 1.37 >diff -u -r1.37 IWorkbenchConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java 29 Mar 2004 15:30:51 -0000 1.37 >+++ Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java 9 Apr 2004 14:48:54 -0000 >@@ -80,6 +80,7 @@ > > // Persistance tags. > public static final String TAG_ID = "id"; //$NON-NLS-1$ >+ public static final String TAG_SECONDARY_ID = "secondaryId"; //$NON-NLS-1$ > public static final String TAG_FOCUS = "focus"; //$NON-NLS-1$ > public static final String TAG_EDITOR = "editor"; //$NON-NLS-1$ > public static final String TAG_DELETED_EDITOR = "deletedEditor"; //$NON-NLS-1$ >Index: Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java,v >retrieving revision 1.15 >diff -u -r1.15 PartSashContainer.java >--- Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java 30 Mar 2004 02:52:05 -0000 1.15 >+++ Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java 9 Apr 2004 14:48:56 -0000 >@@ -223,6 +223,18 @@ > > } > /** >+ * Adds the child using ratio and position attributes >+ * from the specified placeholder without replacing >+ * the placeholder >+ */ >+void addChildForPlaceholder(LayoutPart part, LayoutPart placeholder) { >+ //FIXME we need to get the relation and ratio >+ // from the placholder >+ add(part, SWT.RIGHT, 0.5f, placeholder); >+ root.updateSashes(parent); >+ resizeSashes(parent.getClientArea()); >+} >+/** > * See ILayoutContainer#allowBorder > */ > public boolean allowsBorder() { >Index: Eclipse UI/org/eclipse/ui/internal/Perspective.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java,v >retrieving revision 1.58 >diff -u -r1.58 Perspective.java >--- Eclipse UI/org/eclipse/ui/internal/Perspective.java 25 Mar 2004 21:22:31 -0000 1.58 >+++ Eclipse UI/org/eclipse/ui/internal/Perspective.java 9 Apr 2004 14:48:58 -0000 >@@ -120,7 +120,7 @@ > if (!isFastView(ref)) { > // Only remove the part from the presentation if it > // is actually in the presentation. >- if (presentation.hasPlaceholder(pane.getID()) || >+ if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId()) || > pane.getContainer() != null) > presentation.removePart(pane); > // We are drag-enabling the pane because it has been disabled >@@ -730,11 +730,13 @@ > for (int x = 0; x < views.length; x ++) { > // Get the view details. > IMemento childMem = views[x]; >- String viewID = childMem.getString(IWorkbenchConstants.TAG_ID); >+ String primaryId = childMem.getString(IWorkbenchConstants.TAG_ID); >+ String secondaryId = childMem.getString(IWorkbenchConstants.TAG_SECONDARY_ID); > // Create and open the view. > try { >- if(!"true".equals(childMem.getString(IWorkbenchConstants.TAG_REMOVED))) //$NON-NLS-1$ >- viewFactory.createView(viewID); >+ if(!"true".equals(childMem.getString(IWorkbenchConstants.TAG_REMOVED))) { //$NON-NLS-1$ >+ viewFactory.createView(primaryId, secondaryId); >+ } > } catch (PartInitException e) { > childMem.putString(IWorkbenchConstants.TAG_REMOVED,"true"); //$NON-NLS-1$ > result.add(new Status(IStatus.ERROR,PlatformUI.PLUGIN_ID,0,e.getMessage(),e)); >@@ -786,16 +788,24 @@ > for (int x = 0; x < views.length; x ++) { > // Get the view details. > IMemento childMem = views[x]; >- String viewID = childMem.getString(IWorkbenchConstants.TAG_ID); >- if (viewID.equals(IIntroConstants.INTRO_VIEW_ID)) >+ String primaryId = childMem.getString(IWorkbenchConstants.TAG_ID); >+ String secondaryId = childMem.getString(IWorkbenchConstants.TAG_SECONDARY_ID); >+ if (primaryId.equals(IIntroConstants.INTRO_VIEW_ID)) > continue; > > // Create and open the view. >- WorkbenchPartReference ref = (WorkbenchPartReference)viewFactory.getView(viewID); >+ WorkbenchPartReference ref = (WorkbenchPartReference)viewFactory.getView(primaryId, secondaryId); >+ >+ // report error > if(ref == null) { >+ String[] viewIds; >+ if (secondaryId != null) >+ viewIds = new String[]{primaryId}; >+ else >+ viewIds = new String[]{primaryId+":"+secondaryId}; //$NON-NLS-1$ > result.add(new Status( > Status.ERROR,PlatformUI.PLUGIN_ID,0, >- WorkbenchMessages.format("Perspective.couldNotFind", new String[]{viewID}), //$NON-NLS-1$ >+ WorkbenchMessages.format("Perspective.couldNotFind", viewIds), //$NON-NLS-1$ > null)); > continue; > } >@@ -1137,6 +1147,8 @@ > IViewReference ref = pane.getViewReference(); > IMemento viewMemento = memento.createChild(IWorkbenchConstants.TAG_VIEW); > viewMemento.putString(IWorkbenchConstants.TAG_ID, ref.getId()); >+ if (ref.getSecondaryId() != null) >+ viewMemento.putString(IWorkbenchConstants.TAG_SECONDARY_ID, ref.getSecondaryId()); > } > > if(fastViews.size() > 0) { >@@ -1417,7 +1429,7 @@ > > IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); > int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE); >- if (presentation.hasPlaceholder(viewId)) { >+ if (presentation.hasPlaceholder(viewId, secondaryId)) { > presentation.addPart(pane); > } else if (openViewMode == IPreferenceConstants.OVM_EMBED) { > presentation.addPart(pane); >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 9 Apr 2004 14:48:59 -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 WILD_CARD= new String(new char[] {'*'}); >+ > private IDragOverListener dragTarget = new IDragOverListener() { > > public IDropTarget drag(Control currentControl, Object draggedObject, Point position, final Rectangle dragRectangle) { >@@ -171,15 +175,29 @@ > // 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; >+ >+ if (part instanceof ViewPane) { >+ ViewPane pane = (ViewPane) part; >+ IViewReference ref = (IViewReference)pane.getPartReference(); >+ secondaryId = ref.getSecondaryId(); >+ } >+ if (secondaryId != null) >+ testPart = findPart(primaryId, secondaryId); >+ else >+ testPart = findPart(primaryId); >+ >+ // 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. >+ // placeholder if its not a pattern matching placholder > if (placeholder == null) { > part.reparent(mainLayout.getParent()); > LayoutPart relative = mainLayout.findBottomRight(); >@@ -240,8 +258,15 @@ > part.reparent(mainLayout.getParent()); > } > >- // replace placeholder with real part >- container.replace(placeholder, part); >+ // see if we should replace the placeholder >+ if (placeholder.getID().indexOf(WILD_CARD)!=-1) { >+ if (container instanceof PartSashContainer) >+ ((PartSashContainer)container).addChildForPlaceholder(part, placeholder); >+ else >+ container.add(part); >+ } >+ else >+ container.replace(placeholder, part); > } > } > } >@@ -277,8 +302,12 @@ > * Returns true is not in a tab folder or if it is the top one in a tab > * folder. > */ >- public boolean isPartVisible(String partId) { >- LayoutPart part = findPart(partId); >+ public boolean isPartVisible(String partId, String secondaryId) { >+ LayoutPart part; >+ if (secondaryId != null) >+ part = findPart(partId, secondaryId); >+ else >+ part = findPart(partId); > if (part == null) > return false; > if (part instanceof PartPlaceholder) >@@ -710,6 +739,7 @@ > // } > /** > * Find the first part with a given ID in the presentation. >+ * Wild cards now supported. > */ > private LayoutPart findPart(String id) { > // Check main window. >@@ -736,28 +766,173 @@ > 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; >+ } >+ >+ // Not found. >+ return null; >+ } >+ 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; >+ } >+ } >+ /** > * Find the first part with a given ID in the presentation. > */ > private LayoutPart findPart(String id, LayoutPart[] parts) { >+ MatchingPart currentMatchingPart = null; > for (int i = 0, length = parts.length; i < length; i++) { > LayoutPart part = parts[i]; > if (part.getID().equals(id)) { >+ // parts with a secondary id do not match in this case >+ if (part instanceof ViewPane) { >+ ViewPane pane = (ViewPane) part; >+ IViewReference ref = (IViewReference)pane.getPartReference(); >+ if(ref.getSecondaryId() != null) >+ continue; >+ } > return part; >- } else if (part instanceof EditorArea) { >+ } >+ else if (part.getID().indexOf(WILD_CARD) != -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) { >+ } >+ else if (part instanceof ILayoutContainer) { > part = findPart(id, ((ILayoutContainer) part).getChildren()); > if (part != null) > return part; >- } >+ } > } >+ if (currentMatchingPart != null) >+ return currentMatchingPart.part; > 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, LayoutPart[] parts) { >+ MatchingPart currentMatchingPart = null; >+ LayoutPart wildCard = null; >+ for (int i = 0, length = parts.length; i < length; i++) { >+ LayoutPart part = parts[i]; >+ // check containers first >+ if (part instanceof ILayoutContainer) { >+ LayoutPart testPart = findPart(primaryId, secondaryId, >+ ((ILayoutContainer) part).getChildren()); >+ if (testPart != null) >+ return testPart; >+ } >+ // check for view part equality >+ if (part instanceof ViewPane) { >+ ViewPane pane = (ViewPane) part; >+ IViewReference ref = (IViewReference)pane.getPartReference(); >+ if(ref.getId().equals(primaryId) && >+ ref.getSecondaryId() != null && >+ ref.getSecondaryId().equals(secondaryId)) >+ return part; >+ } >+ // check placeholders >+ else if ((parts[i] instanceof PartPlaceholder)) { >+ String id = part.getID(); >+ if (id.indexOf(":") == -1) { //$NON-NLS-1$ >+ if (id.equals(WILD_CARD)) >+ wildCard = part; >+ continue; >+ } >+ >+ StringTokenizer st = new StringTokenizer(part.getID(), ":"); //$NON-NLS-1$ >+ 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. >+ } >+ } >+ if (currentMatchingPart != null) >+ return currentMatchingPart.part; >+ return wildCard; >+ } >+ /** > * Returns true if a placeholder exists for a given ID. > */ > public boolean hasPlaceholder(String id) { >- LayoutPart testPart = findPart(id); >+ return hasPlaceholder(id, null); >+ } >+ /** >+ * Returns true if a placeholder exists for a given ID. >+ * @since 3.0 >+ */ >+ public boolean hasPlaceholder(String primaryId, String secondaryId) { >+ LayoutPart testPart; >+ if (secondaryId == null) >+ testPart = findPart(primaryId); >+ else >+ testPart = findPart(secondaryId); > return (testPart != null && testPart instanceof PartPlaceholder); > } > /** >@@ -879,7 +1054,15 @@ > // Replace part with a placeholder > ILayoutContainer container = part.getContainer(); > if (container != null) { >- container.replace(part, new PartPlaceholder(part.getID())); >+ String placeHolderId = part.getID(); >+ // check for a secondary id >+ if (part instanceof ViewPane) { >+ ViewPane pane = (ViewPane) part; >+ IViewReference ref = (IViewReference)pane.getPartReference(); >+ if (ref.getSecondaryId() != null) >+ placeHolderId = ref.getId()+":"+ref.getSecondaryId(); //$NON-NLS-1$ >+ } >+ container.replace(part, new PartPlaceholder(placeHolderId)); > > // If the parent is root we're done. Do not try to replace > // it with placeholder. >@@ -967,7 +1150,6 @@ > (LayoutPart) container); > } > containerPlaceholder.setRealContainer(null); >- > } > container.replace(placeholders[i], part); > return; >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java,v >retrieving revision 1.124 >diff -u -r1.124 WorkbenchPage.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 29 Mar 2004 15:30:51 -0000 1.124 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 9 Apr 2004 14:49:06 -0000 >@@ -2760,7 +2760,13 @@ > PerspectivePresentation pres = newPersp.getPresentation(); > for (Iterator iter = set.iterator(); iter.hasNext();) { > PartPane pane = (PartPane) iter.next(); >- boolean isVisible = pres.isPartVisible(pane.getID()); >+ String secondaryId = null; >+ if (pane instanceof ViewPane) { >+ ViewPane vp = (ViewPane) pane; >+ IViewReference ref = (IViewReference)vp.getPartReference(); >+ secondaryId = ref.getSecondaryId(); >+ } >+ boolean isVisible = pres.isPartVisible(pane.getID(), secondaryId); > pane.setVisible(isVisible); > } > } else {
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