Search in sources :

Example 11 with ActionEvent

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

the class GUIPluginFactory method initContent.

@SuppressWarnings("deprecation")
private void initContent() {
    control = new CControl(plugableFrame, false);
    // control.setTheme(control.getThemes().getFactory(2).create());
    control.addControlListener(new CControlListener() {

        @Override
        public void added(CControl control, CDockable dockable) {
        }

        @Override
        public void closed(CControl control, CDockable dockable) {
            Boolean b = recHash.get(Thread.currentThread());
            if (b != null)
                return;
            recHash.put(Thread.currentThread(), true);
            List<TabView> list = new ArrayList<TabView>();
            for (Entry<TabView, TabDockable> e : tabDockables.entrySet()) {
                if (e.getValue().equals(dockable)) {
                    TabView view = e.getKey();
                    list.add(view);
                }
            }
            for (TabView view : list) view.close();
            recHash.remove(Thread.currentThread());
        }

        @Override
        public void opened(CControl control, CDockable dockable) {
        }

        @Override
        public void removed(CControl control, CDockable dockable) {
        }
    });
    control.addFocusListener(new CFocusListener() {

        @Override
        public void focusGained(CDockable dockable) {
            List<View> list = new ArrayList<View>();
            for (Entry<TabView, TabDockable> e : tabDockables.entrySet()) {
                if (e.getValue().equals(dockable)) {
                    TabView view = e.getKey();
                    list.add(view);
                }
            }
            if (dockable instanceof DefaultSingleCDockable) {
                list.add(findUniqueView(((DefaultSingleCDockable) dockable).getUniqueId()));
            }
            for (View view : list) {
                lastActiveView = view;
                view.focusGained();
                plugableFrame.setViewActions(view.getGlobalActions());
                if ((!(view instanceof UniqueView)) && (view instanceof TabView)) {
                    if (currentWorkspace != null)
                        workspaceViews.put(currentWorkspace, view);
                }
            }
        }

        @Override
        public void focusLost(CDockable dockable) {
            List<View> list = new ArrayList<View>();
            for (Entry<TabView, TabDockable> e : tabDockables.entrySet()) {
                if (e.getValue().equals(dockable)) {
                    TabView view = e.getKey();
                    list.add(view);
                }
            }
            if (dockable instanceof DefaultSingleCDockable) {
                list.add(findUniqueView(((DefaultSingleCDockable) dockable).getUniqueId()));
            }
            for (View view : list) view.focusLost();
            plugableFrame.setViewActions(new String[] {});
        }
    });
    // control.setTheme(ThemeMap.KEY_ECLIPSE_THEME);
    contentArea = control.getContentArea();
    plugableFrame.add(contentArea, BorderLayout.CENTER);
    for (UniqueView view : uniqueViews) {
        String id = view.getId();
        final DefaultSingleCDockable dockable = new DefaultSingleCDockable(id, findPluginForViewId(id).getString(id), view.createComponent());
        dockable.setCloseable(true);
        initActions(view.getId(), view, dockable);
        control.addDockable(dockable);
        uniqueDockables.add(dockable);
        framework.addActionListener(id, new ActionListener() {

            @Override
            public void onAction(ActionEvent event) {
                dockable.setVisible(true);
            }
        });
        if (currentWorkspace.equals(view.getDefaultWorkspace()))
            dockable.setVisible(true);
    }
    for (TabbedView view : tabbedViews) {
        String id = view.getId();
        if (getWorkingArea(id) != null)
            continue;
        CWorkingArea area = control.createWorkingArea(id);
        uniqueWorkingAreas.add(area);
        // area.setTitleShown(false);
        // if (currentWorkspace.equals(view.getDefaultWorkspace()))
        area.setVisible(true);
        TabbedFactory factory = new TabbedFactory();
        factories.put(id, factory);
        control.addMultipleDockableFactory(id, factory);
    // dockable.setWorkingArea(area);
    // dockable1.setWorkingArea(area);
    // control.add(dockable1);
    // control.add(dockable);
    // dockable.setLocation(CLocation.base().)
    }
    framework.setMainFrame(plugableFrame);
}
Also used : CControl(bibliothek.gui.dock.common.CControl) TabView(com.ramussoft.gui.common.TabView) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) UniqueView(com.ramussoft.gui.common.UniqueView) TabView(com.ramussoft.gui.common.TabView) TabbedView(com.ramussoft.gui.common.TabbedView) View(com.ramussoft.gui.common.View) CWorkingArea(bibliothek.gui.dock.common.CWorkingArea) TabbedView(com.ramussoft.gui.common.TabbedView) Entry(java.util.Map.Entry) UniqueView(com.ramussoft.gui.common.UniqueView) CFocusListener(bibliothek.gui.dock.common.event.CFocusListener) ActionListener(com.ramussoft.gui.common.event.ActionListener) List(java.util.List) ArrayList(java.util.ArrayList) CControlListener(bibliothek.gui.dock.common.event.CControlListener) DefaultSingleCDockable(bibliothek.gui.dock.common.DefaultSingleCDockable) SingleCDockable(bibliothek.gui.dock.common.SingleCDockable) CDockable(bibliothek.gui.dock.common.intern.CDockable) DefaultSingleCDockable(bibliothek.gui.dock.common.DefaultSingleCDockable) DefaultCDockable(bibliothek.gui.dock.common.intern.DefaultCDockable)

Example 12 with ActionEvent

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

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

the class ReportViewPlugin method addOpenReportEditorListener.

