use of java.util.EventObject in project cogtool by cogtool.
the class DesignEditorUI method createFrameRecoveryHandler.
protected AlertHandler createFrameRecoveryHandler() {
return new AlertHandler() {
public void handleAlert(EventObject alert) {
StructureViewUIModel.FrameRecovery evt = (StructureViewUIModel.FrameRecovery) alert;
if (evt != null) {
DesignEditorFrame frameFigure = evt.getFrameFigure();
selection.deselectFrame(frameFigure);
// If removing the DesignEditorFrame for the
// rename text editor, cancel the rename
// operation and clean up.
cleanupFrameEditor(frameFigure);
}
}
};
}
use of java.util.EventObject in project cogtool by cogtool.
the class DesignEditorUI method createTransitionSelectionHandler.
// createFrameSelectionHandler
protected AlertHandler createTransitionSelectionHandler() {
return new AlertHandler() {
public void handleAlert(EventObject alert) {
TransitionSelectionChange evt = (TransitionSelectionChange) alert;
if (evt != null) {
InteractionDrawingEditor editor = view.getEditor();
if (evt.changedTransitionFigure != null) {
evt.changedTransitionFigure.setSelected(editor, evt.selected);
} else {
Iterator<DesignEditorTransition> transitionFigures = selection.getSelectedTransitionFigures();
while (transitionFigures.hasNext()) {
DesignEditorTransition transitionFigure = transitionFigures.next();
transitionFigure.setSelected(editor, evt.selected);
}
}
// Repaint the contents
delayedRepainting.requestRepaint(REPAINT_ALL);
updateView(evt.changedTransitionFigure == null);
}
}
};
}
use of java.util.EventObject in project cogtool by cogtool.
the class DesignEditorUI method setFrameChangeHandlers.
protected void setFrameChangeHandlers(final Design design) {
design.addHandler(this, NameChangeAlert.class, renameHandler);
AlertHandler frameChangeHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
Design.FrameChange chg = (Design.FrameChange) alert;
if (chg != null) {
updateView(false);
Frame frame = (Frame) chg.element;
if (chg.isAdd) {
DesignEditorFrame frameFigure = structureView.getFrameFigure(frame);
// A newly created frame should be selected.
delayedFrameSelection.addToSelection(frame, frameFigure);
} else {
delayedFrameSelection.removeFromSelection(frame);
}
delayedRepainting.requestRepaint(REPAINT_ALL);
}
}
};
design.addHandler(this, Design.FrameChange.class, frameChangeHandler);
frameChangeHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
Design.FrameSetChange chg = (Design.FrameSetChange) alert;
if (chg != null) {
updateView(false);
if (chg.isAdd) {
for (Frame frame : chg.frames) {
DesignEditorFrame frameFigure = structureView.getFrameFigure(frame);
// A newly created frame should be selected.
delayedFrameSelection.addToSelection(frameFigure.getFrame(), frameFigure);
}
delayedRepainting.requestRepaint(REPAINT_ALL);
} else {
for (Frame frame : chg.frames) {
delayedFrameSelection.removeFromSelection(frame);
}
}
}
}
};
design.addHandler(this, Design.FrameSetChange.class, frameChangeHandler);
design.addHandler(this, Design.DeviceTypeChange.class, new AlertHandler() {
public void handleAlert(EventObject alert) {
Set<DeviceType> deviceTypeSet = design.getDeviceTypes();
int deviceTypes = DeviceType.buildDeviceSet(deviceTypeSet);
view.resetDeviceTypes(deviceTypes);
}
});
}
use of java.util.EventObject in project cogtool by cogtool.
the class DesignEditorUI method createFrameNameChangeHandler.
protected AlertHandler createFrameNameChangeHandler() {
return new AlertHandler() {
public void handleAlert(EventObject alert) {
StructureViewUIModel.FrameNameChange evt = (StructureViewUIModel.FrameNameChange) alert;
Frame f = evt.getFrame();
if (selection.isFrameSelected(f)) {
view.getActionPropertySet().setFrameName(f);
}
}
};
}
use of java.util.EventObject in project cogtool by cogtool.
the class FrameEditorUI method addFrameWidgetHandler.
/**
* Registers a listener that adjusts selection state in response to
* widget additions or removals
*/
protected void addFrameWidgetHandler() {
AlertHandler frameWidgetHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
Frame.WidgetChange chg = (Frame.WidgetChange) alert;
IWidget chgWidget = chg.getChangeElement();
if (chg != null) {
// Check what action was performed
switch(chg.action) {
// Switch the selection to the newly-added widget
case Frame.WidgetChange.ELEMENT_ADD:
{
GraphicalWidget<?> gw = frameUI.getWidgetFigure(chgWidget);
gw.addChangeHandler(widgetChangeHandler, Widget.WidgetChange.class);
gw.addChangeHandler(widgetChangeHandler, IAttributed.AttributeChange.class);
gw.addChangeHandler(widgetChangeHandler, IAttributed.AuthorityChange.class);
delayedWidgetSelection.addToSelection(chgWidget, gw);
view.requestRename();
break;
}
// Reflect the change in selection state
case Frame.WidgetChange.ELEMENT_DELETE:
{
// Cannot depend on the frameUI to have removed
// this widget's graphical version.
// Call deselect with the model itself.
selection.deselectElement(chgWidget);
delayedWidgetSelection.removeFromSelection(chgWidget);
// call to clean up any resize handles.
delayedRepainting.requestRepaint(REPAINT_SELECT_HANDLES);
break;
}
}
}
}
};
frame.addHandler(this, Frame.WidgetChange.class, frameWidgetHandler);
AlertHandler frameEltHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
delayedRepainting.requestRepaint(REPAINT_SELECT_HANDLES);
}
};
// Do the above for both widget and association changes!
frame.addHandler(this, Frame.ElementChange.class, frameEltHandler);
AlertHandler frameAssocHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
Frame.FrameEltGrpChange chg = (Frame.FrameEltGrpChange) alert;
if (chg.action == Frame.FrameEltGrpChange.ELEMENT_DELETE) {
selection.deselectElement(chg.getChangeElement());
} else if (chg.action == Frame.FrameEltGrpChange.ELEMENT_ADD) {
selection.setSelectedSelnFig(uiModel.getGroupHalo(chg.getChangeElement()));
}
}
};
frame.addHandler(this, Frame.FrameEltGrpChange.class, frameAssocHandler);
}
Aggregations