Search in sources :

Example 1 with CControlListener

use of bibliothek.gui.dock.common.event.CControlListener 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)

Aggregations

CControl (bibliothek.gui.dock.common.CControl)1 CWorkingArea (bibliothek.gui.dock.common.CWorkingArea)1 DefaultSingleCDockable (bibliothek.gui.dock.common.DefaultSingleCDockable)1 SingleCDockable (bibliothek.gui.dock.common.SingleCDockable)1 CControlListener (bibliothek.gui.dock.common.event.CControlListener)1 CFocusListener (bibliothek.gui.dock.common.event.CFocusListener)1 CDockable (bibliothek.gui.dock.common.intern.CDockable)1 DefaultCDockable (bibliothek.gui.dock.common.intern.DefaultCDockable)1 TabView (com.ramussoft.gui.common.TabView)1 TabbedView (com.ramussoft.gui.common.TabbedView)1 UniqueView (com.ramussoft.gui.common.UniqueView)1 View (com.ramussoft.gui.common.View)1 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)1 ActionListener (com.ramussoft.gui.common.event.ActionListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1