Search in sources :

Example 81 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project tdi-studio-se by Talend.

the class TalendEditorComponentCreationAssist method createComponent.

protected Object createComponent(IComponent component, org.eclipse.swt.graphics.Point location) {
    if (component == null) {
        return null;
    }
    Object newNode;
    /*
         * TODO support to insert the component on Connection
         */
    Event e = new Event();
    e.x = location.x;
    e.y = location.y;
    e.button = 1;
    e.count = 1;
    e.stateMask = 0;
    e.widget = graphicControl;
    MouseEvent mouseEvent = new MouseEvent(e);
    TalendAssistantCreationTool creationTool = new TalendAssistantCreationTool(new PaletteComponentFactory(component));
    newNode = creationTool.getCreateRequest().getNewObject();
    if (!canCreateAt(newNode, new Point(e.x, e.y))) {
        return null;
    }
    creationTool.mouseMove(mouseEvent, graphicViewer);
    graphicViewer.getEditDomain().setActiveTool(creationTool);
    graphicViewer.getEditDomain().mouseMove(mouseEvent, graphicViewer);
    graphicViewer.getEditDomain().mouseDown(mouseEvent, graphicViewer);
    graphicViewer.getEditDomain().mouseUp(mouseEvent, graphicViewer);
    return newNode;
}
Also used : PaletteComponentFactory(org.talend.designer.core.ui.editor.PaletteComponentFactory) MouseEvent(org.eclipse.swt.events.MouseEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Point(org.eclipse.draw2d.geometry.Point)

Example 82 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project tdi-studio-se by Talend.

the class AbstractScdDialog method addContextHelp.

public void addContextHelp(Control control, final String contextId) {
    final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    helpSystem.setHelp(control, contextId);
    control.addMouseTrackListener(new MouseTrackAdapter() {

        @Override
        public void mouseEnter(MouseEvent e) {
            if (getTray() != null) {
                helpSystem.displayHelp(contextId);
            }
        }
    });
}
Also used : IWorkbenchHelpSystem(org.eclipse.ui.help.IWorkbenchHelpSystem) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter)

Example 83 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project tdi-studio-se by Talend.

the class VersionManagementPage method addItemElements.

@Override
protected void addItemElements(List<ItemVersionObject> elements) {
    if (elements == null || elements.isEmpty()) {
        return;
    }
    itemTable.setRedraw(false);
    final Color redColor = Display.getDefault().getSystemColor(SWT.COLOR_RED);
    for (final ItemVersionObject object : elements) {
        final TableItem tableItem = new TableItem(itemTable, SWT.NONE);
        tableItem.setData(object);
        Item item = object.getItem();
        IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
        Image itemsImage = null;
        if (labelProvider instanceof NavigatorDecoratingLabelProvider) {
            NavigatorDecoratingLabelProvider navigatorProvider = (NavigatorDecoratingLabelProvider) labelProvider;
            itemsImage = navigatorProvider.getImage(object.getRepositoryNode());
        } else {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
            itemsImage = getItemsImage(CoreImageProvider.getIcon(itemType));
        }
        tableItem.setImage(itemsImage);
        tableItem.setText(item.getProperty().getLabel());
        // old version
        tableItem.setText(1, object.getOldVersion());
        TableEditor versionEditor = null;
        if (isFixedVersion()) {
            String version = fixedVersionText.getText();
            tableItem.setText(2, version);
            if (VersionUtils.compareTo(version, object.getOldVersion()) > 0) {
                tableItem.setForeground(2, redColor);
            } else {
                tableItem.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
            }
        } else {
            // new version
            versionEditor = new TableEditor(itemTable);
            Composite versionComposit = new Composite(itemTable, SWT.NONE);
            GridLayout layout = new GridLayout(3, false);
            layout.horizontalSpacing = 1;
            layout.verticalSpacing = 0;
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            versionComposit.setLayout(layout);
            final Text text = new Text(versionComposit, SWT.BORDER | SWT.READ_ONLY);
            GridData data = new GridData(GridData.FILL_HORIZONTAL);
            text.setLayoutData(data);
            text.setEditable(false);
            text.setText(object.getNewVersion());
            if (VersionUtils.compareTo(object.getNewVersion(), object.getOldVersion()) > 0) {
                text.setForeground(redColor);
            } else {
                text.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
            }
            Button tableMajorBtn = new Button(versionComposit, SWT.NONE);
            //$NON-NLS-1$
            tableMajorBtn.setText("M");
            //$NON-NLS-1$
            tableMajorBtn.setToolTipText(Messages.getString("VersionManagementDialog.MajorVersionTip"));
            Button tableMinorBtn = new Button(versionComposit, SWT.NONE);
            //$NON-NLS-1$
            tableMinorBtn.setText("m");
            //$NON-NLS-1$
            tableMinorBtn.setToolTipText(Messages.getString("VersionManagementDialog.MinorVersionTip"));
            tableMajorBtn.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String version = object.getNewVersion();
                    version = VersionUtils.upMajor(version);
                    text.setText(version);
                    text.setForeground(redColor);
                    object.setNewVersion(version);
                }
            });
            tableMinorBtn.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String version = object.getNewVersion();
                    version = VersionUtils.upMinor(version);
                    text.setText(version);
                    text.setForeground(redColor);
                    object.setNewVersion(version);
                }
            });
            versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
            versionEditor.setEditor(versionComposit, tableItem, 2);
        }
        TableEditor delEditor = new TableEditor(itemTable);
        Label delLabel = new Label(itemTable, SWT.CENTER);
        delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
        delLabel.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
        //$NON-NLS-1$
        delLabel.setToolTipText(Messages.getString("VersionManagementDialog.DeletedTip"));
        delLabel.pack();
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                checkedObjects.remove(object);
                removeTableItem(tableItem);
                refreshCheckedTreeView();
                checkButtonsState();
                checkButtonsState(false);
            }
        });
        delEditor.minimumWidth = 25;
        delEditor.horizontalAlignment = SWT.CENTER;
        delEditor.setEditor(delLabel, tableItem, 3);
        if (isFixedVersion()) {
            tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { delEditor });
        } else if (versionEditor != null) {
            tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { versionEditor, delEditor });
        }
        itemTable.setRedraw(true);
    }
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) NavigatorDecoratingLabelProvider(org.eclipse.ui.internal.navigator.NavigatorDecoratingLabelProvider) Color(org.eclipse.swt.graphics.Color) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) TableEditor(org.eclipse.swt.custom.TableEditor) Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 84 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project bndtools by bndtools.

