Search in sources :

Example 6 with MdiEntryVitalityImage

use of com.biglybt.ui.mdi.MdiEntryVitalityImage 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

MdiEntryVitalityImage (com.biglybt.ui.mdi.MdiEntryVitalityImage)6 ViewTitleInfo (com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)2 MdiEntry (com.biglybt.ui.mdi.MdiEntry)2 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)2 ObfuscateImage (com.biglybt.ui.swt.debug.ObfuscateImage)2 Point (org.eclipse.swt.graphics.Point)2 AERunnable (com.biglybt.core.util.AERunnable)1 TimerEvent (com.biglybt.core.util.TimerEvent)1 TimerEventPerformer (com.biglybt.core.util.TimerEventPerformer)1 PluginException (com.biglybt.pif.PluginException)1 InstallablePlugin (com.biglybt.pif.installer.InstallablePlugin)1 PluginInstallationListener (com.biglybt.pif.installer.PluginInstallationListener)1 PluginInstaller (com.biglybt.pif.installer.PluginInstaller)1 StandardPlugin (com.biglybt.pif.installer.StandardPlugin)1 MdiEntryVitalityImageListener (com.biglybt.ui.mdi.MdiEntryVitalityImageListener)1 MdiListener (com.biglybt.ui.mdi.MdiListener)1 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)1 GCStringPrinter (com.biglybt.ui.swt.shells.GCStringPrinter)1 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)1 Field (java.lang.reflect.Field)1