private void addOpenReportEditorListener() {
    framework.addActionListener(OPEN_SCRIPT_REPORT, new ActionListener() {

        @Override
        public void onAction(final ActionEvent event) {
            if (framework.openView(event))
                return;
            final Data data = new Data();
            data.element = (Element) event.getValue();
            data.attributeListener = new ElementAttributeListener() {

                @Override
                public void attributeChanged(AttributeEvent event) {
                    Object value = event.getNewValue();
                    if ((value instanceof String) && (event.getElement().equals(data.element))) {
                        ViewTitleEvent e = new ViewTitleEvent(data.view, value.toString());
                        data.view.titleChanged(e);
                    }
                }
            };
            data.elementListener = new ElementAdapter() {

                @Override
                public void elementDeleted(ElementEvent event) {
                    if (event.getOldElement().equals(data.element)) {
                        data.view.close();
                    }
                }
            };
            engine.addElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
            engine.addElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
            String type = (String) engine.getAttribute(data.element, ReportPlugin.getReportTypeAttribute(engine));
            if (ReportPlugin.TYPE_JSSP.equals(type))
                data.view = new ScriptReportEditorView(framework, data.element) {

                    @Override
                    public void close() {
                        super.close();
                        engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
                        engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
                        TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                        tabRemoved(tEvent);
                    }

                    @Override
                    public String getTitle() {
                        return data.element.getName();
                    }
                };
            else if (ReportPlugin.TYPE_JSSP_DOC_BOOK.equals(type))
                data.view = new DocBookScriptReportEditorView(framework, data.element) {

                    @Override
                    public void close() {
                        super.close();
                        engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
                        engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
                        TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                        tabRemoved(tEvent);
                    }

                    @Override
                    public String getTitle() {
                        return data.element.getName();
                    }
                };
            else
                data.view = new XMLReportEditorView(framework, data.element) {

                    @Override
                    public void close() {
                        super.close();
                        engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
                        engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
                        TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                        tabRemoved(tEvent);
                    }

                    @Override
                    public String getTitle() {
                        return data.element.getName();
                    }
                };
            TabbedEvent tEvent = new TabbedEvent(REPORTS_TAB_VIEW, data.view);
            tabCreated(tEvent);
        }
    });
}
Also used : ElementAdapter(com.ramussoft.common.event.ElementAdapter) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) ElementAttributeListener(com.ramussoft.common.event.ElementAttributeListener) Element(com.ramussoft.common.Element) ElementEvent(com.ramussoft.common.event.ElementEvent) AttributeEvent(com.ramussoft.common.event.AttributeEvent) TabbedEvent(com.ramussoft.gui.common.event.TabbedEvent) XMLReportEditorView(com.ramussoft.report.editor.XMLReportEditorView) DocBookScriptReportEditorView(com.ramussoft.report.editor.DocBookScriptReportEditorView) ViewTitleEvent(com.ramussoft.gui.common.event.ViewTitleEvent) ActionListener(com.ramussoft.gui.common.event.ActionListener) ScriptReportEditorView(com.ramussoft.report.editor.ScriptReportEditorView) DocBookScriptReportEditorView(com.ramussoft.report.editor.DocBookScriptReportEditorView)

Example 14 with ActionEvent

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

the class ChartGUIPlugin method setFramework.

@Override
public void setFramework(GUIFramework aFramework) {
    super.setFramework(aFramework);
    framework.addActionListener(OPEN_CHART, new ActionListener() {

        @Override
        public void onAction(ActionEvent event) {
            if (framework.openView(event))
                return;
            Element element = (Element) event.getValue();
            ChartView view = new ChartView(framework, element) {

                @Override
                public void close() {
                    super.close();
                    TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                    tabRemoved(tEvent);
                }
            };
            TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, view);
            tabCreated(tEvent);
        }
    });
    framework.addActionListener(OPEN_CHART_SET, new ActionListener() {

        @Override
        public void onAction(ActionEvent event) {
            if (framework.openView(event))
                return;
            Element element = (Element) event.getValue();
            ChartSetView view = new ChartSetView(framework, element) {

                @Override
                public void close() {
                    super.close();
                    TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                    tabRemoved(tEvent);
                }
            };
            TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, view);
            tabCreated(tEvent);
        }
    });
}
Also used : ActionListener(com.ramussoft.gui.common.event.ActionListener) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) Element(com.ramussoft.common.Element) TabbedEvent(com.ramussoft.gui.common.event.TabbedEvent)

Example 15 with ActionEvent

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

the class ElistPlugin method setFramework.

@Override
public void setFramework(final GUIFramework framework) {
    super.setFramework(framework);
    framework.addActionListener(OPEN_ELEMENT_LIST, new ActionListener() {

        @Override
        public void onAction(final ActionEvent event) {
            if (framework.openView(event))
                return;
            Attribute attribute = (Attribute) event.getValue();
            ElistTabView elistTabView = new ElistTabView(framework, attribute) {

                @Override
                public void close() {
                    super.close();
                    TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                    tabRemoved(tEvent);
                }
            };
            TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, elistTabView);
            tabCreated(tEvent);
        }
    });
    framework.addActionListener(OPEN_ELEMENT_LIST_IN_TABLE, new ActionListener() {

        @Override
        public void onAction(final ActionEvent event) {
            if (framework.openView(event))
                return;
            Attribute attribute = (Attribute) event.getValue();
            ElistTableTabView elistTabView = new ElistTableTabView(framework, attribute) {

                @Override
                public void close() {
                    super.close();
                    TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                    tabRemoved(tEvent);
                }
            };
            TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, elistTabView);
            tabCreated(tEvent);
        }
    });
}
Also used : ActionListener(com.ramussoft.gui.common.event.ActionListener) Attribute(com.ramussoft.common.Attribute) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) TabbedEvent(com.ramussoft.gui.common.event.TabbedEvent)

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