Package it.freedomotic.reactions

Examples of it.freedomotic.reactions.Command


        try {
            payload = message.getObject();

            if (payload instanceof Command) {
                final Command command = (Command) payload;
                LOG.config(this.getName() + " receives command " + command.getName()
                        + " with parametes {{" + command.getProperties() + "}}");

                Protocol.ActuatorPerforms task;
                lastDestination = message.getJMSReplyTo();
                task =
                        new Protocol.ActuatorPerforms(command,
View Full Code Here


            final JComboBox cmbCommand = new JComboBox();
            cmbCommand.setModel(allHardwareCommands);

            EnvObjectLogic objLogic = (EnvObjectLogic) object;
            Command relatedCommand = objLogic.getHardwareCommand(action);

            if (relatedCommand != null) {
                //related harware command is already defined
                cmbCommand.setSelectedItem(relatedCommand);
            } else {
                cmbCommand.setSelectedIndex(-1); //no mapping
            }

            cmbCommand.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Command command = (Command) cmbCommand.getSelectedItem();
                    object.setAction(action, command);
                }
            });
            commandsControlPanel.addRow();
View Full Code Here

        btnTrigger.setPreferredSize(new Dimension(300, 30));
        btnTrigger.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                if (trigger != null) {
                    Command c = new Command();
                    c.setName("Edit a trigger");
                    c.setReceiver("app.actuators.nlautomationseditor.nlautomationseditor.in");
                    c.setProperty("editor", "trigger");
                    c.setProperty("editable",
                            trigger.getName()); //the default choice
                    c.setReplyTimeout(Integer.MAX_VALUE);

                    Command reply = Freedomotic.sendCommand(c);
                    String newTrigger = reply.getProperty("edited");

                    if (newTrigger != null) {
                        btnTrigger.setName(TriggerPersistence.getTrigger(newTrigger).getName());
                    }
View Full Code Here

    @Override
    protected void onCommand(Command c)
            throws IOException, UnableToExecuteException {
        if (c.getProperty("editor").equalsIgnoreCase("command")) {
            Command command = CommandPersistence.getCommand(c.getProperty("editable"));
//            ReactionList reactionList = new ReactionList(this);
            CustomizeCommand cc = new CustomizeCommand(getApi().getI18n(), command);
            cc.setVisible(true);
        } else {
            if (c.getProperty("editor").equalsIgnoreCase("trigger")) {
View Full Code Here

        try {
            table.getCellEditor().stopCellEditing();
        } catch (Exception e) {
        }

        Command c = new Command();
        c.setName(txtName.getText());
        c.setDescription(txtDescription.getText());

        if (cmbReceiver.isEnabled()) {
            Plugin plugin = (Plugin) clients.get((String) cmbReceiver.getSelectedItem());
            c.setReceiver(plugin.getReadQueue());
        } else {
            c.setReceiver(original.getReceiver());
        }

        System.out.println("receiver for  " + c.getName() + " is: " + c.getReceiver());

        for (int r = 0; r < model.getRowCount(); r++) {
            c.setProperty(model.getValueAt(r, 0).toString(),
                    model.getValueAt(r, 1).toString());
        }

        System.out.println(c.getProperties().toString());

        return c;
    }
View Full Code Here

        pack(  );
    } // </editor-fold>//GEN-END:initComponents

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt)    {//GEN-FIRST:event_btnSaveActionPerformed

        Command c = fillWithFormData();
        c.setEditable(true); //sets it needs to be saved on disk

        int preSize = CommandPersistence.size();
        CommandPersistence.add(c);

        int postSize = CommandPersistence.size();
View Full Code Here

        cmbReceiver.setEnabled(true);
    }//GEN-LAST:event_btnChangeReceiverActionPerformed

    private void btnEditActionPerformed(java.awt.event.ActionEvent evt)    {//GEN-FIRST:event_btnEditActionPerformed

        Command newCommand = fillWithFormData();
        newCommand.setEditable(true);

        int preSize = CommandPersistence.size();
        CommandPersistence.remove(original);
        CommandPersistence.add(newCommand);
View Full Code Here

        this.add(btnCustomize);
        btnCustomize.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                if (command != null) {
                    Command c = new Command();
                    c.setName("Edit a command");
                    c.setReceiver("app.actuators.nlautomationseditor.nlautomationseditor.in");
                    c.setProperty("editor", "command");
                    c.setProperty("editable",
                            command.getName()); //the default choice
                    Freedomotic.sendCommand(c);
                    command = null;
                    setText(INFO_MESSAGE);
                }
View Full Code Here

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        Command c = CommandPersistence.getCommand("Ask data from the harvester");
        Command d;
        if (c != null) {
            try {
                d = c.clone();

                d.setProperty("startDate", Long.toString(((Date) jSpinnerStartDate.getValue()).getTime()));
                d.setProperty("stopDate", Long.toString(((Date) jSpinnerStopDate.getValue()).getTime()));
                d.setProperty("QueryAddress", obj.getPojo().getPhisicalAddress());
                Freedomotic.sendCommand(d);

            } catch (CloneNotSupportedException ex) {
                Logger.getLogger(GraphPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
View Full Code Here

    private void addEnvCommands() {
        String cmdName;
        for (EnvironmentLogic env : EnvironmentPersistence.getEnvironments()) {
            cmdName = "Turn off devices inside area " + env.getPojo().getName();
            Command c = CommandPersistence.getCommand(cmdName);
            if (c != null) {
                CommandPersistence.remove(c);
            }
            c = new Command();
            c.setReceiver("app.actuators.logging.roomevents.in");
            c.setName(cmdName);
            c.setDescription(cmdName);
            c.setProperty("target", env.getPojo().getName());
            c.setProperty("command", "Turn off area devices");
            c.setProperty("devType", "EnvObject.ElectricDevice");
            HashSet<String> tags = new HashSet<String>();
            tags.add("turn");
            tags.add("off");
            tags.add("area");
            tags.add("devices");
            tags.add(env.getPojo().getName());
            c.setTags(tags);
            CommandPersistence.add(c);
        }
    }
View Full Code Here

TOP

Related Classes of it.freedomotic.reactions.Command

Copyright © 2018 www.massapicom. 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.