use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class TableWrapLayoutTest method test_columnAccess.
// //////////////////////////////////////////////////////////////////////////
//
// Dimension operations
//
// //////////////////////////////////////////////////////////////////////////
public void test_columnAccess() throws Exception {
CompositeInfo shell = parseComposite("class Test extends Shell {", " Test() {", " {", " TableWrapLayout layout = new TableWrapLayout();", " layout.numColumns = 2;", " setLayout(layout);", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
shell.refresh();
TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout();
final TableWrapColumnInfo<?> column = layout.getColumns().get(0);
// check initial values
assertEquals(0, column.getIndex());
assertEquals("left", column.getTitle());
assertFalse(column.getGrab());
assertEquals(TableWrapData.LEFT, column.getAlignment().intValue());
// flip grab
column.flipGrab();
assertEditor("class Test extends Shell {", " Test() {", " {", " TableWrapLayout layout = new TableWrapLayout();", " layout.numColumns = 2;", " setLayout(layout);", " }", " {", " Button button = new Button(this, SWT.NONE);", " {", " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", " tableWrapData.grabHorizontal = true;", " button.setLayoutData(tableWrapData);", " }", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " {", " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", " tableWrapData.grabHorizontal = true;", " button.setLayoutData(tableWrapData);", " }", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
assertEquals("left, grab", column.getTitle());
// set alignment
ExecutionUtils.run(shell, new RunnableEx() {
@Override
public void run() throws Exception {
column.setAlignment(TableWrapData.FILL);
}
});
assertEditor("class Test extends Shell {", " Test() {", " {", " TableWrapLayout layout = new TableWrapLayout();", " layout.numColumns = 2;", " setLayout(layout);", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
assertEquals("fill, grab", column.getTitle());
// set different alignment for "0 x 1" button
{
ControlInfo button = shell.getChildrenControls().get(2);
layout.getTableWrapData(button).setHorizontalAlignment(TableWrapData.RIGHT);
assertNull(column.getAlignment());
}
// check other alignments
{
column.setAlignment(TableWrapData.CENTER);
assertEquals("center, grab", column.getTitle());
//
column.setAlignment(TableWrapData.RIGHT);
assertEquals("right, grab", column.getTitle());
}
// delete
column.delete();
assertEditor("class Test extends Shell {", " Test() {", " {", " TableWrapLayout layout = new TableWrapLayout();", " setLayout(layout);", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
}
use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class TableWrapLayoutTest method test_rowAccess.
public void test_rowAccess() throws Exception {
CompositeInfo shell = parseComposite("class Test extends Shell {", " Test() {", " {", " TableWrapLayout layout = new TableWrapLayout();", " layout.numColumns = 2;", " setLayout(layout);", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
shell.refresh();
TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout();
final TableWrapRowInfo<?> row = layout.getRows().get(1);
// check initial values
assertEquals(1, row.getIndex());
assertEquals("top", row.getTitle());
assertFalse(row.getGrab());
assertEquals(TableWrapData.TOP, row.getAlignment().intValue());
// flip grab
row.flipGrab();
assertEditor("class Test extends Shell {", " Test() {", " {", " TableWrapLayout layout = new TableWrapLayout();", " layout.numColumns = 2;", " setLayout(layout);", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " {", " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", " tableWrapData.grabVertical = true;", " button.setLayoutData(tableWrapData);", " }", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " {", " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", " tableWrapData.grabVertical = true;", " button.setLayoutData(tableWrapData);", " }", " button.setText('1 x 1');", " }", " }", "}");
assertEquals("top, grab", row.getTitle());
// set alignment
ExecutionUtils.run(shell, new RunnableEx() {
@Override
public void run() throws Exception {
row.setAlignment(TableWrapData.FILL);
}
});
assertEditor("class Test extends Shell {", " Test() {", " {", " TableWrapLayout layout = new TableWrapLayout();", " layout.numColumns = 2;", " setLayout(layout);", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB, 1, 1));", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB, 1, 1));", " button.setText('1 x 1');", " }", " }", "}");
assertEquals("fill, grab", row.getTitle());
// set different alignment for "0 x 1" button
{
ControlInfo button = shell.getChildrenControls().get(2);
layout.getTableWrapData(button).setVerticalAlignment(TableWrapData.BOTTOM);
assertNull(row.getAlignment());
}
// check other alignments
{
row.setAlignment(TableWrapData.TOP);
assertEquals("top, grab", row.getTitle());
//
row.setAlignment(TableWrapData.MIDDLE);
assertEquals("middle, grab", row.getTitle());
//
row.setAlignment(TableWrapData.BOTTOM);
assertEquals("bottom, grab", row.getTitle());
}
// delete
row.delete();
assertEditor("class Test extends Shell {", " Test() {", " {", " TableWrapLayout layout = new TableWrapLayout();", " setLayout(layout);", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 0');", " }", " }", "}");
}
use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class GridLayoutTest method test_columnAccess.
// //////////////////////////////////////////////////////////////////////////
//
// Dimension operations
//
// //////////////////////////////////////////////////////////////////////////
public void test_columnAccess() throws Exception {
CompositeInfo shell = parseComposite("class Test extends Shell {", " Test() {", " setLayout(new GridLayout(2, false));", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
shell.refresh();
final GridLayoutInfo layout = (GridLayoutInfo) shell.getLayout();
final GridColumnInfo<ControlInfo> column = layout.getColumns().get(0);
// check initial values
assertEquals(0, column.getIndex());
assertEquals("left", column.getTitle());
assertFalse(column.getGrab());
assertEquals(SWT.LEFT, column.getAlignment().intValue());
// flip grab
column.flipGrab();
assertEditor("class Test extends Shell {", " Test() {", " setLayout(new GridLayout(2, false));", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
assertEquals("left, grab", column.getTitle());
// set alignment
column.setAlignment(SWT.FILL);
assertEditor("class Test extends Shell {", " Test() {", " setLayout(new GridLayout(2, false));", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));", " button.setText('0 x 0');", " }", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));", " button.setText('0 x 1');", " }", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
assertEquals("fill, grab", column.getTitle());
// set different alignment for "0 x 1" button
{
ControlInfo button = shell.getChildrenControls().get(2);
GridLayoutInfo.getGridData(button).setHorizontalAlignment(SWT.RIGHT);
assertNull(column.getAlignment());
}
// check other alignments
{
column.setAlignment(SWT.CENTER);
assertEquals("center, grab", column.getTitle());
//
column.setAlignment(SWT.RIGHT);
assertEquals("right, grab", column.getTitle());
}
// delete
ExecutionUtils.run(shell, new RunnableEx() {
@Override
public void run() throws Exception {
column.delete();
}
});
assertEditor("class Test extends Shell {", " Test() {", " setLayout(new GridLayout(1, false));", " new Label(this, SWT.NONE);", " {", " Button button = new Button(this, SWT.NONE);", " button.setText('1 x 1');", " }", " }", "}");
}
use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class FontPreviewCanvas method setFontInfo.
// //////////////////////////////////////////////////////////////////////////
//
// Access
//
// //////////////////////////////////////////////////////////////////////////
/**
* Sets the {@link Font} to display.
*/
public void setFontInfo(final FontInfo fontInfo) {
if (m_image != null) {
m_image.dispose();
m_image = null;
}
if (fontInfo != null) {
ExecutionUtils.runLog(new RunnableEx() {
public void run() throws Exception {
m_image = FontSupport.getFontPreview(fontInfo.getFont());
}
});
}
redraw();
}
use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.
the class TableWrapDataTest method test_verticalFillGrab_2.
/**
* Precondition: constructor with alignment, vertical grab is <code>true</code> in field.<br>
* Action: change vertical alignment to {@link TableWrapData#FILL} and back to
* {@link TableWrapData#TOP}. <br>
* Result: use/not {@link TableWrapData#FILL_GRAB} in constructor.
*/
public void test_verticalFillGrab_2() throws Exception {
CompositeInfo shell = parseComposite("class Test extends Shell {", " Test() {", " setLayout(new TableWrapLayout());", " {", " Button button = new Button(this, SWT.NONE);", " {", " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", " tableWrapData.grabVertical = true;", " button.setLayoutData(tableWrapData);", " }", " }", " }", "}");
shell.refresh();
TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout();
ControlInfo button = shell.getChildrenControls().get(0);
final TableWrapDataInfo tableWrapData = layout.getTableWrapData(button);
// initial state
assertEquals(TableWrapData.TOP, tableWrapData.getVerticalAlignment());
assertTrue(tableWrapData.getVerticalGrab());
// alignment := FILL
ExecutionUtils.run(shell, new RunnableEx() {
@Override
public void run() throws Exception {
tableWrapData.setVerticalAlignment(TableWrapData.FILL);
}
});
assertEquals(TableWrapData.FILL, tableWrapData.getVerticalAlignment());
assertTrue(tableWrapData.getVerticalGrab());
assertEditor("class Test extends Shell {", " Test() {", " setLayout(new TableWrapLayout());", " {", " Button button = new Button(this, SWT.NONE);", " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB));", " }", " }", "}");
// alignment := TOP
ExecutionUtils.run(shell, new RunnableEx() {
@Override
public void run() throws Exception {
tableWrapData.setVerticalAlignment(TableWrapData.TOP);
}
});
assertEquals(TableWrapData.TOP, tableWrapData.getVerticalAlignment());
assertTrue(tableWrapData.getVerticalGrab());
assertEditor("class Test extends Shell {", " Test() {", " setLayout(new TableWrapLayout());", " {", " Button button = new Button(this, SWT.NONE);", " {", " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", " tableWrapData.grabVertical = true;", " button.setLayoutData(tableWrapData);", " }", " }", " }", "}");
}
Aggregations