Examples of Command


Examples of com.vaadin.ui.MenuBar.Command

    }

    private MenuBar createMenuBar(final BeanContainer<String, Task> beans, final Table table) {
        MenuBar menu = new MenuBar();
        menu.setImmediate(true);
        menu.addItem("Reload", new Command() {
            public void menuSelected(MenuItem selectedItem) {
                update(beans);
            }
        });
        menu.addItem("Add", new Command() {
            public void menuSelected(MenuItem selectedItem) {
                Task task = new Task();
                task.setId(UUID.randomUUID().toString());
                task.setTitle("New Task");
                task.setDescription("None");
                taskService.addTask(task);
                beans.addBean(task);
            }
        });
        menu.addItem("Delete", new Command() {
            public void menuSelected(MenuItem selectedItem) {
                String id = (String) table.getValue();
                taskService.deleteTask(id);
                table.removeItem(id);
            }
View Full Code Here

Examples of com.wordpress.salaboy.model.command.Command

        MessageConsumerWorker emergencyDetailsWorker = new MessageConsumerWorker("emergencyDetailsWorldUI", new MessageConsumerWorkerHandler<EmergencyDetailsMessage>() {

            @Override
            public void handleMessage(final EmergencyDetailsMessage message) {
                //Changes emergency animation
                renderCommands.add(new Command() {

                    public void execute() {
                        System.out.println("EmergencyDetailsMessage received");
                        if (emergencies.get(message.getEmergency().getCall().getId())==null){
                            System.out.println("Unknown emergency for call "+message.getEmergency().getCall().getId());
                            return;
                        }
                       
                        emergencies.get(message.getEmergency().getCall().getId()).setAnimation(AnimationFactory.getEmergencyAnimation(message.getType(), message.getNumberOfPeople()));
                        notifyAboutEmergencyStatusChange(message.getEmergency().getCall().getId(), message.getRemaining());
                    }
                });
            }
        });
       
        MessageConsumerWorker vehicleDispatchedWorker = new MessageConsumerWorker("vehicleDispatchedWorldUI", new MessageConsumerWorkerHandler<VehicleDispatchedMessage>() {

            @Override
            public void handleMessage(final VehicleDispatchedMessage message) {
                String callId = trackingService.getCallAttachedToEmergency(message.getEmergencyId());
               
                if (callId == null){
                    throw new IllegalArgumentException("No Call attached to Emergency "+message.getEmergencyId());
                }
               
                if (emergencies.get(callId)==null){
                    throw new IllegalArgumentException("Unknown emergency for call Id "+callId);
                }
               
                Vehicle vehicle = persistenceService.loadVehicle(message.getVehicleId());
                switchToEmergency(callId);
                assignVehicleToEmergency(callId, vehicle);
            }
        });

       
        MessageConsumerWorker hospitalSelectedWorker = new MessageConsumerWorker("hospitalSelectedWorldUI", new MessageConsumerWorkerHandler<HospitalSelectedMessage>() {

            @Override
            public void handleMessage(final HospitalSelectedMessage message) {
                //Changes emergency animation
                renderCommands.add(new Command() {

                    public void execute() {
                      
                        if (emergencies.get(message.getCallId())==null){
                            System.out.println("Unknown emergency for call Id "+message.getCallId());
                            return;
                        }
                        selectHospitalForEmergency(message.getCallId(), message.getHospital());
                       
                    }

                });
            }
        });
       
        MessageConsumerWorker firefigthersDepartmentWorker = new MessageConsumerWorker("firefigthersDepartmentWorldUI", new MessageConsumerWorkerHandler<FirefightersDepartmentSelectedMessage>() {

            @Override
            public void handleMessage(final FirefightersDepartmentSelectedMessage message) {
                //Changes emergency animation
                renderCommands.add(new Command() {

                    public void execute() {
                      
                        if (emergencies.get(message.getCallId())==null){
                            System.out.println("Unknown emergency for call Id "+message.getCallId());
                            return;
                        }
                        selectFirefighterDepartmentForEmergency(message.getCallId(), message.getFirefightersDepartment());
                       
                    }

                });
            }
        });
       
        MessageConsumerWorker fireTruckOutOfWaterWorker = new MessageConsumerWorker("fireTruckOutOfWaterWorkerUI", new MessageConsumerWorkerHandler<FireTruckOutOfWaterMessage>() {

            @Override
            public void handleMessage(final FireTruckOutOfWaterMessage message) {
                //Changes emergency animation
                renderCommands.add(new Command() {

                    @Override
                    public void execute() {
                        String callId = trackingService.getCallAttachedToEmergency(message.getEmergencyId());
                       
                        if (callId == null){
                            System.out.println("The emergency "+message.getEmergencyId()+" doesn't have any associated call!");
                            return;
                        }
                        if (emergencies.get(callId)==null){
                            System.out.println("Unknown emergency for call Id "+callId);
                            return;
                        }
                       
                        notifyAboutFireTruckOutOfWaterToEmergency(callId, message.getVehicleId());
                       
                    }

                });
            }
        });
       
       
        MessageConsumerWorker fireTruckWaterRefilledWorker = new MessageConsumerWorker("fireTruckWaterRefilledWorkerUI", new MessageConsumerWorkerHandler<FireTruckWaterRefilledMessage>() {

            @Override
            public void handleMessage(final FireTruckWaterRefilledMessage message) {
                //Changes emergency animation
                renderCommands.add(new Command() {

                    @Override
                    public void execute() {
                        String callId = trackingService.getCallAttachedToEmergency(message.getEmergencyId());
                       
View Full Code Here

Examples of com.zack6849.alphabot.api.Command

            String seperator = "+" + StringUtils.repeat('-', 16) + "+" + StringUtils.repeat('-', 51) + "+" + StringUtils.repeat('-', 51) + "+";
            event.getUser().send().notice(seperator);
            event.getUser().send().notice(header);
            event.getUser().send().notice(seperator);
            for (String s : CommandRegistry.commands.keySet()) {
                Command command = CommandRegistry.getCommand(s);
                event.getUser().send().notice(String.format("| %s| %s| %s|", StringUtils.rightPad(command.getName(), 15), StringUtils.rightPad(command.getDescription(), 50), StringUtils.rightPad(command.getHelp(), 50)));
            }
            event.getUser().send().notice(seperator);
            return true;
        }
        if (args.length == 2) {
            Command command = CommandRegistry.getCommand(StringUtils.capitalize(args[1].toLowerCase()));
            if (command != null) {
                event.getUser().send().notice(String.format("Help for command: %s - %s - %s", command.getName(), command.getDescription(), command.getHelp()));
            } else {
                event.getUser().send().notice("Could not find the command " + args[1] + ", are you sure you spelled it right?");
            }
            return true;
        }
View Full Code Here

Examples of commands.Command

      long currentTime1 = Calendar.getInstance().getTimeInMillis() - initialTime;
     
      while(!commands.isEmpty()) {
        //This is the "defilage"
        synchronized(this) {
          Command command = commands.remove();
          command.doCommand();
        }
      }
     
     
      // The towers attack !!
View Full Code Here

Examples of controller.commands.Command

  public void actionPerformed(ActionEvent arg0) {
    //Still have some problem that how far need to move? Moving and attacking is in different round or in same round?
    Move moving = new Move();
    moving.moveTo(map.getMoveToX(), map.getMoveToY());
    moving.execute(map.getSelectedAlly(), map.getSelectedEnemy());
    Command attacking = new Attack();
    attacking.execute(map.getSelectedAlly(), map.getSelectedEnemy());
  }
View Full Code Here

Examples of cx.ath.troja.chordless.commands.Command

        final String from = socketToString(this.p.getDhash().getServerInfo());
        final String title = String.format("Subgraph-Response from %s sent to %s",from,peer);
        /*
         * create the command, and sent to the node, which asked for!
         */
        final Command c = new ChordCommand(null, title, message, from,null);
        this.p.getDhash().send(c, sa);

      } catch (final UnknownHostException e) {
        Logger.getLogger(this.getClass()).error("Subgraph-Response receiver is unknown:",e);
      } catch (final ConnectException e) {
View Full Code Here

Examples of darkyenus.dipt.Command

    public String execute(Reference reference, String[] arguments) {
        if(arguments.length != 1){
            System.out.println("Invalid amount of arguments.");
            return "null";
        }else{
            Command command = reference.getCommand(arguments[0]);
            if (command != null) {
                System.out.println(command.getHelp());
                return command.getHelp();
            }else{
                System.out.println("Command \""+arguments[0]+"\" not found.");
                return "null";
            }
        }
View Full Code Here

Examples of de.flapdoodle.embed.mongo.Command

        IMongodConfig mongodConfig = new MongodConfigBuilder()
                .version(Version.Main.PRODUCTION)
                .net(new Net(port, false))
                .build();

        Command command = Command.MongoD;
        IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
                .defaults(command)
                .artifactStore(new ArtifactStoreBuilder()
                                       .defaults(command)
                                       .download(new DownloadConfigBuilder()
View Full Code Here

Examples of de.hpi.eworld.visualizer.simulation.traci.common.Command

    dataOutputStream.writeByte(variable);
    dataOutputStream.writeByte(valueDataType);
    dataOutputStream.writeTraciObject(valueDataType, value);
    dataOutputStream.close();
   
    return new Command(ID, outputStream.toByteArray());
  }
View Full Code Here

Examples of de.innovationgate.utils.remote.commands.Command

                        _log.error("Too many communication failures with client '" + _client.getInetAddress() + "'. Closing connection.");
                        break;
                    }
                   
                    // retrieve command from client
                    Command command = null;
                    try {
                        command = (Command) _xstream.fromXML(new InputStreamReader(_client.getInputStream()));
                    } catch (Exception e) {
                        if (e.getCause() != null) {
                            Throwable cause = e.getCause();
                            if (cause instanceof SocketTimeoutException) {
                                // client connection timed out
                                _log.warn("Connection for client '" + _client.getInetAddress() + "' timed out. Sending disconnect command.");
                                // send disconnect command to client
                                command = new Disconnect();
                            } else {
                                _log.error("Unable to retrieve command from client '" + _client.getInetAddress() + "'.", e);
                                _failures++;
                            }
                        } else {
                            _log.error("Unable to retrieve command from client '" + _client.getInetAddress() + "'.", e);
                            _failures++;
                        }
                       
                    }
                   
                    // execute command
                    if (command != null) {
                        try {
                          if (command instanceof Connect) {
                                _log.info("connect command from client '" + _client.getInetAddress() + "' recieved");
                                String clientVersion = ((Connect)command).getClientVersion();
                                if (clientVersion.equals(getVersion())) {
                                  _log.info("client version accepted");
                                  sendResponse(new Boolean(true));
                                } else {
                                  throw new CommandException("Invalid client version '" + clientVersion + "'.");
                                }                               
                            } else if (command instanceof Disconnect) {
                                _log.info("disconnect command from client '" + _client.getInetAddress() + "' recieved.");
                                sendResponse(new Boolean(true));
                                break;
                            } else {
                              _log.info("executing command '" + command.getClass().getName() + "' for client '" + _client.getInetAddress() + "'.");                                       
                              Object response = _commandHandler.execute(command);
                              _log.info("sending response to client '" + _client.getInetAddress() + "'.");
                              sendResponse(response);
                            }
                        } catch (CommandException e) {
                            _log.warn("executing command '" + command.getClass().getName() + "' for client '" + _client.getInetAddress() + "' failed.", e);
                            // send exception to client
                            sendResponse(e);
                        } catch (Exception e) {
                            _log.error("Unexpected error in ClientWorker.run().", e);
                            // send exception to client
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.