Search in sources :

Example 1 with UndoRedoPlugin

use of com.ramussoft.gui.common.UndoRedoPlugin 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 2 with UndoRedoPlugin

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

the class InternetClient method initAdditionalGuiPlugins.

@Override
protected void initAdditionalGuiPlugins(List<GUIPlugin> plugins) {
    super.initAdditionalGuiPlugins(plugins);
    plugins.add(new UndoRedoPlugin(e));
    plugins.add(new ClientPlugin(userProvider, true));
    try {
        if ((Boolean) connection.invoke("isAdmin", new Object[] {})) {
            UserFactory userFactory;
            userFactory = (UserFactory) createDeligate(UserFactory.class);
            AdminPanelPlugin adminPanelPlugin = new AdminPanelPlugin(userFactory, e);
            plugins.add(adminPanelPlugin);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : UserFactory(com.ramussoft.net.common.UserFactory) RedoObject(com.ramussoft.net.common.internet.RedoObject) UndoObject(com.ramussoft.net.common.internet.UndoObject) ZipException(java.util.zip.ZipException) FileNotFoundException(java.io.FileNotFoundException) InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException) SQLException(java.sql.SQLException) IOException(java.io.IOException) UndoRedoPlugin(com.ramussoft.gui.common.UndoRedoPlugin)

Example 3 with UndoRedoPlugin

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

the class TcpLightClient method initAdditionalGuiPlugins.

@Override
protected void initAdditionalGuiPlugins(List<GUIPlugin> list) {
    super.initAdditionalGuiPlugins(list);
    list.add(new ClientPlugin(userProvider, true));
    list.add(new LogPlugin());
    try {
        if ((Boolean) connection.invoke("canUndoRedo", new Object[] {}))
            list.add(new UndoRedoPlugin(e));
        if ((Boolean) connection.invoke("isAdmin", new Object[] {})) {
            UserFactory userFactory;
            userFactory = (UserFactory) createDeligate(UserFactory.class);
            AdminPanelPlugin adminPanelPlugin = new AdminPanelPlugin(userFactory, e);
            list.add(adminPanelPlugin);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : LogPlugin(com.ramussoft.client.log.LogPlugin) UserFactory(com.ramussoft.net.common.UserFactory) IOException(java.io.IOException) UndoRedoPlugin(com.ramussoft.gui.common.UndoRedoPlugin)

Example 4 with UndoRedoPlugin

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

the class Runner method openInNewWindows.

@SuppressWarnings("unchecked")
public JFrame openInNewWindows(final Engine engine, final AccessRules rules, final File file, final boolean recovered) {
    List<GUIPlugin> list = new ArrayList<GUIPlugin>();
    FilePlugin filePlugin = new FilePlugin((FileIEngineImpl) engine.getDeligate(), engine, rules, file, this);
    list.add(filePlugin);
    list.add(new UndoRedoPlugin(engine));
    initAdditionalGUIPlugins(list, engine, rules);
    final AbstractGUIPluginFactory factory = createGUIPluginFactory(engine, rules, list);
    final JFrame frame = factory.getMainFrame();
    engine.setPluginProperty(CORE, "MainFrame", frame);
    String title = getApplicationTitle();
    if (file != null)
        title += " - " + file.getName();
    frame.setTitle(title);
    factory.getFramework().addCloseMainFrameListener(new CloseMainFrameAdapter() {

        @Override
        public void afterClosed() {
            List<JFrame> list = (List<JFrame>) engine.getPluginProperty(CORE, "AdditionalWindows");
            if (list != null) {
                JFrame[] frames = list.toArray(new JFrame[list.size()]);
                for (JFrame frame : frames) {
                    frame.setVisible(false);
                    frame.dispose();
                }
            }
            FileIEngineImpl impl = (FileIEngineImpl) engine.getDeligate();
            try {
                impl.getTemplate().getConnection().close();
                if (engine instanceof Journaled)
                    ((Journaled) engine).close();
                impl.close();
                impl.clear();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    Object changed = engine.getPluginProperty(CORE, "Changed");
    if (changed != null)
        filePlugin.changed();
    InputStream is = engine.getInputStream("/user/gui/session.binary");
    if (is != null) {
        try {
            ObjectInputStream ois = new ObjectInputStream(is);
            try {
                final List<ActionEvent> session = (List<ActionEvent>) ois.readObject();
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        for (ActionEvent e : session) if (e != null)
                            factory.getFramework().propertyChanged(e);
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                is.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    beforeMainFrameShow(frame);
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            frame.setVisible(true);
            if (recovered) {
                factory.getFramework().propertyChanged("FileRecovered");
            } else
                factory.getFramework().propertyChanged("FileOpened", file);
            postShowVisibaleMainFrame(engine, factory.getFramework());
        }
    });
    return frame;
}
Also used : FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) ObjectInputStream(java.io.ObjectInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ZipException(java.util.zip.ZipException) FileMinimumVersionException(com.ramussoft.core.impl.FileMinimumVersionException) IOException(java.io.IOException) UndoRedoPlugin(com.ramussoft.gui.common.UndoRedoPlugin) Journaled(com.ramussoft.common.journal.Journaled) 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) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

UndoRedoPlugin (com.ramussoft.gui.common.UndoRedoPlugin)4 IOException (java.io.IOException)3 AbstractGUIPluginFactory (com.ramussoft.gui.common.AbstractGUIPluginFactory)2 GUIPlugin (com.ramussoft.gui.common.GUIPlugin)2 CloseMainFrameAdapter (com.ramussoft.gui.common.event.CloseMainFrameAdapter)2 UserFactory (com.ramussoft.net.common.UserFactory)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ZipException (java.util.zip.ZipException)2 JFrame (javax.swing.JFrame)2 LogPlugin (com.ramussoft.client.log.LogPlugin)1 Journaled (com.ramussoft.common.journal.Journaled)1 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)1 FileMinimumVersionException (com.ramussoft.core.impl.FileMinimumVersionException)1 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)1 RedoObject (com.ramussoft.net.common.internet.RedoObject)1 UndoObject (com.ramussoft.net.common.internet.UndoObject)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 FileInputStream (java.io.FileInputStream)1