Search in sources :

Example 1 with TabView

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

the class FilePlugin method saveToFile.

private void saveToFile(File f) throws IOException {
    framework.propertyChanged(BEFORE_FILE_SAVE, f);
    OutputStream out = engine2.getOutputStream("/user/gui/session.binary");
    ObjectOutputStream oos = new ObjectOutputStream(out);
    try {
        List<TabView> views = framework.getTabViews();
        List<com.ramussoft.gui.common.event.ActionEvent> session = new ArrayList<com.ramussoft.gui.common.event.ActionEvent>();
        for (View view : views) {
            com.ramussoft.gui.common.event.ActionEvent event = view.getOpenAction();
            session.add(event);
        }
        oos.writeObject(session);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        oos.close();
    }
    engine.saveToFile(f);
    Runner.saveFileToHistory(f);
    setChangedFalse();
}
Also used : TabView(com.ramussoft.gui.common.TabView) ActionEvent(java.awt.event.ActionEvent) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) ObjectOutputStream(java.io.ObjectOutputStream) TabView(com.ramussoft.gui.common.TabView) View(com.ramussoft.gui.common.View) IOException(java.io.IOException)

Example 2 with TabView

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

the class GUIPluginFactory method addActions.

private void addActions(String id, final View view, final DefaultCDockable dockable, Action[] actions) {
    for (final Action action : actions) if (action == null) {
        dockable.addSeparator();
    } else {
        ImageIcon icon = (ImageIcon) action.getValue(Action.SMALL_ICON);
        if (icon == null) {
            icon = new ImageIcon(getClass().getResource("/com/ramussoft/gui/icon.png"));
        }
        final String command = (String) action.getValue(Action.ACTION_COMMAND_KEY);
        String text = null;
        if (view instanceof TabView) {
            text = ((TabView) view).getString(command);
        }
        if (text == null)
            text = findPluginForViewId(id).getString(command);
        if (text == null) {
            StringGetter getter = (StringGetter) action.getValue(StringGetter.ACTION_STRING_GETTER);
            if (getter != null)
                text = getter.getString(command);
        }
        final CDecorateableAction button;
        if (action.getValue(Action.SELECTED_KEY) == null) {
            final PopupTrigger trigger = (PopupTrigger) action.getValue(POPUP_MENU);
            if (trigger == null)
                button = new CButton(text, icon) {

                    @Override
                    protected void action() {
                        java.awt.event.ActionEvent e = new java.awt.event.ActionEvent(view, 0, command);
                        action.actionPerformed(e);
                    }
                };
            else {
                button = new CPanelPopup() {

                    @Override
                    public void openPopup(PanelPopupWindow window) {
                        super.openPopup(window);
                    }

                    @Override
                    protected void openDialog(JComponent item, Orientation orientation) {
                        JPanel menu = (JPanel) getContent();
                        menu.removeAll();
                        for (Action action : trigger.getPopupActions()) menu.add(new JButton(action));
                        menu.revalidate();
                        menu.repaint();
                        super.openDialog(item, orientation);
                    }
                };
                ((CPanelPopup) button).setContent(new JPanel(new GridLayout(0, 1, 0, 0)));
                button.setText(text);
                button.setIcon(icon);
            }
        } else {
            button = new CCheckBox(text, icon) {

                @Override
                protected void changed() {
                    java.awt.event.ActionEvent e = new java.awt.event.ActionEvent(view, 0, command);
                    action.putValue(Action.SELECTED_KEY, isSelected());
                    action.actionPerformed(e);
                }
            };
            action.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (Action.SELECTED_KEY.equals(evt.getPropertyName())) {
                        ((CCheckBox) button).setSelected((Boolean) evt.getNewValue());
                    }
                }
            });
            ((CCheckBox) button).setSelected((Boolean) action.getValue(Action.SELECTED_KEY));
        }
        String tooltip = (String) action.getValue(Action.LONG_DESCRIPTION);
        if (tooltip == null)
            tooltip = (String) action.getValue(Action.SHORT_DESCRIPTION);
        if (tooltip == null)
            tooltip = text;
        if (tooltip != null)
            button.setTooltip(tooltip);
        KeyStroke stroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
        if (stroke != null)
            button.setAccelerator(stroke);
        actionButtons.put(action, button);
        button.setEnabled(action.isEnabled());
        dockable.addAction(button);
        action.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("enabled")) {
                    button.setEnabled((Boolean) evt.getNewValue());
                }
            }
        });
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) AbstractAction(javax.swing.AbstractAction) CDecorateableAction(bibliothek.gui.dock.common.intern.action.CDecorateableAction) Action(javax.swing.Action) PropertyChangeListener(java.beans.PropertyChangeListener) PanelPopupWindow(bibliothek.gui.dock.common.action.panel.PanelPopupWindow) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) JButton(javax.swing.JButton) StringGetter(com.ramussoft.gui.common.StringGetter) CPanelPopup(bibliothek.gui.dock.common.action.CPanelPopup) GridLayout(java.awt.GridLayout) CCheckBox(bibliothek.gui.dock.common.action.CCheckBox) CDecorateableAction(bibliothek.gui.dock.common.intern.action.CDecorateableAction) CButton(bibliothek.gui.dock.common.action.CButton) PropertyChangeEvent(java.beans.PropertyChangeEvent) TabView(com.ramussoft.gui.common.TabView) PopupTrigger(com.ramussoft.gui.common.PopupTrigger) JComponent(javax.swing.JComponent) Orientation(bibliothek.gui.dock.title.DockTitle.Orientation) KeyStroke(javax.swing.KeyStroke)

