Package it.freedomotic.api

Examples of it.freedomotic.api.Client


                    return (name.endsWith(".xobj"));
                }
            });

            for (File template : templates) {
                Client placeholder;

                try {
                    placeholder = clientStorage.createObjectPlaceholder(template);
                    placeholder = mergePackageConfiguration(placeholder, directory);
                    clientStorage.add(placeholder);
View Full Code Here


                            String name = className.substring(0, className.length() - 6);
                            Class clazz = BoundleLoaderFactory.getClass(jar, name);
                            Class superclass = clazz.getSuperclass();

                            try {
                                Client plugin = (Client) clazz.newInstance();
                                results.add(plugin);
                            } catch (Exception exception) {
                                LOG.info("Exception raised while loading this event. Skip it.");
                                LOG.severe(Freedomotic.getStackTraceInfo(exception));
                            }
View Full Code Here

            if (isCompatible(c)) {
                //force injection as this class is not built by guice
                Freedomotic.INJECTOR.injectMembers(c);
                clients.add(c);
            } else {
                Client client =
                        createPluginPlaceholder(c.getName(),
                        "Plugin",
                        "Not compatible with this framework version v" + Info.getVersion());
                clients.add(client);
                LOG.log(Level.WARNING, "Plugin {0} is not compatible with this framework version v{1}",
View Full Code Here

     * Checks if a plugin is already installed, if is an obsolete or newer
     * version
     */
    @Override
    public int compareVersions(String name, String version) {
        Client client = get(name);

        if ((client != null) && client instanceof Plugin) {
            //already installed
            //now check for version
            Plugin plugin = (Plugin) client;
View Full Code Here

    }

    @Override
    protected void onCommand(Command c)
            throws IOException, UnableToExecuteException {
        Client plugin = getApi().getClientStorage().get(c.getProperty("plugin"));
        String action = c.getProperty("action");

        if (plugin != null) {
            if (action.equalsIgnoreCase("SHOW")) {
                plugin.showGui();
            }

            if (action.equalsIgnoreCase("HIDE")) {
                plugin.hideGui();
            }
            if (action.equalsIgnoreCase("STOP")) {
                if (plugin != this && getApi().getAuth().isPermitted("sys:plugins:stop")) {
                    plugin.stop();
                }
            }
            if (action.equalsIgnoreCase("START")) {
                if (plugin != this && getApi().getAuth().isPermitted("sys:plugins:start")) {
                    plugin.start();
                }
            }
            if (action.equalsIgnoreCase("RESTART")) {
                if (plugin != this && getApi().getAuth().isPermitted("sys:plugins:stop") && getApi().getAuth().isPermitted("sys:plugins:start")) {
                    plugin.stop();
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(PluginRemoteController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    plugin.start();
                }
            }

        } else {
            LOG.log(Level.WARNING, "Impossible to act on plugin {0}", c.getProperty("plugin"));
View Full Code Here

            @Override
            public void mouseClicked(MouseEvent e) {
                Point p = e.getPoint();
                int i = locationToIndex(p);
                java.util.List<Client> clients = (java.util.List<Client>) getApi().getClients(getFilter());
                Client client = (Client) clients.get(i);

                if (e.getButton() == MouseEvent.BUTTON1) {
                    if (e.getClickCount() == 2) {
                        if (client.isRunning()) {
                            client.stop();
                        } else {
                            client.start();
                        }

                        update();
                    }
                }
            }

            @Override
            public void mousePressed(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    doPop(e);
                } else {
                    //drag started
                    inDrag = true;
                    dragged = 0;
                }
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    doPop(e);
                }
            }

            private void doPop(MouseEvent e) {
                Point p = e.getPoint();
                int i = locationToIndex(p);
                java.util.List<Client> clients = (java.util.List<Client>) getApi().getClients(getFilter());
                final Client client = (Client) clients.get(i);
                JPopupMenu menu = new JPopupMenu();
                JMenuItem mnuConfigure = null;

                if (client.getType().equalsIgnoreCase("plugin")) {
                    mnuConfigure = new JMenuItem("Configure " + client.getName());
                } else {
                    if (client.getType().equalsIgnoreCase("object")) {
                        mnuConfigure = new JMenuItem("Add " + client.getName() + " Object");
                    } else {
                        mnuConfigure = new JMenuItem("Placeholder menu");
                    }
                }

                mnuConfigure.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        if (client.getType().equalsIgnoreCase("plugin")) {
                            client.start();
                            client.showGui();
                            update();
                        }

                        if (client.getType().equalsIgnoreCase("object")) {
                            ObjectPluginPlaceholder objp = (ObjectPluginPlaceholder) client;

                            if (parent instanceof MainWindow) {
                                MainWindow mw = (MainWindow) parent;
                                objp.startOnEnv(mw.getDrawer().getCurrEnv()); //adds the object to the environment
View Full Code Here

        loaded.getPojo().setProtocol(protocol);
        loaded.getPojo().setPhisicalAddress(address);
        loaded.setRandomLocation();

        //set the PREFERRED MAPPING of the protocol plugin (if any is defined in its manifest)
        Client addon = clientStorage.getClientByProtocol(protocol);

        if (addon != null) {
            for (int i = 0; i < addon.getConfiguration().getTuples().size(); i++) {
                Map tuple = addon.getConfiguration().getTuples().getTuple(i);
                String regex = (String) tuple.get("object.class");

                if ((regex != null) && clazz.matches(regex)) {
                    //map object behaviors to hardware triggers
                    for (Behavior behavior : loaded.getPojo().getBehaviors()) {
View Full Code Here

TOP

Related Classes of it.freedomotic.api.Client

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.