Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 81338
Collapse All | Expand All

(-)Eclipse UI Tests/org/eclipse/ui/tests/UiTestSuite.java (+3 lines)
Lines 33-38 Link Here
33
import org.eclipse.ui.tests.multipageeditor.MultiPageEditorTestSuite;
33
import org.eclipse.ui.tests.multipageeditor.MultiPageEditorTestSuite;
34
import org.eclipse.ui.tests.navigator.NavigatorTestSuite;
34
import org.eclipse.ui.tests.navigator.NavigatorTestSuite;
35
import org.eclipse.ui.tests.preferences.PreferencesTestSuite;
35
import org.eclipse.ui.tests.preferences.PreferencesTestSuite;
36
import org.eclipse.ui.tests.presentation.PresentablePartFolderTest;
36
import org.eclipse.ui.tests.presentations.PresentationsTestSuite;
37
import org.eclipse.ui.tests.presentations.PresentationsTestSuite;
37
import org.eclipse.ui.tests.propertysheet.PropertySheetTestSuite;
38
import org.eclipse.ui.tests.propertysheet.PropertySheetTestSuite;
38
import org.eclipse.ui.tests.themes.ThemesTestSuite;
39
import org.eclipse.ui.tests.themes.ThemesTestSuite;
Lines 54-59 Link Here
54
     * Construct the test suite.
55
     * Construct the test suite.
55
     */
56
     */
