Search in sources :

Example 1 with HTTPServer

use of com.ramussoft.pb.print.web.HTTPServer in project ramus by Vitaliy-Yakovchuk.

the class IDEF0ViewPlugin method getActionDescriptors.

@SuppressWarnings("unused")
@Override
public ActionDescriptor[] getActionDescriptors() {
    ActionDescriptor openStreans = new ActionDescriptor();
    openStreans.setActionLevel(ActionLevel.GLOBAL);
    openStreans.setMenu("Tools");
    openStreans.setAction(new AbstractAction() {

        {
            putValue(ACTION_COMMAND_KEY, "streams");
        }

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            framework.propertyChanged(OPEN_STREAMS);
        }
    });
    ActionDescriptor runWebServer = new ActionDescriptor();
    runWebServer.setActionLevel(ActionLevel.GLOBAL);
    runWebServer.setMenu("Tools");
    runWebServer.setAction(new AbstractAction() {

        {
            putValue(ACTION_COMMAND_KEY, MainFrame.OPEN_WEB_SERVER);
        }

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (server == null) {
                server = new HTTPServer("0", NDataPluginFactory.getDataPlugin(null, engine, rules), framework) {

                    @Override
                    protected void serverStarted() {
                        AbstractAttributePlugin.openUrl("http://127.0.0.1:" + getServer().getLocalPort(), framework);
                    }
                };
            } else {
                AbstractAttributePlugin.openUrl("http://127.0.0.1:" + server.getServer().getLocalPort(), framework);
            }
        }
    });
    ActionDescriptor idef0Separator = new ActionDescriptor();
    idef0Separator.setMenu("IDEF0");
    ActionDescriptor loadModelsFromFile = new ActionDescriptor();
    loadModelsFromFile.setActionLevel(ActionLevel.GLOBAL);
    loadModelsFromFile.setMenu("IDEF0");
    loadModelsFromFile.setAction(new AbstractAction() {

        {
            putValue(ACTION_COMMAND_KEY, "loadModelsFromFile");
        }

        @Override
        public void actionPerformed(java.awt.event.ActionEvent event) {
            DataPlugin plugin = NDataPluginFactory.getDataPlugin(null, engine, rules);
            try {
                final JFileChooser chooser = frame.getChooser();
                if (chooser.showOpenDialog(framework.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
                    plugin.loadFromParalel(chooser.getSelectedFile(), framework);
                }
            } catch (final IOException e) {
                JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
            }
        }
    });
    ActionDescriptor toolsSeparator = new ActionDescriptor();
    toolsSeparator.setMenu("Tools");
    if ((Metadata.DEMO) && (!new SerialCheker().check(Options.getString("SERIAL")))) {
        Metadata.DEMO_REGISTERED = false;
        if (Metadata.DEMO) {
            framework.addActionListener("MainFrameShown", new ActionListener() {

                @Override
                public void onAction(ActionEvent event) {
                    String title = framework.getMainFrame().getTitle();
                    if (!Metadata.DEMO_REGISTERED)
                        title += " " + GlobalResourcesManager.getString("UnregisteredCopy");
                    else
                        title += " " + MessageFormat.format(GlobalResourcesManager.getString("RegisteredName"), Metadata.REGISTERED_FOR);
                    framework.getMainFrame().setTitle(title);
                }
            });
        }
        return new ActionDescriptor[] { runWebServer, openStreans, findAction(CURSOR_TOOL), findAction(FUNCTION_TOOL), findAction(ARROW_TOOL), findAction(TILDA_TOOL), findAction(TEXT_TOOL), findAction(EXTERNAL_REFERENCE_TOOL), findAction(DFDS_ROLE_TOOL), findAction(DATA_STORE_TOOL), findAction(IDEF0_NET), findAction(GO_TO_PARENT), findAction(GO_TO_CHILD), idef0Separator, findAction(CENTER_ALL_SECTORS), idef0Separator, loadModelsFromFile, toolsSeparator, findAction(ADD_MODEL_TO_TEMPLATE, "Tools"), findAction(USER_TEMPLATES, "Tools"), idef0Separator, findAction(MODEL_PROPETIES), findAction(DIAGRAM_PROPETIES), idef0Separator, findAction(EXPORT_TO_IMAGES), createExportToIDL(), createImportFromIDL(), createRegisterAction(), toolsSeparator, findAction(CREATE_LEVEL) };
    } else {
        if (Metadata.DEMO) {
            framework.addActionListener("MainFrameShown", new ActionListener() {

                @Override
                public void onAction(ActionEvent event) {
                    String title = framework.getMainFrame().getTitle();
                    if (!Metadata.DEMO_REGISTERED)
                        title += " " + GlobalResourcesManager.getString("UnregisteredCopy");
                    else
                        title += " " + MessageFormat.format(GlobalResourcesManager.getString("RegisteredName"), Metadata.REGISTERED_FOR);
                    framework.getMainFrame().setTitle(title);
                }
            });
        }
        ActionDescriptor editSeparator = new ActionDescriptor();
        editSeparator.setMenu("Edit");
        ActionDescriptor cut = new ActionDescriptor();
        cut.setMenu("Edit");
        cut.setAction(frame.findAction(MainFrame.CUT));
        ActionDescriptor copy = new ActionDescriptor();
        copy.setMenu("Edit");
        copy.setAction(frame.findAction(MainFrame.COPY));
        ActionDescriptor paste = new ActionDescriptor();
        paste.setMenu("Edit");
        paste.setAction(frame.findAction(MainFrame.PASTE));
        return new ActionDescriptor[] { runWebServer, openStreans, findAction(CURSOR_TOOL), findAction(FUNCTION_TOOL), findAction(ARROW_TOOL), findAction(TILDA_TOOL), findAction(TEXT_TOOL), findAction(EXTERNAL_REFERENCE_TOOL), findAction(DFDS_ROLE_TOOL), findAction(DATA_STORE_TOOL), findAction(IDEF0_NET), findAction(GO_TO_PARENT), findAction(GO_TO_CHILD), idef0Separator, findAction(CENTER_ALL_SECTORS), idef0Separator, loadModelsFromFile, toolsSeparator, findAction(ADD_MODEL_TO_TEMPLATE, "Tools"), findAction(USER_TEMPLATES, "Tools"), idef0Separator, findAction(MODEL_PROPETIES), findAction(DIAGRAM_PROPETIES), idef0Separator, findAction(EXPORT_TO_IMAGES), createExportToIDL(), createImportFromIDL(), editSeparator, cut, copy, paste };
    }
}
Also used : SerialCheker(com.ramussoft.pb.frames.components.SerialCheker) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) IOException(java.io.IOException) HTTPServer(com.ramussoft.pb.print.web.HTTPServer) JFileChooser(javax.swing.JFileChooser) ActionListener(com.ramussoft.gui.common.event.ActionListener) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) AbstractAction(javax.swing.AbstractAction)

Aggregations

ActionEvent (com.ramussoft.gui.common.event.ActionEvent)1 ActionListener (com.ramussoft.gui.common.event.ActionListener)1 DataPlugin (com.ramussoft.pb.DataPlugin)1 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)1 SerialCheker (com.ramussoft.pb.frames.components.SerialCheker)1 HTTPServer (com.ramussoft.pb.print.web.HTTPServer)1 IOException (java.io.IOException)1 AbstractAction (javax.swing.AbstractAction)1 JFileChooser (javax.swing.JFileChooser)1