View | Details | Raw Unified | Return to bug 248103 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (+5 lines)
Lines 3909-3914 Link Here
3909
            id="org.eclipse.ui.tests.enabledCount"
3909
            id="org.eclipse.ui.tests.enabledCount"
3910
            name="Enabled Count">
3910
            name="Enabled Count">
3911
      </command>
3911
      </command>
3912
      <command
3913
            defaultHandler="org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler"
3914
            id="org.eclipse.ui.views.properties.NewPropertySheetCommandTest"
3915
            name="TestNewPropertySheetCommand">
3916
      </command>
3912
   </extension>
3917
   </extension>
3913
   <extension
3918
   <extension
3914
         point="org.eclipse.ui.handlers">
3919
         point="org.eclipse.ui.handlers">
(-)Eclipse UI Tests/org/eclipse/ui/tests/session/SessionTests.java (-1 / +4 lines)
Lines 100-106 Link Here
100
				Bug108033Test.class));
100
				Bug108033Test.class));
101
		addTest(new WorkbenchSessionTest("editorSessionTests",
101
		addTest(new WorkbenchSessionTest("editorSessionTests",
102
				ArbitraryPropertiesViewTest.class));
102
				ArbitraryPropertiesViewTest.class));
103
		addTest(new WorkbenchSessionTest("editorSessionTests", NonRestorableViewTest.class));
103
		addTest(new WorkbenchSessionTest("editorSessionTests",
104
				NonRestorableViewTest.class));
105
		addTest(new WorkbenchSessionTest("editorSessionTests",
106
				NonRestorablePropertySheetTest.class));
104
		addTest(new WorkbenchSessionTest("editorSessionTests",
107
		addTest(new WorkbenchSessionTest("editorSessionTests",
105
				MarkersViewColumnSizeTest.class));
108
				MarkersViewColumnSizeTest.class));
106
	}
109
	}