the class ResolutionChoiceSelectionDialog method createDialogArea.

@SuppressWarnings("unused")
@Override
protected Control createDialogArea(Composite parent) {
    setTitle("Multiple Provider Candidates");
    setMessage("Use the candidate list to specify your preferences. Candidates at the top of the list will be preferred by the resolver.");
    // Create controls
    Composite outer = (Composite) super.createDialogArea(parent);
    Composite contents = new Composite(outer, SWT.NONE);
    Label lblRequirement = new Label(contents, SWT.NONE);
    lblRequirement.setText("Requirement Info");
    lblRequirement.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    StyledText txtRequirement = new StyledText(contents, SWT.WRAP | SWT.BORDER);
    txtRequirement.setEditable(false);
    txtRequirement.setCaret(null);
    //        txtRequirement.setBackground(contents.getBackground());
    txtRequirement.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
    new Label(contents, SWT.NONE);
    Label lblCandidates = new Label(contents, SWT.NONE);
    lblCandidates.setText("Candidates");
    lblCandidates.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    Composite lowerPanel = new Composite(contents, SWT.NONE);
    Table tbl = new Table(lowerPanel, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
    viewer = new CheckboxTableViewer(tbl);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new CapabilityLabelProvider());
    btnUp = new Button(lowerPanel, SWT.PUSH);
    btnUp.setText("Move Up");
    btnUp.setEnabled(false);
    btnDown = new Button(lowerPanel, SWT.PUSH);
    btnDown.setText("Move Down");
    btnDown.setEnabled(false);
    Composite cmpPreferences = new Composite(contents, SWT.NONE);
    btnSavePreference = new Button(cmpPreferences, SWT.CHECK | SWT.WRAP);
    txtSavePreference = new StyledText(cmpPreferences, SWT.WRAP);
    txtSavePreference.setEditable(false);
    txtSavePreference.setCaret(null);
    txtSavePreference.setBackground(contents.getBackground());
    txtSavePreference.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
    // Events
    txtSavePreference.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            btnSavePreference.setSelection(!btnSavePreference.getSelection());
        }
    });
    // Load data
    StyledString label = createRequirementText();
    txtRequirement.setText(label.getString());
    txtRequirement.setStyleRanges(label.getStyleRanges());
    viewer.setInput(candidates);
    updateSavePreferenceText();
    // Layout
    GridLayout layout;
    GridData gd;
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    contents.setLayoutData(gd);
    layout = new GridLayout(1, false);
    contents.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.NONE, true, false);
    gd.horizontalIndent = 5;
    txtRequirement.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.NONE, true, false);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    lowerPanel.setLayoutData(gd);
    layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    lowerPanel.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
    gd.widthHint = 450;
    gd.heightHint = 250;
    tbl.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.NONE, false, false);
    btnUp.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.NONE, false, false);
    btnDown.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.NONE, true, false);
    cmpPreferences.setLayoutData(gd);
    layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    cmpPreferences.setLayout(layout);
    gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    btnSavePreference.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    txtSavePreference.setLayoutData(gd);
    return contents;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) CapabilityLabelProvider(bndtools.model.resolution.CapabilityLabelProvider) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) StyledString(org.eclipse.jface.viewers.StyledString) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData)

Example 85 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project eclipse.platform.swt by eclipse.

the class Tab method log.

/**
 * Logs an untyped event to the event console.
 */
