Search in sources :

Example 26 with Display

use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.

the class MyRowLayout method main.

public static void main(String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell();
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 10;
    rowLayout.marginLeft = 5;
    rowLayout.spacing = 2;
    // true or false 
    rowLayout.wrap = true;
    rowLayout.type = SWT.HORIZONTAL;
    //# rowLayout.type = SWT.VERTICAL;
    rowLayout.pack = true;
    rowLayout.justify = false;
    new Button(shell, SWT.NONE).setText("b1");
    new Button(shell, SWT.NONE).setText("button2");
    Button b = new Button(shell, SWT.NONE);
    b.setText("btn3");
    RowData rowData = new RowData(50, 50);
    b.setLayoutData(rowData);
    shell.setLayout(rowLayout);
    shell.setText("RowLayout");
    shell.setSize(200, 200);
    shell.layout();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) Display(org.eclipse.swt.widgets.Display)

Example 27 with Display

use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.

the class MyStackLayout method open.

void open() {
    final Display display = Display.getDefault();
    final Shell shell = new Shell();
    final Composite comp1 = new Composite(shell, SWT.NONE);
    final StackLayout stackLayout = new StackLayout();
    final Text txt1 = new Text(comp1, SWT.BORDER);
    txt1.setText("T1");
    final Text txt2 = new Text(comp1, SWT.BORDER);
    txt2.setText("T2");
    Composite comp2 = new Composite(shell, SWT.NONE);
    comp2.setLayout(new RowLayout());
    Button btn1 = new Button(comp2, SWT.NONE);
    Button btn2 = new Button(comp2, SWT.NONE);
    btn1.setText("T1");
    btn2.setText("T2");
    comp1.setLayout(stackLayout);
    stackLayout.topControl = txt1;
    btn1.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            stackLayout.topControl = txt1;
            comp1.layout();
        }
    });
    btn2.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            stackLayout.topControl = txt2;
            comp1.layout();
        }
    });
    shell.setLayout(new FillLayout());
    shell.setText("StackLayout");
    shell.setSize(200, 200);
    //		shell.setMaximized(true);
    shell.layout();
    shell.open();
    while (!shell.isDisposed()) if (!display.readAndDispatch())
        display.sleep();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StackLayout(org.eclipse.swt.custom.StackLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Display(org.eclipse.swt.widgets.Display)

Example 28 with Display

use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.

the class ImageCanvasTest method main.

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    ImageViewer ic = new ImageViewer(shell);
    shell.setLayout(new FillLayout());
    FileDialog dialog = new FileDialog(shell, SWT.OPEN);
    dialog.setText("Open an image file or cancel");
    String string = dialog.open();
    ImageLoader loader = new ImageLoader();
    ImageData[] imageDatas = loader.load(string);
    if (imageDatas.length == 0)
        return;
    else if (imageDatas.length == 1) {
        ic.setImage(imageDatas[0]);
    } else {
        ic.setImages(imageDatas, loader.repeatCount);
    }
    ic.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ImageData(org.eclipse.swt.graphics.ImageData) FillLayout(org.eclipse.swt.layout.FillLayout) ImageLoader(org.eclipse.swt.graphics.ImageLoader) FileDialog(org.eclipse.swt.widgets.FileDialog) Display(org.eclipse.swt.widgets.Display)

Example 29 with Display

use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.

the class ScrolledComposite_TEST method main.

public static void main(String[] args) {
    Display display = new Display();
    Color red = display.getSystemColor(SWT.COLOR_RED);
    Color blue = display.getSystemColor(SWT.COLOR_BLUE);
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    // set the size of the scrolled content - method 1
    final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    final Composite c1 = new Composite(sc1, SWT.NONE);
    sc1.setContent(c1);
    c1.setBackground(red);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    c1.setLayout(layout);
    Button b1 = new Button(c1, SWT.PUSH);
    b1.setText("first button");
    c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    // set the minimum width and height of the scrolled content - method 2
    final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    sc2.setExpandHorizontal(true);
    sc2.setExpandVertical(true);
    final Composite c2 = new Composite(sc2, SWT.NONE);
    sc2.setContent(c2);
    c2.setBackground(blue);
    layout = new GridLayout();
    layout.numColumns = 4;
    c2.setLayout(layout);
    Button b2 = new Button(c2, SWT.PUSH);
    b2.setText("first button");
    sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    Button add = new Button(shell, SWT.PUSH);
    add.setText("add children");
    final int[] index = new int[] { 0 };
    add.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            index[0]++;
            Button button = new Button(c1, SWT.PUSH);
            button.setText("button " + index[0]);
            // reset size of content so children can be seen - method 1
            c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            c1.layout();
            button = new Button(c2, SWT.PUSH);
            button.setText("button " + index[0]);
            // reset the minimum width and height so children can be seen - method 2
            sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            c2.layout();
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) Color(org.eclipse.swt.graphics.Color) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Event(org.eclipse.swt.widgets.Event) FillLayout(org.eclipse.swt.layout.FillLayout) Display(org.eclipse.swt.widgets.Display)

Example 30 with Display

use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.

the class DispelTreeEditorBug method open.

/**
	 * Open the window
	 */
public void open() {
    final Display display = Display.getDefault();
    createContents();
    shell.open();
    shell.layout();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
Also used : Display(org.eclipse.swt.widgets.Display)

Aggregations

Display (org.eclipse.swt.widgets.Display)191 Shell (org.eclipse.swt.widgets.Shell)49 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)28 InvocationTargetException (java.lang.reflect.InvocationTargetException)25 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)22 Point (org.eclipse.swt.graphics.Point)17 ITask (com.cubrid.common.core.task.ITask)15 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)15 Color (org.eclipse.swt.graphics.Color)15 GridLayout (org.eclipse.swt.layout.GridLayout)14 Button (org.eclipse.swt.widgets.Button)14 FillLayout (org.eclipse.swt.layout.FillLayout)13 GridData (org.eclipse.swt.layout.GridData)12 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)11 IStatus (org.eclipse.core.runtime.IStatus)11 Status (org.eclipse.core.runtime.Status)11 Composite (org.eclipse.swt.widgets.Composite)11 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)10 ArrayList (java.util.ArrayList)10