(-)Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java (-12 / +4 lines)
Lines 14-32 Link Here
14
import org.eclipse.ui.part.ViewPart;
14
import org.eclipse.ui.part.ViewPart;
15
15
16
public class NonRestorableView extends ViewPart {
16
public class NonRestorableView extends ViewPart {
17
	public static final String ID ="org.eclipse.ui.tests.session.NonRestorableView";
17
18
18
	public NonRestorableView() {
19
	public NonRestorableView() {	}
19
		// TODO Auto-generated constructor stub
20
	}
21
20
22
	public void createPartControl(Composite parent) {
21
	public void createPartControl(Composite parent) {}
23
		// TODO Auto-generated method stub
24
25
	}
26
27
	public void setFocus() {
28
		// TODO Auto-generated method stub
29
30
	}
31
22
23
	public void setFocus() {	}
32
}
24
}
(-)META-INF/MANIFEST.MF (-2 / +3 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Eclipse UI Tests
3
Bundle-Name: Eclipse UI Tests
4
Bundle-SymbolicName: org.eclipse.ui.tests; singleton:=true
4
Bundle-SymbolicName: org.eclipse.ui.tests; singleton:=true
5
Bundle-Version: 3.3.0.qualifier
5
Bundle-Version: 3.4.0.qualifier
6
Bundle-ClassPath: uitests.jar
6
Bundle-ClassPath: uitests.jar
7
Bundle-Activator: org.eclipse.core.internal.compatibility.PluginActivator
7
Bundle-Activator: org.eclipse.core.internal.compatibility.PluginActivator
8
Bundle-Vendor: Eclipse.org
8
Bundle-Vendor: Eclipse.org
Lines 25-31 Link Here
25
 org.eclipse.core.databinding,
25
 org.eclipse.core.databinding,
26
 org.eclipse.core.databinding.beans,
26
 org.eclipse.core.databinding.beans,
27
 org.eclipse.jface.databinding,
27
 org.eclipse.jface.databinding,
28
 org.eclipse.ui.navigator.resources
28
 org.eclipse.ui.navigator.resources,
29
 org.eclipse.core.runtime
29
Eclipse-AutoStart: true
30
Eclipse-AutoStart: true
30
Plugin-Class: org.eclipse.ui.tests.TestPlugin
31
Plugin-Class: org.eclipse.ui.tests.TestPlugin
31
Export-Package: org.eclipse.ui.tests.api
32
Export-Package: org.eclipse.ui.tests.api
(-)Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetTestSuite.java (+3 lines)
Lines 30-35 Link Here
30
     * Construct the test suite.
30
     * Construct the test suite.
31
     */
31
     */
32
    public PropertySheetTestSuite() {
32
    public PropertySheetTestSuite() {
33
        addTest(new TestSuite(PropertyContextTest.class));
34
        addTest(new TestSuite(MultiInstancePropertySheetTest.class));
35
        addTest(new TestSuite(NewPropertySheetHandlerTest.class));
33
        addTest(new TestSuite(PropertySheetAuto.class));
36
        addTest(new TestSuite(PropertySheetAuto.class));
34
        addTest(new TestSuite(ComboBoxPropertyDescriptorTest.class));
37
        addTest(new TestSuite(ComboBoxPropertyDescriptorTest.class));
35
    }
38
    }
(-)Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java (-1 / +3 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.tests.propertysheet;
12
package org.eclipse.ui.tests.propertysheet;
12
13
Lines 16-21 Link Here
16
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.swt.graphics.RGB;
18
import org.eclipse.swt.graphics.RGB;
18
import org.eclipse.swt.widgets.Display;
19
import org.eclipse.swt.widgets.Display;
20
import org.eclipse.ui.IPageLayout;
19
import org.eclipse.ui.ISaveablePart;
21
import org.eclipse.ui.ISaveablePart;
20
import org.eclipse.ui.IViewPart;
22
import org.eclipse.ui.IViewPart;
21
import org.eclipse.ui.IWorkbenchPage;
23
import org.eclipse.ui.IWorkbenchPage;
Lines 245-251 Link Here
245
247
246
    protected IWorkbenchPart createTestPart(IWorkbenchPage page)
248
    protected IWorkbenchPart createTestPart(IWorkbenchPage page)
247
            throws Throwable {
249
            throws Throwable {
248
        IViewPart view = page.showView("org.eclipse.ui.views.PropertySheet");
250
        IViewPart view = page.showView(IPageLayout.ID_PROP_SHEET);
249
        selectionProviderView = (SelectionProviderView) page
251
        selectionProviderView = (SelectionProviderView) page
250
                .showView(SelectionProviderView.ID);
252
                .showView(SelectionProviderView.ID);
251
        return view;
253
        return view;
(-)Eclipse (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.tests.propertysheet;
13
14
import org.eclipse.jface.action.ActionContributionItem;
15
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.action.IContributionItem;
17
import org.eclipse.jface.action.IToolBarManager;
18
import org.eclipse.ui.IActionBars;
19
import org.eclipse.ui.IPageLayout;
20
import org.eclipse.ui.IViewReference;
21
import org.eclipse.ui.IWorkbenchPage;
22
import org.eclipse.ui.IWorkbenchWindow;
23
import org.eclipse.ui.tests.harness.util.UITestCase;
24
import org.eclipse.ui.views.properties.PropertySheet;
25
26
/**
27
 * @since 3.4
28
 * 
29
 */
30
public abstract class AbstractPropertySheetTest extends UITestCase {
31
32
	private static final String PIN_PROPERTY_SHEET_ACTION_ID_PREFIX = "org.eclipse.ui.views.properties.PinPropertySheetAction";
33
	protected IWorkbenchPage activePage;
34
	protected PropertySheet propertySheet;
35
36
	public AbstractPropertySheetTest(String testName) {
37
		super(testName);
38
	}
39
40
	/*
41
	 * (non-Javadoc)
42
	 * 
43
	 * @see org.eclipse.ui.tests.harness.util.UITestCase#doSetUp()
44
	 */
45
	protected void doSetUp() throws Exception {
46
		super.doSetUp();
47
		IWorkbenchWindow workbenchWindow = openTestWindow();
48
		activePage = workbenchWindow.getActivePage();
49
	}
50
51
	/**
52
	 * @return the count of PropertySheets
53
	 */
54
	protected int countPropertySheetViews() {
55
		int count = 0;
56
		IViewReference[] views = activePage.getViewReferences();
57
		for (int i = 0; i < views.length; i++) {
58
			IViewReference ref = views[i];
59
			if (ref.getId().equals(IPageLayout.ID_PROP_SHEET)) {
60
				count++;
61
			}
62
		}
63
		return count;
64
	}
65
66
	protected IAction getPinPropertySheetAction(PropertySheet propertySheet) {
67
		IActionBars actionBars = propertySheet.getViewSite().getActionBars();
68
		IToolBarManager toolBarManager = actionBars.getToolBarManager();
69
		IContributionItem[] items = toolBarManager.getItems();
70
		for (int i = 0; i < items.length; i++) {
71
			IContributionItem contributionItem = items[i];
72
			if (contributionItem.getId() != null
73
					&& contributionItem.getId().startsWith(
74
							PIN_PROPERTY_SHEET_ACTION_ID_PREFIX)) {
75
				IAction action = ((ActionContributionItem) contributionItem)
76
						.getAction();
77
				return action;
78
			}
79
		}
80
		return null;
81
	}
82
}
(-)Eclipse (+190 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.tests.propertysheet;
13
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.StructuredSelection;
16
import org.eclipse.ui.IPageLayout;
17
import org.eclipse.ui.IViewPart;
18
import org.eclipse.ui.PartInitException;
19
import org.eclipse.ui.views.properties.PropertyContext;
20
21
/**
22
 * @since 3.5
23
 * 
24
 */
25
public class PropertyContextTest extends AbstractPropertySheetTest {
26
27
	public PropertyContextTest(String testName) {
28
		super(testName);
29
	}
30
31
	/**
32
	 * Test method for
33
	 * {@link org.eclipse.ui.views.properties.PropertyContext#hashCode()}.
34
	 */
35
	public final void testHashCode() {
36
		PropertyContext psc1 = new PropertyContext(null, (ISelection) null);
37
		PropertyContext psc2 = new PropertyContext(null, (ISelection) null);
38
		assertEquals(psc1.hashCode(), psc2.hashCode());
39
	}
40
41
	/**
42
	 * Test method for
43
	 * {@link org.eclipse.ui.views.properties.PropertyContext#hashCode()}.
44
	 */
45
	public final void testHashCode2() {
46
		PropertyContext psc1 = new PropertyContext(null,
47
				StructuredSelection.EMPTY);
48
		PropertyContext psc2 = new PropertyContext(null,
49
				StructuredSelection.EMPTY);
50
		assertEquals(psc1.hashCode(), psc2.hashCode());
51
	}
52
53
	/**
54
	 * Test method for
55
	 * {@link org.eclipse.ui.views.properties.PropertyContext#hashCode()}.
56
	 * 
57
	 * @throws PartInitException
58
	 */
59
	public final void testHashCode3() throws PartInitException {
60
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
61
		PropertyContext psc1 = new PropertyContext(showView,
62
				StructuredSelection.EMPTY);
63
		PropertyContext psc2 = new PropertyContext(showView,
64
				StructuredSelection.EMPTY);
65
		assertEquals(psc1.hashCode(), psc2.hashCode());
66
	}
67
68
	/**
69
	 * Test method for
70
	 * {@link org.eclipse.ui.views.properties.PropertyContext#hashCode()}.
71
	 * 
72
	 * @throws PartInitException
73
	 */
74
	public final void testHashCode4() throws PartInitException {
75
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
76
		PropertyContext psc1 = new PropertyContext(showView,
77
				null);
78
		PropertyContext psc2 = new PropertyContext(showView,
79
				null);
80
		assertEquals(psc1.hashCode(), psc2.hashCode());
81
	}
82
83
	/**
84
	 * Test method for
85
	 * {@link org.eclipse.ui.views.properties.PropertyContext#hashCode()}.
86
	 * 
87
	 * @throws PartInitException
88
	 */
89
	public final void testHashCode5() throws PartInitException {
90
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
91
		PropertyContext psc1 = new PropertyContext(showView, StructuredSelection.EMPTY);
92
		PropertyContext psc2 = new PropertyContext(null, StructuredSelection.EMPTY);
93
		assertFalse(psc1.hashCode() == psc2.hashCode());
94
	}
95
96
	/**
97
	 * Test method for
98
	 * {@link org.eclipse.ui.views.properties.PropertyContext#hashCode()}.
99
	 * 
100
	 * @throws PartInitException
101
	 */
102
	public final void testHashCode6() throws PartInitException {
103
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
104
		PropertyContext psc1 = new PropertyContext(showView, null);
105
		PropertyContext psc2 = new PropertyContext(showView, StructuredSelection.EMPTY);
106
		assertFalse(psc1.hashCode() == psc2.hashCode());
107
	}
108
109
	/**
110
	 * Test method for
111
	 * {@link org.eclipse.ui.views.properties.PropertyContext#equals(Object)}
112
	 * .
113
	 */
114
	public final void testEquals() {
115
		PropertyContext psc1 = new PropertyContext(null, null);
116
		PropertyContext psc2 = new PropertyContext(null, null);
117
		assertEquals(psc1, psc2);
118
	}
119
120
	/**
121
	 * Test method for
122
	 * {@link org.eclipse.ui.views.properties.PropertyContext#equals(Object)}
123
	 * .
124
	 */
125
	public final void testEquals2() {
126
		PropertyContext psc1 = new PropertyContext(null,
127
				StructuredSelection.EMPTY);
128
		PropertyContext psc2 = new PropertyContext(null,
129
				StructuredSelection.EMPTY);
130
		assertEquals(psc1, psc2);
131
	}
132
133
	/**
134
	 * Test method for
135
	 * {@link org.eclipse.ui.views.properties.PropertyContext#equals(Object)}
136
	 * .
137
	 * 
138
	 * @throws PartInitException
139
	 */
140
	public final void testEquals3() throws PartInitException {
141
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
142
		PropertyContext psc1 = new PropertyContext(showView,
143
				StructuredSelection.EMPTY);
144
		PropertyContext psc2 = new PropertyContext(showView,
145
				StructuredSelection.EMPTY);
146
		assertEquals(psc1, psc2);
147
	}
148
149
	/**
150
	 * Test method for
151
	 * {@link org.eclipse.ui.views.properties.PropertyContext#equals(Object)}
152
	 * .
153
	 * 
154
	 * @throws PartInitException
155
	 */
156
	public final void testEquals4() throws PartInitException {
157
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
158
		PropertyContext psc1 = new PropertyContext(showView, null);
159
		PropertyContext psc2 = new PropertyContext(showView, null);
160
		assertEquals(psc1, psc2);
161
	}
162
163
	/**
164
	 * Test method for
165
	 * {@link org.eclipse.ui.views.properties.PropertyContext#equals(Object)}
166
	 * .
167
	 * 
168
	 * @throws PartInitException
169
	 */
170
	public final void testEquals5() throws PartInitException {
171
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
172
		PropertyContext psc1 = new PropertyContext(showView, StructuredSelection.EMPTY);
173
		PropertyContext psc2 = new PropertyContext(null, StructuredSelection.EMPTY);
174
		assertFalse(psc1.equals(psc2));
175
	}
176
177
	/**
178
	 * Test method for
179
	 * {@link org.eclipse.ui.views.properties.PropertyContext#equals(Object)}
180
	 * .
181
	 * 
182
	 * @throws PartInitException
183
	 */
184
	public final void testEquals6() throws PartInitException {
185
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
186
		PropertyContext psc1 = new PropertyContext(showView, null);
187
		PropertyContext psc2 = new PropertyContext(showView, StructuredSelection.EMPTY);
188
		assertFalse(psc1.equals(psc2));
189
	}
190
}
(-)Eclipse (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.tests.propertysheet;
13
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.ui.PartInitException;
17
import org.eclipse.ui.views.properties.NewPropertySheetHandler;
18
import org.eclipse.ui.views.properties.PropertySheet;
19
import org.eclipse.ui.views.properties.PropertyContext;
20
21
/**
22
 * @since 3.5
23
 * 
24
 */
25
public class TestNewPropertySheetHandler extends NewPropertySheetHandler {
26
27
	public static final String ID = NewPropertySheetHandler.ID + "Test";
28
29
	/*
30
	 * (non-Javadoc)
31
	 * 
32
	 * @see
33
	 * org.eclipse.ui.views.properties.NewPropertySheetHandler#execute(org.eclipse
34
	 * .core.commands.ExecutionEvent)
35
	 */
36
	public Object execute(ExecutionEvent event) throws ExecutionException {
37
		return super.execute(event);
38
	}
39
40
	/*
41
	 * (non-Javadoc)
42
	 * 
43
	 * @see
44
	 * org.eclipse.ui.views.properties.NewPropertySheetHandler#getShowInContext
45
	 * (org.eclipse.core.commands.ExecutionEvent)
46
	 */
47
	public PropertyContext getPropertyContext(ExecutionEvent event)
48
			throws ExecutionException {
49
		return super.getPropertyContext(event);
50
	}
51
52
	/*
53
	 * (non-Javadoc)
54
	 * 
55
	 * @see
56
	 * org.eclipse.ui.views.properties.NewPropertySheetHandler#findPropertySheet
57
	 * (org.eclipse.core.commands.ExecutionEvent,
58
	 * org.eclipse.ui.views.properties.PropertyShowInContext)
59
	 */
60
	protected PropertySheet findPropertySheet(ExecutionEvent event,
61
			PropertyContext context) throws PartInitException,
62
			ExecutionException {
63
		return super.findPropertySheet(event, context);
64
	}
65
}
(-)Eclipse (+79 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant  and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.tests.propertysheet;
13
14
import org.eclipse.core.runtime.IAdapterFactory;
15
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.views.properties.IPropertySheetPage;
18
import org.eclipse.ui.views.properties.PropertySheetPage;
19
20
/**
21
 * @since 3.4
22
 * 
23
 */
24
public class TestPropertySheetPage extends PropertySheetPage implements
25
		IPropertySheetPage, IAdapterFactory {
26
27
	private ISelection fSelection;
28
	private IWorkbenchPart fPart;
29
30
	/*
31
	 * (non-Javadoc)
32
	 * 
33
	 * @see
34
	 * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
35
	 * java.lang.Class)
36
	 */
37
	public Object getAdapter(Object adaptableObject, Class adapterType) {
38
		// singleton cleanup
39
		fSelection = null;
40
		fPart = null;
41
		return this;
42
	}
43
44
	/*
45
	 * (non-Javadoc)
46
	 * 
47
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
48
	 */
49
	public Class[] getAdapterList() {
50
		return new Class[] { IPropertySheetPage.class };
51
	}
52
53
	/*
54
	 * (non-Javadoc)
55
	 * 
56
	 * @see
57
	 * org.eclipse.ui.views.properties.PropertySheetPage#selectionChanged(org
58
	 * .eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
59
	 */
60
	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
61
		super.selectionChanged(part, selection);
62
		fPart = part;
63
		fSelection = selection;
64
	}
65
66
	/**
67
	 * @return Returns the selection.
68
	 */
69
	public ISelection getSelection() {
70
		return fSelection;
71
	}
72
73
	/**
74
	 * @return Returns the part.
75
	 */
76
	public IWorkbenchPart getPart() {
77
		return fPart;
78
	}
79
}
(-)Eclipse (+94 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.tests.session;
13
14
import junit.framework.TestCase;
15
import junit.framework.TestSuite;
16
17
import org.eclipse.ui.IPageLayout;
18
import org.eclipse.ui.IViewPart;
19
import org.eclipse.ui.IViewReference;
20
import org.eclipse.ui.IWorkbench;
21
import org.eclipse.ui.IWorkbenchPage;
22
import org.eclipse.ui.PartInitException;
23
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.views.properties.PropertySheet;
25
26
/**
27
 * The secondary property sheets should be closed so there aren't restored in
28
 * the next workbench session.
29
 * 
30
 * @since 3.4
31
 */
32
public class NonRestorablePropertySheetTest extends TestCase {
33
34
	public static TestSuite suite() {
35
		return new TestSuite(NonRestorablePropertySheetTest.class);
36
	}
37
38
	public NonRestorablePropertySheetTest(String testName) {
39
		super(testName);
40
	}
41
42
	/**
43
	 * This is the first part instantiates a bunch of property sheets
44
	 * 
45
	 * @throws PartInitException
46
	 */
47
	public void test01ActivateView() throws PartInitException {
48
		final IWorkbench workbench = PlatformUI.getWorkbench();
49
		final IWorkbenchPage page = workbench.getActiveWorkbenchWindow()
50
				.getActivePage();
51
52
		IViewPart part = page.showView(IPageLayout.ID_PROP_SHEET);
53
		assertNotNull(part);
54
		assertTrue(part instanceof PropertySheet);
55
56
		for (int j = 0; j < 3; j++) {
57
			try {
58
				page.showView(IPageLayout.ID_PROP_SHEET, "#" + j,
59
						IWorkbenchPage.VIEW_ACTIVATE);
60
			} catch (PartInitException e) {
61
				fail(e.getMessage());
62
			}
63
		}
64
		assertTrue(countPropertySheetViews(page) == 4);
65
	}
66
67
	/**
68
	 * In the second session the property sheet views with secondary ids
69
	 * shouldn't be instantiated.
70
	 * 
71
	 * @throws PartInitException
72
	 */
73
	public void test02SecondOpening() throws PartInitException {
74
		final IWorkbench workbench = PlatformUI.getWorkbench();
75
		final IWorkbenchPage page = workbench.getActiveWorkbenchWindow()
76
				.getActivePage();
77
78
		assertTrue(countPropertySheetViews(page) == 1);
79
	}
80
81
	// simple counts how many property sheet instances are open
82
	private int countPropertySheetViews(final IWorkbenchPage page) {
83
		int count = 0;
84
		IViewReference[] views = page.getViewReferences();
85
		for (int i = 0; i < views.length; i++) {
86
			IViewReference ref = views[i];
87
			if (ref.getId().equals(IPageLayout.ID_PROP_SHEET)) {
88
				count++;
89
			}
90
		}
91
		return count;
92
	}
93
94
}
(-)Eclipse (+276 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.tests.propertysheet;
13
14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.commands.NotEnabledException;
16
import org.eclipse.core.commands.NotHandledException;
17
import org.eclipse.core.commands.common.NotDefinedException;
18
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.jface.action.IAction;
20
import org.eclipse.swt.widgets.Event;
21
import org.eclipse.ui.IPageLayout;
22
import org.eclipse.ui.IWorkbenchPage;
23
import org.eclipse.ui.IWorkbenchPart;
24
import org.eclipse.ui.PartInitException;
25
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.handlers.IHandlerService;
27
import org.eclipse.ui.tests.SelectionProviderView;
28
import org.eclipse.ui.tests.session.NonRestorableView;
29
import org.eclipse.ui.views.properties.NewPropertySheetHandler;
30
import org.eclipse.ui.views.properties.PropertySheet;
31
import org.eclipse.ui.views.properties.PropertySheetPage;
32
33
/**
34
 * @since 3.4
35
 */
36
public class MultiInstancePropertySheetTest extends AbstractPropertySheetTest {
37
38
	/**
39
	 * TestPropertySheetPage exposes certain members for testability
40
	 */
41
	private TestPropertySheetPage testPropertySheetPage = new TestPropertySheetPage();
42
	private SelectionProviderView selectionProviderView;
43
44
	public MultiInstancePropertySheetTest(String testName) {
45
		super(testName);
46
	}
47
48
	/*
49
	 * (non-Javadoc)
50
	 * 
51
	 * @see
52
	 * org.eclipse.ui.tests.propertysheet.AbstractPropertySheetTest#doSetUp()
53
	 */
54
	protected void doSetUp() throws Exception {
55
		super.doSetUp();
56
		// open the property sheet with the TestPropertySheetPage
57
		Platform.getAdapterManager().registerAdapters(testPropertySheetPage,
58
				PropertySheet.class);
59
		propertySheet = (PropertySheet) activePage
60
				.showView(IPageLayout.ID_PROP_SHEET);
61
62
		selectionProviderView = (SelectionProviderView) activePage
63
				.showView(SelectionProviderView.ID);
64
	}
65
66
	/*
67
	 * (non-Javadoc)
68
	 * 
69
	 * @see org.eclipse.ui.tests.harness.util.UITestCase#doTearDown()
70
	 */
71
	protected void doTearDown() throws Exception {
72
		super.doTearDown();
73
		Platform.getAdapterManager().unregisterAdapters(testPropertySheetPage,
74
				PropertySheet.class);
75
	}
76
77
	/**
78
	 * The if the registered {@link TestPropertySheetPage} is set as the default
79
	 * page of the PropertySheet
80
	 * 
81
	 * @throws PartInitException
82
	 */
83
	public void testDefaultPage() throws PartInitException {
84
		PropertySheet propertySheet = (PropertySheet) activePage
85
				.showView(IPageLayout.ID_PROP_SHEET);
86
		assertTrue(propertySheet.getCurrentPage() instanceof PropertySheetPage);
87
	}
88
89
	/**
90
	 * Test if the registered {@link TestPropertySheetPage} is set as the
91
	 * default page of the PropertyShecet
92
	 * 
93
	 * @throws PartInitException
94
	 */
95
	public void testDefaultPageAdapter() throws PartInitException {
96
		Platform.getAdapterManager().registerAdapters(testPropertySheetPage,
97
				PropertySheet.class);
98
		PropertySheet propertySheet = (PropertySheet) activePage
99
				.showView(IPageLayout.ID_PROP_SHEET);
100
		assertTrue(propertySheet.getCurrentPage() instanceof TestPropertySheetPage);
101
	}
102
103
	/**
104
	 * Test if the PropertySheet allows multiple instances
105
	 * 
106
	 * @throws PartInitException
107
	 */
108
	public void testAllowsMultiple() throws PartInitException {
109
		activePage.showView(IPageLayout.ID_PROP_SHEET);
110
		try {
111
			activePage.showView(IPageLayout.ID_PROP_SHEET, "aSecondaryId",
112
					IWorkbenchPage.VIEW_ACTIVATE);
113
		} catch (PartInitException e) {
114
			fail(e.getMessage());
115
		}
116
	}
117
118
	/**
119
	 * Test if the PropertySheet follows selection
120
	 * 
121
	 * @throws Throwable
122
	 */
123
	public void testFollowsSelection() throws Throwable {
124
		// selection before selection changes
125
		TestPropertySheetPage firstPage = (TestPropertySheetPage) propertySheet
126
				.getCurrentPage();
127
		Object firstSelection = firstPage.getSelection();
128
		assertNotNull(firstSelection);
129
130
		// change the selection explicitly
131
		selectionProviderView.setSelection(new Object());
132
		TestPropertySheetPage secondPage = (TestPropertySheetPage) propertySheet
133
				.getCurrentPage();
134
135
		assertNotSame("PropertySheet hasn't changed selection", firstSelection,
136
				secondPage.getSelection());
137
	}
138
139
	/**
140
	 * Test if the PropertySheet follows part events
141
	 * 
142
	 * @throws Throwable
143
	 */
144
	public void testFollowsParts() throws Throwable {
145
		// selection before selection changes
146
		TestPropertySheetPage firstPage = (TestPropertySheetPage) propertySheet
147
				.getCurrentPage();
148
		Object firstPart = firstPage.getPart();
149
		assertNotNull(firstPart);
150
151
		// change the part explicitly (reusing the NonRestorableView here)
152
		TestPropertySheetPage testPropertySheetPage2 = new TestPropertySheetPage();
153
		Platform.getAdapterManager().registerAdapters(testPropertySheetPage2,
154
				org.eclipse.ui.tests.session.NonRestorableView.class);
155
		activePage.showView(NonRestorableView.ID);
156
157
		TestPropertySheetPage secondPage = (TestPropertySheetPage) propertySheet
158
				.getCurrentPage();
159
160
		assertEquals(testPropertySheetPage2, secondPage);
161
		assertNotSame("PropertySheet hasn't changed selection", firstPart,
162
				secondPage.getSelection());
163
	}
164
165
	/**
166
	 * Test if pinning works in the PropertySheet
167
	 * 
168
	 * @throws Throwable
169
	 */
170
	public void testPinning() throws Throwable {
171
		// execute the pin action on the property sheet
172
		IAction action = getPinPropertySheetAction(propertySheet);
173
		action.setChecked(true);
174
175
		// get the content of the pinned property sheet for later comparison
176
		TestPropertySheetPage firstPage = (TestPropertySheetPage) propertySheet
177
				.getCurrentPage();
178
		assertNotNull(firstPage);
179
		Object firstSelection = firstPage.getSelection();
180
		assertNotNull(firstSelection);
181
		IWorkbenchPart firstPart = firstPage.getPart();
182
		assertNotNull(firstPart);
183
184
		// change the selection/part
185
		selectionProviderView.setSelection(new Object());
186
		TestPropertySheetPage testPropertySheetPage2 = new TestPropertySheetPage();
187
		Platform.getAdapterManager().registerAdapters(testPropertySheetPage2,
188
				org.eclipse.ui.tests.session.NonRestorableView.class);
189
		activePage.showView(NonRestorableView.ID);
190
191
		TestPropertySheetPage secondPage = (TestPropertySheetPage) propertySheet
192
				.getCurrentPage();
193
		assertEquals("PropertySheet has changed page", firstPage, secondPage);
194
		assertEquals("PropertySheetPage has changed selection", firstSelection,
195
				secondPage.getSelection());
196
		assertEquals("PropertySheetPage has changed part", firstPart,
197
				secondPage.getPart());
198
	}
199
200
	/**
201
	 * Test if the PropertySheet unpinns if the contributing part is closed
202
	 * 
203
	 * @throws Throwable
204
	 */
205
	public void testUnpinningWhenPinnedPartIsClosed() throws Throwable {
206
		// execute the pin action on the property sheet
207
		IAction action = getPinPropertySheetAction(propertySheet);
208
		action.setChecked(true);
209
210
		// close the part the property sheet is pinned to
211
		activePage.hideView(selectionProviderView);
212
213
		// the action and therefore the property sheet should be unpinned
214
		assertFalse(action.isChecked());
215
	}
216
217
	/**
218
	 * Test if the PropertySheet's new handler creates a new instance
219
	 * 
220
	 * @throws NotHandledException
221
	 * @throws NotEnabledException
222
	 * @throws NotDefinedException
223
	 * @throws ExecutionException
224
	 */
225
	public void testNewPropertySheet() throws ExecutionException,
226
			NotDefinedException, NotEnabledException, NotHandledException {
227
		assertTrue(countPropertySheetViews() == 1);
228
		executeNewPropertySheetHandler();
229
		assertTrue(countPropertySheetViews() == 2);
230
	}
231
232
	/**
233
	 * @throws ExecutionException
234
	 * @throws NotDefinedException
235
	 * @throws NotEnabledException
236
	 * @throws NotHandledException
237
	 */
238
	private void executeNewPropertySheetHandler() throws ExecutionException,
239
			NotDefinedException, NotEnabledException, NotHandledException {
240
241
		// the propertysheet is the active part if its view toolbar command gets
242
		// pressed
243
		activePage.activate(propertySheet);
244
245
		IHandlerService handlerService = (IHandlerService) PlatformUI
246
				.getWorkbench().getService(IHandlerService.class);
247
		Event event = new Event();
248
		handlerService.executeCommand(NewPropertySheetHandler.ID, event);
249
	}
250
251
	/**
252
	 * Test if the PropertySheet pins the parent if a second instance is opened
253
	 * 
254
	 * @throws NotHandledException
255
	 * @throws NotEnabledException
256
	 * @throws NotDefinedException
257
	 * @throws ExecutionException
258
	 */
259
	public void testParentIsPinned() throws ExecutionException,
260
			NotDefinedException, NotEnabledException, NotHandledException {
261
		executeNewPropertySheetHandler();
262
263
		IAction pinAction = getPinPropertySheetAction(propertySheet);
264
		assertTrue("Parent property sheet isn't pinned", pinAction.isChecked());
265
	}
266
267
	/**
268
	 * Test if the PropertySheet pins the parent if a second instance is opened
269
	 * 
270
	 * @throws Throwable
271
	 */
272
	public void testPinningWithMultipleInstances() throws Throwable {
273
		executeNewPropertySheetHandler();
274
		testPinning();
275
	}
276
}
(-)Eclipse (+286 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.tests.propertysheet;
13
14
import java.util.HashMap;
15
16
import org.eclipse.core.commands.Command;
17
import org.eclipse.core.commands.ExecutionEvent;
18
import org.eclipse.core.commands.ExecutionException;
19
import org.eclipse.core.expressions.IEvaluationContext;
20
import org.eclipse.core.runtime.IAdapterFactory;
21
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.jface.viewers.StructuredSelection;
23
import org.eclipse.ui.IPageLayout;
24
import org.eclipse.ui.IViewPart;
25
import org.eclipse.ui.PartInitException;
26
import org.eclipse.ui.PlatformUI;
27
import org.eclipse.ui.commands.ICommandService;
28
import org.eclipse.ui.handlers.IHandlerService;
29
import org.eclipse.ui.part.IShowInSource;
30
import org.eclipse.ui.part.ShowInContext;
31
import org.eclipse.ui.tests.SelectionProviderView;
32
import org.eclipse.ui.views.properties.PropertySheet;
33
import org.eclipse.ui.views.properties.PropertyContext;
34
35
/**
36
 * @since 3.5
37
 * 
38
 */
39
public class NewPropertySheetHandlerTest extends AbstractPropertySheetTest {
40
41
	private TestNewPropertySheetHandler testNewPropertySheetHandler;
42
43
	public NewPropertySheetHandlerTest(String testName) {
44
		super(testName);
45
	}
46
47
	/*
48
	 * (non-Javadoc)
49
	 * 
50
	 * @see
51
	 * org.eclipse.ui.tests.propertysheet.AbstractPropertySheetTest#doSetUp()
52
	 */
53
	protected void doSetUp() throws Exception {
54
		super.doSetUp();
55
		testNewPropertySheetHandler = new TestNewPropertySheetHandler();
56
	}
57
58
	private ExecutionEvent getExecutionEvent() {
59
		IHandlerService handlerService = (IHandlerService) PlatformUI
60
				.getWorkbench().getService(IHandlerService.class);
61
		ICommandService commandService = (ICommandService) PlatformUI
62
				.getWorkbench().getService(ICommandService.class);
63
		IEvaluationContext evalContext = handlerService.getCurrentState();
64
		Command command = commandService
65
				.getCommand(TestNewPropertySheetHandler.ID);
66
		ExecutionEvent executionEvent = new ExecutionEvent(command,
67
				new HashMap(), null, evalContext);
68
		return executionEvent;
69
	}
70
71
	/**
72
	 * Test method for
73
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#getPropertyContext(org.eclipse.core.commands.ExecutionEvent)}
74
	 * .
75
	 * 
76
	 * @throws ExecutionException
77
	 * @throws PartInitException
78
	 *             StructuredSelection.EMPTY,
79
	 */
80
	public final void testGetShowInContextFromPropertySheet()
81
			throws ExecutionException, PartInitException {
82
		activePage.showView(IPageLayout.ID_PROP_SHEET);
83
84
		PropertyContext context = testNewPropertySheetHandler
85
				.getPropertyContext(getExecutionEvent());
86
		assertNotNull(context);
87
		assertNull(context.getSelection());
88
		assertNull(context.getPart());
89
	}
90
91
	/**
92
	 * Test method for
93
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#getPropertyContext(org.eclipse.core.commands.ExecutionEvent)}
94
	 * .
95
	 * 
96
	 * @throws ExecutionException
97
	 * @throws PartInitException
98
	 */
99
	public final void testGetShowInContextFromAShowInSource()
100
			throws ExecutionException, PartInitException {
101
		IAdapterFactory factory = new IAdapterFactory() {
102
			public Object getAdapter(Object adaptableObject, Class adapterType) {
103
				return new IShowInSource() {
104
					public ShowInContext getShowInContext() {
105
						return new ShowInContext(StructuredSelection.EMPTY,
106
								StructuredSelection.EMPTY);
107
					}
108
				};
109
			}
110
111
			public Class[] getAdapterList() {
112
				return new Class[] { IShowInSource.class };
113
			}
114
		};
115
		try {
116
			SelectionProviderView selectionProviderView = (SelectionProviderView) activePage
117
					.showView(SelectionProviderView.ID);
118
			selectionProviderView.setSelection(StructuredSelection.EMPTY);
119
			Platform.getAdapterManager().registerAdapters(factory,
120
					SelectionProviderView.class);
121
122
			PropertyContext context = testNewPropertySheetHandler
123
					.getPropertyContext(getExecutionEvent());
124
			assertNotNull(context);
125
			assertEquals(StructuredSelection.EMPTY, context.getSelection());
126
			assertEquals(selectionProviderView, context.getPart());
127
		} finally {
128
			Platform.getAdapterManager().unregisterAdapters(factory);
129
		}
130
	}
131
132
	/**
133
	 * Test method for
134
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#getPropertyContext(org.eclipse.core.commands.ExecutionEvent)}
135
	 * .
136
	 * 
137
	 * @throws ExecutionException
138
	 * @throws PartInitException
139
	 */
140
	public final void testGetShowInContextWithNoShowInSource()
141
			throws PartInitException, ExecutionException {
142
		SelectionProviderView selectionProviderView = (SelectionProviderView) activePage
143
				.showView(SelectionProviderView.ID);
144
		assertFalse(selectionProviderView instanceof IShowInSource);
145
		assertNull(selectionProviderView.getAdapter(IShowInSource.class));
146
147
		PropertyContext context = testNewPropertySheetHandler
148
				.getPropertyContext(getExecutionEvent());
149
		assertNotNull(context);
150
		assertNull(context.getSelection());
151
		assertEquals(selectionProviderView, context.getPart());
152
	}
153
154
	/**
155
	 * Test method for
156
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#getPropertyContext(org.eclipse.core.commands.ExecutionEvent)}
157
	 * .
158
	 */
159
	public final void testGetShowInContextWithNoActivePart() {
160
		try {
161
			testNewPropertySheetHandler.getPropertyContext(getExecutionEvent());
162
		} catch (ExecutionException e) {
163
			return;
164
		}
165
		fail("Expected ExecutionException due to no active part");
166
	}
167
168
	/**
169
	 * Test method for
170
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyContext)}
171
	 * .
172
	 * 
173
	 * @throws ExecutionException
174
	 * @throws PartInitException
175
	 */
176
	public final void testFindPropertySheetWithoutActivePart()
177
			throws PartInitException, ExecutionException {
178
		assertNull(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
179
				.getActivePage().getActivePart());
180
181
		try {
182
			testNewPropertySheetHandler.findPropertySheet(getExecutionEvent(),
183
					new PropertyContext(null, StructuredSelection.EMPTY));
184
		} catch (ExecutionException e) {
185
			return;
186
		}
187
		fail("Expected ExecutionException due to no active part");
188
	}
189
190
	/**
191
	 * Test method for
192
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyContext)}
193
	 * .
194
	 * 
195
	 * @throws ExecutionException
196
	 * @throws PartInitException
197
	 */
198
	public final void testFindPropertySheetWithOtherSheetActive()
199
			throws PartInitException, ExecutionException {
200
		propertySheet = (PropertySheet) activePage
201
				.showView(IPageLayout.ID_PROP_SHEET);
202
		assertTrue(countPropertySheetViews() == 1);
203
204
		PropertySheet foundSheet = testNewPropertySheetHandler
205
				.findPropertySheet(getExecutionEvent(),
206
						new PropertyContext(propertySheet,
207
								StructuredSelection.EMPTY));
208
		assertNotNull(foundSheet);
209
		assertNotSame(propertySheet, foundSheet);
210
		assertTrue(countPropertySheetViews() == 2);
211
	}
212
213
	/**
214
	 * Test method for
215
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyContext)}
216
	 * .
217
	 * 
218
	 * @throws ExecutionException
219
	 * @throws PartInitException
220
	 */
221
	public final void testFindPropertySheetWithSPVActive()
222
			throws PartInitException, ExecutionException {
223
		IViewPart showView = activePage.showView(IPageLayout.ID_PROP_SHEET);
224
		IViewPart spv = activePage.showView(SelectionProviderView.ID);
225
		assertTrue(countPropertySheetViews() == 1);
226
227
		PropertySheet foundSheet = testNewPropertySheetHandler
228
				.findPropertySheet(getExecutionEvent(),
229
						new PropertyContext(spv,
230
								StructuredSelection.EMPTY));
231
		assertNotNull(foundSheet);
232
		assertEquals(showView, foundSheet);
233
		assertTrue(countPropertySheetViews() == 1);
234
	}
235
236
	/**
237
	 * Test method for
238
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyContext)}
239
	 * .
240
	 * 
241
	 * @throws ExecutionException
242
	 * @throws PartInitException
243
	 */
244
	public final void testFindPropertySheetWithPinnedPSandSPVActive()
245
			throws PartInitException, ExecutionException {
246
		PropertySheet sheet = (PropertySheet) activePage
247
				.showView(IPageLayout.ID_PROP_SHEET);
248
		sheet.setPinned(true);
249
		IViewPart spv = activePage.showView(SelectionProviderView.ID);
250
		assertTrue(countPropertySheetViews() == 1);
251
252
		PropertySheet foundSheet = testNewPropertySheetHandler
253
				.findPropertySheet(getExecutionEvent(),
254
						new PropertyContext(spv,
255
								StructuredSelection.EMPTY));
256
		assertNotNull(foundSheet);
257
		assertNotSame(sheet, foundSheet);
258
		assertTrue(countPropertySheetViews() == 2);
259
	}
260
261
	/**
262
	 * Test method for
263
	 * {@link org.eclipse.ui.tests.propertysheet.TestNewPropertySheetHandler#findPropertySheet(org.eclipse.core.commands.ExecutionEvent, org.eclipse.ui.views.properties.PropertyContext)}
264
	 * .
265
	 * 
266
	 * @throws ExecutionException
267
	 * @throws PartInitException
268
	 */
269
	public final void testFindPropertySheetWithUnpinnedPSandSPVActive()
270
			throws PartInitException, ExecutionException {
271
		PropertySheet sheet = (PropertySheet) activePage
272
				.showView(IPageLayout.ID_PROP_SHEET);
273
		IViewPart showView = activePage.showView(SelectionProviderView.ID);
274
		PropertyContext context = new PropertyContext(showView,
275
				StructuredSelection.EMPTY);
276
		assertTrue(sheet.show(context));
277
		sheet.setPinned(true);
278
		assertTrue(countPropertySheetViews() == 1);
279
280
		PropertySheet foundSheet = testNewPropertySheetHandler
281
				.findPropertySheet(getExecutionEvent(), context);
282
		assertNotNull(foundSheet);
283
		assertEquals(sheet, foundSheet);
284
		assertTrue(countPropertySheetViews() == 1);
285
	}
286
}
(-)src/org/eclipse/ui/internal/views/properties/messages.properties (+3 lines)
Lines 29-34 Link Here
29
Filter_text = Show &Advanced Properties
29
Filter_text = Show &Advanced Properties
30
Filter_toolTip = Show Advanced Properties
30
Filter_toolTip = Show Advanced Properties
31
31
32
Pin_text = &Pin to selection
33
Pin_toolTip = Pin property to current selection
34
32
PropertyViewer_property = Property
35
PropertyViewer_property = Property
33
PropertyViewer_value = Value
36
PropertyViewer_value = Value
34
PropertyViewer_misc = Misc
37
PropertyViewer_misc = Misc
(-)src/org/eclipse/ui/internal/views/properties/PropertiesMessages.java (+6 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.internal.views.properties;
12
package org.eclipse.ui.internal.views.properties;
12
13
Lines 47-52 Link Here
47
	public static String Filter_toolTip;
48
	public static String Filter_toolTip;
48
49
49
	/** */
50
	/** */
51
	public static String Pin_text;
52
	/** */
53
	public static String Pin_toolTip;
54
55
	/** */
50
	public static String PropertyViewer_property;
56
	public static String PropertyViewer_property;
51
	/** */
57
	/** */
52
	public static String PropertyViewer_value;
58
	public static String PropertyViewer_value;
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.ui.views; singleton:=true
4
Bundle-SymbolicName: org.eclipse.ui.views; singleton:=true
5
Bundle-Version: 3.3.100.qualifier
5
Bundle-Version: 3.4.0.qualifier
6
Bundle-ClassPath: .
6
Bundle-ClassPath: .
7
Bundle-Activator: org.eclipse.ui.internal.views.ViewsPlugin
7
Bundle-Activator: org.eclipse.ui.internal.views.ViewsPlugin
8
Bundle-ActivationPolicy: lazy
8
Bundle-ActivationPolicy: lazy
(-)src/org/eclipse/ui/views/properties/IPropertiesHelpContextIds.java (+4 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.views.properties;
12
package org.eclipse.ui.views.properties;
12
13
Lines 36-41 Link Here
36
    public static final String COPY_PROPERTY_ACTION = PREFIX
37
    public static final String COPY_PROPERTY_ACTION = PREFIX
37
            + "properties_copy_action_context"; //$NON-NLS-1$
38
            + "properties_copy_action_context"; //$NON-NLS-1$
38
39
40
    public static final String PIN_ACTION = PREFIX
41
    		+ "properties_pin_action_context"; //$NON-NLS-1$;
42
    
39
    // Views
43
    // Views
40
    public static final String PROPERTY_SHEET_VIEW = PREFIX
44
    public static final String PROPERTY_SHEET_VIEW = PREFIX
41
            + "property_sheet_view_context"; //$NON-NLS-1$
45
            + "property_sheet_view_context"; //$NON-NLS-1$
(-)src/org/eclipse/ui/views/properties/PropertySheet.java (-10 / +135 lines)
Lines 7-20 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.views.properties;
12
package org.eclipse.ui.views.properties;
12
13
14
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.action.IMenuManager;
16
import org.eclipse.jface.action.IToolBarManager;
17
import org.eclipse.jface.action.Separator;
13
import org.eclipse.jface.viewers.ISelection;
18
import org.eclipse.jface.viewers.ISelection;
14
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.ui.IMemento;
15
import org.eclipse.ui.ISaveablePart;
21
import org.eclipse.ui.ISaveablePart;
16
import org.eclipse.ui.ISelectionListener;
22
import org.eclipse.ui.ISelectionListener;
17
import org.eclipse.ui.IViewSite;
23
import org.eclipse.ui.IViewSite;
24
import org.eclipse.ui.IWorkbenchActionConstants;
18
import org.eclipse.ui.IWorkbenchPage;
25
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.IWorkbenchPart;
26
import org.eclipse.ui.IWorkbenchPart;
20
import org.eclipse.ui.PartInitException;
27
import org.eclipse.ui.PartInitException;
Lines 73-78 Link Here
73
    private ISelection bootstrapSelection;
80
    private ISelection bootstrapSelection;
74
81
75
    /**
82
    /**
83
     * The current selection of the property sheet
84
     */
85
    private ISelection currentSelection;
86
87
    /**
88
     * The current part for which this property sheets is active
89
     */
90
	private IWorkbenchPart currentPart;
91
92
	/**
93
	 * Whether this property sheet instance is pinned or not 
94
	 */
95
	private IAction pinPropertySheetAction;
96
	
97
    /**
76
     * Creates a property sheet view.
98
     * Creates a property sheet view.
77
     */
99
     */
78
    public PropertySheet() {
100
    public PropertySheet() {
Lines 84-101 Link Here
84
     * Returns the default property sheet page.
106
     * Returns the default property sheet page.
85
     */
107
     */
86
    protected IPage createDefaultPage(PageBook book) {
108
    protected IPage createDefaultPage(PageBook book) {
87
        PropertySheetPage page = new PropertySheetPage();
109
        IPageBookViewPage page = (IPageBookViewPage) ViewsPlugin.getAdapter(this,
110
                IPropertySheetPage.class, false);
111
        if(page == null) {
112
        	page = new PropertySheetPage();
113
        }
88
        initPage(page);
114
        initPage(page);
89
        page.createControl(book);
115
        page.createControl(book);
90
        return page;
116
        return page;
91
    }
117
    }
92
118
93
    /**
119
	/**
94
     * The <code>PropertySheet</code> implementation of this <code>IWorkbenchPart</code>
120
     * The <code>PropertySheet</code> implementation of this <code>IWorkbenchPart</code>
95
     * method creates a <code>PageBook</code> control with its default page showing.
121
     * method creates a <code>PageBook</code> control with its default page showing.
96
     */
122
     */
97
    public void createPartControl(Composite parent) {
123
    public void createPartControl(Composite parent) {
98
        super.createPartControl(parent);
124
        super.createPartControl(parent);
125
         
126
        pinPropertySheetAction = new PinPropertySheetAction();
127
		IMenuManager menuManager = getViewSite().getActionBars()
128
				.getMenuManager();
129
		menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
130
		menuManager.add(pinPropertySheetAction);
131
132
		IToolBarManager toolBarManager = getViewSite().getActionBars()
133
				.getToolBarManager();
134
		menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
135
		toolBarManager.add(pinPropertySheetAction);
136
		
99
        getSite().getPage().getWorkbenchWindow().getWorkbench().getHelpSystem()
137
        getSite().getPage().getWorkbenchWindow().getWorkbench().getHelpSystem()
100
				.setHelp(getPageBook(),
138
				.setHelp(getPageBook(),
101
						IPropertiesHelpContextIds.PROPERTY_SHEET_VIEW);
139
						IPropertiesHelpContextIds.PROPERTY_SHEET_VIEW);
Lines 116-122 Link Here
116
     * Method declared on PageBookView.
154
     * Method declared on PageBookView.
117
     */
155
     */
118
    protected PageRec doCreatePage(IWorkbenchPart part) {
156
    protected PageRec doCreatePage(IWorkbenchPart part) {
119
        // Try to get a custom property sheet page.
157
        // Get a custom property sheet page but not if the part is also a
158
		// PropertySheet. In this case the child property sheet would
159
		// accidentally reuse the parent's property sheet page.
160
    	if(part instanceof PropertySheet) {
161
    		return null;
162
    	}
120
        IPropertySheetPage page = (IPropertySheetPage) ViewsPlugin.getAdapter(part,
163
        IPropertySheetPage page = (IPropertySheetPage) ViewsPlugin.getAdapter(part,
121
                IPropertySheetPage.class, false);
164
                IPropertySheetPage.class, false);
122
        if (page != null) {
165
        if (page != null) {
Lines 158-176 Link Here
158
     * Method declared on IViewPart.
201
     * Method declared on IViewPart.
159
     */
202
     */
160
    public void init(IViewSite site) throws PartInitException {
203
    public void init(IViewSite site) throws PartInitException {
161
        site.getPage().addSelectionListener(this);
204
   		site.getPage().addSelectionListener(this);
162
        super.init(site);
205
   		super.init(site);
163
    }
206
    }
164
207
165
    /* (non-Javadoc)
208
    /* (non-Javadoc)
209
	 * @see org.eclipse.ui.part.ViewPart#saveState(org.eclipse.ui.IMemento)
210
	 * since 3.4
211
	 */
212
	public void saveState(IMemento memento) {
213
		// close all but the primary/parent property sheet
214
		String secondaryId = getViewSite().getSecondaryId();
215
		if (null == secondaryId) {
216
			super.saveState(memento);
217
		} else {
218
			getViewSite().getPage().hideView(this);
219
		}
220
	}
221
222
    /* (non-Javadoc)
166
     * Method declared on PageBookView.
223
     * Method declared on PageBookView.
167
     * The property sheet may show properties for any view other than this view.
224
     * The property sheet may show properties for any view other than this view.
168
     */
225
     */
169
    protected boolean isImportant(IWorkbenchPart part) {
226
    protected boolean isImportant(IWorkbenchPart part) {
170
        return part != this;
227
    	 return pinPropertySheetAction == null
228
    	 				|| (pinPropertySheetAction != null && !pinPropertySheetAction
229
    	 						.isChecked()) && !(part instanceof PropertySheet);
171
    }
230
    }
172
231
173
    /**
232
    /* (non-Javadoc)
233
	 * @see org.eclipse.ui.part.PageBookView#partClosed(org.eclipse.ui.IWorkbenchPart)
234
	 * since 3.4
235
	 */
236
	public void partClosed(IWorkbenchPart part) {
237
		if (pinPropertySheetAction.isChecked() && part.equals(currentPart)) {
238
			pinPropertySheetAction.setChecked(false);
239
		}
240
		super.partClosed(part);
241
	}
242
243
	/**
174
     * The <code>PropertySheet</code> implementation of this <code>IPartListener</code>
244
     * The <code>PropertySheet</code> implementation of this <code>IPartListener</code>
175
     * method first sees if the active part is an <code>IContributedContentsView</code>
245
     * method first sees if the active part is an <code>IContributedContentsView</code>
176
     * adapter and if so, asks it for its contributing part.
246
     * adapter and if so, asks it for its contributing part.
Lines 190-195 Link Here
190
			super.partActivated(part);
260
			super.partActivated(part);
191
		}
261
		}
192
262
263
        if(isImportant(part)) {
264
        	currentPart = part;
265
        }
266
        
193
        // When the view is first opened, pass the selection to the page		
267
        // When the view is first opened, pass the selection to the page		
194
        if (bootstrapSelection != null) {
268
        if (bootstrapSelection != null) {
195
            IPropertySheetPage page = (IPropertySheetPage) getCurrentPage();
269
            IPropertySheetPage page = (IPropertySheetPage) getCurrentPage();
Lines 206-219 Link Here
206
     */
280
     */
207
    public void selectionChanged(IWorkbenchPart part, ISelection sel) {
281
    public void selectionChanged(IWorkbenchPart part, ISelection sel) {
208
        // we ignore our own selection or null selection
282
        // we ignore our own selection or null selection
209
        if (part == this || sel == null) {
283
		if (sel == null || !isImportant(part)
284
				|| (!isImportant(part) && sel.equals(currentSelection))) {
210
			return;
285
			return;
211
		}
286
		}
212
287
        
288
        currentPart = part;
289
        currentSelection = sel;
290
        
213
        // pass the selection to the page		
291
        // pass the selection to the page		
214
        IPropertySheetPage page = (IPropertySheetPage) getCurrentPage();
292
        IPropertySheetPage page = (IPropertySheetPage) getCurrentPage();
215
        if (page != null) {
293
        if (page != null) {
216
			page.selectionChanged(part, sel);
294
			page.selectionChanged(currentPart, currentSelection);
217
		}
295
		}
218
    }
296
    }
219
    
297
    
Lines 246-249 Link Here
246
		}
324
		}
247
		return null;
325
		return null;
248
	}
326
	}
327
	
328
	/**
329
	 * @return whether this property sheet is currently pinned
330
	 * @since 3.4
331
	 */
332
	public boolean isPinned() {
333
		return pinPropertySheetAction.isChecked();
334
	}
335
336
	/**
337
	 * @return The current context of this property sheet
338
	 * @since 3.4
339
	 */
340
	public PropertyContext getContext() {
341
		return new PropertyContext(currentPart, currentSelection);
342
	}
343
344
	/**
345
	 * @param aContext
346
	 *            Shows the given context in this property sheet
347
	 * @return true if the context has been set, false if this instance is
348
	 *         pinned and therefore cannot show the given context
349
	 * @since 3.4
350
	 */
351
	public boolean show(PropertyContext aContext) {
352
		if (!pinPropertySheetAction.isChecked()) {
353
			partActivated(aContext.getPart());
354
			selectionChanged(aContext.getPart(), aContext.getSelection());
355
			return true;
356
		}
357
		return false;
358
	}
359
360
	/***
361
	 * @param pinned Whether this sheet should be pinned
362
	 * @since 3.4
363
	 */
364
	public void setPinned(boolean pinned) {
365
		pinPropertySheetAction.setChecked(pinned);
366
	}
367
368
	/**
369
	 * @return true if this instance is visible
370
	 */
371
	public boolean isVisible() {
372
		return getCurrentPage().getControl().isVisible();
373
	}
249
}
374
}
(-)plugin.properties (+1 lines)
Lines 12-16 Link Here
12
providerName= Eclipse.org
12
providerName= Eclipse.org
13
13
14
Views.PropertySheet = Properties
14
Views.PropertySheet = Properties
15
Views.NewPropertySheet = Open new properties
15
Views.ContentOutline = Outline
16
Views.ContentOutline = Outline
16
17
(-)plugin.xml (-3 / +33 lines)
Lines 5-15 Link Here
5
     <extension
5
     <extension
6
         point="org.eclipse.ui.views">
6
         point="org.eclipse.ui.views">
7
      <view
7
      <view
8
            name="%Views.PropertySheet"
8
            allowMultiple="true"
9
            icon="$nl$/icons/full/eview16/prop_ps.gif"
10
            category="org.eclipse.ui"
9
            category="org.eclipse.ui"
11
            class="org.eclipse.ui.views.properties.PropertySheet"
10
            class="org.eclipse.ui.views.properties.PropertySheet"
12
            id="org.eclipse.ui.views.PropertySheet">
11
            icon="$nl$/icons/full/eview16/prop_ps.gif"
12
            id="org.eclipse.ui.views.PropertySheet"
13
            name="%Views.PropertySheet">
13
      </view>
14
      </view>
14
      <view
15
      <view
15
            name="%Views.ContentOutline"
16
            name="%Views.ContentOutline"
Lines 19-23 Link Here
19
            id="org.eclipse.ui.views.ContentOutline">
20
            id="org.eclipse.ui.views.ContentOutline">
20
      </view>
21
      </view>
21
   </extension>
22
   </extension>
23
     <extension
24
           point="org.eclipse.ui.menus">
25
		<menuContribution
26
				locationURI="popup:org.eclipse.ui.menus.showInMenu">
27
			<command
28
				commandId="org.eclipse.ui.views.properties.NewPropertySheetCommand"
29
				icon="platform:/plugin/org.eclipse.ui.views/icons/full/eview16/prop_ps.gif"
30
				label="%Views.PropertySheet"
31
				style="push">
32
	        </command>
33
		</menuContribution>
34
  <menuContribution
35
        locationURI="toolbar:org.eclipse.ui.views.PropertySheet">
36
     <command
37
           commandId="org.eclipse.ui.views.properties.NewPropertySheetCommand"
38
           icon="icons/full/elcl16/new.gif"
39
           label="%Views.NewPropertySheet"
40
           style="push">
41
     </command>
42
  </menuContribution>
43
	</extension>
44
     <extension
45
           point="org.eclipse.ui.commands">
46
        <command
47
              defaultHandler="org.eclipse.ui.views.properties.NewPropertySheetHandler"
48
              id="org.eclipse.ui.views.properties.NewPropertySheetCommand"
49
              name="%Views.PropertySheet">
50
        </command>
51
     </extension>
22
   
52
   
23
</plugin>
53
</plugin>
(-)src/org/eclipse/ui/views/properties/NewPropertySheetHandler.java (+131 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.views.properties;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.viewers.ISelection;
18
import org.eclipse.ui.IPageLayout;
19
import org.eclipse.ui.IViewReference;
20
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.IWorkbenchPart;
22
import org.eclipse.ui.PartInitException;
23
import org.eclipse.ui.handlers.HandlerUtil;
24
import org.eclipse.ui.part.IShowInSource;
25
import org.eclipse.ui.part.ShowInContext;
26
27
/**
28
 * @since 3.4
29
 */
30
public class NewPropertySheetHandler extends AbstractHandler {
31
32
	/**
33
	 * Command id
34
	 */
35
	public static final String ID = "org.eclipse.ui.views.properties.NewPropertySheetCommand"; //$NON-NLS-1$
36
37
	/**
38
	 * First tries to find a suitable instance to reuse for the given context,
39
	 * then creates a new instance if necessary.
40
	 * 
41
	 * @param event
42
	 * @return an instance for the given context
43
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
44
	 */
45
	public Object execute(ExecutionEvent event) throws ExecutionException {
46
		IWorkbenchPart activePart = HandlerUtil.getActivePartChecked(event);
47
48
		PropertyContext context = getPropertyContext(event);
49
		try {
50
			PropertySheet sheet = findPropertySheet(event, context);
51
			sheet.show(context);
52
			if (activePart instanceof PropertySheet) {
53
				PropertySheet parent = (PropertySheet) activePart;
54
				parent.setPinned(true);
55
			} else {
56
				sheet.setPinned(true);
57
			}
58
		} catch (PartInitException e) {
59
			throw new ExecutionException("Part could not be initialized", e); //$NON-NLS-1$
60
		}
61
		return null;
62
	}
63
64
	/**
65
	 * @param event
66
	 *            {@link ExecutionEvent} for which the
67
	 *            {@link PropertyContext} is requested
68
	 * @return a {@link PropertyContext} containing the the
69
	 *         {@link ISelection} and {@link IWorkbenchPart} for the given
70
	 *         {@link ExecutionEvent}
71
	 * @throws ExecutionException
72
	 */
73
	protected PropertyContext getPropertyContext(ExecutionEvent event)
74
			throws ExecutionException {
75
		IWorkbenchPart activePart = HandlerUtil.getActivePartChecked(event);
76
		if (activePart instanceof PropertySheet) {
77
			PropertySheet sheet = (PropertySheet) activePart;
78
			return sheet.getContext();
79
		}
80
		IShowInSource adapter = (IShowInSource) activePart
81
				.getAdapter(IShowInSource.class);
82
		if (adapter != null) {
83
			ShowInContext showInContext = adapter.getShowInContext();
84
			return new PropertyContext(activePart, showInContext.getSelection());
85
		}
86
		return new PropertyContext(activePart, HandlerUtil
87
				.getShowInSelection(event));
88
	}
89
90
	/**
91
	 * Returns a PropertySheet instance
92
	 * 
93
	 * @param event
94
	 * @param context
95
	 *            a {@link ShowInContext} to handle
96
	 * @return a PropertySheet that can handle the given {@link ShowInContext}
97
	 * @throws PartInitException
98
	 * @throws ExecutionException
99
	 */
100
	protected PropertySheet findPropertySheet(ExecutionEvent event,
101
			PropertyContext context) throws PartInitException,
102
			ExecutionException {
103
		IWorkbenchPage page = HandlerUtil.getActivePartChecked(event).getSite()
104
				.getPage();
105
		String secondaryId = null;
106
		// New sheet button has been pressed
107
		if (HandlerUtil.getActivePart(event) instanceof PropertySheet) {
108
			secondaryId = Long.toString(System.currentTimeMillis());
109
		} else { // show in properties has been pressed
110
			IViewReference[] refs = page.getViewReferences();
111
			secondaryId = Long.toString(System.currentTimeMillis());
112
			for (int i = 0; i < refs.length; i++) {
113
				IViewReference viewReference = refs[i];
114
				if (IPageLayout.ID_PROP_SHEET.equals(viewReference.getId())) {
115
					PropertySheet sheet = (PropertySheet) viewReference
116
							.getView(true);
117
					if (!sheet.isPinned()
118
							|| (sheet.isPinned() && sheet.getContext()
119
									.equals(context))) {
120
						secondaryId = sheet.getViewSite().getSecondaryId();
121
						if(sheet.isVisible()) {
122
							break;
123
						}
124
					}
125
				}
126
			}
127
		}
128
		return (PropertySheet) page.showView(IPageLayout.ID_PROP_SHEET,
129
				secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
130
	}
131
}
(-)src/org/eclipse/ui/views/properties/PropertyContext.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.views.properties;
13
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.ui.IWorkbenchPart;
16
17
/**
18
 * @since 3.4
19
 * 
20
 */
21
public class PropertyContext {
22
23
	private IWorkbenchPart part;
24
	private ISelection selection;
25
26
	/**
27
	 * @param aSelection
28
	 * @param aPart 
29
	 */
30
	public PropertyContext(IWorkbenchPart aPart, ISelection aSelection) {
31
		part = aPart;
32
		selection = aSelection;
33
	}
34
35
	/**
36
	 * @return Returns the part.
37
	 */
38
	public IWorkbenchPart getPart() {
39
		return part;
40
	}
41
42
	/**
43
	 * @return Returns the selection.
44
	 */
45
	public ISelection getSelection() {
46
		return selection;
47
	}
48
49
	/*
50
	 * (non-Javadoc)
51
	 * 
52
	 * @see java.lang.Object#hashCode()
53
	 */
54
	public int hashCode() {
55
		final int prime = 31;
56
		int result = 1;
57
		result = prime * result + ((part == null) ? 0 : part.hashCode())
58
				+ ((selection == null) ? 0 : selection.hashCode());
59
		return result;
60
	}
61
62
	/*
63
	 * (non-Javadoc)
64
	 * 
65
	 * @see java.lang.Object#equals(java.lang.Object)
66
	 */
67
	public boolean equals(Object obj) {
68
		if (this == obj)
69
			return true;
70
		if (obj == null)
71
			return false;
72
		if (getClass() != obj.getClass())
73
			return false;
74
		PropertyContext other = (PropertyContext) obj;
75
		// part needs to be equal
76
		if (part == null) {
77
			if (other.part != null)
78
				return false;
79
		} else if (!part.equals(other.part))
80
			return false;
81
		// selection needs to be equal
82
		if (selection == null) {
83
			if (other.selection != null)
84
				return false;
85
		} else if (!selection.equals(other.selection))
86
			return false;
87
		return true;
88
	}
89
}
(-)src/org/eclipse/ui/views/properties/PinPropertySheetAction.java (+42 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Alexander Kuppe (Versant Corp.) - https://bugs.eclipse.org/248103
10
 ******************************************************************************/
11
12
package org.eclipse.ui.views.properties;
13
14
import org.eclipse.jface.action.Action;
15
import org.eclipse.jface.action.IAction;
16
import org.eclipse.ui.PlatformUI;
17
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
18
import org.eclipse.ui.internal.WorkbenchImages;
19
import org.eclipse.ui.internal.views.properties.PropertiesMessages;
20
21
/**
22
 * Pins the properties view instance to the current selection.
23
 * 
24
 * @since 3.4
25
 */
26
public class PinPropertySheetAction extends Action {
27
28
	public PinPropertySheetAction() {
29
		super(PropertiesMessages.Pin_text, IAction.AS_CHECK_BOX);
30
31
		setId(PinPropertySheetAction.class.getName()
32
				+ "#" + Long.toString(System.currentTimeMillis())); //$NON-NLS-1$
33
		setToolTipText(PropertiesMessages.Pin_toolTip);
34
		setImageDescriptor(WorkbenchImages
35
				.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR));
36
		setDisabledImageDescriptor(WorkbenchImages
37
				.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR_DISABLED));
38
39
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
40
				IPropertiesHelpContextIds.PIN_ACTION);
41
	}
42
}

Return to bug 248103