blob: 687432e71ccf1347bbfe85843ca92f6b9ebe5256 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/*****************************************************************************
* Copyright (c) 2009 CEA LIST & LIFL
*
*
* 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:
* Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.sasheditor.editor;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple.SimpleSashWindowsContentProvider;
import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* A standalone application testing the Sash system.
* It must be run as Java program.
*
* @author dumoulin
*/
public class ShellEditor {
protected SashWindowsContainer sashContainer;
protected ISashWindowsContentProvider contentProvider;
/**
* Constructor.
*
* @param parent
*/
public ShellEditor(Shell parent) {
parent.setText(this.getClass().getSimpleName());
init();
createPartControl(parent);
// add tabItem
int count = 0;
IPageModel tabItem = new MessagePartModel("msg" + count++);
contentProvider.addPage(tabItem);
tabItem = new MessagePartModel("msg" + count++);
contentProvider.addPage(tabItem);
sashContainer.refreshTabs();
}
/**
* init th class
*/
protected void init() {
contentProvider = new SimpleSashWindowsContentProvider();
sashContainer = new SashWindowsContainer();
initContentProvider();
sashContainer.setContentProvider(contentProvider);
}
/**
* Create some windows.
*/
protected void initContentProvider() {
int count = 0;
IPageModel tabItem = new MessagePartModel("msg" + count++);
contentProvider.addPage(tabItem);
tabItem = new MessagePartModel("msg0" + count++);
contentProvider.addPage(tabItem);
}
/**
* Create SWT control of this class
*
* @param parent
*/
protected void createPartControl(Composite parent) {
// Text newText = new Text(parent, SWT.BORDER & SWT.SCROLL_PAGE);
sashContainer.createPartControl(parent);
}
/**
* @param args
*/
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new ShellEditor(shell);
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
|