Search in sources :

Example 6 with ViewTitleEvent

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

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

the class QualifierPlugin method setFramework.

@Override
public void setFramework(final GUIFramework framework) {
    super.setFramework(framework);
    this.engine = framework.getEngine();
    this.accessor = framework.getAccessRules();
    framework.addActionListener(OPEN_QUALIFIER, new ActionListener() {

        @Override
        public void onAction(final ActionEvent event) {
            if (framework.openView(event))
                return;
            final Data data = new Data();
            data.qualifier = (Qualifier) event.getValue();
            if (data.qualifier != null) {
                data.qualifier = engine.getQualifier(data.qualifier.getId());
            }
            if (data.qualifier == null)
                return;
            data.listener = new QualifierAdapter() {

                @Override
                public void qualifierUpdated(QualifierEvent event) {
                    if (event.getNewQualifier().equals(data.qualifier)) {
                        ViewTitleEvent e = new ViewTitleEvent(data.view, event.getNewQualifier().getName());
                        data.view.titleChanged(e);
                    }
                }

                @Override
                public void qualifierDeleted(QualifierEvent event) {
                    if (event.getOldQualifier().equals(data.qualifier)) {
                        data.view.close();
                    }
                }
            };
            engine.addQualifierListener(data.listener);
            data.view = new TableTabView(framework, engine, accessor, data.qualifier) {

                @Override
                public void close() {
                    super.close();
                    engine.removeQualifierListener(data.listener);
                    TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                    tabRemoved(tEvent);
                }

                @Override
                public String getTitle() {
                    return qualifier.getName();
                }

                @Override
                public ActionEvent getOpenAction() {
                    return new ActionEvent(OPEN_QUALIFIER, data.qualifier);
                }
            };
            TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, (TabView) data.view);
            tabCreated(tEvent);
        }
    });
    framework.setSystemAttributeName(StandardAttributesPlugin.getAttributeNameAttribute(engine), GlobalResourcesManager.getString("AttributeName"));
    framework.setSystemAttributeName(StandardAttributesPlugin.getAttributeTypeNameAttribute(engine), GlobalResourcesManager.getString("AttributeTypeName"));
}
Also used : QualifierAdapter(com.ramussoft.common.event.QualifierAdapter) ViewTitleEvent(com.ramussoft.gui.common.event.ViewTitleEvent) ActionListener(com.ramussoft.gui.common.event.ActionListener) TabView(com.ramussoft.gui.common.TabView) TableTabView(com.ramussoft.gui.qualifier.table.TableTabView) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) TableTabView(com.ramussoft.gui.qualifier.table.TableTabView) Qualifier(com.ramussoft.common.Qualifier) QualifierEvent(com.ramussoft.common.event.QualifierEvent) TabbedEvent(com.ramussoft.gui.common.event.TabbedEvent)

Aggregations

ViewTitleEvent (com.ramussoft.gui.common.event.ViewTitleEvent)7 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)3 ActionListener (com.ramussoft.gui.common.event.ActionListener)3 TabbedEvent (com.ramussoft.gui.common.event.TabbedEvent)3 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 ActionChangeAdapter (com.ramussoft.gui.common.event.ActionChangeAdapter)2 ActionChangeEvent (com.ramussoft.gui.common.event.ActionChangeEvent)2 ViewTitleListener (com.ramussoft.gui.common.event.ViewTitleListener)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AbstractAction (javax.swing.AbstractAction)2 Action (javax.swing.Action)2 CDecorateableAction (bibliothek.gui.dock.common.intern.action.CDecorateableAction)1 Element (com.ramussoft.common.Element)1 Qualifier (com.ramussoft.common.Qualifier)1 AttributeEvent (com.ramussoft.common.event.AttributeEvent)1 ElementAttributeListener (com.ramussoft.common.event.ElementAttributeListener)1