use of org.eclipse.swt.widgets.CoolBar in project tdi-studio-se by Talend.
the class AbstractSQLEditorComposite method createToolBar.
/**
* qzhang Comment method "createToolBar".
*/
protected void createToolBar() {
// create coolbar
coolBar = new CoolBar(this, SWT.NONE);
coolBarMgr = new CoolBarManager(coolBar);
GridData gid = new GridData();
gid.horizontalAlignment = GridData.FILL;
coolBar.setLayoutData(gid);
// initialize default actions
defaultToolBarMgr = new ToolBarManager(SWT.NONE);
execSQLAction = new ExecSQLAction(SQLResultComposite.getInstance(), this);
openFileAction = new OpenFileAction();
openFileAction.setEditor(this);
saveSQLAction = new SaveSQLAction(getRepositoryNode(), connParam);
saveSQLAction.setEditor(this);
saveAsSQLAction = new SaveAsSQLAction(getRepositoryNode(), connParam);
saveAsSQLAction.setEditor(this);
exportAction = new SaveFileAsAction();
exportAction.setEditor(this);
clearTextAction = new ClearTextAction();
clearTextAction.setEditor(this);
guiModificationQueryAction = new GUIModificationQueryAction(getRepositoryNode(), connParam, dialog);
guiModificationQueryAction.setEditor(this);
// initialize hyWang's ACTION
contextModeAction = new ContextModeAction(getRepositoryNode(), connParam);
addDefaultActions();
// initialize session actions
sessionToolBarMgr = new ToolBarManager(SWT.NONE);
sessionSwitcher = new SQLEditorSessionSwitcher(this);
sessionToolBarMgr.add(sessionSwitcher);
// initialize hyWang's BUTTON and TOOLBAR
contextToolBarMgr = new ToolBarManager(SWT.NONE);
contextmode = new ContextModeSessionSwitcher(this, contextModeAction);
contextToolBarMgr.add(contextmode);
// add all toolbars to parent coolbar
coolBar.setLocked(true);
coolBarMgr.add(new ToolBarContributionItem(defaultToolBarMgr));
coolBarMgr.add(new ToolBarContributionItem(sessionToolBarMgr));
// add hyWang's toolbar to coolbar
coolBarMgr.add(new ToolBarContributionItem(contextToolBarMgr));
coolBarMgr.update(true);
}
use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.
the class ControlsWithLabelsExample method main.
public static void main(String[] args) {
display = new Display();
shell = new Shell(display);
shell.setLayout(new GridLayout(4, true));
shell.setText("All Controls Test");
new Label(shell, SWT.NONE).setText("Label for Label");
label = new Label(shell, SWT.NONE);
label.setText("Label");
new Label(shell, SWT.NONE).setText("Label for CLabel");
cLabel = new CLabel(shell, SWT.NONE);
cLabel.setText("CLabel");
new Label(shell, SWT.NONE).setText("Label for Push Button");
buttonPush = new Button(shell, SWT.PUSH);
buttonPush.setText("Push Button");
new Label(shell, SWT.NONE).setText("Label for Radio Button");
buttonRadio = new Button(shell, SWT.RADIO);
buttonRadio.setText("Radio Button");
new Label(shell, SWT.NONE).setText("Label for Check Button");
buttonCheck = new Button(shell, SWT.CHECK);
buttonCheck.setText("Check Button");
new Label(shell, SWT.NONE).setText("Label for Toggle Button");
buttonToggle = new Button(shell, SWT.TOGGLE);
buttonToggle.setText("Toggle Button");
new Label(shell, SWT.NONE).setText("Label for Editable Combo");
combo = new Combo(shell, SWT.BORDER);
for (int i = 0; i < 4; i++) {
combo.add("item" + i);
}
combo.select(0);
new Label(shell, SWT.NONE).setText("Label for Read-Only Combo");
combo = new Combo(shell, SWT.READ_ONLY | SWT.BORDER);
for (int i = 0; i < 4; i++) {
combo.add("item" + i);
}
combo.select(0);
new Label(shell, SWT.NONE).setText("Label for CCombo");
cCombo = new CCombo(shell, SWT.BORDER);
for (int i = 0; i < 5; i++) {
cCombo.add("item" + i);
}
cCombo.select(0);
new Label(shell, SWT.NONE).setText("Label for List");
list = new List(shell, SWT.SINGLE | SWT.BORDER);
list.setItems("Item0", "Item1", "Item2");
new Label(shell, SWT.NONE).setText("Label for Spinner");
spinner = new Spinner(shell, SWT.BORDER);
new Label(shell, SWT.NONE).setText("Label for Single-line Text");
textSingle = new Text(shell, SWT.SINGLE | SWT.BORDER);
textSingle.setText("Contents of Single-line Text");
new Label(shell, SWT.NONE).setText("Label for Multi-line Text");
textMulti = new Text(shell, SWT.MULTI | SWT.BORDER);
textMulti.setText("\nContents of Multi-line Text\n");
new Label(shell, SWT.NONE).setText("Label for StyledText");
styledText = new StyledText(shell, SWT.MULTI | SWT.BORDER);
styledText.setText("\nContents of Multi-line StyledText\n");
new Label(shell, SWT.NONE).setText("Label for Table");
table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
table.setHeaderVisible(true);
table.setLinesVisible(true);
for (int col = 0; col < 3; col++) {
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText("Col " + col);
column.setWidth(50);
}
for (int row = 0; row < 3; row++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] { "C0R" + row, "C1R" + row, "C2R" + row });
}
new Label(shell, SWT.NONE).setText("Label for Tree");
tree = new Tree(shell, SWT.BORDER | SWT.MULTI);
for (int i = 0; i < 3; i++) {
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText("Item" + i);
for (int j = 0; j < 4; j++) {
new TreeItem(item, SWT.NONE).setText("Item" + i + j);
}
}
new Label(shell, SWT.NONE).setText("Label for Tree with columns");
treeTable = new Tree(shell, SWT.BORDER | SWT.MULTI);
treeTable.setHeaderVisible(true);
treeTable.setLinesVisible(true);
for (int col = 0; col < 3; col++) {
TreeColumn column = new TreeColumn(treeTable, SWT.NONE);
column.setText("Col " + col);
column.setWidth(50);
}
for (int i = 0; i < 3; i++) {
TreeItem item = new TreeItem(treeTable, SWT.NONE);
item.setText(new String[] { "I" + i + "C0", "I" + i + "C1", "I" + i + "C2" });
for (int j = 0; j < 4; j++) {
new TreeItem(item, SWT.NONE).setText(new String[] { "I" + i + j + "C0", "I" + i + j + "C1", "I" + i + j + "C2" });
}
}
new Label(shell, SWT.NONE).setText("Label for ToolBar");
toolBar = new ToolBar(shell, SWT.FLAT);
for (int i = 0; i < 3; i++) {
ToolItem item = new ToolItem(toolBar, SWT.PUSH);
item.setText("Item" + i);
item.setToolTipText("ToolItem ToolTip" + i);
}
new Label(shell, SWT.NONE).setText("Label for CoolBar");
coolBar = new CoolBar(shell, SWT.FLAT);
for (int i = 0; i < 2; i++) {
CoolItem coolItem = new CoolItem(coolBar, SWT.PUSH);
ToolBar coolItemToolBar = new ToolBar(coolBar, SWT.FLAT);
int toolItemWidth = 0;
for (int j = 0; j < 2; j++) {
ToolItem item = new ToolItem(coolItemToolBar, SWT.PUSH);
item.setText("Item" + i + j);
item.setToolTipText("ToolItem ToolTip" + i + j);
if (item.getWidth() > toolItemWidth)
toolItemWidth = item.getWidth();
}
coolItem.setControl(coolItemToolBar);
Point size = coolItemToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point coolSize = coolItem.computeSize(size.x, size.y);
coolItem.setMinimumSize(toolItemWidth, coolSize.y);
coolItem.setPreferredSize(coolSize);
coolItem.setSize(coolSize);
}
new Label(shell, SWT.NONE).setText("Label for Canvas");
canvas = new Canvas(shell, SWT.BORDER);
canvas.setLayoutData(new GridData(64, 64));
canvas.addPaintListener(e -> e.gc.drawString("Canvas", 15, 25));
canvas.setCaret(new Caret(canvas, SWT.NONE));
/* Hook key listener so canvas will take focus during traversal in. */
canvas.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
});
/* Hook traverse listener to make canvas give up focus during traversal out. */
canvas.addTraverseListener(e -> e.doit = true);
new Label(shell, SWT.NONE).setText("Label for Group");
group = new Group(shell, SWT.NONE);
group.setText("Group");
group.setLayout(new FillLayout());
new Text(group, SWT.SINGLE | SWT.BORDER).setText("Text in Group");
new Label(shell, SWT.NONE).setText("Label for TabFolder");
tabFolder = new TabFolder(shell, SWT.NONE);
for (int i = 0; i < 3; i++) {
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText("TabItem &" + i);
item.setToolTipText("TabItem ToolTip" + i);
Text itemText = new Text(tabFolder, SWT.SINGLE | SWT.BORDER);
itemText.setText("Text for TabItem " + i);
item.setControl(itemText);
}
new Label(shell, SWT.NONE).setText("Label for CTabFolder");
cTabFolder = new CTabFolder(shell, SWT.BORDER);
for (int i = 0; i < 3; i++) {
CTabItem item = new CTabItem(cTabFolder, SWT.NONE);
item.setText("CTabItem &" + i);
item.setToolTipText("CTabItem ToolTip" + i);
Text itemText = new Text(cTabFolder, SWT.SINGLE | SWT.BORDER);
itemText.setText("Text for CTabItem " + i);
item.setControl(itemText);
}
cTabFolder.setSelection(cTabFolder.getItem(0));
new Label(shell, SWT.NONE).setText("Label for Scale");
scale = new Scale(shell, SWT.NONE);
new Label(shell, SWT.NONE).setText("Label for Slider");
slider = new Slider(shell, SWT.NONE);
new Label(shell, SWT.NONE).setText("Label for ProgressBar");
progressBar = new ProgressBar(shell, SWT.NONE);
progressBar.setSelection(50);
new Label(shell, SWT.NONE).setText("Label for Sash");
sash = new Sash(shell, SWT.NONE);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_CoolItem method test_setControlLorg_eclipse_swt_widgets_Control.
@Test
public void test_setControlLorg_eclipse_swt_widgets_Control() {
CoolBar coolBar = new CoolBar(shell, 0);
CoolItem coolItem = new CoolItem(coolBar, 0);
coolItem.setControl(null);
Button button = new Button(coolBar, SWT.PUSH);
button.setText("foobar");
Point size = coolItem.getSize();
coolItem.setControl(button);
Point size2 = coolItem.getSize();
assertTrue(size2.x > size.x);
if (!MINIMAL_CONFORMANCE) {
size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
size2 = coolItem.computeSize(size.x, size.y);
assertEquals(size2, coolItem.getSize());
}
button = new Button(coolBar, SWT.PUSH);
button.dispose();
try {
coolItem.setControl(button);
fail("No exception when control.isDisposed()");
} catch (IllegalArgumentException e) {
}
button = new Button(shell, SWT.PUSH);
try {
coolItem.setControl(button);
fail("No exception thrown when control has wrong parent");
} catch (IllegalArgumentException e) {
}
}
use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_CoolItem method test_getParent.
@Test
public void test_getParent() {
CoolBar coolBar = new CoolBar(shell, 0);
CoolItem coolItem = new CoolItem(coolBar, 0);
assertEquals(coolBar, coolItem.getParent());
}
use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_CoolItem method test_getBounds.
@Test
public void test_getBounds() {
CoolBar coolBar = new CoolBar(shell, 0);
CoolItem coolItem = new CoolItem(coolBar, 0);
Button button = new Button(coolBar, SWT.PUSH);
button.setText("foo");
coolItem.setControl(button);
Rectangle rect = coolItem.getBounds();
Point size = coolItem.getSize();
assertEquals(size.x, rect.width);
assertEquals(size.y, rect.height);
coolItem.setSize(25, 25);
rect = coolItem.getBounds();
coolItem.setSize(100, 25);
Rectangle newRect = coolItem.getBounds();
assertEquals(rect.width + 75, newRect.width);
assertEquals(rect.x, newRect.x);
assertEquals(rect.y, newRect.y);
}
Aggregations