use of java.util.EventObject in project cogtool by cogtool.
the class FrameEditorUI method addBackgroundImageHandler.
/**
* Registers a listener that enables/disables the
* "remove background image" menu item as necessary.
*
* Also enable or disabled the capture Background button.
* TODO: when capture background becomes a menu item, add to setEnabled
*/
protected void addBackgroundImageHandler() {
AlertHandler backgroundEnabler = new AlertHandler() {
public void handleAlert(EventObject alert) {
// Checks to see if the frame has a background.
// if so enable remove background and capture background
// buttons.
boolean enable = (frame.getBackgroundImage() == null) ? MenuUtil.DISABLED : MenuUtil.ENABLED;
// Enable or disabled the remove background menu item
setEnabled(CogToolLID.RemoveBackgroundImage, ListenerIdentifierMap.ALL, enable);
// Enable or disabled the capture background button
view.setIsBackgroundAvailable(enable);
}
};
frame.addHandler(this, Frame.BackgroundImageChange.class, backgroundEnabler);
}
use of java.util.EventObject in project cogtool by cogtool.
the class FrameEditorUI method addWidgetShapeChangeHandler.
/**
* Registers a listener that redraws the frame in response to changes in
* the appearance of widgets
*
* When this event occurs, resize handles are redrawn, the window's size is
* recomputed, and the display updated.
*
*/
protected void addWidgetShapeChangeHandler() {
AlertHandler widgetTitleChangeHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
FrameUIModel.WidgetTitleChange chg = (FrameUIModel.WidgetTitleChange) alert;
// selected widget
if (selection.getElementSelectionCount() == 1) {
FrameElement elt = selection.getSelectedIFrameElements()[0];
if (chg.widget == elt.getAttribute(WidgetAttributes.REMOTE_LABEL_ATTR)) {
view.setRemoteLabelText(chg.widget.getTitle());
}
}
}
};
frameUI.addHandler(this, FrameUIModel.WidgetTitleChange.class, widgetTitleChangeHandler);
AlertHandler widgetShapeChangeHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
delayedRepainting.requestRepaint(SHAPE_CHANGE_REPAINT);
// a FULL repaint is probably not needed
}
};
frameUI.addHandler(this, FrameUIModel.WidgetShapeImageChange.class, widgetShapeChangeHandler);
AlertHandler widgetGroupChangeHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
FrameUIModel.WidgetGroupChange evt = (FrameUIModel.WidgetGroupChange) alert;
if (evt.isAdd) {
GraphicalWidget<?> gw = frameUI.getWidgetFigure(evt.widget);
delayedWidgetSelection.addToSelection(evt.widget, gw);
} else {
delayedWidgetSelection.removeFromSelection(evt.widget);
SimpleWidgetGroup group = evt.widget.getParentGroup();
if (group.size() == 0) {
//evt.widget was the last widget in this group,
//so hide the halo for it
removeHalo(evt.widget);
}
}
}
};
frameUI.addHandler(this, FrameUIModel.WidgetGroupChange.class, widgetGroupChangeHandler);
}
use of java.util.EventObject in project cogtool by cogtool.
the class FrameEditorUI method init.
/**
* Set up this object for editing widgets.
* This method should be called from within the constructor.
*/
private void init() {
// Add listeners to the view
addEventListeners();
addSelectionChangeListeners();
// Add listeners to the model
addBackgroundImageHandler();
addFrameWidgetHandler();
addWidgetShapeChangeHandler();
project.addHandler(this, Project.DesignChange.class, new AlertHandler() {
public void handleAlert(EventObject alert) {
Project.DesignChange chg = (Project.DesignChange) alert;
if ((!chg.isAdd) && (chg.element == design)) {
closeOpenController();
}
}
});
design.addHandler(this, Design.FrameChange.class, new AlertHandler() {
public void handleAlert(EventObject alert) {
Design.FrameChange chg = (Design.FrameChange) alert;
if ((!chg.isAdd) && (chg.element == frame)) {
closeOpenController();
}
}
});
design.addHandler(this, Design.DeviceTypeChange.class, new AlertHandler() {
public void handleAlert(EventObject alert) {
Set<DeviceType> dts = design.getDeviceTypes();
int deviceTypes = DeviceType.buildDeviceSet(dts);
view.resetDeviceTypes(deviceTypes);
}
});
// Add listeners to rename events on project and design
frame.addHandler(this, NameChangeAlert.class, renameHandler);
design.addHandler(this, NameChangeAlert.class, renameHandler);
// Some items should always be enabled.
// Should be the last call in the constructor
setInitiallyEnabled(true);
}
use of java.util.EventObject in project cogtool by cogtool.
the class DesignEditorUI method createFrameSelectionHandler.
protected AlertHandler createFrameSelectionHandler() {
return new AlertHandler() {
public void handleAlert(EventObject alert) {
FrameSelectionChange evt = (FrameSelectionChange) alert;
ActionPropertySet actionProps = view.getActionPropertySet();
if (evt != null) {
if (evt.changedFrameFigure != null) {
evt.changedFrameFigure.setSelected(evt.selected);
// Handle property sheet selection
Frame[] selectedFrames = selection.getSelectedFrames();
int selectedFrameCount = selectedFrames.length;
if (selectedFrameCount > 0) {
actionProps.setComposite(ActionPropertySet.FRAME);
if (selectedFrameCount == 1) {
actionProps.setFrameName(selectedFrames[0]);
}
} else {
actionProps.setComposite(ActionSet.USE_NONE);
}
actionProps.enableFrameName(selectedFrameCount == 1);
} else {
actionProps.setComposite(ActionSet.USE_NONE);
Iterator<DesignEditorFrame> frameFigures = selection.getSelectedFrameFigures();
while (frameFigures.hasNext()) {
DesignEditorFrame frameFigure = frameFigures.next();
frameFigure.setSelected(evt.selected);
}
}
// Repaint the frame contents
delayedRepainting.requestRepaint(REPAINT_ALL);
}
}
};
}
use of java.util.EventObject in project intellij-community by JetBrains.
the class NewErrorTreeEditor method isCellEditable.
@Override
public boolean isCellEditable(EventObject e) {
Object node;
if (e instanceof MouseEvent) {
final Point point = ((MouseEvent) e).getPoint();
final TreePath location = myTree.getClosestPathForLocation(point.x, point.y);
node = location.getLastPathComponent();
} else {
node = myTree.getLastSelectedPathComponent();
}
final ErrorTreeElement element = getElement(node);
return element instanceof EditableMessageElement;
}
Aggregations