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 92934 Details for
Bug 215797
[ViewMgmt] [WorkbenchParts] Extends org.eclipse.ui.views EP to allow non-restorable views
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Revised patch including a testcase which obsoletes the previous patch
clipboard.txt (text/plain), 16.24 KB, created by
Markus Kuppe
on 2008-03-19 12:50:30 EDT
(
hide
)
Description:
Revised patch including a testcase which obsoletes the previous patch
Filename:
MIME Type:
Creator:
Markus Kuppe
Created:
2008-03-19 12:50:30 EDT
Size:
16.24 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/views/IViewDescriptor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/views/IViewDescriptor.java,v >retrieving revision 1.3 >diff -u -r1.3 IViewDescriptor.java >--- Eclipse UI/org/eclipse/ui/views/IViewDescriptor.java 14 Mar 2005 17:02:52 -0000 1.3 >+++ Eclipse UI/org/eclipse/ui/views/IViewDescriptor.java 19 Mar 2008 16:48:55 -0000 >@@ -88,4 +88,11 @@ > */ > public boolean getAllowMultiple(); > >+ /** >+ * Returns whether this view can be restored upon workbench restart. >+ * >+ * @return whether whether this view can be restored upon workbench restart >+ */ >+ public boolean getRestorable(); >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/ViewFactory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewFactory.java,v >retrieving revision 1.62 >diff -u -r1.62 ViewFactory.java >--- Eclipse UI/org/eclipse/ui/internal/ViewFactory.java 7 Mar 2008 04:43:55 -0000 1.62 >+++ Eclipse UI/org/eclipse/ui/internal/ViewFactory.java 19 Mar 2008 16:48:54 -0000 >@@ -283,8 +283,10 @@ > > final IViewReference refs[] = getViews(); > for (int i = 0; i < refs.length; i++) { >- //for dynamic UI - add the following line to replace subsequent code which is commented out >- saveViewState(memento, refs[i], result); >+ if(refs[i].isRestorable()) { >+ //for dynamic UI - add the following line to replace subsequent code which is commented out >+ saveViewState(memento, refs[i], result); >+ } > } > return result; > } >Index: Eclipse UI/org/eclipse/ui/internal/FastViewManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewManager.java,v >retrieving revision 1.21 >diff -u -r1.21 FastViewManager.java >--- Eclipse UI/org/eclipse/ui/internal/FastViewManager.java 15 May 2007 18:34:19 -0000 1.21 >+++ Eclipse UI/org/eclipse/ui/internal/FastViewManager.java 19 Mar 2008 16:48:54 -0000 >@@ -742,12 +742,14 @@ > Iterator itr = fvRefs.iterator(); > while (itr.hasNext()) { > IViewReference ref = (IViewReference) itr.next(); >- IMemento viewMemento = childMem >- .createChild(IWorkbenchConstants.TAG_VIEW); >- String id = ViewFactory.getKey(ref); >- viewMemento.putString(IWorkbenchConstants.TAG_ID, id); >- float ratio = perspective.getFastViewWidthRatio(ref); >- viewMemento.putFloat(IWorkbenchConstants.TAG_RATIO, ratio); >+ if(ref.isRestorable()) { >+ IMemento viewMemento = childMem >+ .createChild(IWorkbenchConstants.TAG_VIEW); >+ String id = ViewFactory.getKey(ref); >+ viewMemento.putString(IWorkbenchConstants.TAG_ID, id); >+ float ratio = perspective.getFastViewWidthRatio(ref); >+ viewMemento.putFloat(IWorkbenchConstants.TAG_RATIO, ratio); >+ } > } > } > } >Index: Eclipse UI/org/eclipse/ui/internal/ViewReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewReference.java,v >retrieving revision 1.29 >diff -u -r1.29 ViewReference.java >--- Eclipse UI/org/eclipse/ui/internal/ViewReference.java 14 Nov 2007 07:59:50 -0000 1.29 >+++ Eclipse UI/org/eclipse/ui/internal/ViewReference.java 19 Mar 2008 16:48:54 -0000 >@@ -10,20 +10,16 @@ > *******************************************************************************/ > package org.eclipse.ui.internal; > >-import org.eclipse.osgi.util.NLS; >- >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.layout.FillLayout; >-import org.eclipse.swt.widgets.Composite; >- > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; >- > import org.eclipse.jface.action.ContributionManager; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.resource.ImageDescriptor; >- >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.IKeyBindingService; > import org.eclipse.ui.IMemento; > import org.eclipse.ui.IViewPart; >@@ -500,4 +496,11 @@ > public IMemento getMemento() { > return memento; > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IViewReference#isRestorable() >+ */ >+ public boolean isRestorable() { >+ return this.factory.getViewRegistry().find(getId()).getRestorable(); >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/Perspective.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java,v >retrieving revision 1.168 >diff -u -r1.168 Perspective.java >--- Eclipse UI/org/eclipse/ui/internal/Perspective.java 12 Mar 2008 15:00:54 -0000 1.168 >+++ Eclipse UI/org/eclipse/ui/internal/Perspective.java 19 Mar 2008 16:48:54 -0000 >@@ -1665,10 +1665,12 @@ > while (itr.hasNext()) { > ViewPane pane = (ViewPane) itr.next(); > IViewReference ref = pane.getViewReference(); >- IMemento viewMemento = memento >- .createChild(IWorkbenchConstants.TAG_VIEW); >- viewMemento.putString(IWorkbenchConstants.TAG_ID, ViewFactory >- .getKey(ref)); >+ if(ref.isRestorable()) { >+ IMemento viewMemento = memento >+ .createChild(IWorkbenchConstants.TAG_VIEW); >+ viewMemento.putString(IWorkbenchConstants.TAG_ID, ViewFactory >+ .getKey(ref)); >+ } > } > > // save all fastview state >Index: Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java,v >retrieving revision 1.34 >diff -u -r1.34 ViewDescriptor.java >--- Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java 28 Nov 2007 21:56:43 -0000 1.34 >+++ Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java 19 Mar 2008 16:48:54 -0000 >@@ -233,6 +233,14 @@ > String string = configElement.getAttribute(IWorkbenchRegistryConstants.ATT_ALLOW_MULTIPLE); > return string == null ? false : Boolean.valueOf(string).booleanValue(); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.views.IViewDescriptor#getRestorable() >+ */ >+ public boolean getRestorable() { >+ String string = configElement.getAttribute(IWorkbenchRegistryConstants.ATT_RESTORABLE); >+ return string == null ? true : Boolean.valueOf(string).booleanValue(); >+ } > > /* (non-Javadoc) > * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) >Index: Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java,v >retrieving revision 1.34 >diff -u -r1.34 IWorkbenchRegistryConstants.java >--- Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java 29 Feb 2008 17:52:51 -0000 1.34 >+++ Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java 19 Mar 2008 16:48:54 -0000 >@@ -47,6 +47,11 @@ > public static String ATT_ALLOW_MULTIPLE = "allowMultiple"; //$NON-NLS-1$ > > /** >+ * Attribute that specifies whether a view gets restored upon workbench restart. Value <code>restorable</code>. >+ */ >+ public static String ATT_RESTORABLE = "restorable"; //$NON-NLS-1$ >+ >+ /** > * Attribute that specifies whether a wizard is immediately capable of > * finishing. Value <code>canFinishEarly</code>. > */ >@@ -1302,7 +1307,7 @@ > public static String TAG_SERVICE_FACTORY = "serviceFactory"; //$NON-NLS-1$ > > public static String TAG_SERVICE = "service"; //$NON-NLS-1$ >- >+ > public static final String ATTR_FACTORY_CLASS = "factoryClass"; //$NON-NLS-1$ > > public static final String ATTR_SERVICE_CLASS = "serviceClass"; //$NON-NLS-1$ >Index: Eclipse UI/org/eclipse/ui/IViewReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IViewReference.java,v >retrieving revision 1.11 >diff -u -r1.11 IViewReference.java >--- Eclipse UI/org/eclipse/ui/IViewReference.java 16 Mar 2007 18:00:37 -0000 1.11 >+++ Eclipse UI/org/eclipse/ui/IViewReference.java 19 Mar 2008 16:48:54 -0000 >@@ -40,4 +40,9 @@ > * Returns true if the view is a fast view otherwise returns false. > */ > public boolean isFastView(); >+ >+ /** >+ * Returns true if the view is restorable otherwise returns false. >+ */ >+ public boolean isRestorable(); > } >#P org.eclipse.ui >Index: schema/views.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui/schema/views.exsd,v >retrieving revision 1.18 >diff -u -r1.18 views.exsd >--- schema/views.exsd 5 Mar 2008 19:17:03 -0000 1.18 >+++ schema/views.exsd 19 Mar 2008 16:48:56 -0000 >@@ -159,6 +159,13 @@ > </documentation> > </annotation> > </attribute> >+ <attribute name="restorable" type="boolean" use="default" value="true"> >+ <annotation> >+ <documentation> >+ flag indicating whether this view allows to be restored upon workbench restart. If set to false, the view will not be open after a workbench restart. The default is true. >+ </documentation> >+ </annotation> >+ </attribute> > </complexType> > </element> > >@@ -225,6 +232,7 @@ > </complexType> > </element> > >+ > <annotation> > <appinfo> > <meta.section type="examples"/> >#P org.eclipse.ui.tests >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/plugin.xml,v >retrieving revision 1.254 >diff -u -r1.254 plugin.xml >--- plugin.xml 3 Mar 2008 15:45:11 -0000 1.254 >+++ plugin.xml 19 Mar 2008 16:48:57 -0000 >@@ -459,6 +459,12 @@ > id="org.eclipse.ui.tests.layout.constraints.LayoutConstraintsView" > name="Layout Constraints Test"> > </view> >+ <view >+ class="org.eclipse.ui.tests.session.NonRestorableView" >+ id="org.eclipse.ui.tests.session.NonRestorableView" >+ name="NonRestorableView" >+ restorable="false"> >+ </view> > > </extension> > <extension >Index: Eclipse UI Tests/org/eclipse/ui/tests/session/SessionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/SessionTests.java,v >retrieving revision 1.15 >diff -u -r1.15 SessionTests.java >--- Eclipse UI Tests/org/eclipse/ui/tests/session/SessionTests.java 7 Sep 2007 17:21:44 -0000 1.15 >+++ Eclipse UI Tests/org/eclipse/ui/tests/session/SessionTests.java 19 Mar 2008 16:48:57 -0000 >@@ -10,11 +10,11 @@ > *******************************************************************************/ > package org.eclipse.ui.tests.session; > >-import org.eclipse.ui.tests.harness.util.TweakletCheckTest; >- > import junit.framework.Test; > import junit.framework.TestSuite; > >+import org.eclipse.ui.tests.harness.util.TweakletCheckTest; >+ > /** > * @since 3.1 > */ >@@ -98,5 +98,7 @@ > Bug108033Test.class)); > addTest(new WorkbenchSessionTest("editorSessionTests", > ArbitraryPropertiesViewTest.class)); >+ addTest(new WorkbenchSessionTest("editorSessionTests", >+ NonRestorableViewTest.class)); > } > } >Index: Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java >=================================================================== >RCS file: Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java >diff -N Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Versant Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.tests.session; >+ >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.part.ViewPart; >+ >+public class NonRestorableView extends ViewPart { >+ >+ public NonRestorableView() { >+ // TODO Auto-generated constructor stub >+ } >+ >+ public void createPartControl(Composite parent) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void setFocus() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+} >Index: Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorableViewTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorableViewTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorableViewTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorableViewTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,73 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Versant Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.tests.session; >+ >+import junit.framework.TestCase; >+import junit.framework.TestSuite; >+ >+import org.eclipse.ui.IViewReference; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * If a view is set to non restorable during a session, it's part is not instantiated. >+ * This tests that case, and the outcome should be that the view doesn't get >+ * instanciated in the second session. >+ * >+ * @since 3.4 >+ */ >+public class NonRestorableViewTest extends TestCase { >+ >+ private static final String NON_RESTORABLE_VIEW_ID = "org.eclipse.ui.tests.session.NonRestorableView"; >+ >+ public static TestSuite suite() { >+ return new TestSuite(NonRestorableViewTest.class); >+ } >+ >+ public NonRestorableViewTest(String testName) { >+ super(testName); >+ } >+ >+ /** >+ * This is the first part instantiates a non restorable view >+ * >+ * @throws Throwable >+ */ >+ public void test01ActivateView() throws Throwable { >+ final IWorkbench workbench = PlatformUI.getWorkbench(); >+ final IWorkbenchPage page = workbench.getActiveWorkbenchWindow() >+ .getActivePage(); >+ >+ page.showView(NON_RESTORABLE_VIEW_ID); >+ } >+ >+ /** >+ * In the second session the view shouldn't be >+ * instantiated. >+ * >+ * @throws Throwable >+ */ >+ public void test02SecondOpening() throws Throwable { >+ final IWorkbench workbench = PlatformUI.getWorkbench(); >+ final IWorkbenchPage page = workbench.getActiveWorkbenchWindow() >+ .getActivePage(); >+ >+ IViewReference[] views = page.getViewReferences(); >+ for (int i = 0; i < views.length; i++) { >+ IViewReference ref = views[i]; >+ if (ref.getId().equals(NON_RESTORABLE_VIEW_ID)) { >+ assertNull("The view should not be instantiated", ref >+ .getPart(false)); >+ } >+ } >+ } >+}
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 215797
:
87498
|
87499
|
92934
|
92935
|
92980
|
93779