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 114388 Details for
Bug 248103
[PropertiesView] Multi-instance Properties View
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New patch version ready for review
248103.txt (text/plain), 77.92 KB, created by
Markus Kuppe
on 2008-10-07 04:00:53 EDT
(
hide
)
Description:
New patch version ready for review
Filename:
MIME Type:
Creator:
Markus Kuppe
Created:
2008-10-07 04:00:53 EDT
Size:
77.92 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.views >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 7 Oct 2008 07:58:44 -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,11 @@ > public static String Filter_toolTip; > > /** */ >+ public static String Pin_text; >+ /** */ >+ public static String Pin_toolTip; >+ >+ /** */ > public static String PropertyViewer_property; > /** */ > public static String PropertyViewer_value; >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 7 Oct 2008 07:58:44 -0000 >@@ -29,6 +29,9 @@ > Filter_text = Show &Advanced Properties > Filter_toolTip = Show Advanced Properties > >+Pin_text = &Pin to selection >+Pin_toolTip = Pin property to current selection >+ > PropertyViewer_property = Property > PropertyViewer_value = Value > PropertyViewer_misc = Misc >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 7 Oct 2008 07:58:44 -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,9 @@ > 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$; >+ > // 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 7 Oct 2008 07:58:44 -0000 >@@ -7,14 +7,21 @@ > * > * 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.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; >@@ -22,8 +29,11 @@ > import org.eclipse.ui.part.IContributedContentsView; > import org.eclipse.ui.part.IPage; > import org.eclipse.ui.part.IPageBookViewPage; >+import org.eclipse.ui.part.IShowInSource; >+import org.eclipse.ui.part.IShowInTarget; > import org.eclipse.ui.part.PageBook; > import org.eclipse.ui.part.PageBookView; >+import org.eclipse.ui.part.ShowInContext; > > /** > * Main class for the Property Sheet View. >@@ -61,18 +71,39 @@ > * @noinstantiate This class is not intended to be instantiated by clients. > * @noextend This class is not intended to be subclassed by clients. > */ >-public class PropertySheet extends PageBookView implements ISelectionListener { >+public class PropertySheet extends PageBookView implements ISelectionListener, IShowInTarget, IShowInSource { > /** > * No longer used but preserved to avoid api change > */ > public static final String HELP_CONTEXT_PROPERTY_SHEET_VIEW = IPropertiesHelpContextIds.PROPERTY_SHEET_VIEW; > >+ /** >+ * The PropertySheet view id >+ * since 3.4 >+ */ >+// public static final String ID = "org.eclipse.ui.views.PropertySheet"; //$NON-NLS-1$ >+ > /** > * The initial selection when the property sheet opens > */ > 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; >+ >+ /** > * Creates a property sheet view. > */ > public PropertySheet() { >@@ -84,18 +115,34 @@ > * 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(); >+ IMenuManager menuManager = getViewSite().getActionBars() >+ .getMenuManager(); >+ menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); >+ menuManager.add(pinPropertySheetAction); >+ >+ IToolBarManager toolBarManager = getViewSite().getActionBars() >+ .getToolBarManager(); >+ menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); >+ toolBarManager.add(pinPropertySheetAction); >+ > getSite().getPage().getWorkbenchWindow().getWorkbench().getHelpSystem() > .setHelp(getPageBook(), > IPropertiesHelpContextIds.PROPERTY_SHEET_VIEW); >@@ -116,7 +163,12 @@ > * Method declared on PageBookView. > */ > protected PageRec doCreatePage(IWorkbenchPart part) { >- // Try to get a custom property sheet page. >+ // Get a custom property sheet page but not if the part is also a >+ // PropertySheet. In this case the child property sheet would >+ // accidentally reuse the parent's property sheet page. >+ if(part instanceof PropertySheet) { >+ return null; >+ } > IPropertySheetPage page = (IPropertySheetPage) ViewsPlugin.getAdapter(part, > IPropertySheetPage.class, false); > if (page != null) { >@@ -158,19 +210,46 @@ > * 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) >+ * since 3.4 >+ */ >+ 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) >+ * since 3.4 >+ */ >+ 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 +269,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 +289,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 +333,43 @@ > } > return null; > } >+ >+ /** >+ * @return whether this property sheet is currently pinned >+ * @since 3.4 >+ */ >+ public boolean isPinned() { >+ return pinPropertySheetAction.isChecked(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.part.IShowInSource#getShowInContext() >+ * @since 3.4 >+ */ >+ public ShowInContext getShowInContext() { >+ return new PropertyShowInContext(currentPart, currentSelection); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext) >+ * @since 3.4 >+ */ >+ public boolean show(ShowInContext aContext) { >+ if (!pinPropertySheetAction.isChecked() >+ && aContext instanceof PropertyShowInContext) { >+ PropertyShowInContext context = (PropertyShowInContext) aContext; >+ partActivated(context.getPart()); >+ selectionChanged(context.getPart(), context.getSelection()); >+ return true; >+ } >+ return false; >+ } >+ >+ /*** >+ * @param pinned Whether this sheet should be pinned >+ * @since 3.4 >+ */ >+ public void setPinned(boolean pinned) { >+ pinPropertySheetAction.setChecked(pinned); >+ } > } >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.views/plugin.properties,v >retrieving revision 1.13 >diff -u -r1.13 plugin.properties >--- plugin.properties 8 May 2006 20:53:18 -0000 1.13 >+++ plugin.properties 7 Oct 2008 07:58:44 -0000 >@@ -12,5 +12,6 @@ > providerName= Eclipse.org > > Views.PropertySheet = Properties >+Views.NewPropertySheet = Open new properties > Views.ContentOutline = Outline > >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 7 Oct 2008 07:58:44 -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" >@@ -19,5 +20,34 @@ > id="org.eclipse.ui.views.ContentOutline"> > </view> > </extension> >+ <extension >+ point="org.eclipse.ui.menus"> >+ <menuContribution >+ locationURI="popup:org.eclipse.ui.menus.showInMenu"> >+ <command >+ commandId="org.eclipse.ui.views.properties.NewPropertySheetCommand" >+ icon="platform:/plugin/org.eclipse.ui.views/icons/full/eview16/prop_ps.gif" >+ label="%Views.PropertySheet" >+ style="push"> >+ </command> >+ </menuContribution> >+ <menuContribution >+ locationURI="toolbar:org.eclipse.ui.views.PropertySheet"> >+ <command >+ commandId="org.eclipse.ui.views.properties.NewPropertySheetCommand" >+ icon="icons/full/elcl16/new.gif" >+ label="%Views.NewPropertySheet" >+ style="push"> >+ </command> >+ </menuContribution> >+ </extension> >+ <extension >+ point="org.eclipse.ui.commands"> >+ <command >+ defaultHandler="org.eclipse.ui.views.properties.NewPropertySheetHandler" >+ id="org.eclipse.ui.views.properties.NewPropertySheetCommand" >+ name="%Views.PropertySheet"> >+ </command> >+ </extension> > > </plugin> >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 7 Oct 2008 07:58:44 -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: 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�����; >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 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.views.properties; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.IWorkbenchGraphicConstants; >+import org.eclipse.ui.internal.WorkbenchImages; >+import org.eclipse.ui.internal.views.properties.PropertiesMessages; >+ >+/** >+ * Pins the properties view instance to the current selection. >+ * >+ * @since 3.4 >+ */ >+public class PinPropertySheetAction extends Action { >+ >+ public PinPropertySheetAction() { >+ super(PropertiesMessages.Pin_text, IAction.AS_CHECK_BOX); >+ >+ setId(PinPropertySheetAction.class.getName() >+ + "#" + Long.toString(System.currentTimeMillis())); //$NON-NLS-1$ >+ setToolTipText(PropertiesMessages.Pin_toolTip); >+ setImageDescriptor(WorkbenchImages >+ .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR)); >+ setDisabledImageDescriptor(WorkbenchImages >+ .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR_DISABLED)); >+ >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, >+ IPropertiesHelpContextIds.PIN_ACTION); >+ } >+} >Index: src/org/eclipse/ui/views/properties/PropertyShowInContext.java >=================================================================== >RCS file: src/org/eclipse/ui/views/properties/PropertyShowInContext.java >diff -N src/org/eclipse/ui/views/properties/PropertyShowInContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/views/properties/PropertyShowInContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,107 @@ >+/******************************************************************************* >+ * 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.views.properties; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.part.ShowInContext; >+ >+/** >+ * @since 3.4 >+ * >+ */ >+public class PropertyShowInContext extends ShowInContext { >+ >+ private IWorkbenchPart part; >+ >+ /** >+ * @param aPart >+ * @param selection >+ */ >+ public PropertyShowInContext(IWorkbenchPart aPart, ISelection selection) { >+ super(selection, selection); >+ part = aPart; >+ } >+ >+ /** >+ * @param aPart >+ * @param aShowInContext >+ */ >+ public PropertyShowInContext(IWorkbenchPart aPart, >+ ShowInContext aShowInContext) { >+ super(aShowInContext.getInput(), aShowInContext.getSelection()); >+ part = aPart; >+ } >+ >+ /** >+ * @return Returns the part. >+ */ >+ public IWorkbenchPart getPart() { >+ return part; >+ } >+ >+ /** >+ * @param part >+ * The part to set. >+ */ >+ public void setPart(IWorkbenchPart part) { >+ this.part = part; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.lang.Object#hashCode() >+ */ >+ public int hashCode() { >+ final int prime = 31; >+ int result = 1; >+ result = prime * result + ((part == null) ? 0 : part.hashCode()) >+ + ((getSelection() == null) ? 0 : getSelection().hashCode()) >+ + ((getInput() == null) ? 0 : getInput().hashCode()); >+ return result; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ if (this == obj) >+ return true; >+ if (obj == null) >+ return false; >+ if (getClass() != obj.getClass()) >+ return false; >+ PropertyShowInContext other = (PropertyShowInContext) obj; >+ // part needs to be equal >+ if (part == null) { >+ if (other.part != null) >+ return false; >+ } else if (!part.equals(other.part)) >+ return false; >+ // selection needs to be equal >+ if (getSelection() == null) { >+ if (other.getSelection() != null) >+ return false; >+ } else if (!getSelection().equals(other.getSelection())) >+ return false; >+ // input needs to be equal >+ if (getInput() == null) { >+ if (other.getInput() != null) >+ return false; >+ } else if (!getInput().equals(other.getInput())) >+ return false; >+ return true; >+ } >+} >Index: src/org/eclipse/ui/views/properties/NewPropertySheetHandler.java >=================================================================== >RCS file: src/org/eclipse/ui/views/properties/NewPropertySheetHandler.java >diff -N src/org/eclipse/ui/views/properties/NewPropertySheetHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/views/properties/NewPropertySheetHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,128 @@ >+/******************************************************************************* >+ * 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.views.properties; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.ui.IPageLayout; >+import org.eclipse.ui.IViewReference; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.ui.part.IShowInSource; >+import org.eclipse.ui.part.ShowInContext; >+ >+/** >+ * @since 3.4 >+ */ >+public class NewPropertySheetHandler extends AbstractHandler { >+ >+ /** >+ * Command id >+ */ >+ public static final String ID = "org.eclipse.ui.views.properties.NewPropertySheetCommand"; //$NON-NLS-1$ >+ >+ /** >+ * First tries to find a suitable instance to reuse for the given context, >+ * then creates a new instance if necessary. >+ * >+ * @param event >+ * @return an instance for the given context >+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IWorkbenchPart activePart = HandlerUtil.getActivePartChecked(event); >+ >+ PropertyShowInContext context = getShowInContext(event); >+ try { >+ PropertySheet sheet = findPropertySheet(event, context); >+ sheet.show(context); >+ if (activePart instanceof PropertySheet) { >+ PropertySheet parent = (PropertySheet) activePart; >+ parent.setPinned(true); >+ } else { >+ sheet.setPinned(true); >+ } >+ } catch (PartInitException e) { >+ throw new ExecutionException("Part could not be initialized", e); //$NON-NLS-1$ >+ } >+ return null; >+ } >+ >+ /** >+ * @param event >+ * {@link ExecutionEvent} for which the >+ * {@link PropertyShowInContext} is requested >+ * @return a {@link PropertyShowInContext} containing the the >+ * {@link ISelection} and {@link IWorkbenchPart} for the given >+ * {@link ExecutionEvent} >+ * @throws ExecutionException >+ */ >+ protected PropertyShowInContext getShowInContext(ExecutionEvent event) >+ throws ExecutionException { >+ IWorkbenchPart activePart = HandlerUtil.getActivePartChecked(event); >+ if (activePart instanceof PropertySheet) { >+ PropertySheet sheet = (PropertySheet) activePart; >+ return (PropertyShowInContext) sheet.getShowInContext(); >+ } >+ IShowInSource adapter = (IShowInSource) activePart >+ .getAdapter(IShowInSource.class); >+ if (adapter != null) { >+ ShowInContext showInContext = adapter.getShowInContext(); >+ return new PropertyShowInContext(activePart, showInContext); >+ } >+ return new PropertyShowInContext(activePart, HandlerUtil >+ .getShowInSelection(event)); >+ } >+ >+ /** >+ * Returns a PropertySheet instance >+ * >+ * @param event >+ * @param context >+ * a {@link ShowInContext} to handle >+ * @return a PropertySheet that can handle the given {@link ShowInContext} >+ * @throws PartInitException >+ * @throws ExecutionException >+ */ >+ protected PropertySheet findPropertySheet(ExecutionEvent event, >+ PropertyShowInContext context) throws PartInitException, >+ ExecutionException { >+ IWorkbenchPage page = HandlerUtil.getActivePartChecked(event).getSite() >+ .getPage(); >+ String secondaryId = null; >+ if (HandlerUtil.getActivePart(event) instanceof PropertySheet) { >+ secondaryId = Long.toString(System.currentTimeMillis()); >+ } else { >+ IViewReference[] refs = page.getViewReferences(); >+ for (int i = 0; i < refs.length; i++) { >+ IViewReference viewReference = refs[i]; >+ if (IPageLayout.ID_PROP_SHEET.equals(viewReference.getId())) { >+ secondaryId = Long.toString(System.currentTimeMillis()); >+ PropertySheet sheet = (PropertySheet) viewReference >+ .getView(true); >+ if (!sheet.isPinned() >+ || (sheet.isPinned() && sheet.getShowInContext() >+ .equals(context))) { >+ secondaryId = sheet.getViewSite().getSecondaryId(); >+ break; >+ } >+ } >+ } >+ } >+ return (PropertySheet) page.showView(IPageLayout.ID_PROP_SHEET, >+ secondaryId, IWorkbenchPage.VIEW_ACTIVATE); >+ } >+} >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java,v >retrieving revision 1.15 >diff -u -r1.15 PropertySheetAuto.java >--- Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java 8 May 2006 20:51:33 -0000 1.15 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java 7 Oct 2008 07:58:47 -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.tests.propertysheet; > >@@ -16,6 +17,7 @@ > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.IPageLayout; > import org.eclipse.ui.ISaveablePart; > import org.eclipse.ui.IViewPart; > import org.eclipse.ui.IWorkbenchPage; >@@ -245,7 +247,7 @@ > > protected IWorkbenchPart createTestPart(IWorkbenchPage page) > throws Throwable { >- IViewPart view = page.showView("org.eclipse.ui.views.PropertySheet"); >+ IViewPart view = page.showView(IPageLayout.ID_PROP_SHEET); > selectionProviderView = (SelectionProviderView) page > .showView(SelectionProviderView.ID); > return view; >Index: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetTestSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetTestSuite.java,v >retrieving revision 1.10 >diff -u -r1.10 PropertySheetTestSuite.java >--- Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetTestSuite.java 16 Mar 2007 18:00:02 -0000 1.10 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetTestSuite.java 7 Oct 2008 07:58:47 -0000 >@@ -30,6 +30,10 @@ > * Construct the test suite. > */ > public PropertySheetTestSuite() { >+ addTest(new TestSuite(PropertyShowInContextTest.class)); >+ addTest(new TestSuite(MultiInstancePropertySheetTest.class)); >+ addTest(new TestSuite(ShowInPropertySheetTest.class)); >+ addTest(new TestSuite(NewPropertySheetHandlerTest.class)); > addTest(new TestSuite(PropertySheetAuto.class)); > addTest(new TestSuite(ComboBoxPropertyDescriptorTest.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 7 Oct 2008 07:58:47 -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 7 Oct 2008 07:58:47 -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 >@@ -25,7 +25,8 @@ > org.eclipse.core.databinding, > org.eclipse.core.databinding.beans, > org.eclipse.jface.databinding, >- org.eclipse.ui.navigator.resources >+ org.eclipse.ui.navigator.resources, >+ org.eclipse.core.runtime > Eclipse-AutoStart: true > Plugin-Class: org.eclipse.ui.tests.TestPlugin > Export-Package: org.eclipse.ui.tests.api >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/plugin.xml,v >retrieving revision 1.259 >diff -u -r1.259 plugin.xml >--- plugin.xml 2 Oct 2008 18:28:45 -0000 1.259 >+++ plugin.xml 7 Oct 2008 07:58:47 -0000 >@@ -3909,6 +3909,11 @@ > id="org.eclipse.ui.tests.enabledCount" > name="Enabled Count"> > </command> >+ <command >+ defaultHandler="org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler" >+ id="org.eclipse.ui.views.properties.NewPropertySheetCommandTest" >+ name="TestNewPropertySheetCommand"> >+ </command> > </extension> > <extension > point="org.eclipse.ui.handlers"> >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 7 Oct 2008 07:58:47 -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 UI Tests/org/eclipse/ui/tests/propertysheet/AbstractPropertySheetTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/AbstractPropertySheetTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/AbstractPropertySheetTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/AbstractPropertySheetTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/******************************************************************************* >+ * 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.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.IPageLayout; >+import org.eclipse.ui.IViewReference; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.tests.harness.util.UITestCase; >+import org.eclipse.ui.views.properties.PropertySheet; >+ >+/** >+ * @since 3.4 >+ * >+ */ >+public abstract class AbstractPropertySheetTest extends UITestCase { >+ >+ private static final String PIN_PROPERTY_SHEET_ACTION_ID_PREFIX = "org.eclipse.ui.views.properties.PinPropertySheetAction"; >+ protected IWorkbenchPage activePage; >+ protected PropertySheet propertySheet; >+ >+ public AbstractPropertySheetTest(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(); >+ } >+ >+ /** >+ * @return the count of PropertySheets >+ */ >+ protected int countPropertySheetViews() { >+ int count = 0; >+ IViewReference[] views = activePage.getViewReferences(); >+ for (int i = 0; i < views.length; i++) { >+ IViewReference ref = views[i]; >+ if (ref.getId().equals(IPageLayout.ID_PROP_SHEET)) { >+ count++; >+ } >+ } >+ return count; >+ } >+ >+ protected IAction getPinPropertySheetAction(PropertySheet propertySheet) { >+ 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( >+ PIN_PROPERTY_SHEET_ACTION_ID_PREFIX)) { >+ IAction action = ((ActionContributionItem) contributionItem) >+ .getAction(); >+ return action; >+ } >+ } >+ return null; >+ } >+} >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,94 @@ >+/******************************************************************************* >+ * 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.IPageLayout; >+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.4 >+ */ >+public class NonRestorablePropertySheetTest extends TestCase { >+ >+ 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(IPageLayout.ID_PROP_SHEET); >+ assertNotNull(part); >+ assertTrue(part instanceof PropertySheet); >+ >+ for (int j = 0; j < 3; j++) { >+ try { >+ page.showView(IPageLayout.ID_PROP_SHEET, "#" + 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(IPageLayout.ID_PROP_SHEET)) { >+ count++; >+ } >+ } >+ return count; >+ } >+ >+} >Index: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/ShowInPropertySheetTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/ShowInPropertySheetTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/ShowInPropertySheetTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/ShowInPropertySheetTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,100 @@ >+/******************************************************************************* >+ * 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.jface.viewers.StructuredSelection; >+import org.eclipse.ui.IPageLayout; >+import org.eclipse.ui.part.IShowInTarget; >+import org.eclipse.ui.part.ShowInContext; >+import org.eclipse.ui.views.properties.PropertySheet; >+import org.eclipse.ui.views.properties.PropertyShowInContext; >+ >+/** >+ * @since 3.4 >+ * >+ */ >+public class ShowInPropertySheetTest extends AbstractPropertySheetTest { >+ >+ public ShowInPropertySheetTest(String testName) { >+ super(testName); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.tests.propertysheet.AbstractPropertySheetTest#doSetUp() >+ */ >+ protected void doSetUp() throws Exception { >+ super.doSetUp(); >+ >+ propertySheet = (PropertySheet) activePage >+ .showView(IPageLayout.ID_PROP_SHEET); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.tests.harness.util.UITestCase#doTearDown() >+ */ >+ protected void doTearDown() throws Exception { >+ super.doTearDown(); >+ } >+ >+ /** >+ * Tries to get the IShowInTarget adapter >+ */ >+ public void testGetIShowInTargetAdapter() { >+ Object adapter = propertySheet.getAdapter(IShowInTarget.class); >+ assertNotNull("No IShowInTarget adapter returned", adapter); >+ assertTrue(adapter instanceof IShowInTarget); >+ } >+ >+ /** >+ * Tests ShowIn PropertySheet with various inputs >+ */ >+ public void testShowInPropertySheet() { >+ IShowInTarget showInTarget = (IShowInTarget) propertySheet >+ .getAdapter(IShowInTarget.class); >+ ShowInContext context = new PropertyShowInContext(activePage >+ .getActivePart(), StructuredSelection.EMPTY); >+ assertTrue(showInTarget.show(context)); >+ } >+ >+ /** >+ * Tests ShowIn PropertySheet with various inputs >+ */ >+ public void testShowInPropertySheetWithNull() { >+ IShowInTarget showInTarget = (IShowInTarget) propertySheet >+ .getAdapter(IShowInTarget.class); >+ assertFalse(showInTarget.show(null)); >+ } >+ >+ /** >+ * Tests ShowIn PropertySheet with various inputs >+ */ >+ public void testShowInPropertySheetWithNullContext() { >+ IShowInTarget showInTarget = (IShowInTarget) propertySheet >+ .getAdapter(IShowInTarget.class); >+ assertFalse(showInTarget.show(new ShowInContext(null, null))); >+ } >+ >+ /** >+ * Tests ShowIn PropertySheet with various inputs >+ */ >+ public void testShowInPropertySheetWithNullPart() { >+ IShowInTarget showInTarget = (IShowInTarget) propertySheet >+ .getAdapter(IShowInTarget.class); >+ assertFalse(showInTarget.show(new ShowInContext(new Object(), >+ StructuredSelection.EMPTY))); >+ } >+} >Index: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertyShowInContextTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertyShowInContextTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertyShowInContextTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertyShowInContextTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,244 @@ >+/******************************************************************************* >+ * 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.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.ui.IPageLayout; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.part.ShowInContext; >+import org.eclipse.ui.views.properties.PropertyShowInContext; >+ >+/** >+ * @since 3.5 >+ * >+ */ >+public class PropertyShowInContextTest extends AbstractPropertySheetTest { >+ >+ public PropertyShowInContextTest(String testName) { >+ super(testName); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#hashCode()}. >+ */ >+ public final void testHashCode() { >+ ShowInContext psc1 = new PropertyShowInContext(null, (ISelection) null); >+ ShowInContext psc2 = new PropertyShowInContext(null, (ISelection) null); >+ assertEquals(psc1.hashCode(), psc2.hashCode()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#hashCode()}. >+ */ >+ public final void testHashCode2() { >+ ShowInContext psc1 = new PropertyShowInContext(null, >+ StructuredSelection.EMPTY); >+ ShowInContext psc2 = new PropertyShowInContext(null, >+ StructuredSelection.EMPTY); >+ assertEquals(psc1.hashCode(), psc2.hashCode()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#hashCode()}. >+ * >+ * @throws PartInitException >+ */ >+ public final void testHashCode3() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext psc1 = new PropertyShowInContext(showView, >+ StructuredSelection.EMPTY); >+ ShowInContext psc2 = new PropertyShowInContext(showView, >+ StructuredSelection.EMPTY); >+ assertEquals(psc1.hashCode(), psc2.hashCode()); >+ psc2.setSelection(new StructuredSelection(new Object())); >+ assertFalse(psc1.hashCode() == psc2.hashCode()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#hashCode()}. >+ * >+ * @throws PartInitException >+ */ >+ public final void testHashCode4() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext psc1 = new PropertyShowInContext(showView, >+ new ShowInContext(null, null)); >+ PropertyShowInContext psc2 = new PropertyShowInContext(showView, >+ new ShowInContext(null, null)); >+ assertEquals(psc1.hashCode(), psc2.hashCode()); >+ >+ psc2.setPart(null); >+ assertFalse(psc1.hashCode() == psc2.hashCode()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#hashCode()}. >+ * >+ * @throws PartInitException >+ */ >+ public final void testHashCode5() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext showInContext = new ShowInContext(null, null); >+ ShowInContext psc1 = new PropertyShowInContext(showView, showInContext); >+ ShowInContext psc2 = new PropertyShowInContext(showView, showInContext); >+ assertEquals(psc1.hashCode(), psc2.hashCode()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#hashCode()}. >+ * >+ * @throws PartInitException >+ */ >+ public final void testHashCode6() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext psc1 = new PropertyShowInContext(showView, >+ new ShowInContext(new Object(), null)); >+ ShowInContext psc2 = new PropertyShowInContext(showView, >+ new ShowInContext(null, null)); >+ assertFalse(psc1.hashCode() == psc2.hashCode()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#hashCode()}. >+ * >+ * @throws PartInitException >+ */ >+ public final void testHashCode7() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext psc1 = new PropertyShowInContext(showView, >+ new ShowInContext(null, null)); >+ ShowInContext psc2 = new PropertyShowInContext(showView, >+ new ShowInContext(null, StructuredSelection.EMPTY)); >+ assertFalse(psc1.hashCode() == psc2.hashCode()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#equals(Object)} >+ * . >+ */ >+ public final void testEquals() { >+ ShowInContext psc1 = new PropertyShowInContext(null, >+ StructuredSelection.EMPTY); >+ psc1.setSelection(null); >+ ShowInContext psc2 = new PropertyShowInContext(null, >+ StructuredSelection.EMPTY); >+ psc2.setSelection(null); >+ assertEquals(psc1, psc2); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#equals(Object)} >+ * . >+ */ >+ public final void testEquals2() { >+ ShowInContext psc1 = new PropertyShowInContext(null, >+ StructuredSelection.EMPTY); >+ ShowInContext psc2 = new PropertyShowInContext(null, >+ StructuredSelection.EMPTY); >+ assertEquals(psc1, psc2); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#equals(Object)} >+ * . >+ * >+ * @throws PartInitException >+ */ >+ public final void testEquals3() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext psc1 = new PropertyShowInContext(showView, >+ StructuredSelection.EMPTY); >+ ShowInContext psc2 = new PropertyShowInContext(showView, >+ StructuredSelection.EMPTY); >+ assertEquals(psc1, psc2); >+ psc2.setSelection(new StructuredSelection(new Object())); >+ assertFalse(psc1.equals(psc2)); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#equals(Object)} >+ * . >+ * >+ * @throws PartInitException >+ */ >+ public final void testEquals4() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext psc1 = new PropertyShowInContext(showView, >+ new ShowInContext(null, null)); >+ PropertyShowInContext psc2 = new PropertyShowInContext(showView, >+ new ShowInContext(null, null)); >+ assertEquals(psc1, psc2); >+ >+ psc2.setPart(null); >+ assertFalse(psc1.equals(psc2)); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#equals(Object)} >+ * . >+ * >+ * @throws PartInitException >+ */ >+ public final void testEquals5() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext showInContext = new ShowInContext(null, null); >+ ShowInContext psc1 = new PropertyShowInContext(showView, showInContext); >+ ShowInContext psc2 = new PropertyShowInContext(showView, showInContext); >+ assertEquals(psc1, psc2); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#equals(Object)} >+ * . >+ * >+ * @throws PartInitException >+ */ >+ public final void testEquals6() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext psc1 = new PropertyShowInContext(showView, >+ new ShowInContext(new Object(), null)); >+ ShowInContext psc2 = new PropertyShowInContext(showView, >+ new ShowInContext(null, null)); >+ assertFalse(psc1.equals(psc2)); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.views.properties.PropertyShowInContext#equals(Object)} >+ * . >+ * >+ * @throws PartInitException >+ */ >+ public final void testEquals7() throws PartInitException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ ShowInContext psc1 = new PropertyShowInContext(showView, >+ new ShowInContext(null, null)); >+ ShowInContext psc2 = new PropertyShowInContext(showView, >+ new ShowInContext(null, StructuredSelection.EMPTY)); >+ assertFalse(psc1.equals(psc2)); >+ } >+} >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,79 @@ >+/******************************************************************************* >+ * 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.4 >+ * >+ */ >+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) { >+ // singleton cleanup >+ 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/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,276 @@ >+/******************************************************************************* >+ * 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.commands.ExecutionException; >+import org.eclipse.core.commands.NotEnabledException; >+import org.eclipse.core.commands.NotHandledException; >+import org.eclipse.core.commands.common.NotDefinedException; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IPageLayout; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.handlers.IHandlerService; >+import org.eclipse.ui.tests.SelectionProviderView; >+import org.eclipse.ui.tests.session.NonRestorableView; >+import org.eclipse.ui.views.properties.NewPropertySheetHandler; >+import org.eclipse.ui.views.properties.PropertySheet; >+import org.eclipse.ui.views.properties.PropertySheetPage; >+ >+/** >+ * @since 3.4 >+ */ >+public class MultiInstancePropertySheetTest extends AbstractPropertySheetTest { >+ >+ /** >+ * TestPropertySheetPage exposes certain members for testability >+ */ >+ private TestPropertySheetPage testPropertySheetPage = new TestPropertySheetPage(); >+ private SelectionProviderView selectionProviderView; >+ >+ public MultiInstancePropertySheetTest(String testName) { >+ super(testName); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.tests.propertysheet.AbstractPropertySheetTest#doSetUp() >+ */ >+ protected void doSetUp() throws Exception { >+ super.doSetUp(); >+ // open the property sheet with the TestPropertySheetPage >+ Platform.getAdapterManager().registerAdapters(testPropertySheetPage, >+ PropertySheet.class); >+ propertySheet = (PropertySheet) activePage >+ .showView(IPageLayout.ID_PROP_SHEET); >+ >+ 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); >+ } >+ >+ /** >+ * 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(IPageLayout.ID_PROP_SHEET); >+ assertTrue(propertySheet.getCurrentPage() instanceof PropertySheetPage); >+ } >+ >+ /** >+ * Test if the registered {@link TestPropertySheetPage} is set as the >+ * default page of the PropertyShecet >+ * >+ * @throws PartInitException >+ */ >+ public void testDefaultPageAdapter() throws PartInitException { >+ Platform.getAdapterManager().registerAdapters(testPropertySheetPage, >+ PropertySheet.class); >+ PropertySheet propertySheet = (PropertySheet) activePage >+ .showView(IPageLayout.ID_PROP_SHEET); >+ assertTrue(propertySheet.getCurrentPage() instanceof TestPropertySheetPage); >+ } >+ >+ /** >+ * Test if the PropertySheet allows multiple instances >+ * >+ * @throws PartInitException >+ */ >+ public void testAllowsMultiple() throws PartInitException { >+ activePage.showView(IPageLayout.ID_PROP_SHEET); >+ try { >+ activePage.showView(IPageLayout.ID_PROP_SHEET, "aSecondaryId", >+ IWorkbenchPage.VIEW_ACTIVATE); >+ } catch (PartInitException e) { >+ fail(e.getMessage()); >+ } >+ } >+ >+ /** >+ * Test if the PropertySheet follows selection >+ * >+ * @throws Throwable >+ */ >+ 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()); >+ } >+ >+ /** >+ * Test if the PropertySheet follows part events >+ * >+ * @throws Throwable >+ */ >+ 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()); >+ } >+ >+ /** >+ * Test if pinning works in the PropertySheet >+ * >+ * @throws Throwable >+ */ >+ public void testPinning() throws Throwable { >+ // execute the pin action on the property sheet >+ IAction action = getPinPropertySheetAction(propertySheet); >+ 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()); >+ } >+ >+ /** >+ * Test if the PropertySheet unpinns if the contributing part is closed >+ * >+ * @throws Throwable >+ */ >+ public void testUnpinningWhenPinnedPartIsClosed() throws Throwable { >+ // execute the pin action on the property sheet >+ IAction action = getPinPropertySheetAction(propertySheet); >+ 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()); >+ } >+ >+ /** >+ * Test if the PropertySheet's new handler creates a new instance >+ * >+ * @throws NotHandledException >+ * @throws NotEnabledException >+ * @throws NotDefinedException >+ * @throws ExecutionException >+ */ >+ public void testNewPropertySheet() throws ExecutionException, >+ NotDefinedException, NotEnabledException, NotHandledException { >+ assertTrue(countPropertySheetViews() == 1); >+ executeNewPropertySheetHandler(); >+ assertTrue(countPropertySheetViews() == 2); >+ } >+ >+ /** >+ * @throws ExecutionException >+ * @throws NotDefinedException >+ * @throws NotEnabledException >+ * @throws NotHandledException >+ */ >+ private void executeNewPropertySheetHandler() throws ExecutionException, >+ NotDefinedException, NotEnabledException, NotHandledException { >+ >+ // the propertysheet is the active part if its view toolbar command gets >+ // pressed >+ activePage.activate(propertySheet); >+ >+ IHandlerService handlerService = (IHandlerService) PlatformUI >+ .getWorkbench().getService(IHandlerService.class); >+ Event event = new Event(); >+ handlerService.executeCommand(NewPropertySheetHandler.ID, event); >+ } >+ >+ /** >+ * Test if the PropertySheet pins the parent if a second instance is opened >+ * >+ * @throws NotHandledException >+ * @throws NotEnabledException >+ * @throws NotDefinedException >+ * @throws ExecutionException >+ */ >+ public void testParentIsPinned() throws ExecutionException, >+ NotDefinedException, NotEnabledException, NotHandledException { >+ executeNewPropertySheetHandler(); >+ >+ IAction pinAction = getPinPropertySheetAction(propertySheet); >+ assertTrue("Parent property sheet isn't pinned", pinAction.isChecked()); >+ } >+ >+ /** >+ * Test if the PropertySheet pins the parent if a second instance is opened >+ * >+ * @throws Throwable >+ */ >+ public void testPinningWithMultipleInstances() throws Throwable { >+ executeNewPropertySheetHandler(); >+ testPinning(); >+ } >+} >Index: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * 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.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.views.properties.NewPropertySheetHandler; >+import org.eclipse.ui.views.properties.PropertySheet; >+import org.eclipse.ui.views.properties.PropertyShowInContext; >+ >+/** >+ * @since 3.5 >+ * >+ */ >+public class TestNewPropertySheetHandler extends NewPropertySheetHandler { >+ >+ public static final String ID = NewPropertySheetHandler.ID + "Test"; >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.views.properties.NewPropertySheetHandler#execute(org.eclipse >+ * .core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ return super.execute(event); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.views.properties.NewPropertySheetHandler#getShowInContext >+ * (org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public PropertyShowInContext getShowInContext(ExecutionEvent event) >+ throws ExecutionException { >+ return super.getShowInContext(event); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.views.properties.NewPropertySheetHandler#findPropertySheet >+ * (org.eclipse.core.commands.ExecutionEvent, >+ * org.eclipse.ui.views.properties.PropertyShowInContext) >+ */ >+ protected PropertySheet findPropertySheet(ExecutionEvent event, >+ PropertyShowInContext context) throws PartInitException, >+ ExecutionException { >+ return super.findPropertySheet(event, context); >+ } >+} >Index: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/NewPropertySheetHandlerTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/NewPropertySheetHandlerTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/NewPropertySheetHandlerTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/NewPropertySheetHandlerTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,289 @@ >+/******************************************************************************* >+ * 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 java.util.HashMap; >+ >+import org.eclipse.core.commands.Command; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.expressions.IEvaluationContext; >+import org.eclipse.core.runtime.IAdapterFactory; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.ui.IPageLayout; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.commands.ICommandService; >+import org.eclipse.ui.handlers.IHandlerService; >+import org.eclipse.ui.part.IShowInSource; >+import org.eclipse.ui.part.ShowInContext; >+import org.eclipse.ui.tests.SelectionProviderView; >+import org.eclipse.ui.views.properties.PropertySheet; >+import org.eclipse.ui.views.properties.PropertyShowInContext; >+ >+/** >+ * @since 3.5 >+ * >+ */ >+public class NewPropertySheetHandlerTest extends AbstractPropertySheetTest { >+ >+ private TestNewPropertySheetHandler testNewPropertySheetHandler; >+ >+ public NewPropertySheetHandlerTest(String testName) { >+ super(testName); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.tests.propertysheet.AbstractPropertySheetTest#doSetUp() >+ */ >+ protected void doSetUp() throws Exception { >+ super.doSetUp(); >+ testNewPropertySheetHandler = new TestNewPropertySheetHandler(); >+ } >+ >+ private ExecutionEvent getExecutionEvent() { >+ IHandlerService handlerService = (IHandlerService) PlatformUI >+ .getWorkbench().getService(IHandlerService.class); >+ ICommandService commandService = (ICommandService) PlatformUI >+ .getWorkbench().getService(ICommandService.class); >+ IEvaluationContext evalContext = handlerService.getCurrentState(); >+ Command command = commandService >+ .getCommand(TestNewPropertySheetHandler.ID); >+ ExecutionEvent executionEvent = new ExecutionEvent(command, >+ new HashMap(), null, evalContext); >+ return executionEvent; >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#getShowInContext(org.eclipse.core.commands.ExecutionEvent)} >+ * . >+ * >+ * @throws ExecutionException >+ * @throws PartInitException >+ * StructuredSelection.EMPTY, >+ */ >+ public final void testGetShowInContextFromPropertySheet() >+ throws ExecutionException, PartInitException { >+ activePage.showView(IPageLayout.ID_PROP_SHEET); >+ >+ PropertyShowInContext context = testNewPropertySheetHandler >+ .getShowInContext(getExecutionEvent()); >+ assertNotNull(context); >+ assertNull(context.getSelection()); >+ assertNull(context.getPart()); >+ assertNull(context.getInput()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#getShowInContext(org.eclipse.core.commands.ExecutionEvent)} >+ * . >+ * >+ * @throws ExecutionException >+ * @throws PartInitException >+ */ >+ public final void testGetShowInContextFromAShowInSource() >+ throws ExecutionException, PartInitException { >+ IAdapterFactory factory = new IAdapterFactory() { >+ public Object getAdapter(Object adaptableObject, Class adapterType) { >+ return new IShowInSource() { >+ public ShowInContext getShowInContext() { >+ return new ShowInContext(StructuredSelection.EMPTY, >+ StructuredSelection.EMPTY); >+ } >+ }; >+ } >+ >+ public Class[] getAdapterList() { >+ return new Class[] { IShowInSource.class }; >+ } >+ }; >+ try { >+ SelectionProviderView selectionProviderView = (SelectionProviderView) activePage >+ .showView(SelectionProviderView.ID); >+ selectionProviderView.setSelection(StructuredSelection.EMPTY); >+ Platform.getAdapterManager().registerAdapters(factory, >+ SelectionProviderView.class); >+ >+ PropertyShowInContext context = testNewPropertySheetHandler >+ .getShowInContext(getExecutionEvent()); >+ assertNotNull(context); >+ assertEquals(StructuredSelection.EMPTY, context.getSelection()); >+ assertEquals(StructuredSelection.EMPTY, context.getInput()); >+ assertEquals(selectionProviderView, context.getPart()); >+ } finally { >+ Platform.getAdapterManager().unregisterAdapters(factory); >+ } >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#getShowInContext(org.eclipse.core.commands.ExecutionEvent)} >+ * . >+ * >+ * @throws ExecutionException >+ * @throws PartInitException >+ */ >+ public final void testGetShowInContextWithNoShowInSource() >+ throws PartInitException, ExecutionException { >+ SelectionProviderView selectionProviderView = (SelectionProviderView) activePage >+ .showView(SelectionProviderView.ID); >+ assertFalse(selectionProviderView instanceof IShowInSource); >+ assertNull(selectionProviderView.getAdapter(IShowInSource.class)); >+ >+ PropertyShowInContext context = testNewPropertySheetHandler >+ .getShowInContext(getExecutionEvent()); >+ assertNotNull(context); >+ assertNull(context.getSelection()); >+ assertNull(context.getInput()); >+ assertEquals(selectionProviderView, context.getPart()); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#getShowInContext(org.eclipse.core.commands.ExecutionEvent)} >+ * . >+ */ >+ public final void testGetShowInContextWithNoActivePart() { >+ try { >+ testNewPropertySheetHandler.getShowInContext(getExecutionEvent()); >+ } catch (ExecutionException e) { >+ return; >+ } >+ fail("Expected ExecutionException due to no active part"); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyShowInContext)} >+ * . >+ * >+ * @throws ExecutionException >+ * @throws PartInitException >+ */ >+ public final void testFindPropertySheetWithoutActivePart() >+ throws PartInitException, ExecutionException { >+ assertNull(PlatformUI.getWorkbench().getActiveWorkbenchWindow() >+ .getActivePage().getActivePart()); >+ >+ try { >+ testNewPropertySheetHandler.findPropertySheet(getExecutionEvent(), >+ new PropertyShowInContext(null, StructuredSelection.EMPTY)); >+ } catch (ExecutionException e) { >+ return; >+ } >+ fail("Expected ExecutionException due to no active part"); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyShowInContext)} >+ * . >+ * >+ * @throws ExecutionException >+ * @throws PartInitException >+ */ >+ public final void testFindPropertySheetWithOtherSheetActive() >+ throws PartInitException, ExecutionException { >+ propertySheet = (PropertySheet) activePage >+ .showView(IPageLayout.ID_PROP_SHEET); >+ assertTrue(countPropertySheetViews() == 1); >+ >+ PropertySheet foundSheet = testNewPropertySheetHandler >+ .findPropertySheet(getExecutionEvent(), >+ new PropertyShowInContext(propertySheet, >+ StructuredSelection.EMPTY)); >+ assertNotNull(foundSheet); >+ assertNotSame(propertySheet, foundSheet); >+ assertTrue(countPropertySheetViews() == 2); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyShowInContext)} >+ * . >+ * >+ * @throws ExecutionException >+ * @throws PartInitException >+ */ >+ public final void testFindPropertySheetWithSPVActive() >+ throws PartInitException, ExecutionException { >+ IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET); >+ IViewPart spv = activePage.showView(SelectionProviderView.ID); >+ assertTrue(countPropertySheetViews() == 1); >+ >+ PropertySheet foundSheet = testNewPropertySheetHandler >+ .findPropertySheet(getExecutionEvent(), >+ new PropertyShowInContext(spv, >+ StructuredSelection.EMPTY)); >+ assertNotNull(foundSheet); >+ assertEquals(showView, foundSheet); >+ assertTrue(countPropertySheetViews() == 1); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyShowInContext)} >+ * . >+ * >+ * @throws ExecutionException >+ * @throws PartInitException >+ */ >+ public final void testFindPropertySheetWithPinnedPSandSPVActive() >+ throws PartInitException, ExecutionException { >+ PropertySheet sheet = (PropertySheet) activePage >+ .showView(IPageLayout.ID_PROP_SHEET); >+ sheet.setPinned(true); >+ IViewPart spv = activePage.showView(SelectionProviderView.ID); >+ assertTrue(countPropertySheetViews() == 1); >+ >+ PropertySheet foundSheet = testNewPropertySheetHandler >+ .findPropertySheet(getExecutionEvent(), >+ new PropertyShowInContext(spv, >+ StructuredSelection.EMPTY)); >+ assertNotNull(foundSheet); >+ assertNotSame(sheet, foundSheet); >+ assertTrue(countPropertySheetViews() == 2); >+ } >+ >+ /** >+ * Test method for >+ * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyShowInContext)} >+ * . >+ * >+ * @throws ExecutionException >+ * @throws PartInitException >+ */ >+ public final void testFindPropertySheetWithUnpinnedPSandSPVActive() >+ throws PartInitException, ExecutionException { >+ PropertySheet sheet = (PropertySheet) activePage >+ .showView(IPageLayout.ID_PROP_SHEET); >+ IViewPart showView = activePage.showView(SelectionProviderView.ID); >+ PropertyShowInContext context = new PropertyShowInContext(showView, >+ StructuredSelection.EMPTY); >+ assertTrue(sheet.show(context)); >+ sheet.setPinned(true); >+ assertTrue(countPropertySheetViews() == 1); >+ >+ PropertySheet foundSheet = testNewPropertySheetHandler >+ .findPropertySheet(getExecutionEvent(), context); >+ assertNotNull(foundSheet); >+ assertEquals(sheet, foundSheet); >+ assertTrue(countPropertySheetViews() == 1); >+ } >+}
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