Search in sources :

Example 6 with ActionEvent

use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.

the class History method afterStore.

@Override
public void afterStore(JournalEvent event) {
    if ((framework == null) || (framework.getMainFrame() == null))
        return;
    // return;
    synchronized (engine) {
        if (event.getCommand() instanceof StartUserTransactionCommand) {
            ActionEvent actionEvent = framework.getOpenDynamicViewEvent();
            if (actionEvent == null) {
                View view = framework.getLastActiveView();
                if (view != null) {
                    actionEvent = view.getOpenActionForSave();
                }
            }
            if (actionEvent != null) {
                long branch = -1l;
                if (event.getJournal() != null)
                    branch = event.getJournal().getBranch();
                Command command = new Command(event.getIndex(), actionEvent, framework.getCurrentWorkspace(), branch);
                Hashtable<Long, Command> hash = getHash(command.branchId);
                hash.put(event.getIndex(), command);
                if (objectOut != null) {
                    writeCommand(command);
                }
            }
        }
    }
}
Also used : StartUserTransactionCommand(com.ramussoft.common.journal.command.StartUserTransactionCommand) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) StartUserTransactionCommand(com.ramussoft.common.journal.command.StartUserTransactionCommand)

Example 7 with ActionEvent

use of com.ramussoft.gui.common.event.ActionEvent 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)

Example 8 with ActionEvent

use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.

the class IDEF0ViewPlugin method addOpenDiagramListener.

private void addOpenDiagramListener() {
    framework.addActionListener(OPEN_DIAGRAM, new ActionListener() {

        @Override
        public void onAction(final ActionEvent event) {
            if (framework.openView(event))
                return;
            final DiagramData data = new DiagramData();
            data.openDiagram = (OpenDiagram) event.getValue();
            data.listener = new QualifierAdapter() {

                @Override
                public void qualifierDeleted(QualifierEvent event) {
                    if (event.getOldQualifier().equals(data.openDiagram.getQualifier())) {
                        data.view.close();
                    }
                }

                @Override
                public void qualifierUpdated(QualifierEvent event) {
                    if (data.openDiagram.getQualifier().equals(event.getNewQualifier())) {
                        IDEF0TabView view = (IDEF0TabView) data.view;
                        if (view.isBaseFunctionSelected()) {
                            ViewTitleEvent event2 = new ViewTitleEvent(data.view, event.getNewQualifier().getName());
                            view.titleChanged(event2);
                        }
                    }
                }
            };
            data.elementListener = new ElementAdapter() {

                @Override
                public void elementDeleted(ElementEvent event) {
                    if (((IDEF0TabView) data.view).isSelectedElementId(event.getOldElement()))
                        data.view.close();
                }
            };
            engine.addQualifierListener(data.listener);
            engine.addElementListener(data.openDiagram.getQualifier(), data.elementListener);
            data.view = new IDEF0TabView(framework, NDataPluginFactory.getDataPlugin(data.openDiagram.getQualifier(), engine, rules), data.openDiagram.getFunctionId(), frame, rules) {

                @Override
                public void close() {
                    super.close();
                    engine.removeQualifierListener(data.listener);
                    engine.removeElementListener(data.openDiagram.getQualifier(), data.elementListener);
                    TabbedEvent tEvent = new TabbedEvent(IDEF0TabbedView.IDEF0_TAB_VIEW, this);
                    tabRemoved(tEvent);
                }
            };
            TabbedEvent tEvent = new TabbedEvent(IDEF0TabbedView.IDEF0_TAB_VIEW, (TabView) data.view);
            tabCreated(tEvent);
        }
    });
}
Also used : QualifierAdapter(com.ramussoft.common.event.QualifierAdapter) ElementAdapter(com.ramussoft.common.event.ElementAdapter) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) QualifierEvent(com.ramussoft.common.event.QualifierEvent) ElementEvent(com.ramussoft.common.event.ElementEvent) TabbedEvent(com.ramussoft.gui.common.event.TabbedEvent) ViewTitleEvent(com.ramussoft.gui.common.event.ViewTitleEvent) ActionListener(com.ramussoft.gui.common.event.ActionListener)

Example 9 with ActionEvent

use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.

the class IDEF0ViewPlugin method addOpenStreamsViewListener.

private void addOpenStreamsViewListener() {
    framework.addActionListener(OPEN_STREAMS, new ActionListener() {

        @Override
        public void onAction(final ActionEvent event) {
            if (framework.openView(event))
                return;
            final StreamsData data = new StreamsData();
            data.view = new StreamsTabView(framework) {

                @Override
                public void close() {
                    super.close();
                    TabbedEvent tEvent = new TabbedEvent(IDEF0TabbedView.IDEF0_TAB_VIEW, this);
                    tabRemoved(tEvent);
                }
            };
            TabbedEvent tEvent = new TabbedEvent(IDEF0TabbedView.IDEF0_TAB_VIEW, (TabView) data.view);
            tabCreated(tEvent);
        }
    });
}
Also used : ActionListener(com.ramussoft.gui.common.event.ActionListener) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) TabbedEvent(com.ramussoft.gui.common.event.TabbedEvent)

Example 10 with ActionEvent

use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.

the class IDEF0ViewPlugin method setFramework.

