Search in sources :

Example 6 with FileIEngineImpl

use of com.ramussoft.core.impl.FileIEngineImpl in project ramus by Vitaliy-Yakovchuk.

the class AbstractDataPlugin method loadFromParalel.

public void loadFromParalel(final File file, final GUIFramework framework) throws IOException {
    Thread t = new Thread() {

        @Override
        public void run() {
            try {
                framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, false);
                framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, true);
                framework.showAnimation(ResourceLoader.getString("Wait.Message"));
                MemoryDatabase md = new MemoryDatabase() {

                    protected String getJournalDirectoryName(String tmp) {
                        return null;
                    }

                    @Override
                    protected File getFile() {
                        return file;
                    }
                };
                LoadFromParalelDialog dialog = new LoadFromParalelDialog(framework.getMainFrame(), md.getEngine("idef0"));
                if (dialog.showModal()) {
                    ((Journaled) getEngine()).startUserTransaction();
                    try {
                        DataPlugin fdp = NDataPluginFactory.getDataPlugin(null, md.getEngine("idef0"), md.getAccessRules("idef0"));
                        ModelParaleler paraleler = new ModelParaleler(fdp, AbstractDataPlugin.this, framework);
                        paraleler.loadFromParalel(dialog.isImportAll(), dialog.getSelected());
                    } finally {
                        ((Journaled) getEngine()).commitUserTransaction();
                    }
                }
                FileIEngineImpl impl = (FileIEngineImpl) md.getEngine("idef0").getDeligate();
                impl.close();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, true);
                framework.propertyChanged(ModelsView.REFRESH_ALL_MODELS);
                framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, false);
                framework.hideAnimation();
            }
        }
    };
    t.start();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) ModelParaleler(com.ramussoft.idef0.ModelParaleler) LoadFromParalelDialog(com.ramussoft.pb.idef.frames.LoadFromParalelDialog) MemoryDatabase(com.ramussoft.database.MemoryDatabase) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) IOException(java.io.IOException)

Example 7 with FileIEngineImpl

use of com.ramussoft.core.impl.FileIEngineImpl in project ramus by Vitaliy-Yakovchuk.

the class AbstractDataPlugin method createParalel.

public boolean createParalel(final Function base, final boolean copyAllRows, final boolean clearElements, final File file, final GUIFramework framework, final DataPlugin dataPlugin) throws IOException {
    Thread thread = new Thread("Model-paraleler") {

        public void run() {
            try {
                framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, false);
                framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, true);
                framework.showAnimation(ResourceLoader.getString("Wait.Message"));
                MemoryDatabase md = new MemoryDatabase() {

                    protected String getJournalDirectoryName(String tmp) {
                        return null;
                    }
                };
                final NDataPlugin fdp = new NDataPlugin(md.getEngine("idef0"), md.getAccessRules("idef0"));
                final ModelParaleler paraleler = new ModelParaleler(AbstractDataPlugin.this, fdp, framework);
                paraleler.createParalel(base, copyAllRows);
                FileIEngineImpl impl = (FileIEngineImpl) md.getEngine("idef0").getDeligate();
                impl.saveToFile(file);
                impl.close();
                if (clearElements) {
                    ((Journaled) getEngine()).startUserTransaction();
                    try {
                        paraleler.clear(base);
                    } finally {
                        ((Journaled) getEngine()).commitUserTransaction();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
            } finally {
                framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, false);
                framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, true);
                framework.propertyChanged(ModelsView.REFRESH_ALL_MODELS);
                framework.hideAnimation();
            }
        }
    };
    thread.start();
    return true;
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) ModelParaleler(com.ramussoft.idef0.ModelParaleler) MemoryDatabase(com.ramussoft.database.MemoryDatabase) IOException(java.io.IOException)

Example 8 with FileIEngineImpl

use of com.ramussoft.core.impl.FileIEngineImpl 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)

Example 9 with FileIEngineImpl

use of com.ramussoft.core.impl.FileIEngineImpl in project ramus by Vitaliy-Yakovchuk.

the class HTMLEditPanel method getSetupEditorAction.

/**
 * This method initializes jButton1
 *
 * @return javax.swing.JButton
 */
private AbstractAction getSetupEditorAction() {
    if (setupEditorAction == null) {
        setupEditorAction = new AbstractAction() {

            /**
             */
            private static final long serialVersionUID = 5355396413361705651L;

            {
                putValue(TOOL_TIP_TEXT_KEY, GlobalResourcesManager.getString("HTMLEditor.Options"));
                putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/com/ramussoft/gui/preferencies.png")));
                putValue(ACTION_COMMAND_KEY, "HTMLEditor.Options");
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                editorOptions();
            }
        };
        setupEditorAction.setEnabled((engine.getDeligate() instanceof FileIEngineImpl));
    }
    return setupEditorAction;
}
Also used : ImageIcon(javax.swing.ImageIcon) FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 10 with FileIEngineImpl

use of com.ramussoft.core.impl.FileIEngineImpl in project ramus by Vitaliy-Yakovchuk.

the class HTMLEditPanel method openEditor.

private boolean openEditor() {
    final String html = Options.getString("HTML_EDITOR");
    if (html == null)
        return false;
    FileIEngineImpl impl = (FileIEngineImpl) engine.getDeligate();
    final ProcessBuilder builder = new ProcessBuilder(new String[] { html, impl.getFileForPath(page.getPath()).getAbsolutePath() });
    try {
        builder.start();
    } catch (final IOException e) {
        return false;
    }
    if (openFiles.indexOf(page.getPath()) < 0)
        openFiles.add(page.getPath());
    return true;
}
Also used : FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) IOException(java.io.IOException)

Aggregations

FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)13 IOException (java.io.IOException)11 MemoryDatabase (com.ramussoft.database.MemoryDatabase)7 Engine (com.ramussoft.common.Engine)5 ArrayList (java.util.ArrayList)5 Journaled (com.ramussoft.common.journal.Journaled)4 ZipException (java.util.zip.ZipException)4 IEngine (com.ramussoft.common.IEngine)3 PluginFactory (com.ramussoft.common.PluginFactory)3 PluginProvider (com.ramussoft.common.PluginProvider)3 ModelParaleler (com.ramussoft.idef0.ModelParaleler)3 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)3 File (java.io.File)3 AccessRules (com.ramussoft.common.AccessRules)2 FileMinimumVersionException (com.ramussoft.core.impl.FileMinimumVersionException)2 AbstractGUIPluginFactory (com.ramussoft.gui.common.AbstractGUIPluginFactory)2 IDEF0PluginProvider (com.ramussoft.idef0.IDEF0PluginProvider)2 DataPlugin (com.ramussoft.pb.DataPlugin)2 LoadFromParalelDialog (com.ramussoft.pb.idef.frames.LoadFromParalelDialog)2 SQLException (java.sql.SQLException)2