use of java.util.EventObject in project Payara by payara.
the class CheckMgr method fireAllTestsFinishedEvent.
// call once per test, when all tests for the mgr are done
protected void fireAllTestsFinishedEvent() {
Object[] listeners;
synchronized (listenerList) {
listeners = listenerList.toArray();
}
if (listeners == null)
return;
// those that are interested in this event
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] instanceof VerifierEventsListener) {
// create the event:
EventObject event = new EventObject(this);
((VerifierEventsListener) listeners[i]).allTestsFinished(event);
}
}
}
use of java.util.EventObject in project jdk8u_jdk by JetBrains.
the class DefaultTreeCellEditor method isCellEditable.
/**
* If the <code>realEditor</code> returns true to this
* message, <code>prepareForEditing</code>
* is messaged and true is returned.
*/
public boolean isCellEditable(EventObject event) {
boolean retValue = false;
boolean editable = false;
if (event != null) {
if (event.getSource() instanceof JTree) {
setTree((JTree) event.getSource());
if (event instanceof MouseEvent) {
TreePath path = tree.getPathForLocation(((MouseEvent) event).getX(), ((MouseEvent) event).getY());
editable = (lastPath != null && path != null && lastPath.equals(path));
if (path != null) {
lastRow = tree.getRowForPath(path);
Object value = path.getLastPathComponent();
boolean isSelected = tree.isRowSelected(lastRow);
boolean expanded = tree.isExpanded(path);
TreeModel treeModel = tree.getModel();
boolean leaf = treeModel.isLeaf(value);
determineOffset(tree, value, isSelected, expanded, leaf, lastRow);
}
}
}
}
if (!realEditor.isCellEditable(event))
return false;
if (canEditImmediately(event))
retValue = true;
else if (editable && shouldStartEditingTimer(event)) {
startEditingTimer();
} else if (timer != null && timer.isRunning())
timer.stop();
if (retValue)
prepareForEditing();
return retValue;
}
use of java.util.EventObject in project cogtool by cogtool.
the class FrameUIModel method addFrameChangeListeners.
/**
* Add listeners for when things change on the frame.
*/
protected void addFrameChangeListeners() {
AlertHandler frameChangeHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
Frame.WidgetChange chg = (Frame.WidgetChange) alert;
IWidget chgWidget = chg.getChangeElement();
if (chg != null) {
// action dictated by the change.
switch(chg.action) {
// Add the graphical representation of the widget
case Frame.WidgetChange.ELEMENT_ADD:
createGraphicalWidget(chgWidget);
raiseAlert(new FrameUIModel.WidgetShapeImageChange(FrameUIModel.this, chgWidget));
break;
// Remove the graphical representation of the widget
case Frame.WidgetChange.ELEMENT_DELETE:
removeWidget(chgWidget);
raiseAlert(new FrameUIModel.WidgetShapeImageChange(FrameUIModel.this, chgWidget));
break;
// Update all existing widgets to the new color
case Frame.WidgetChange.WIDGET_COLORS_CHANGED:
Iterator<GraphicalWidget<?>> gws = figureList.values().iterator();
// Update graphical widgets
while (gws.hasNext()) {
GraphicalWidget<?> gw = gws.next();
gw.setColor(frame.getWidgetColor());
// gw.setFastMode(false);
}
// Update potential temporary widget
contents.setWidgetColor(frame.getWidgetColor());
break;
}
}
// Draw the viewable widgets.
// Adds any new items from the lists.. or moves them
drawWidgets();
}
};
// Add the new handler for frame changes to the list of things to
// alert to changes on the frame
frame.addHandler(this, Frame.WidgetChange.class, frameChangeHandler);
// A separate handler is required to take care of changes of the
// background on the frame.
AlertHandler frameBackgroundChangeHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
Frame.BackgroundImageChange chg = (Frame.BackgroundImageChange) alert;
if (chg != null) {
// Dispose the old background image if there was one
if (backgroundImage.getImage() != null) {
backgroundImage.getImage().dispose();
}
byte[] bgImg = frame.getBackgroundImage();
// If the image is null, don't create it.
if (bgImg != null) {
// the cache is probably out of date
try {
Image img = new Image(null, new ByteArrayInputStream(bgImg));
// AUIModel.imageCache.put(frame, img);
// set the new image to the background
backgroundImage.setImage(img);
// get the size of the image
org.eclipse.swt.graphics.Rectangle bounds = img.getBounds();
// resize background image with the new bounds
backgroundImage.setSize(bounds.width, bounds.height);
} catch (SWTException ex) {
throw new GraphicsUtil.ImageException("Setting frame background image failed", ex);
}
} else {
// Clear the background image.
backgroundImage.setImage(null);
backgroundImage.setSize(0, 0);
}
}
drawWidgets();
// Need to raise Alert after draw widgets since
// the alert call seems to reset the "bounds"
raiseAlert(new FrameUIModel.WidgetShapeImageChange(FrameUIModel.this, null));
}
};
// Add this handler to the list for changes in the background image
frame.addHandler(this, Frame.BackgroundImageChange.class, frameBackgroundChangeHandler);
}
use of java.util.EventObject in project cogtool by cogtool.
the class FrameUIModel method addDesignChangeListeners.
/**
* Add listeners for when things change on the design.
*/
protected void addDesignChangeListeners() {
AlertHandler designChangeHandler = new AlertHandler() {
public void handleAlert(EventObject alert) {
Design.WidgetAppearanceChange chg = (Design.WidgetAppearanceChange) alert;
if (chg != null) {
Iterator<GraphicalWidget<?>> gws = figureList.values().iterator();
// Update graphical widgets
while (gws.hasNext()) {
GraphicalWidget<?> gw = gws.next();
gw.updateType();
}
}
}
};
// Add the new handler for design changes to the list of things to
// alert to changes on the design
frame.getDesign().addHandler(this, Design.WidgetAppearanceChange.class, designChangeHandler);
}
use of java.util.EventObject in project cogtool by cogtool.
the class ProjectUIModel method installTreeColumn.
protected void installTreeColumn(final TreeColumn designColumn, Design design) {
designColumn.addListener(SWT.Dispose, onDisposeColumn);
designColumn.setText(design.getName());
designColumn.setResizable(true);
designColumn.setWidth(CogToolPref.KLM_RESULT_RANGE.getBoolean() ? COL_WIDTH_WITH_RANGE : COL_WIDTH_NO_RANGE);
designColumn.setMoveable(true);
designColumn.addListener(SWT.Move, onColumnReorder);
CogToolPref.ALERTER.addHandler(this, CogToolPref.PreferencesChange.class, new AlertHandler() {
public void handleAlert(EventObject evt) {
if (evt == null) {
return;
}
Set<CogToolPref> changed = ((CogToolPref.PreferencesChange) evt).getPrefs();
if (changed.contains(CogToolPref.KLM_RESULT_RANGE)) {
if (CogToolPref.KLM_RESULT_RANGE.getBoolean()) {
if (designColumn.getWidth() < COL_WIDTH_WITH_RANGE) {
designColumn.setWidth(COL_WIDTH_WITH_RANGE);
}
} else {
if (designColumn.getWidth() > COL_WIDTH_NO_RANGE) {
designColumn.setWidth(COL_WIDTH_NO_RANGE);
}
}
redisplayAllResults();
} else if (changed.contains(CogToolPref.DISPLAY_DIGITS)) {
redisplayAllResults();
}
}
});
AlertHandler handler = new AlertHandler() {
public void handleAlert(EventObject alert) {
Design design = (Design) designColumn.getData();
designColumn.setText(design.getName());
designColumn.setToolTipText(design.getName() + "\n" + selectDesignHelp + "\n" + editDesignHelp);
}
};
designColumn.setData(design);
designColumn.setToolTipText(design.getName() + "\n" + selectDesignHelp + "\n" + editDesignHelp);
design.addHandler(this, NameChangeAlert.class, handler);
design.addHandler(this, Demonstration.StatusChange.class, updateStateHandler);
// Update data cells when a change happens
design.addHandler(this, TaskApplication.TaskApplicationResultChange.class, taskApplicationResultHandler);
if (columnHook != null) {
columnHook.onColumnCreation(designColumn);
}
}
Aggregations