Search in sources :

Example 1 with CloseMainFrameAdapter

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

the class FilePlugin method setFramework.

@SuppressWarnings("unused")
@Override
public void setFramework(final GUIFramework framework) {
    super.setFramework(framework);
    framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {

        @Override
        public boolean close() {
            boolean close = closeFrame(framework);
            return close;
        }

        @Override
        public void closed() {
            plugins.remove(FilePlugin.this);
        }
    });
    setFile(file);
    if ((!Metadata.CORPORATE) && (Options.getBoolean(CHECK_FOR_UPDATES, true)) && (isTimeToUpdate())) {
        Thread thread = new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    Thread.sleep(20000);
                    checkForUpdates();
                } catch (Exception e) {
                }
            }
        }, "Update-checker");
        thread.setPriority(Thread.MIN_PRIORITY);
        thread.start();
    }
    if (Metadata.DEMO) {
        framework.put("FilePlugin", this);
        framework.addActionListener("DisableSaveActions", new ActionListener() {

            @Override
            public void onAction(com.ramussoft.gui.common.event.ActionEvent event) {
                saveAction.setEnabled(false);
                saveFileAsAction.setEnabled(false);
            }
        });
        framework.addActionListener("EnableSaveActions", new ActionListener() {

            @Override
            public void onAction(com.ramussoft.gui.common.event.ActionEvent event) {
                saveAction.setEnabled(true);
                saveFileAsAction.setEnabled(true);
            }
        });
    }
}
Also used : CloseMainFrameAdapter(com.ramussoft.gui.common.event.CloseMainFrameAdapter) ActionListener(com.ramussoft.gui.common.event.ActionListener) IOException(java.io.IOException)

Example 2 with CloseMainFrameAdapter

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

the class Runner method openInNewWindows.

@SuppressWarnings("unchecked")
public void openInNewWindows(final Engine engine, AccessRules rules) {
    List<GUIPlugin> list = new ArrayList<GUIPlugin>();
    initAdditionalGUIPlugins(list, engine, rules);
    list.add(new UndoRedoPlugin(engine));
    final AbstractGUIPluginFactory factory = createGUIPluginFactory(engine, rules, list);
    final JFrame frame = factory.getMainFrame();
    List<JFrame> frames = (List<JFrame>) engine.getPluginProperty(CORE, "AdditionalWindows");
    if (frames == null) {
        frames = new ArrayList<JFrame>();
        engine.setPluginProperty(CORE, "AdditionalWindows", frames);
    }
    frames.add(frame);
    final JFrame mainFrame = (JFrame) engine.getPluginProperty(CORE, "MainFrame");
    frame.setTitle("[" + mainFrame.getTitle() + "]");
    final PropertyChangeListener titleListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            frame.setTitle("[" + (String) evt.getNewValue() + "]");
        }
    };
    factory.getFramework().addCloseMainFrameListener(new CloseMainFrameAdapter() {

        @Override
        public void afterClosed() {
            mainFrame.removePropertyChangeListener("title", titleListener);
            List<JFrame> list = (List<JFrame>) engine.getPluginProperty(CORE, "AdditionalWindows");
            list.remove(frame);
        }
    });
    mainFrame.addPropertyChangeListener("title", titleListener);
    beforeMainFrameShow(frame);
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            frame.setVisible(true);
            postShowVisibaleMainFrame(engine, factory.getFramework());
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) UndoRedoPlugin(com.ramussoft.gui.common.UndoRedoPlugin) CloseMainFrameAdapter(com.ramussoft.gui.common.event.CloseMainFrameAdapter) JFrame(javax.swing.JFrame) List(java.util.List) ArrayList(java.util.ArrayList) GUIPlugin(com.ramussoft.gui.common.GUIPlugin) AbstractGUIPluginFactory(com.ramussoft.gui.common.AbstractGUIPluginFactory)

Example 3 with CloseMainFrameAdapter

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

the class Client method run.

