Search in sources :

Example 1 with ArmEvent

use of org.eclipse.swt.events.ArmEvent 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)

Example 2 with ArmEvent

use of org.eclipse.swt.events.ArmEvent in project archi by archimatetool.

the class MagicConnectionCreationTool method addElementAction.

private MenuItem addElementAction(Menu menu, final EClass type) {
    final MenuItem item = new MenuItem(menu, SWT.CASCADE);
    item.setText(ArchiLabelProvider.INSTANCE.getDefaultName(type));
    item.setImage(ArchiLabelProvider.INSTANCE.getImage(type));
    // Add arm listener to notify Hints View and also set element if elements first
    item.addArmListener(new ArmListener() {

        @Override
        public void widgetArmed(ArmEvent e) {
            if (!fSetRelationshipTypeWhenHoveringOnConnectionMenuItem) {
                // User will hover over element, then connection
                getFactory().setElementType(type);
            }
            ComponentSelectionManager.INSTANCE.fireSelectionEvent(item, type);
        }
    });
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getFactory().setElementType(type);
        }
    });
    return item;
}
Also used : ArmListener(org.eclipse.swt.events.ArmListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArmEvent(org.eclipse.swt.events.ArmEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem)

Example 3 with ArmEvent

use of org.eclipse.swt.events.ArmEvent in project archi by archimatetool.

the class MagicConnectionCreationTool method addConnectionAction.

/**
 * Add a Connection Action with a relationship type
 */
private MenuItem addConnectionAction(Menu menu, final EClass relationshipType, final boolean reverseDirection) {
    final MenuItem item = new MenuItem(menu, SWT.CASCADE);
    item.setText(ArchiLabelProvider.INSTANCE.getRelationshipPhrase(relationshipType, reverseDirection));
    item.setImage(ArchiLabelProvider.INSTANCE.getImage(relationshipType));
    // Add arm listener to notify Hints View
    item.addArmListener(new ArmListener() {

        @Override
        public void widgetArmed(ArmEvent e) {
            if (fSetRelationshipTypeWhenHoveringOnConnectionMenuItem) {
                // User will hover over connection, then element
                getFactory().setRelationshipType(relationshipType);
            }
            ComponentSelectionManager.INSTANCE.fireSelectionEvent(item, relationshipType);
        }
    });
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getFactory().setRelationshipType(relationshipType);
            getFactory().setSwapSourceAndTarget(reverseDirection);
        }
    });
    return item;
}
Also used : ArmListener(org.eclipse.swt.events.ArmListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArmEvent(org.eclipse.swt.events.ArmEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem)

Aggregations

ArmEvent (org.eclipse.swt.events.ArmEvent)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 ArmListener (org.eclipse.swt.events.ArmListener)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 ControlEvent (org.eclipse.swt.events.ControlEvent)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 HelpEvent (org.eclipse.swt.events.HelpEvent)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 MenuEvent (org.eclipse.swt.events.MenuEvent)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 ShellEvent (org.eclipse.swt.events.ShellEvent)1 TraverseEvent (org.eclipse.swt.events.TraverseEvent)1 TreeEvent (org.eclipse.swt.events.TreeEvent)1 TypedEvent (org.eclipse.swt.events.TypedEvent)1 VerifyEvent (org.eclipse.swt.events.VerifyEvent)1 Point (org.eclipse.swt.graphics.Point)1