@Override
public void setFramework(final GUIFramework framework) {
    super.setFramework(framework);
    this.engine = framework.getEngine();
    this.rules = framework.getAccessRules();
    this.frame.setEngine(framework);
    addOpenDiagramListener();
    addOpenStreamsViewListener();
    framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {

        @Override
        public void closed() {
            Options.save();
            if (navigator != null)
                navigator.dispose();
            if (engine.getPluginProperty("Core", "MainFrame") == framework.getMainFrame()) {
                NDataPlugin dataPlugin = (NDataPlugin) engine.getPluginProperty("IDEF0", "DataPlugin");
                if (dataPlugin != null) {
                    dataPlugin.clear();
                    dataPlugin.clearAll();
                }
            }
            if (server != null) {
                try {
                    server.getServer().close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                server.interrupt();
            }
        }
    });
    framework.addActionListener("FileOpened", new ActionListener() {

        @Override
        public void onAction(ActionEvent event) {
            if (event.getValue() == null) {
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        NewProjectDialog dialog = new NewProjectDialog(framework.getMainFrame());
                        dialog.showModal(engine, rules, framework);
                    }
                });
            }
        }
    });
    framework.addActionListener(Commands.FULL_REFRESH, new ActionListener() {

        @Override
        public void onAction(ActionEvent event) {
            if (NDataPluginFactory.getExistingDataPlugin(engine) != null)
                NDataPluginFactory.fullRefrash(framework);
        }
    });
    framework.setSystemAttributeName(IDEF0Plugin.getBackgroundColorAttribute(engine), ResourceLoader.getString("bk_color"));
    framework.setSystemAttributeName(IDEF0Plugin.getForegroundColorAttribute(engine), ResourceLoader.getString("fg_color"));
    framework.setSystemAttributeName(IDEF0Plugin.getFontAttribute(engine), ResourceLoader.getString("font"));
    framework.setSystemAttributeName(IDEF0Plugin.getFunctionTypeAttribute(engine), ResourceLoader.getString("function_type"));
    framework.setSystemAttributeName(IDEF0Plugin.getFunctionOunerAttribute(engine), ResourceLoader.getString("select_owner"));
    StreamAttributePlugin plugin = new StreamAttributePlugin();
    plugin.setFramework(framework);
    framework.setSystemAttributePlugin(IDEF0Plugin.getStreamAttribute(engine), plugin);
    framework.setSystemAttributeName(IDEF0Plugin.getStreamAttribute(engine), ResourceLoader.getString("stream"));
    framework.setSystemAttributePlugin(IDEF0Plugin.getSectorBorderEndAttribute(engine), new SectorFontAttributePlugin());
    framework.setSystemAttributeName(IDEF0Plugin.getSectorBorderEndAttribute(engine), ResourceLoader.getString("font"));
    framework.setSystemAttributePlugin(IDEF0Plugin.getSectorBorderStartAttribute(engine), new SectorColorAttributePlugin());
    framework.setSystemAttributeName(IDEF0Plugin.getSectorBorderStartAttribute(engine), ResourceLoader.getString("color"));
    framework.setSystemAttributePlugin(IDEF0Plugin.getSectorFunctionAttribute(engine), new LineStyleAttributePlugin());
    framework.setSystemAttributeName(IDEF0Plugin.getSectorFunctionAttribute(engine), ResourceLoader.getString("arrow"));
}
Also used : NewProjectDialog(com.ramussoft.pb.master.NewProjectDialog) SectorFontAttributePlugin(com.ramussoft.idef0.attribute.SectorFontAttributePlugin) StreamAttributePlugin(com.ramussoft.idef0.attribute.StreamAttributePlugin) CloseMainFrameAdapter(com.ramussoft.gui.common.event.CloseMainFrameAdapter) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) ActionListener(com.ramussoft.gui.common.event.ActionListener) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) IOException(java.io.IOException) SectorColorAttributePlugin(com.ramussoft.idef0.attribute.SectorColorAttributePlugin) LineStyleAttributePlugin(com.ramussoft.idef0.attribute.LineStyleAttributePlugin)

Aggregations

ActionEvent (com.ramussoft.gui.common.event.ActionEvent)17 ActionListener (com.ramussoft.gui.common.event.ActionListener)11 TabbedEvent (com.ramussoft.gui.common.event.TabbedEvent)6 TabView (com.ramussoft.gui.common.TabView)3 ViewTitleEvent (com.ramussoft.gui.common.event.ViewTitleEvent)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Element (com.ramussoft.common.Element)2 Qualifier (com.ramussoft.common.Qualifier)2 ElementAdapter (com.ramussoft.common.event.ElementAdapter)2 ElementEvent (com.ramussoft.common.event.ElementEvent)2 QualifierAdapter (com.ramussoft.common.event.QualifierAdapter)2 QualifierEvent (com.ramussoft.common.event.QualifierEvent)2 StartUserTransactionCommand (com.ramussoft.common.journal.command.StartUserTransactionCommand)2 Row (com.ramussoft.database.common.Row)2 TabbedView (com.ramussoft.gui.common.TabbedView)2 UniqueView (com.ramussoft.gui.common.UniqueView)2 View (com.ramussoft.gui.common.View)2 CloseMainFrameAdapter (com.ramussoft.gui.common.event.CloseMainFrameAdapter)2