public void run(final String[] args) {
    final SplashScreen screen = new SplashScreen() {

        /**
         */
        private static final long serialVersionUID = -4641958771849938048L;

        @Override
        protected String getImageName() {
            for (String s : args) if (s.equals("-season"))
                return "/com/ramussoft/season/about.png";
            return "/com/ramussoft/gui/about.png";
        }
    };
    if (Metadata.CLIENT) {
        Metadata.REGISTERED_FOR = ClientConnection.getName();
        Metadata.DEMO_REGISTERED = ClientConnection.getName() != null;
    }
    screen.setLocationRelativeTo(null);
    boolean hide = false;
    for (String s : args) if ("--hide-splash".equals(s))
        hide = true;
    if (!hide)
        screen.setVisible(true);
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            List<PluginProvider> suits = new ArrayList<PluginProvider>();
            suits.add(new SimpleAttributePluginSuit());
            initAdditionalPluginSuits(suits);
            PluginFactory factory = createPluginFactory(suits);
            PersistentFactory persistentFactory = new PersistentFactory(null, factory.getAttributePlugins(), null);
            persistentFactory.reinit();
            Engine engine = getEngine(factory, persistentFactory);
            AccessRules rules = getAccessRules();
            e = engine;
            e.setPluginProperty("Core", "PluginList", factory.getPlugins());
            e.setPluginProperty("Core", "PluginFactory", factory);
            LightClient.staticEngine = e;
            LightClient.staticAccessRules = rules;
            List<GUIPlugin> list = new ArrayList<GUIPlugin>();
            QualifierPluginSuit.addPlugins(list, e, rules);
            initAdditionalGuiPlugins(list);
            User me = getMe();
            List<Group> groups = me.getGroups();
            String[] grps = new String[groups.size()];
            for (int i = 0; i < grps.length; i++) grps[i] = groups.get(i).getName();
            AbstractGUIPluginFactory factory1;
            String ws = Options.getString("WindowsControl", "simple");
            if (ws.equals("simple"))
                factory1 = new SimleGUIPluginFactory(list, e, rules, getType(), grps, loadPlugins);
            else
                factory1 = new GUIPluginFactory(list, e, rules, getType(), grps, loadPlugins);
            framework = factory1.getFramework();
            framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {

                @Override
                public void afterClosed() {
                    Client.this.close();
                }
            });
            final JFrame frame = factory1.getMainFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            String title = getTitle();
            frame.setTitle(title);
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    frame.setVisible(true);
                    screen.setVisible(false);
                }
            });
        }
    });
    t.start();
    Thread thread = new Thread("Icons-buffer-cleaner") {

        @Override
        public void run() {
            while (true) {
                try {
                    Thread.sleep(20000);
                    IconFactory.clearIconsBuffer(LightClient.staticEngine);
                    IconFactory.clearQualifierIconsBuffer(LightClient.staticEngine);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    thread.setDaemon(true);
    thread.setPriority(Thread.MIN_PRIORITY);
    thread.start();
}
Also used : PersistentFactory(com.ramussoft.core.persistent.PersistentFactory) SimleGUIPluginFactory(com.ramussoft.gui.core.simple.SimleGUIPluginFactory) User(com.ramussoft.net.common.User) AbstractGUIPluginFactory(com.ramussoft.gui.common.AbstractGUIPluginFactory) SimleGUIPluginFactory(com.ramussoft.gui.core.simple.SimleGUIPluginFactory) GUIPluginFactory(com.ramussoft.gui.core.GUIPluginFactory) PluginProvider(com.ramussoft.common.PluginProvider) CloseMainFrameAdapter(com.ramussoft.gui.common.event.CloseMainFrameAdapter) SimpleAttributePluginSuit(com.ramussoft.core.attribute.simple.SimpleAttributePluginSuit) JFrame(javax.swing.JFrame) SplashScreen(com.ramussoft.gui.common.SplashScreen) AccessRules(com.ramussoft.common.AccessRules) ArrayList(java.util.ArrayList) List(java.util.List) AbstractGUIPluginFactory(com.ramussoft.gui.common.AbstractGUIPluginFactory) SimleGUIPluginFactory(com.ramussoft.gui.core.simple.SimleGUIPluginFactory) GUIPluginFactory(com.ramussoft.gui.core.GUIPluginFactory) PluginFactory(com.ramussoft.common.PluginFactory) Engine(com.ramussoft.common.Engine) GUIPlugin(com.ramussoft.gui.common.GUIPlugin) AbstractGUIPluginFactory(com.ramussoft.gui.common.AbstractGUIPluginFactory)

Example 4 with CloseMainFrameAdapter

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

the class OtherElementPlugin method setFramework.

@Override
public void setFramework(GUIFramework framework) {
    super.setFramework(framework);
    final QualifierListener listener = new QualifierAdapter() {

        @Override
        public void qualifierDeleted(QualifierEvent event) {
            RowSetValue value = sets.get(event.getOldQualifier());
            if (value != null) {
                value.rowSet.close();
                sets.remove(event.getOldQualifier());
            }
        }
    };
    framework.getEngine().addQualifierListener(listener);
    framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {

        @Override
        public void closed() {
            for (RowSetValue value : sets.values()) {
                try {
                    value.rowSet.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            sets.clear();
            OtherElementPlugin.this.framework.getEngine().removeQualifierListener(listener);
        }
    });
}
Also used : QualifierAdapter(com.ramussoft.common.event.QualifierAdapter) CloseMainFrameAdapter(com.ramussoft.gui.common.event.CloseMainFrameAdapter) QualifierListener(com.ramussoft.common.event.QualifierListener) QualifierEvent(com.ramussoft.common.event.QualifierEvent)

Example 5 with CloseMainFrameAdapter

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

CloseMainFrameAdapter (com.ramussoft.gui.common.event.CloseMainFrameAdapter)6 AbstractGUIPluginFactory (com.ramussoft.gui.common.AbstractGUIPluginFactory)3 GUIPlugin (com.ramussoft.gui.common.GUIPlugin)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 JFrame (javax.swing.JFrame)3 UndoRedoPlugin (com.ramussoft.gui.common.UndoRedoPlugin)2 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)2 ActionListener (com.ramussoft.gui.common.event.ActionListener)2 AccessRules (com.ramussoft.common.AccessRules)1 Engine (com.ramussoft.common.Engine)1 PluginFactory (com.ramussoft.common.PluginFactory)1 PluginProvider (com.ramussoft.common.PluginProvider)1 QualifierAdapter (com.ramussoft.common.event.QualifierAdapter)1 QualifierEvent (com.ramussoft.common.event.QualifierEvent)1 QualifierListener (com.ramussoft.common.event.QualifierListener)1 Journaled (com.ramussoft.common.journal.Journaled)1 SimpleAttributePluginSuit (com.ramussoft.core.attribute.simple.SimpleAttributePluginSuit)1 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)1