Search in sources :

Example 26 with MultipleDocumentInterface

use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.

the class SBC_LibraryView method setViewMode.

public void setViewMode(int viewMode, boolean save) {
    if (viewMode >= modeViewIDs.length || viewMode < 0 || viewMode == this.viewMode) {
        return;
    }
    if (!COConfigurationManager.getBooleanParameter("Library.EnableSimpleView")) {
        viewMode = MODE_SMALLTABLE;
    }
    int oldViewMode = this.viewMode;
    this.viewMode = viewMode;
    if (oldViewMode >= 0 && oldViewMode < modeViewIDs.length) {
        SWTSkinObject soOldViewArea = getSkinObject(modeViewIDs[oldViewMode]);
        // SWTSkinObject soOldViewArea = skin.getSkinObjectByID(modeIDs[oldViewMode]);
        if (soOldViewArea != null) {
            soOldViewArea.setVisible(false);
        }
    }
    SelectedContentManager.clearCurrentlySelectedContent();
    SWTSkinObject soViewArea = getSkinObject(modeViewIDs[viewMode]);
    if (soViewArea == null) {
        soViewArea = skin.createSkinObject(modeIDs[viewMode] + torrentFilterMode, modeIDs[viewMode], soListArea);
        soViewArea.getControl().setData("SBC_LibraryView:ViewMode", viewMode);
        skin.layout();
        soViewArea.setVisible(true);
        soViewArea.getControl().setLayoutData(Utils.getFilledFormData());
    } else {
        soViewArea.setVisible(true);
    }
    if (save) {
        COConfigurationManager.setParameter(torrentFilter + ".viewmode", viewMode);
    }
    String entryID = null;
    if (torrentFilterMode == TORRENTS_ALL) {
        entryID = SideBar.SIDEBAR_SECTION_LIBRARY;
    } else if (torrentFilterMode == TORRENTS_COMPLETE) {
        entryID = SideBar.SIDEBAR_SECTION_LIBRARY_CD;
    } else if (torrentFilterMode == TORRENTS_INCOMPLETE) {
        entryID = SideBar.SIDEBAR_SECTION_LIBRARY_DL;
    } else if (torrentFilterMode == TORRENTS_UNOPENED) {
        entryID = SideBar.SIDEBAR_SECTION_LIBRARY_UNOPENED;
    }
    if (entryID != null) {
        MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
        currentEntry = mdi.getEntry(entryID);
        if (currentEntry != null) {
            currentEntry.setLogID(entryID + "-" + viewMode);
        }
    }
    SB_Transfers sb_t = MainMDISetup.getSb_transfers();
    if (sb_t != null) {
        sb_t.triggerCountRefreshListeners();
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) Point(org.eclipse.swt.graphics.Point)

Example 27 with MultipleDocumentInterface

use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.

the class SB_Dashboard method setupMDIEntry.

public MdiEntry setupMDIEntry() {
    ViewTitleInfo title_info = new ViewTitleInfo() {

        @Override
        public Object getTitleInfoProperty(int propertyID) {
            if (propertyID == TITLE_INDICATOR_TEXT) {
                return (String.valueOf(items.size()));
            }
            if (propertyID == TITLE_INDICATOR_TEXT_TOOLTIP) {
                return (null);
            }
            return null;
        }
    };
    mdi_entry = mdi.createEntryFromSkinRef("", MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD, "dashboard", "{sidebar.header.dashboard}", title_info, null, false, null);
    mdi_entry.setImageLeftID("image.sidebar.dashboard");
    MdiEntryVitalityImage cog = mdi_entry.addVitalityImage("image.sidebar.cog");
    cog.setToolTip(MessageText.getString("configure.dashboard"));
    final long[] cog_click_time = { 0 };
    cog.addListener(new MdiEntryVitalityImageListener() {

        @Override
        public void mdiEntryVitalityImage_clicked(int x, int y) {
            synchronized (items) {
                cog_click_time[0] = SystemTime.getMonotonousTime();
                new DBConfigWindow(new ArrayList<DashboardItem>(items));
            }
        }
    });
    cog.setVisible(true);
    mdi.addListener(new MdiListener() {

        @Override
        public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
            if (mdi_entry == newEntry && mdi_entry == oldEntry) {
                SimpleTimer.addEvent("changed", SystemTime.getOffsetTime(250), new TimerEventPerformer() {

                    @Override
                    public void perform(TimerEvent event) {
                        synchronized (items) {
                            if (SystemTime.getMonotonousTime() - cog_click_time[0] < 250) {
                                return;
                            }
                        }
                        fireChanged();
                    }
                });
            }
        }

        public void mdiDisposed(MultipleDocumentInterface mdi) {
        }
    });
    return (mdi_entry);
}
Also used : MdiListener(com.biglybt.ui.mdi.MdiListener) MdiEntryVitalityImageListener(com.biglybt.ui.mdi.MdiEntryVitalityImageListener) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) Point(org.eclipse.swt.graphics.Point) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) TimerEventPerformer(com.biglybt.core.util.TimerEventPerformer) TimerEvent(com.biglybt.core.util.TimerEvent) MdiEntryVitalityImage(com.biglybt.ui.mdi.MdiEntryVitalityImage) ViewTitleInfo(com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)

Aggregations

MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)27 MdiEntry (com.biglybt.ui.mdi.MdiEntry)15 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)6 PluginInterface (com.biglybt.pif.PluginInterface)5 Point (org.eclipse.swt.graphics.Point)5 ParameterListener (com.biglybt.core.config.ParameterListener)4 UIManager (com.biglybt.pif.ui.UIManager)4 MdiListener (com.biglybt.ui.mdi.MdiListener)4 ArrayList (java.util.ArrayList)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 CoreRunningListener (com.biglybt.core.CoreRunningListener)3 Subscription (com.biglybt.core.subs.Subscription)3 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)3 GlobalManager (com.biglybt.core.global.GlobalManager)2 LogEvent (com.biglybt.core.logging.LogEvent)2 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)2 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)2 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)2 UIFunctions (com.biglybt.ui.UIFunctions)2