Search in sources :

Example 1 with ActionListener

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

the class ElistView method createComponent.

@Override
public JComponent createComponent() {
    framework.addActionListener(FULL_REFRESH, new ActionListener() {

        @Override
        public void onAction(com.ramussoft.gui.common.event.ActionEvent event) {
            component.close();
            root.removeAll();
            createInnerComponent();
        }
    });
    root = new JPanel(new BorderLayout());
    createInnerComponent();
    return root;
}
Also used : JPanel(javax.swing.JPanel) ActionListener(com.ramussoft.gui.common.event.ActionListener) BorderLayout(java.awt.BorderLayout)

Example 2 with ActionListener

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

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

the class SimleGUIPluginFactory method initContent.

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

        @Override
        public void closed(Control control, DFrame 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, TabFrame> 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());
        }
    });
    control.addFocusListener(new FrameFocusListener() {

        @Override
        public void focusGained(DFrame dockable) {
            List<View> list = new ArrayList<View>();
            for (Entry<TabView, TabFrame> e : tabDockables.entrySet()) {
                if (e.getValue().equals(dockable)) {
                    TabView view = e.getKey();
                    list.add(view);
                }
            }
            if (dockable instanceof UniqueDFrame) {
                list.add(findUniqueView(((UniqueDFrame) 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(DFrame dockable) {
            List<View> list = new ArrayList<View>();
            for (Entry<TabView, TabFrame> e : tabDockables.entrySet()) {
                if (e.getValue().equals(dockable)) {
                    TabView view = e.getKey();
                    list.add(view);
                }
            }
            if (dockable instanceof UniqueDFrame) {
                list.add(findUniqueView(((UniqueDFrame) 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 UniqueDFrame dockable = new UniqueDFrame(control, id, findPluginForViewId(id).getString(id), view);
        dockable.setCloseable(true);
        initActions(view.getId(), view, dockable);
        control.add(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);
    }
    control.commitUniqueViews();
    for (TabbedView view : tabbedViews) {
        String id = view.getId();
        if (getWorkingArea(id) != null)
            continue;
        Area area = control.createWorkingArea(id);
        uniqueWorkingAreas.add(area);
        area.setVisible(true);
    }
    framework.setMainFrame(plugableFrame);
}
Also used : 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) TabbedView(com.ramussoft.gui.common.TabbedView) Entry(java.util.Map.Entry) UniqueView(com.ramussoft.gui.common.UniqueView) ActionListener(com.ramussoft.gui.common.event.ActionListener) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with ActionListener

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

the class ShowWorkspacePlugin method setFramework.

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

        @Override
        public void onAction(com.ramussoft.gui.common.event.ActionEvent event) {
            for (ActionDescriptor action : actions) if (action.getAction() instanceof ShowWorkspaceAction) {
                if (((ShowWorkspaceAction) action.getAction()).getWorkspace().equals(event.getValue())) {
                    action.getAction().actionPerformed(null);
                    action.getAction().putValue(Action.SELECTED_KEY, Boolean.TRUE);
                }
            }
        }
    });
}
Also used : ActionListener(com.ramussoft.gui.common.event.ActionListener) ActionDescriptor(com.ramussoft.gui.common.ActionDescriptor)

Example 5 with ActionListener

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

the class GUIFramework method propertyChanged.

public void propertyChanged(String key, final Object value, Object metadata) {
    ActionEvent event = new ActionEvent(key, value, metadata);
    put(key, event);
    for (ActionListener listener : getActionListeners()) {
        listener.onAction(event);
    }
    EventListenerList list = keyListeners.get(key);
    if (list != null) {
        for (ActionListener listener : list.getListeners(ActionListener.class)) {
            listener.onAction(event);
        }
    }
    View activeView = getActiveView();
    if (activeView != null)
        for (String a : activeView.getGlobalActions()) {
            if (a.equals(key)) {
                activeView.onAction(event);
            }
        }
}
Also used : ActionListener(com.ramussoft.gui.common.event.ActionListener) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) EventListenerList(javax.swing.event.EventListenerList)

Aggregations

ActionListener (com.ramussoft.gui.common.event.ActionListener)16 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)11 TabbedEvent (com.ramussoft.gui.common.event.TabbedEvent)7 TabView (com.ramussoft.gui.common.TabView)3 ViewTitleEvent (com.ramussoft.gui.common.event.ViewTitleEvent)3 IOException (java.io.IOException)3 Element (com.ramussoft.common.Element)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 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 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 CControl (bibliothek.gui.dock.common.CControl)1