Search in sources :

Example 1 with Widget

use of org.eclipse.swt.widgets.Widget in project eclipse.themes.darker by jinmingjian.

the class CSSPropertyDarkerButtonBackgroundColorHandler method applyCSSProperty.

public boolean applyCSSProperty(Object element, String property, CSSValue value, String pseudo, CSSEngine engine) throws Exception {
    final Widget widget = SWTElementHelpers.getWidget(element);
    final Display display = widget.getDisplay();
    final Color color = (Color) engine.convert(value, Color.class, display);
    if (widget instanceof Button) {
        final Button b = (Button) widget;
        if ((b.getStyle() & SWT.PUSH) != 0) {
            b.addPaintListener(new PaintListener() {

                @Override
                public void paintControl(PaintEvent e) {
                    b.setBackground(color);
                    e.gc.setBackground(color);
                    e.gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
                    e.gc.fillRoundRectangle(0, 0, b.getBounds().width, b.getBounds().height, 2, 2);
                    //					e.gc.drawRoundRectangle(0, 0, 
                    //							b.getBounds().width,
                    //							b.getBounds().height, 
                    //							2, 2);
                    e.gc.drawString(b.getText(), 5, 5);
                }
            });
            return true;
        }
    }
    return false;
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) Button(org.eclipse.swt.widgets.Button) PaintListener(org.eclipse.swt.events.PaintListener) Color(org.eclipse.swt.graphics.Color) Widget(org.eclipse.swt.widgets.Widget) Display(org.eclipse.swt.widgets.Display)

Example 2 with Widget

use of org.eclipse.swt.widgets.Widget in project dbeaver by serge-rider.

the class TreeLoadVisualizer method completeLoading.

@Override
public void completeLoading(Object[] children) {
    final Control viewerControl = viewer.getControl();
    if (viewerControl.isDisposed()) {
        return;
    }
    try {
        viewerControl.setRedraw(false);
        Widget widget = viewer.testFindItem(parent);
        if (widget != null && !widget.isDisposed()) {
            TreeItem item = (TreeItem) viewer.testFindItem(placeHolder);
            if (children == null) {
                // Some error occurred. In good case children must be at least an empty array
                viewer.collapseToLevel(parent, -1);
            } else if (children.length != 0) {
                viewer.add(parent, children);
            }
            if (item != null && !item.isDisposed()) {
                if (item.getParentItem() != null && !item.getParentItem().isDisposed() || this.parent instanceof IWorkspaceRoot) {
                    viewer.remove(placeHolder);
                }
            }
        }
    } finally {
        placeHolder.dispose(parent);
        if (!viewerControl.isDisposed()) {
            viewerControl.setRedraw(true);
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) TreeItem(org.eclipse.swt.widgets.TreeItem) Widget(org.eclipse.swt.widgets.Widget)

Example 3 with Widget

use of org.eclipse.swt.widgets.Widget in project translationstudio8 by heartsome.

the class WizardFileSystemResourceExportPage2 method handleEvent.

/**
	 * Handle all events and enablements for widgets in this page
	 * @param e
	 *            Event
	 */
public void handleEvent(Event e) {
    Widget source = e.widget;
    if (source == destinationBrowseButton) {
        handleDestinationBrowseButtonPressed();
    }
    updatePageCompletion();
}
Also used : Widget(org.eclipse.swt.widgets.Widget)

Example 4 with Widget

use of org.eclipse.swt.widgets.Widget in project azure-tools-for-java by Microsoft.

the class DropDownHandler method pullDropdown.

public void pullDropdown(Event event) {
    Widget widget = event.widget;
    if (widget instanceof ToolItem) {
        ToolItem toolItem = (ToolItem) widget;
        Listener[] listeners = toolItem.getListeners(SWT.Selection);
        if (listeners.length > 0) {
            Listener listener = listeners[0];
            Event eve = new Event();
            eve.type = SWT.Selection;
            eve.widget = toolItem;
            eve.detail = SWT.DROP_DOWN;
            eve.x = toolItem.getBounds().x;
            eve.y = toolItem.getBounds().height;
            listener.handleEvent(eve);
        }
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Widget(org.eclipse.swt.widgets.Widget) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Event(org.eclipse.swt.widgets.Event) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 5 with Widget

use of org.eclipse.swt.widgets.Widget in project tdi-studio-se by Talend.

the class SchemasTreeDnD method addDragAndDrop.

public void addDragAndDrop() {
    // drag
    DragSource source = new DragSource(getTree(), operations);
    source.setTransfer(transferTypes);
    source.addDragListener(new TreeDragSourceEffect(getTree()));
    // drop
    DropTarget target = new DropTarget(getTree(), operations);
    target.setTransfer(transferTypes);
    target.addDropListener(new TreeDropTargetEffect(getTree()) {

        private SchemasKeyData source;

        @Override
        public void dragEnter(DropTargetEvent event) {
            super.dragEnter(event);
            Widget item = event.item;
            if (item != null) {
                TreeItem treeItem = (TreeItem) event.item;
                Object data = treeItem.getData();
                if (data != null && data instanceof SchemasKeyData) {
                    this.source = (SchemasKeyData) data;
                    event.feedback = DND.FEEDBACK_EXPAND;
                    return;
                }
            }
            event.detail = DND.DROP_NONE;
        }

        @Override
        public void drop(DropTargetEvent event) {
            super.drop(event);
            if (event.item != null && source != null) {
                TreeItem item = (TreeItem) event.item;
                Object data = item.getData();
                if (data != null && data instanceof SchemasKeyData) {
                    SchemasKeyData target = (SchemasKeyData) data;
                    target.addChild(source);
                    schemaTreeViewer.refresh();
                }
            }
            source = null;
        }
    });
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) Widget(org.eclipse.swt.widgets.Widget) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DragSource(org.eclipse.swt.dnd.DragSource) DropTarget(org.eclipse.swt.dnd.DropTarget) TreeDragSourceEffect(org.eclipse.swt.dnd.TreeDragSourceEffect) TreeDropTargetEffect(org.eclipse.swt.dnd.TreeDropTargetEffect) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData)

Aggregations

Widget (org.eclipse.swt.widgets.Widget)15 Combo (org.eclipse.swt.widgets.Combo)5 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)3 Point (org.eclipse.swt.graphics.Point)3 GridData (org.eclipse.swt.layout.GridData)3 Composite (org.eclipse.swt.widgets.Composite)3 Menu (org.eclipse.swt.widgets.Menu)3 ToolItem (org.eclipse.swt.widgets.ToolItem)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Control (org.eclipse.swt.widgets.Control)2 Label (org.eclipse.swt.widgets.Label)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ColumnViewerEditorActivationEvent (org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent)1