Search in sources :

Example 1 with MdiEntryVitalityImageListener

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

TimerEvent (com.biglybt.core.util.TimerEvent)1 TimerEventPerformer (com.biglybt.core.util.TimerEventPerformer)1 ViewTitleInfo (com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)1 MdiEntry (com.biglybt.ui.mdi.MdiEntry)1 MdiEntryVitalityImage (com.biglybt.ui.mdi.MdiEntryVitalityImage)1 MdiEntryVitalityImageListener (com.biglybt.ui.mdi.MdiEntryVitalityImageListener)1 MdiListener (com.biglybt.ui.mdi.MdiListener)1 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)1 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)1 Point (org.eclipse.swt.graphics.Point)1