56
    public UiTestSuite() {
57
    public UiTestSuite() {
58
        addTest(new TestSuite(PresentablePartFolderTest.class));
59
        
57
    	addTest(new UIAutomatedSuite());
60
    	addTest(new UIAutomatedSuite());
58
    	addTest(new TestSuite(NestedSyncExecDeadlockTest.class));
61
    	addTest(new TestSuite(NestedSyncExecDeadlockTest.class));
59
        addTest(new ApiTestSuite());
62
        addTest(new ApiTestSuite());
(-)Eclipse (+101 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.presentation;
12
13
import junit.framework.Assert;
14
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Shell;
18
import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder;
19
import org.eclipse.ui.internal.presentations.newapi.AbstractTabFolder;
20
import org.eclipse.ui.internal.presentations.newapi.PresentablePartFolder;
21
import org.eclipse.ui.tests.util.UITestCase;
22
23
/**
24
 * 
25
 * @since 3.1
26
 */
27
public class PresentablePartFolderTest extends UITestCase {
28
29
    private Shell testShell;
30
    private PresentablePartFolder folder;
31
    private TestPresentablePart part;
32
    
33
    
34
    /**
35
     * @param testName
36
     */
37
    public PresentablePartFolderTest(String testName) {
38
        super(testName);
39
    }
40
41
    /* (non-Javadoc)
42
     * @see org.eclipse.ui.tests.util.UITestCase#doSetUp()
43
     */
44
    protected void doSetUp() throws Exception {
45
        testShell = new Shell(SWT.NONE);
46
47
        folder = createPartFolder(testShell);        
48
        testShell.open();
49
        testShell.pack(true);
50
        
51
        part = new TestPresentablePart(testShell);
52
        
53
        folder.insert(part, 0);
54
        folder.select(part);
55
        
56
        super.doSetUp();
57
    }
58
    
59
    /* (non-Javadoc)
60
     * @see org.eclipse.ui.tests.util.UITestCase#doTearDown()
61
     */
62
    protected void doTearDown() throws Exception {
63
        testShell.dispose();
64
        testShell = null;
65
        super.doTearDown();
66
        Assert.assertFalse(part.hasListeners());
67
    }
68
    
69
    protected AbstractTabFolder createTabFolder(Composite parent) {
70
        AbstractTabFolder result = new DefaultTabFolder(parent, SWT.BORDER, 
71
                true, true);
72
73
        return result;
74
    }
75
    
76
    protected final PresentablePartFolder createPartFolder(Composite parent) {
77
        PresentablePartFolder result = new PresentablePartFolder(createTabFolder(parent));
78
        
79
        return result;
80
    }
81
    
82
    public void testListeners() throws Exception {
83
    }
84
        
85
    public void testFolderDisposeFirst() throws Exception {
86
        part.enableViewMenu(true);
87
        part.enableToolbar(true);
88
        
89
        folder.getTabFolder().getControl().dispose();
90
        part.getControl().dispose();
91
    }
92
    
93
    public void testPartDisposeFirst() throws Exception {
94
        part.enableViewMenu(true);
95
        part.enableToolbar(true);
96
        
97
        part.getControl().dispose();
98
        folder.getTabFolder().getControl().dispose();
99
    }
100
101
}
(-)Eclipse (+227 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.presentation;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.jface.resource.ImageDescriptor;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.Rectangle;
21
import org.eclipse.swt.layout.FillLayout;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Text;
25
import org.eclipse.swt.widgets.ToolBar;
26
import org.eclipse.swt.widgets.ToolItem;
27
import org.eclipse.ui.IPropertyListener;
28
import org.eclipse.ui.presentations.IPartMenu;
29
import org.eclipse.ui.presentations.IPresentablePart;
30
31
/**
32
 * @since 3.1
33
 */
34
public class TestPresentablePart implements IPresentablePart {
35
36
    private Composite ctrl;
37
    private Control toolbar = null;
38
    private List listeners = new ArrayList();
39
    private String name = "";
40
    private String title = "";
41
    private String contentDescription = "";
42
    private Image titleImage = ImageDescriptor.getMissingImageDescriptor().createImage();
43
    private boolean dirty = false;
44
    private String toolTip = "";
45
    private boolean busy = false;
46
    private boolean closeable = true;
47
    private boolean hasMenu = false;
48
    private IPartMenu testMenu = new IPartMenu() {
49
    /* (non-Javadoc)
50
     * @see org.eclipse.ui.presentations.IPartMenu#showMenu(org.eclipse.swt.graphics.Point)
51
     */
52
    public void showMenu(Point location) {
53
54
    }  
55
    };
56
    
57
    public TestPresentablePart(Composite parent) {
58
        ctrl = new Composite(parent, SWT.NONE);
59
        ctrl.setLayout(new FillLayout());
60
        // Create a text box so that we can accept focus
61
        new Text(parent, SWT.BORDER);
62
    }
63
    
64
    /* (non-Javadoc)
65
     * @see org.eclipse.ui.presentations.IPresentablePart#setBounds(org.eclipse.swt.graphics.Rectangle)
66
     */
67
    public void setBounds(Rectangle bounds) {
68
        if (!ctrl.isDisposed()) {
69
            ctrl.setBounds(bounds);
70
        }
71
    }
72
73
    /* (non-Javadoc)
74
     * @see org.eclipse.ui.presentations.IPresentablePart#setVisible(boolean)
75
     */
76
    public void setVisible(boolean isVisible) {
77
        if (!ctrl.isDisposed()) {
78
            ctrl.setVisible(isVisible);
79
        }
80
    }
81
82
    /* (non-Javadoc)
83
     * @see org.eclipse.ui.presentations.IPresentablePart#setFocus()
84
     */
85
    public void setFocus() {
86
        if (!ctrl.isDisposed()) {
87
            ctrl.setFocus();
88
        }
89
    }
90
91
    /* (non-Javadoc)
92
     * @see org.eclipse.ui.presentations.IPresentablePart#addPropertyListener(org.eclipse.ui.IPropertyListener)
93
     */
94
    public void addPropertyListener(IPropertyListener listener) {
95
        listeners.add(listener);
96
    }
97
98
    /* (non-Javadoc)
99
     * @see org.eclipse.ui.presentations.IPresentablePart#removePropertyListener(org.eclipse.ui.IPropertyListener)
100
     */
101
    public void removePropertyListener(IPropertyListener listener) {
102
        listeners.remove(listener);
103
    }
104
105
    /* (non-Javadoc)
106
     * @see org.eclipse.ui.presentations.IPresentablePart#getName()
107
     */
108
    public String getName() {
109
        return name;
110
    }
111
112
    /* (non-Javadoc)
113
     * @see org.eclipse.ui.presentations.IPresentablePart#getTitle()
114
     */
115
    public String getTitle() {
116
        return title;
117
    }
118
119
    /* (non-Javadoc)
120
     * @see org.eclipse.ui.presentations.IPresentablePart#getTitleStatus()
121
     */
122
    public String getTitleStatus() {
123
        return contentDescription;
124
    }
125
126
    /* (non-Javadoc)
127
     * @see org.eclipse.ui.presentations.IPresentablePart#getTitleImage()
128
     */
129
    public Image getTitleImage() {
130
        return titleImage;
131
    }
132
133
    /* (non-Javadoc)
134
     * @see org.eclipse.ui.presentations.IPresentablePart#getTitleToolTip()
135
     */
136
    public String getTitleToolTip() {
137
        return toolTip;
138
    }
139
140
    /* (non-Javadoc)
141
     * @see org.eclipse.ui.presentations.IPresentablePart#isDirty()
142
     */
143
    public boolean isDirty() {
144
        return dirty;
145
    }
146
147
    /* (non-Javadoc)
148
     * @see org.eclipse.ui.presentations.IPresentablePart#isBusy()
149
     */
150
    public boolean isBusy() {
151
        return busy;
152
    }
153
154
    /* (non-Javadoc)
155
     * @see org.eclipse.ui.presentations.IPresentablePart#isCloseable()
156
     */
157
    public boolean isCloseable() {
158
        return closeable;
159
    }
160
161
    /* (non-Javadoc)
162
     * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
163
     */
164
    public Control getToolBar() {
165
        return toolbar;
166
    }
167
168
    /* (non-Javadoc)
169
     * @see org.eclipse.ui.presentations.IPresentablePart#getMenu()
170
     */
171
    public IPartMenu getMenu() {
172
        return hasMenu ? testMenu : null;
173
    }
174
175
    /* (non-Javadoc)
176
     * @see org.eclipse.ui.presentations.IPresentablePart#getControl()
177
     */
178
    public Control getControl() {
179
        return ctrl;
180
    }
181
    
182
    public void firePropertyChange(int propertyId) {
183
        for (int i = 0; i < listeners.size(); i++) {
184
            ((IPropertyListener) listeners.get(i)).propertyChanged(this,
185
                    propertyId);
186
        }
187
    }
188
189
    public boolean hasToolbar() {
190
        return toolbar != null;
191
    }
192
    
193
    public boolean hasListeners() {
194
        return !listeners.isEmpty();
195
    }
196
    
197
    public void enableToolbar(boolean enable) {
198
        if (enable == hasToolbar()) {
199
            return;
200
        }
201
        
202
        if (enable) {
203
            ToolBar tb = new ToolBar(ctrl.getParent(), SWT.FLAT | SWT.WRAP);
204
            toolbar = tb;
205
            new ToolItem(tb, SWT.PUSH);
206
        } else {
207
            toolbar.dispose();
208
            toolbar = null;
209
        }
210
        
211
        firePropertyChange(IPresentablePart.PROP_TOOLBAR);
212
    }
213
    
214
    public void enableViewMenu(boolean enabled) {
215
        if (hasMenu == enabled) {
216
            return;
217
        }
218
        
219
        hasMenu = enabled;
220
        firePropertyChange(IPresentablePart.PROP_PANE_MENU);
221
    }
222
    
223
    public void dispose() {
224
        ctrl.dispose();
225
        enableToolbar(false);
226
    }
227
}

Return to bug 81338