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 113604 Details for
Bug 248103
[PropertiesView] Multi-instance Properties View
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]
draft v1
248103.txt (text/plain), 36.20 KB, created by
Markus Kuppe
on 2008-09-26 11:39:00 EDT
(
hide
)
Description:
draft v1
Filename:
MIME Type:
Creator:
Markus Kuppe
Created:
2008-09-26 11:39:00 EDT
Size:
36.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.views >Index: src/org/eclipse/ui/internal/views/properties/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/internal/views/properties/messages.properties,v >retrieving revision 1.4 >diff -u -r1.4 messages.properties >--- src/org/eclipse/ui/internal/views/properties/messages.properties 9 May 2008 14:12:53 -0000 1.4 >+++ src/org/eclipse/ui/internal/views/properties/messages.properties 26 Sep 2008 15:36:36 -0000 >@@ -29,6 +29,12 @@ > Filter_text = Show &Advanced Properties > Filter_toolTip = Show Advanced Properties > >+Pin_text = &Pin to selection >+Pin_toolTip = Pin property to current selection >+ >+New_text = &Open new property view >+New_toolTip = Open a second property view >+ > PropertyViewer_property = Property > PropertyViewer_value = Value > PropertyViewer_misc = Misc >Index: src/org/eclipse/ui/internal/views/properties/PropertiesMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/internal/views/properties/PropertiesMessages.java,v >retrieving revision 1.4 >diff -u -r1.4 PropertiesMessages.java >--- src/org/eclipse/ui/internal/views/properties/PropertiesMessages.java 9 May 2008 14:12:53 -0000 1.4 >+++ src/org/eclipse/ui/internal/views/properties/PropertiesMessages.java 26 Sep 2008 15:36:36 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103 > *******************************************************************************/ > package org.eclipse.ui.internal.views.properties; > >@@ -47,6 +48,16 @@ > public static String Filter_toolTip; > > /** */ >+ public static String Pin_text; >+ /** */ >+ public static String Pin_toolTip; >+ >+ /** */ >+ public static String New_text; >+ /** */ >+ public static String New_toolTip; >+ >+ /** */ > public static String PropertyViewer_property; > /** */ > public static String PropertyViewer_value; >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.views/META-INF/MANIFEST.MF,v >retrieving revision 1.14 >diff -u -r1.14 MANIFEST.MF >--- META-INF/MANIFEST.MF 10 Sep 2008 07:54:34 -0000 1.14 >+++ META-INF/MANIFEST.MF 26 Sep 2008 15:36:36 -0000 >@@ -2,7 +2,7 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %pluginName > Bundle-SymbolicName: org.eclipse.ui.views; singleton:=true >-Bundle-Version: 3.3.100.qualifier >+Bundle-Version: 3.4.0.qualifier > Bundle-ClassPath: . > Bundle-Activator: org.eclipse.ui.internal.views.ViewsPlugin > Bundle-ActivationPolicy: lazy >Index: src/org/eclipse/ui/views/properties/IPropertiesHelpContextIds.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/IPropertiesHelpContextIds.java,v >retrieving revision 1.7 >diff -u -r1.7 IPropertiesHelpContextIds.java >--- src/org/eclipse/ui/views/properties/IPropertiesHelpContextIds.java 16 Mar 2007 18:00:54 -0000 1.7 >+++ src/org/eclipse/ui/views/properties/IPropertiesHelpContextIds.java 26 Sep 2008 15:36:36 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103 > *******************************************************************************/ > package org.eclipse.ui.views.properties; > >@@ -36,6 +37,12 @@ > public static final String COPY_PROPERTY_ACTION = PREFIX > + "properties_copy_action_context"; //$NON-NLS-1$ > >+ public static final String PIN_ACTION = PREFIX >+ + "properties_pin_action_context"; //$NON-NLS-1$; >+ >+ public static final String NEW_ACTION = PREFIX >+ + "properties_new_action_context"; //$NON-NLS-1$; >+ > // Views > public static final String PROPERTY_SHEET_VIEW = PREFIX > + "property_sheet_view_context"; //$NON-NLS-1$ >Index: src/org/eclipse/ui/views/properties/PropertySheet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java,v >retrieving revision 1.16 >diff -u -r1.16 PropertySheet.java >--- src/org/eclipse/ui/views/properties/PropertySheet.java 9 May 2008 14:12:53 -0000 1.16 >+++ src/org/eclipse/ui/views/properties/PropertySheet.java 26 Sep 2008 15:36:36 -0000 >@@ -7,18 +7,30 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103 > *******************************************************************************/ > package org.eclipse.ui.views.properties; > >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.IToolBarManager; >+import org.eclipse.jface.action.Separator; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.IMemento; > import org.eclipse.ui.ISaveablePart; > import org.eclipse.ui.ISelectionListener; > import org.eclipse.ui.IViewSite; >+import org.eclipse.ui.IWorkbenchActionConstants; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.views.ViewsPlugin; >+import org.eclipse.ui.internal.views.properties.PropertiesMessages; > import org.eclipse.ui.part.IContributedContentsView; > import org.eclipse.ui.part.IPage; > import org.eclipse.ui.part.IPageBookViewPage; >@@ -73,6 +85,27 @@ > private ISelection bootstrapSelection; > > /** >+ * The current selection of the property sheet >+ */ >+ private ISelection currentSelection; >+ >+ /** >+ * The current part for which this property sheets is active >+ */ >+ private IWorkbenchPart currentPart; >+ >+ /** >+ * Whether this property sheet instance is pinned or not >+ */ >+ private IAction pinPropertySheetAction; >+ >+ /** >+ * Used to identify new property sheet instances >+ */ >+ //TODO create a real secondaryId in case property sheets should restore >+ private static int SECONDARY_ID_COUNTER; >+ >+ /** > * Creates a property sheet view. > */ > public PropertySheet() { >@@ -84,18 +117,38 @@ > * Returns the default property sheet page. > */ > protected IPage createDefaultPage(PageBook book) { >- PropertySheetPage page = new PropertySheetPage(); >+ IPageBookViewPage page = (IPageBookViewPage) ViewsPlugin.getAdapter(this, >+ IPropertySheetPage.class, false); >+ if(page == null) { >+ page = new PropertySheetPage(); >+ } > initPage(page); > page.createControl(book); > return page; > } > >- /** >+ /** > * The <code>PropertySheet</code> implementation of this <code>IWorkbenchPart</code> > * method creates a <code>PageBook</code> control with its default page showing. > */ > public void createPartControl(Composite parent) { > super.createPartControl(parent); >+ >+ pinPropertySheetAction = new PinPropertySheetAction(SECONDARY_ID_COUNTER); >+ IAction newPropertySheetAction = new NewPropertySheetAction(); >+ >+ IMenuManager menuManager = getViewSite().getActionBars() >+ .getMenuManager(); >+ menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); >+ menuManager.add(pinPropertySheetAction); >+ menuManager.add(newPropertySheetAction); >+ >+ IToolBarManager toolBarManager = getViewSite().getActionBars() >+ .getToolBarManager(); >+ menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); >+ toolBarManager.add(pinPropertySheetAction); >+ toolBarManager.add(newPropertySheetAction); >+ > getSite().getPage().getWorkbenchWindow().getWorkbench().getHelpSystem() > .setHelp(getPageBook(), > IPropertiesHelpContextIds.PROPERTY_SHEET_VIEW); >@@ -116,7 +169,12 @@ > * Method declared on PageBookView. > */ > protected PageRec doCreatePage(IWorkbenchPart part) { >- // Try to get a custom property sheet page. >+ // Try to get a custom property sheet page but not if the part is also a >+ // PropertySheet in which case we would chain parent and child property >+ // sheet with causes trouble if the child . >+ if(part instanceof PropertySheet) { >+ return null; >+ } > IPropertySheetPage page = (IPropertySheetPage) ViewsPlugin.getAdapter(part, > IPropertySheetPage.class, false); > if (page != null) { >@@ -158,19 +216,44 @@ > * Method declared on IViewPart. > */ > public void init(IViewSite site) throws PartInitException { >- site.getPage().addSelectionListener(this); >- super.init(site); >+ site.getPage().addSelectionListener(this); >+ super.init(site); > } > > /* (non-Javadoc) >+ * @see org.eclipse.ui.part.ViewPart#saveState(org.eclipse.ui.IMemento) >+ */ >+ public void saveState(IMemento memento) { >+ // close all but the primary/parent property sheet >+ String secondaryId = getViewSite().getSecondaryId(); >+ if (null == secondaryId) { >+ super.saveState(memento); >+ } else { >+ getViewSite().getPage().hideView(this); >+ } >+ } >+ >+ /* (non-Javadoc) > * Method declared on PageBookView. > * The property sheet may show properties for any view other than this view. > */ > protected boolean isImportant(IWorkbenchPart part) { >- return part != this; >+ return pinPropertySheetAction == null >+ || (pinPropertySheetAction != null && !pinPropertySheetAction >+ .isChecked()) && !(part instanceof PropertySheet); > } > >- /** >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.part.PageBookView#partClosed(org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void partClosed(IWorkbenchPart part) { >+ if (pinPropertySheetAction.isChecked() && part.equals(currentPart)) { >+ pinPropertySheetAction.setChecked(false); >+ } >+ super.partClosed(part); >+ } >+ >+ /** > * The <code>PropertySheet</code> implementation of this <code>IPartListener</code> > * method first sees if the active part is an <code>IContributedContentsView</code> > * adapter and if so, asks it for its contributing part. >@@ -190,6 +273,10 @@ > super.partActivated(part); > } > >+ if(isImportant(part)) { >+ currentPart = part; >+ } >+ > // When the view is first opened, pass the selection to the page > if (bootstrapSelection != null) { > IPropertySheetPage page = (IPropertySheetPage) getCurrentPage(); >@@ -206,14 +293,18 @@ > */ > public void selectionChanged(IWorkbenchPart part, ISelection sel) { > // we ignore our own selection or null selection >- if (part == this || sel == null) { >+ if (sel == null || !isImportant(part) >+ || (!isImportant(part) && sel.equals(currentSelection))) { > return; > } >- >+ >+ currentPart = part; >+ currentSelection = sel; >+ > // pass the selection to the page > IPropertySheetPage page = (IPropertySheetPage) getCurrentPage(); > if (page != null) { >- page.selectionChanged(part, sel); >+ page.selectionChanged(currentPart, currentSelection); > } > } > >@@ -246,4 +337,51 @@ > } > return null; > } >+ >+ /** >+ * Open a new view instance with the current selection. >+ * @since 3.5 >+ */ >+ private class NewPropertySheetAction extends Action { >+ >+ private NewPropertySheetAction() { >+ super(PropertiesMessages.New_text); >+ >+ setId(NewPropertySheetAction.class.getName() >+ + "#" + SECONDARY_ID_COUNTER); //$NON-NLS-1$ >+ setToolTipText(PropertiesMessages.New_toolTip); >+ setImageDescriptor(ViewsPlugin >+ .getViewImageDescriptor("elcl16/new.gif")); //$NON-NLS-1$ >+ >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, >+ IPropertiesHelpContextIds.NEW_ACTION); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.action.Action#run() >+ */ >+ public void run() { >+ super.run(); >+ try { >+ IWorkbenchPage workbenchPage = getViewSite().getPage(); >+ >+ PropertySheet newSheet = (PropertySheet) workbenchPage >+ .showView( >+ getViewSite().getId(), >+ PropertySheet.class.getName() >+ + "#" + ++SECONDARY_ID_COUNTER, IWorkbenchPage.VIEW_ACTIVATE); //$NON-NLS-1$ >+ newSheet.partActivated(currentPart); >+ newSheet.selectionChanged(currentPart, currentSelection); >+ >+ // and pin this one >+ pinPropertySheetAction.setChecked(true); >+ } catch (PartInitException e) { >+ ViewsPlugin.getDefault().getLog().log( >+ new Status(IStatus.ERROR, ViewsPlugin.PLUGIN_ID, >+ IStatus.OK, e.getMessage(), e)); >+ } >+ } >+ } > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.views/plugin.xml,v >retrieving revision 1.26 >diff -u -r1.26 plugin.xml >--- plugin.xml 23 Feb 2006 19:35:46 -0000 1.26 >+++ plugin.xml 26 Sep 2008 15:36:36 -0000 >@@ -5,11 +5,12 @@ > <extension > point="org.eclipse.ui.views"> > <view >- name="%Views.PropertySheet" >- icon="$nl$/icons/full/eview16/prop_ps.gif" >+ allowMultiple="true" > category="org.eclipse.ui" > class="org.eclipse.ui.views.properties.PropertySheet" >- id="org.eclipse.ui.views.PropertySheet"> >+ icon="$nl$/icons/full/eview16/prop_ps.gif" >+ id="org.eclipse.ui.views.PropertySheet" >+ name="%Views.PropertySheet"> > </view> > <view > name="%Views.ContentOutline" >Index: icons/full/elcl16/pin.gif >=================================================================== >RCS file: icons/full/elcl16/pin.gif >diff -N icons/full/elcl16/pin.gif >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ icons/full/elcl16/pin.gif 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+GIF89a����2]������0t�Dv�Fw�Fx�>��>��]��������]�Î�Ú�����Z��o����X��s�����������������������������������������������������������r6a.R'�>5�Xr�I}�Q�Ê��n���������������!�8,�@�pH,�H��%KW�X��A_Â��p<��lc���I�r�hV/X�X8 >+�z�nD7 >+��|3�C�!!!���B6 >+""�#6D4 >+%$%%%5D* >+&��)D >+'(' �� D����NHA; >Index: icons/full/dlcl16/pin.gif >=================================================================== >RCS file: icons/full/dlcl16/pin.gif >diff -N icons/full/dlcl16/pin.gif >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ icons/full/dlcl16/pin.gif 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,2 @@ >+GIF89a���������������������������Թ����������������������������������������y�~������������������!�,\�'�di�(Ú)�i[�z����w��#�L. >+'�����d0La�T�.�a|���b��!�v�P���eÏ·4,s���i;�,3&!; >Index: src/org/eclipse/ui/views/properties/PinPropertySheetAction.java >=================================================================== >RCS file: src/org/eclipse/ui/views/properties/PinPropertySheetAction.java >diff -N src/org/eclipse/ui/views/properties/PinPropertySheetAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/views/properties/PinPropertySheetAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant 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: >+ * Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.views.properties; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.views.ViewsPlugin; >+import org.eclipse.ui.internal.views.properties.PropertiesMessages; >+ >+/** >+ * Pins the properties view instance to the current selection. >+ * @since 3.5 >+ */ >+public class PinPropertySheetAction extends Action { >+ >+ /** >+ * @param id suffix that is used to create a unique id. >+ */ >+ public PinPropertySheetAction(int id) { >+ super(PropertiesMessages.Pin_text, IAction.AS_CHECK_BOX); >+ >+ setId(PinPropertySheetAction.class.getName() + "#" + id); //$NON-NLS-1$ >+ setToolTipText(PropertiesMessages.Pin_toolTip); >+ setImageDescriptor(ViewsPlugin.getViewImageDescriptor("elcl16/pin.gif")); //$NON-NLS-1$ >+ setDisabledImageDescriptor(ViewsPlugin >+ .getViewImageDescriptor("dlcl16/pin.gif")); //$NON-NLS-1$ >+ >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, >+ IPropertiesHelpContextIds.PIN_ACTION); >+ } >+ >+} >Index: icons/full/elcl16/new.gif >=================================================================== >RCS file: icons/full/elcl16/new.gif >diff -N icons/full/elcl16/new.gif >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ icons/full/elcl16/new.gif 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+GIF89a�Ft�Fu�S��Dv�Fw�Hy�S��k��l���������������v�������h��m������s��������������������������������������������������������������������������������������������������������������������������������������������������������������Ë�j������������������ѵ�#��#��&���������ë©~`�y���������ß���������å�e��Q��Wjq��Z��\��K��M��O˪_��\��T��V�p��r���!�w,@w������V��H�� >+ >+TUHUU�aNORSMaw� >+``Y_^�n�� +,]b]u�o!��)-4?WEv�p&'"26;cJq�i#�#09=dBr�s$�1:Ge<t�jJx�".�b�>��q&H�l��!��I�`�c��6�РabJ�-KÖ ï¿½B�����; >#P org.eclipse.ui.tests >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.19 >diff -u -r1.19 SessionTests.java >--- Eclipse UI Tests/org/eclipse/ui/tests/session/SessionTests.java 29 Jul 2008 15:09:01 -0000 1.19 >+++ Eclipse UI Tests/org/eclipse/ui/tests/session/SessionTests.java 26 Sep 2008 15:36:38 -0000 >@@ -100,7 +100,10 @@ > Bug108033Test.class)); > addTest(new WorkbenchSessionTest("editorSessionTests", > ArbitraryPropertiesViewTest.class)); >- addTest(new WorkbenchSessionTest("editorSessionTests", NonRestorableViewTest.class)); >+ addTest(new WorkbenchSessionTest("editorSessionTests", >+ NonRestorableViewTest.class)); >+ addTest(new WorkbenchSessionTest("editorSessionTests", >+ NonRestorablePropertySheetTest.class)); > addTest(new WorkbenchSessionTest("editorSessionTests", > MarkersViewColumnSizeTest.class)); > } >Index: Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java,v >retrieving revision 1.1 >diff -u -r1.1 NonRestorableView.java >--- Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java 20 Mar 2008 02:01:05 -0000 1.1 >+++ Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java 26 Sep 2008 15:36:38 -0000 >@@ -14,19 +14,11 @@ > import org.eclipse.ui.part.ViewPart; > > public class NonRestorableView extends ViewPart { >+ public static final String ID ="org.eclipse.ui.tests.session.NonRestorableView"; > >- public NonRestorableView() { >- // TODO Auto-generated constructor stub >- } >+ public NonRestorableView() { } > >- public void createPartControl(Composite parent) { >- // TODO Auto-generated method stub >- >- } >- >- public void setFocus() { >- // TODO Auto-generated method stub >- >- } >+ public void createPartControl(Composite parent) {} > >+ public void setFocus() { } > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/META-INF/MANIFEST.MF,v >retrieving revision 1.11 >diff -u -r1.11 MANIFEST.MF >--- META-INF/MANIFEST.MF 13 Aug 2008 22:58:31 -0000 1.11 >+++ META-INF/MANIFEST.MF 26 Sep 2008 15:36:38 -0000 >@@ -2,7 +2,7 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: Eclipse UI Tests > Bundle-SymbolicName: org.eclipse.ui.tests; singleton:=true >-Bundle-Version: 3.3.0.qualifier >+Bundle-Version: 3.4.0.qualifier > Bundle-ClassPath: uitests.jar > Bundle-Activator: org.eclipse.core.internal.compatibility.PluginActivator > Bundle-Vendor: Eclipse.org >Index: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestPropertySheetPage.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestPropertySheetPage.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestPropertySheetPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestPropertySheetPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant 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: >+ * Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.tests.propertysheet; >+ >+import org.eclipse.core.runtime.IAdapterFactory; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.views.properties.IPropertySheetPage; >+import org.eclipse.ui.views.properties.PropertySheetPage; >+ >+/** >+ * @since 3.5 >+ * >+ */ >+public class TestPropertySheetPage extends PropertySheetPage implements >+ IPropertySheetPage, IAdapterFactory { >+ >+ private ISelection fSelection; >+ private IWorkbenchPart fPart; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) >+ */ >+ public Object getAdapter(Object adaptableObject, Class adapterType) { >+ fSelection = null; >+ fPart = null; >+ return this; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() >+ */ >+ public Class[] getAdapterList() { >+ return new Class[]{IPropertySheetPage.class}; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.views.properties.PropertySheetPage#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IWorkbenchPart part, ISelection selection) { >+ super.selectionChanged(part, selection); >+ fPart = part; >+ fSelection = selection; >+ } >+ >+ /** >+ * @return Returns the selection. >+ */ >+ public ISelection getSelection() { >+ return fSelection; >+ } >+ >+ /** >+ * @return Returns the part. >+ */ >+ public IWorkbenchPart getPart() { >+ return fPart; >+ } >+} >Index: Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorablePropertySheetTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorablePropertySheetTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorablePropertySheetTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorablePropertySheetTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corp 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: >+ * Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.tests.session; >+ >+import junit.framework.TestCase; >+import junit.framework.TestSuite; >+ >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IViewReference; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.views.properties.PropertySheet; >+ >+/** >+ * The secondary property sheets should be closed so there aren't restored in the next workbench session. >+ * >+ * @since 3.5 >+ */ >+public class NonRestorablePropertySheetTest extends TestCase { >+ >+ private static final String PROPERTY_SHEET_VIEW_ID = "org.eclipse.ui.views.PropertySheet"; >+ >+ public static TestSuite suite() { >+ return new TestSuite(NonRestorablePropertySheetTest.class); >+ } >+ >+ public NonRestorablePropertySheetTest(String testName) { >+ super(testName); >+ } >+ /** >+ * This is the first part instantiates a bunch of property sheets >+ * >+ * @throws PartInitException >+ */ >+ public void test01ActivateView() throws PartInitException { >+ final IWorkbench workbench = PlatformUI.getWorkbench(); >+ final IWorkbenchPage page = workbench.getActiveWorkbenchWindow() >+ .getActivePage(); >+ >+ IViewPart part = page.showView(PROPERTY_SHEET_VIEW_ID); >+ assertNotNull(part); >+ assertTrue(part instanceof PropertySheet); >+ >+ for (int j = 0; j < 3; j++) { >+ try { >+ page.showView(PROPERTY_SHEET_VIEW_ID, "#" + j, IWorkbenchPage.VIEW_ACTIVATE); >+ } catch (PartInitException e) { >+ fail(e.getMessage()); >+ } >+ } >+ assertTrue(countPropertySheetViews(page) == 4); >+ } >+ >+ /** >+ * In the second session the property sheet views with secondary ids shouldn't be >+ * instantiated. >+ * >+ * @throws PartInitException >+ */ >+ public void test02SecondOpening() throws PartInitException { >+ final IWorkbench workbench = PlatformUI.getWorkbench(); >+ final IWorkbenchPage page = workbench.getActiveWorkbenchWindow() >+ .getActivePage(); >+ >+ assertTrue(countPropertySheetViews(page) == 1); >+ } >+ >+ // simple counts how many property sheet instances are open >+ private int countPropertySheetViews(final IWorkbenchPage page) { >+ int count = 0; >+ IViewReference[] views = page.getViewReferences(); >+ for (int i = 0; i < views.length; i++) { >+ IViewReference ref = views[i]; >+ if (ref.getId().equals(PROPERTY_SHEET_VIEW_ID)) { >+ count++; >+ } >+ } >+ return count; >+ } >+ >+} >Index: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/MultiInstancePropertySheetTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/MultiInstancePropertySheetTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/MultiInstancePropertySheetTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/MultiInstancePropertySheetTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,229 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corp. 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: >+ * Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.tests.propertysheet; >+ >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.action.ActionContributionItem; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.action.IContributionItem; >+import org.eclipse.jface.action.IToolBarManager; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.tests.SelectionProviderView; >+import org.eclipse.ui.tests.harness.util.UITestCase; >+import org.eclipse.ui.tests.session.NonRestorableView; >+import org.eclipse.ui.views.properties.PropertySheet; >+import org.eclipse.ui.views.properties.PropertySheetPage; >+ >+/** >+ * @since 3.5 >+ */ >+public class MultiInstancePropertySheetTest extends UITestCase { >+ >+ private static final String PIN_PROPERTY_SHEET_ACTION_ID_PREFIX = "org.eclipse.ui.views.properties.PinPropertySheetAction"; >+// private static final String NEW_PROPERTY_SHEET_ACTION_ID_PREFIX = "org.eclipse.ui.views.properties.PropertySheet$NewPropertySheetAction"; >+ private static final String PROPERTY_SHEET_ID = "org.eclipse.ui.views.PropertySheet"; >+ >+ /** >+ * TestPropertySheetPage exposes certain members for testability >+ */ >+ private TestPropertySheetPage testPropertySheetPage = new TestPropertySheetPage(); >+ private IWorkbenchPage activePage; >+ private PropertySheet propertySheet; >+ private SelectionProviderView selectionProviderView; >+ >+ /** >+ * @param testName >+ */ >+ public MultiInstancePropertySheetTest(String testName) { >+ super(testName); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.tests.harness.util.UITestCase#doSetUp() >+ */ >+ protected void doSetUp() throws Exception { >+ super.doSetUp(); >+ IWorkbenchWindow workbenchWindow = openTestWindow(); >+ activePage = workbenchWindow.getActivePage(); >+ >+ // open the property sheet with the TestPropertySheetPage >+ Platform.getAdapterManager().registerAdapters(testPropertySheetPage, >+ PropertySheet.class); >+ propertySheet = (PropertySheet) activePage >+ .showView(PROPERTY_SHEET_ID); >+ >+ selectionProviderView = (SelectionProviderView) activePage >+ .showView(SelectionProviderView.ID); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ui.tests.harness.util.UITestCase#doTearDown() >+ */ >+ protected void doTearDown() throws Exception { >+ super.doTearDown(); >+ Platform.getAdapterManager().unregisterAdapters(testPropertySheetPage, >+ PropertySheet.class); >+ } >+ >+ /** >+ * @param propertySheet >+ */ >+ private IAction getPropertySheetAction(PropertySheet propertySheet, >+ String id) { >+ IActionBars actionBars = propertySheet.getViewSite().getActionBars(); >+ IToolBarManager toolBarManager = actionBars.getToolBarManager(); >+ IContributionItem[] items = toolBarManager.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ IContributionItem contributionItem = items[i]; >+ if (contributionItem.getId() != null && contributionItem.getId().startsWith(id)) { >+ IAction action = ((ActionContributionItem) contributionItem) >+ .getAction(); >+ return action; >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * The if the registered {@link TestPropertySheetPage} is set as the default >+ * page of the PropertySheet >+ * >+ * @throws PartInitException >+ */ >+ public void testDefaultPage() throws PartInitException { >+ PropertySheet propertySheet = (PropertySheet) activePage >+ .showView(PROPERTY_SHEET_ID); >+ assertTrue(propertySheet.getCurrentPage() instanceof PropertySheetPage); >+ } >+ >+ /** >+ * Test if the registered {@link TestPropertySheetPage} is set as the >+ * default page of the PropertySheet >+ * >+ * @throws PartInitException >+ */ >+ public void testDefaultPageAdapter() throws PartInitException { >+ Platform.getAdapterManager().registerAdapters(testPropertySheetPage, >+ PropertySheet.class); >+ PropertySheet propertySheet = (PropertySheet) activePage >+ .showView(PROPERTY_SHEET_ID); >+ assertTrue(propertySheet.getCurrentPage() instanceof TestPropertySheetPage); >+ } >+ >+ /** >+ * Test if the PropertySheet allows multiple instances >+ * >+ * @throws PartInitException >+ */ >+ public void testAllowsMultiple() throws PartInitException { >+ activePage.showView(PROPERTY_SHEET_ID); >+ try { >+ activePage.showView(PROPERTY_SHEET_ID, >+ "aSecondaryId", IWorkbenchPage.VIEW_ACTIVATE); >+ } catch (PartInitException e) { >+ fail(e.getMessage()); >+ } >+ } >+ >+ // make sure the property sheet follows selection/part changes >+ public void testFollowsSelection() throws Throwable { >+ // selection before selection changes >+ TestPropertySheetPage firstPage = (TestPropertySheetPage) propertySheet >+ .getCurrentPage(); >+ Object firstSelection = firstPage.getSelection(); >+ assertNotNull(firstSelection); >+ >+ // change the selection explicitly >+ selectionProviderView.setSelection(new Object()); >+ TestPropertySheetPage secondPage = (TestPropertySheetPage) propertySheet >+ .getCurrentPage(); >+ >+ assertNotSame("PropertySheet hasn't changed selection", firstSelection, >+ secondPage.getSelection()); >+ } >+ >+ // make sure the property sheet follows selection/part changes >+ public void testFollowsParts() throws Throwable { >+ // selection before selection changes >+ TestPropertySheetPage firstPage = (TestPropertySheetPage) propertySheet >+ .getCurrentPage(); >+ Object firstPart = firstPage.getPart(); >+ assertNotNull(firstPart); >+ >+ // change the part explicitly (reusing the NonRestorableView here) >+ TestPropertySheetPage testPropertySheetPage2 = new TestPropertySheetPage(); >+ Platform.getAdapterManager().registerAdapters(testPropertySheetPage2, >+ org.eclipse.ui.tests.session.NonRestorableView.class); >+ activePage.showView(NonRestorableView.ID); >+ >+ TestPropertySheetPage secondPage = (TestPropertySheetPage) propertySheet >+ .getCurrentPage(); >+ >+ assertEquals(testPropertySheetPage2, secondPage); >+ assertNotSame("PropertySheet hasn't changed selection", firstPart, >+ secondPage.getSelection()); >+ } >+ >+ public void testPinning() throws Throwable { >+ >+ // execute the pin action on the property sheet >+ IAction action = getPropertySheetAction(propertySheet, >+ PIN_PROPERTY_SHEET_ACTION_ID_PREFIX); >+ action.setChecked(true); >+ >+ // get the content of the pinned property sheet for later comparison >+ TestPropertySheetPage firstPage = (TestPropertySheetPage) propertySheet >+ .getCurrentPage(); >+ assertNotNull(firstPage); >+ Object firstSelection = firstPage.getSelection(); >+ assertNotNull(firstSelection); >+ IWorkbenchPart firstPart = firstPage.getPart(); >+ assertNotNull(firstPart); >+ >+ // change the selection/part >+ selectionProviderView.setSelection(new Object()); >+ TestPropertySheetPage testPropertySheetPage2 = new TestPropertySheetPage(); >+ Platform.getAdapterManager().registerAdapters(testPropertySheetPage2, >+ org.eclipse.ui.tests.session.NonRestorableView.class); >+ activePage.showView(NonRestorableView.ID); >+ >+ TestPropertySheetPage secondPage = (TestPropertySheetPage) propertySheet >+ .getCurrentPage(); >+ assertEquals("PropertySheet has changed page", firstPage, secondPage); >+ assertEquals("PropertySheetPage has changed selection", firstSelection, >+ secondPage.getSelection()); >+ assertEquals("PropertySheetPage has changed part", firstPart, >+ secondPage.getPart()); >+ } >+ >+ public void testUnpinningWhenPinnedPartIsClosed() throws Throwable { >+ // execute the pin action on the property sheet >+ IAction action = getPropertySheetAction(propertySheet, >+ PIN_PROPERTY_SHEET_ACTION_ID_PREFIX); >+ action.setChecked(true); >+ >+ // close the part the property sheet is pinned to >+ activePage.hideView(selectionProviderView); >+ >+ // the action and therefore the property sheet should be unpinned >+ assertFalse(action.isChecked()); >+ } >+ >+ public void testNewPropertySheet() { >+ fail("Not yet implemented"); >+ } >+}
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 248103
:
113604
|
114388
|
114389
|
115122
|
115123
|
115414
|
115890
|
119782
|
119785
|
124014