Example 3 with TabView

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

the class GUIPluginFactory method loadCurrentWorkspase.

private void loadCurrentWorkspase() {
    control.load(this.currentWorkspace);
    if (this.currentWorkspace != null) {
        View view = workspaceViews.get(this.currentWorkspace);
        if (view != null) {
            Enumeration<TabView> enumeration = tabDockables.keys();
            while (enumeration.hasMoreElements()) {
                TabView tabView = enumeration.nextElement();
                if (view == tabView) {
                    TabDockable dockable = tabDockables.get(view);
                    dockable.intern().getController().setFocusedDockable(dockable.intern(), false);
                }
            }
        }
    }
}
Also used : TabView(com.ramussoft.gui.common.TabView) UniqueView(com.ramussoft.gui.common.UniqueView) TabView(com.ramussoft.gui.common.TabView) TabbedView(com.ramussoft.gui.common.TabbedView) View(com.ramussoft.gui.common.View)

Example 4 with TabView

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

the class GUIPluginFactory method tabCreated.

protected void tabCreated(TabbedEvent event) {
    TabView view = event.getTabableView();
    TabDockable dockable = tabDockables.get(event.getTabableView());
    if (dockable != null) {
        dockable.intern().getController().setFocusedDockable(dockable.intern(), false);
        return;
    }
    String id = event.getTabViewId();
    CWorkingArea area = getWorkingArea(id);
    if (!area.isVisible())
        area.setVisible(true);
    dockable = new TabDockable(factories.get(id), view.createComponent());
    tabDockables.put(view, dockable);
    dockable.setRemoveOnClose(true);
    initActions(id, view, dockable);
    dockable.setLocation(CLocation.working(area).rectangle(0, 0, 1, 1));
    dockable.setTitleText(view.getTitle());
    dockable.setCloseable(true);
    area.add(dockable);
    dockable.setVisible(true);
    dockable.intern().getController().setFocusedDockable(dockable.intern(), false);
}
Also used : TabView(com.ramussoft.gui.common.TabView) CWorkingArea(bibliothek.gui.dock.common.CWorkingArea)

Example 5 with TabView

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

the class SimleGUIPluginFactory method tabCreated.

protected void tabCreated(TabbedEvent event) {
    TabView view = event.getTabableView();
    TabFrame dockable = tabDockables.get(event.getTabableView());
    if (dockable != null) {
        control.setActive(dockable);
        return;
    }
    String id = event.getTabViewId();
    Area area = getWorkingArea(id);
    if (!area.isVisible())
        area.setVisible(true);
    dockable = new TabFrame(control, area, view);
    tabDockables.put(view, dockable);
    dockable.setRemoveOnClose(true);
    initActions(id, view, dockable);
    // dockable.setTitleText(view.getTitle());
    dockable.setCloseable(true);
    dockable.setVisible(true);
}
Also used : TabView(com.ramussoft.gui.common.TabView)

Aggregations

TabView (com.ramussoft.gui.common.TabView)12 UniqueView (com.ramussoft.gui.common.UniqueView)7 View (com.ramussoft.gui.common.View)5 TabbedView (com.ramussoft.gui.common.TabbedView)4 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)4 ActionListener (com.ramussoft.gui.common.event.ActionListener)3 ArrayList (java.util.ArrayList)3 CWorkingArea (bibliothek.gui.dock.common.CWorkingArea)2 DefaultSingleCDockable (bibliothek.gui.dock.common.DefaultSingleCDockable)2 OutputStream (java.io.OutputStream)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 CControl (bibliothek.gui.dock.common.CControl)1 SingleCDockable (bibliothek.gui.dock.common.SingleCDockable)1 CButton (bibliothek.gui.dock.common.action.CButton)1 CCheckBox (bibliothek.gui.dock.common.action.CCheckBox)1 CPanelPopup (bibliothek.gui.dock.common.action.CPanelPopup)1 PanelPopupWindow (bibliothek.gui.dock.common.action.panel.PanelPopupWindow)1 CControlListener (bibliothek.gui.dock.common.event.CControlListener)1 CFocusListener (bibliothek.gui.dock.common.event.CFocusListener)1