Search in sources :

Example 41 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class DNDExample method createDragOperations.

private void createDragOperations(Composite parent) {
    parent.setLayout(new RowLayout(SWT.VERTICAL));
    final Button moveButton = new Button(parent, SWT.CHECK);
    moveButton.setText("DND.DROP_MOVE");
    moveButton.addSelectionListener(widgetSelectedAdapter(e -> {
        Button b = (Button) e.widget;
        if (b.getSelection()) {
            dragOperation |= DND.DROP_MOVE;
        } else {
            dragOperation = dragOperation & ~DND.DROP_MOVE;
            if (dragOperation == 0) {
                dragOperation = DND.DROP_MOVE;
                moveButton.setSelection(true);
            }
        }
        if (dragEnabled) {
            createDragSource();
        }
    }));
    Button copyButton = new Button(parent, SWT.CHECK);
    copyButton.setText("DND.DROP_COPY");
    copyButton.addSelectionListener(widgetSelectedAdapter(e -> {
        Button b = (Button) e.widget;
        if (b.getSelection()) {
            dragOperation |= DND.DROP_COPY;
        } else {
            dragOperation = dragOperation & ~DND.DROP_COPY;
            if (dragOperation == 0) {
                dragOperation = DND.DROP_MOVE;
                moveButton.setSelection(true);
            }
        }
        if (dragEnabled) {
            createDragSource();
        }
    }));
    Button linkButton = new Button(parent, SWT.CHECK);
    linkButton.setText("DND.DROP_LINK");
    linkButton.addSelectionListener(widgetSelectedAdapter(e -> {
        Button b = (Button) e.widget;
        if (b.getSelection()) {
            dragOperation |= DND.DROP_LINK;
        } else {
            dragOperation = dragOperation & ~DND.DROP_LINK;
            if (dragOperation == 0) {
                dragOperation = DND.DROP_MOVE;
                moveButton.setSelection(true);
            }
        }
        if (dragEnabled) {
            createDragSource();
        }
    }));
    // initialize state
    moveButton.setSelection(true);
    copyButton.setSelection(true);
    linkButton.setSelection(true);
    dragOperation |= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) URL(java.net.URL) DND(org.eclipse.swt.dnd.DND) TableColumn(org.eclipse.swt.widgets.TableColumn) FontMetrics(org.eclipse.swt.graphics.FontMetrics) Point(org.eclipse.swt.graphics.Point) SWTError(org.eclipse.swt.SWTError) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) URLTransfer(org.eclipse.swt.dnd.URLTransfer) Composite(org.eclipse.swt.widgets.Composite) TreeColumn(org.eclipse.swt.widgets.TreeColumn) DropTarget(org.eclipse.swt.dnd.DropTarget) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) Display(org.eclipse.swt.widgets.Display) Transfer(org.eclipse.swt.dnd.Transfer) MenuItem(org.eclipse.swt.widgets.MenuItem) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) List(org.eclipse.swt.widgets.List) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Label(org.eclipse.swt.widgets.Label) RTFTransfer(org.eclipse.swt.dnd.RTFTransfer) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Table(org.eclipse.swt.widgets.Table) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Canvas(org.eclipse.swt.widgets.Canvas) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) FileTransfer(org.eclipse.swt.dnd.FileTransfer) DragSource(org.eclipse.swt.dnd.DragSource) TableItem(org.eclipse.swt.widgets.TableItem) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) MalformedURLException(java.net.MalformedURLException) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) FormLayout(org.eclipse.swt.layout.FormLayout) FileDialog(org.eclipse.swt.widgets.FileDialog) FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment) Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) File(java.io.File) RowLayout(org.eclipse.swt.layout.RowLayout) Menu(org.eclipse.swt.widgets.Menu) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout)

Example 42 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class DNDExample method createDropTypes.