void log(Event event) {
    int i = 0;
    while (i < EVENT_INFO.length) {
        if (EVENT_INFO[i].type == event.type)
            break;
        i++;
    }
    String toString = EVENT_INFO[i].name + " [" + event.type + "]: ";
    if (!untypedEvents) {
        switch(event.type) {
            case SWT.KeyDown:
            case SWT.KeyUp:
                toString += new KeyEvent(event).toString();
                break;
            case SWT.MouseDown:
            case SWT.MouseUp:
            case SWT.MouseMove:
            case SWT.MouseEnter:
            case SWT.MouseExit:
            case SWT.MouseDoubleClick:
            case SWT.MouseWheel:
            case SWT.MouseHover:
                toString += new MouseEvent(event).toString();
                break;
            case SWT.Paint:
                toString += new PaintEvent(event).toString();
                break;
            case SWT.Move:
            case SWT.Resize:
                toString += new ControlEvent(event).toString();
                break;
            case SWT.Dispose:
                toString += new DisposeEvent(event).toString();
                break;
            case SWT.Selection:
            case SWT.DefaultSelection:
                toString += new SelectionEvent(event).toString();
                break;
            case SWT.FocusIn:
            case SWT.FocusOut:
                toString += new FocusEvent(event).toString();
                break;
            case SWT.Expand:
            case SWT.Collapse:
                toString += new TreeEvent(event).toString();
                break;
            case SWT.Iconify:
            case SWT.Deiconify:
            case SWT.Close:
            case SWT.Activate:
            case SWT.Deactivate:
                toString += new ShellEvent(event).toString();
                break;
            case SWT.Show:
            case SWT.Hide:
                toString += (event.widget instanceof Menu) ? new MenuEvent(event).toString() : event.toString();
                break;
            case SWT.Modify:
                toString += new ModifyEvent(event).toString();
                break;
            case SWT.Verify:
                toString += new VerifyEvent(event).toString();
                break;
            case SWT.Help:
                toString += new HelpEvent(event).toString();
                break;
            case SWT.Arm:
                toString += new ArmEvent(event).toString();
                break;
            case SWT.Traverse:
                toString += new TraverseEvent(event).toString();
                break;
            case SWT.HardKeyDown:
            case SWT.HardKeyUp:
            case SWT.DragDetect:
            case SWT.MenuDetect:
            case SWT.SetData:
            default:
                toString += event.toString();
        }
    } else {
        toString += event.toString();
    }
    log(toString);
    /* Return values for event fields. */
    int mask = EVENT_INFO[i].setFields;
    if (!ignore && mask != 0) {
        Event setFieldsEvent = EVENT_INFO[i].event;
        if ((mask & DOIT) != 0)
            event.doit = setFieldsEvent.doit;
        if ((mask & DETAIL) != 0)
            event.detail = setFieldsEvent.detail;
        if ((mask & TEXT) != 0)
            event.text = setFieldsEvent.text;
        if ((mask & X) != 0)
            event.x = setFieldsEvent.x;
        if ((mask & Y) != 0)
            event.y = setFieldsEvent.y;
        if ((mask & WIDTH) != 0)
            event.width = setFieldsEvent.width;
        if ((mask & HEIGHT) != 0)
            event.height = setFieldsEvent.height;
        eventConsole.append(ControlExample.getResourceString("Returning"));
        ignore = true;
        log(event);
        ignore = false;
    }
}
Also used : HelpEvent(org.eclipse.swt.events.HelpEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ArmEvent(org.eclipse.swt.events.ArmEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) TypedEvent(org.eclipse.swt.events.TypedEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) MenuEvent(org.eclipse.swt.events.MenuEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ArmEvent(org.eclipse.swt.events.ArmEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) VerifyEvent(org.eclipse.swt.events.VerifyEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) HelpEvent(org.eclipse.swt.events.HelpEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) ControlEvent(org.eclipse.swt.events.ControlEvent) VerifyEvent(org.eclipse.swt.events.VerifyEvent) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

MouseEvent (org.eclipse.swt.events.MouseEvent)100 MouseAdapter (org.eclipse.swt.events.MouseAdapter)50 GridData (org.eclipse.swt.layout.GridData)37 MouseListener (org.eclipse.swt.events.MouseListener)32 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 Point (org.eclipse.swt.graphics.Point)32 KeyEvent (org.eclipse.swt.events.KeyEvent)27 Composite (org.eclipse.swt.widgets.Composite)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20 Button (org.eclipse.swt.widgets.Button)20 FocusEvent (org.eclipse.swt.events.FocusEvent)18 PaintEvent (org.eclipse.swt.events.PaintEvent)18 Event (org.eclipse.swt.widgets.Event)15 Label (org.eclipse.swt.widgets.Label)15 Text (org.eclipse.swt.widgets.Text)14 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)13 PaintListener (org.eclipse.swt.events.PaintListener)13 KeyListener (org.eclipse.swt.events.KeyListener)12 ModifyEvent (org.eclipse.swt.events.ModifyEvent)12