@Override public void finished(GOEvent event) { if (action != null) { this.connector.fireAction(this.action); } }
/** * Creates a new connector for the given interface. * * @param content * The map. */ public MapInterfaceConnector(MapContent content) { this.content = content; actionFirerer.setBlockingListener(content); }
@Override public void fireAction(IAction action) { this.actionFirerer.fireAction(action); }
@Override public void run() { FireringAction action; while (!stopped) { try { synchronized (toFireMutex) { while (toFire.isEmpty() && !stopped) { toFireMutex.wait(); } if (stopped) { break; } action = toFire.poll(); } startWatchdog(action.startTime); fireTo.fireAction(action.action); stopWatchdog(); } catch (Throwable e) { System.err.println("Exception while handling action:"); e.printStackTrace(); if (blockingListener != null) { blockingListener.actionThreadCaughtException(e); } } if (toFire.isEmpty()) { disableWatchdog(); } } } }
protected void disableWatchdog() { sendIsBlocking(false); }
public TabButton(AbstractContentProvider content, OriginalImageLink image, OriginalImageLink activeImage, String description) { super(new ChangePanelAction(content), image, activeImage, description); this.content = content; }
private void sendIsBlocking(boolean blocking) { synchronized (blockingListenerMutex) { if (isBlockingSent != blocking && blockingListener != null) { blockingListener.actionThreadSlow(blocking); } isBlockingSent = blocking; } }
protected Action getActionForStep(int step) { EWaypointType waypoint; if (step <= 0) { waypoint = SetTradingWaypointAction.EWaypointType.WAYPOINT_1; } else if (step <= 1) { waypoint = SetTradingWaypointAction.EWaypointType.WAYPOINT_2; } else if (step <= 2) { waypoint = SetTradingWaypointAction.EWaypointType.WAYPOINT_3; } else { waypoint = SetTradingWaypointAction.EWaypointType.DESTINATION; } return new AskSetTradingWaypointAction(waypoint); } }
/** * Creates a new action firerer and starts it. * * @param fireTo * The object we should fire to. */ public ActionFirerer(ActionFireable fireTo) { this.fireTo = fireTo; this.thread = new ActionFirererThread(); this.thread.setDaemon(true); this.thread.start(); }
/** * Schedules an action to be fired. */ @Override public void fireAction(IAction action) { synchronized (toFireMutex) { toFire.offer(new FireringAction(action, System.currentTimeMillis())); toFireMutex.notifyAll(); } }
/** * Stops all threads related to the graphics display. You may experience crazy results when trying to use the map view afterwards. */ @Override public void shutdown() { actionFirerer.stop(); content.stop(); }
@Override public void execute() { setBarFill(relativeFill, relativeFill); if (listener != null) { listener.execute(); } } };
private void fireActionEvent(GOEvent event, Action action) { event.setHandler(new ActionHandler(action, this)); }
@Override public void contentHiding(ActionFireable actionFireable, AbstractContentProvider nextContent) { uiContentUpdater.stop(); if (activeBuilding != null) { actionFireable.fireAction(new ShowConstructionMarksAction(null)); } } }
protected void startWatchdog(long startTime) { long destTime = startTime + ACTION_FIRERER_TIMEOUT; long timeUntilFreezeState = System.currentTimeMillis() - destTime; if (timeUntilFreezeState <= 0) { sendIsBlocking(true); } else { watchdogTimerTask = new TimerTask() { @Override public void run() { sendIsBlocking(true); } }; watchdogTimer.schedule(watchdogTimerTask, timeUntilFreezeState); } }
public GOEventHandlerImplementation(UIPoint lastpoint) { last = toMapPosition(lastpoint); firerer.fireAction(new StartDrawingAction(last)); starty = lastpoint.getY(); }
@Override public void finished(GOEvent event) { eventDataChanged(event); firerer.fireAction(new EndDrawingAction(last)); }
@Override public void contentHiding(ActionFireable actionFireable, AbstractContentProvider nextContent) { if (!nextContent.isForSelection()) { // TODO: Replace with a deselect-all-action actionFireable.fireAction(new Action(EActionType.DESELECT)); } super.contentHiding(actionFireable, nextContent); }
@Override public void eventDataChanged(GOEvent event) { UIPoint pos = ((GODrawEvent) event).getDrawPosition(); ShortPoint2D cur = toMapPosition(pos); firerer.fireAction(new DrawLineAction(last, cur, pos.getY() - starty)); last = cur; } }
/** * Forward a single action * * @throws InterruptedException */ protected void forwardSingleAction() throws InterruptedException { IAction action = toFire.take(); if (action instanceof DrawLineAction && toFire.peek() instanceof DrawLineAction) { ShortPoint2D start = ((DrawLineAction) action).getStart(); ShortPoint2D end = ((DrawLineAction) action).getEnd(); double uidy = ((DrawLineAction) action).getUidy(); while (toFire.peek() instanceof DrawLineAction) { DrawLineAction next = (DrawLineAction) toFire.poll(); end = next.getEnd(); uidy += next.getUidy(); } action = new DrawLineAction(start, end, uidy); } fireTo.fireAction(action); }