private void createDropTypes(Composite parent) {
    parent.setLayout(new RowLayout(SWT.VERTICAL));
    Button textButton = new Button(parent, SWT.CHECK);
    textButton.setText("Text Transfer");
    textButton.addSelectionListener(widgetSelectedAdapter(e -> {
        Button b = (Button) e.widget;
        if (b.getSelection()) {
            addDropTransfer(TextTransfer.getInstance());
        } else {
            removeDropTransfer(TextTransfer.getInstance());
        }
    }));
    Button b = new Button(parent, SWT.CHECK);
    b.setText("RTF Transfer");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            addDropTransfer(RTFTransfer.getInstance());
        } else {
            removeDropTransfer(RTFTransfer.getInstance());
        }
    }));
    b = new Button(parent, SWT.CHECK);
    b.setText("HTML Transfer");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            addDropTransfer(HTMLTransfer.getInstance());
        } else {
            removeDropTransfer(HTMLTransfer.getInstance());
        }
    }));
    b = new Button(parent, SWT.CHECK);
    b.setText("URL Transfer");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            addDropTransfer(URLTransfer.getInstance());
        } else {
            removeDropTransfer(URLTransfer.getInstance());
        }
    }));
    b = new Button(parent, SWT.CHECK);
    b.setText("File Transfer");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            addDropTransfer(FileTransfer.getInstance());
        } else {
            removeDropTransfer(FileTransfer.getInstance());
        }
    }));
    // initialize state
    textButton.setSelection(true);
    addDropTransfer(TextTransfer.getInstance());
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) URL(java.net.URL) DND(org.eclipse.swt.dnd.DND) TableColumn(org.eclipse.swt.widgets.TableColumn) FontMetrics(org.eclipse.swt.graphics.FontMetrics) Point(org.eclipse.swt.graphics.Point) SWTError(org.eclipse.swt.SWTError) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) URLTransfer(org.eclipse.swt.dnd.URLTransfer) Composite(org.eclipse.swt.widgets.Composite) TreeColumn(org.eclipse.swt.widgets.TreeColumn) DropTarget(org.eclipse.swt.dnd.DropTarget) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) Display(org.eclipse.swt.widgets.Display) Transfer(org.eclipse.swt.dnd.Transfer) MenuItem(org.eclipse.swt.widgets.MenuItem) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) List(org.eclipse.swt.widgets.List) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Label(org.eclipse.swt.widgets.Label) RTFTransfer(org.eclipse.swt.dnd.RTFTransfer) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Table(org.eclipse.swt.widgets.Table) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Canvas(org.eclipse.swt.widgets.Canvas) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) FileTransfer(org.eclipse.swt.dnd.FileTransfer) DragSource(org.eclipse.swt.dnd.DragSource) TableItem(org.eclipse.swt.widgets.TableItem) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) MalformedURLException(java.net.MalformedURLException) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) FormLayout(org.eclipse.swt.layout.FormLayout) FileDialog(org.eclipse.swt.widgets.FileDialog) FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment) Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) File(java.io.File) RowLayout(org.eclipse.swt.layout.RowLayout) Menu(org.eclipse.swt.widgets.Menu) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout)

Example 43 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class GraphicsExample method createControlPanel.

/**
 * Creates the control panel
 * @param parent
 */
void createControlPanel(Composite parent) {
    Group group;
    tabControlPanel = group = new Group(parent, SWT.NONE);
    // $NON-NLS-1$
    group.setText(getResourceString("Settings"));
    tabControlPanel.setLayout(new RowLayout());
}
Also used : Group(org.eclipse.swt.widgets.Group) RowLayout(org.eclipse.swt.layout.RowLayout)

Example 44 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class Bug306067_DesktopEffectShellEvent method main.

public static void main(String[] args) {
    Device.DEBUG = true;
    display = new Display();
    shell = new Shell(display);
    shell.setLayout(new RowLayout());
    // create the drop down shell
    dropDownShell = new Shell(shell, SWT.ON_TOP | SWT.DROP_DOWN);
    dropDownShell.setLayout(new RowLayout());
    dropDownShell.setVisible(false);
    dropDownShell.addListener(SWT.Deactivate, event -> {
        System.out.println("dropDownShell entering Deactivate event handler and will hide the dropdown shell");
        hideDropDown();
    });
    dropDownShell.addListener(SWT.Close, event -> hideDropDown());
    // create the button
    button = new Button(shell, SWT.PUSH);
    button.setText("Open");
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!dropDownShell.isVisible()) {
                System.out.println("Open button entering widgetSelected event handler and will show the dropdown shell");
                showDropDown();
            }
        }
    });
    button.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            System.out.println("Open button entering mouseDown event handler");
            super.mouseDown(e);
        }

        @Override
        public void mouseUp(MouseEvent e) {
            System.out.println("Open button entering mouseUp event handler");
            super.mouseUp(e);
        }
    });
    shell.setSize(300, 300);
    shell.addDisposeListener(e -> {
        if (dropDownShell != null && !dropDownShell.isDisposed()) {
            dropDownShell.dispose();
            dropDownShell = null;
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MouseEvent(org.eclipse.swt.events.MouseEvent) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Display(org.eclipse.swt.widgets.Display)

Example 45 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class Bug509514_IncorrectToDisplayLocation method main.

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    final RowLayout layout = new RowLayout(SWT.VERTICAL);
    layout.fill = true;
    shell.setLayout(layout);
    final Combo combo = new Combo(shell, SWT.BORDER);
    installPopup(combo);
    final Text text = new Text(shell, SWT.BORDER);
    installPopup(text);
    shell.setSize(400, 300);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) RowLayout(org.eclipse.swt.layout.RowLayout) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) Display(org.eclipse.swt.widgets.Display)

Aggregations

RowLayout (org.eclipse.swt.layout.RowLayout)86 Composite (org.eclipse.swt.widgets.Composite)73 GridData (org.eclipse.swt.layout.GridData)55 Button (org.eclipse.swt.widgets.Button)54 GridLayout (org.eclipse.swt.layout.GridLayout)52 Label (org.eclipse.swt.widgets.Label)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)34 Group (org.eclipse.swt.widgets.Group)27 Text (org.eclipse.swt.widgets.Text)23 Combo (org.eclipse.swt.widgets.Combo)19 Shell (org.eclipse.swt.widgets.Shell)17 Display (org.eclipse.swt.widgets.Display)16 Point (org.eclipse.swt.graphics.Point)12 ArrayList (java.util.ArrayList)10 StyledText (org.eclipse.swt.custom.StyledText)10 Table (org.eclipse.swt.widgets.Table)10 List (java.util.List)9 SelectionListener (org.eclipse.swt.events.SelectionListener)9 FillLayout (org.eclipse.swt.layout.FillLayout)9