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;
}
}
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;
}
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;
}
Aggregations