Search in sources :

Example 1 with BaseMdiEntry

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

the class SideBar method getEntryFromSkinObject.

// @see MultipleDocumentInterfaceSWT#getEntryFromSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject)
@Override
public MdiEntrySWT getEntryFromSkinObject(PluginUISWTSkinObject pluginSkinObject) {
    if (pluginSkinObject instanceof SWTSkinObject) {
        Control control = ((SWTSkinObject) pluginSkinObject).getControl();
        while (control != null && !control.isDisposed()) {
            Object entry = control.getData("BaseMDIEntry");
            if (entry instanceof BaseMdiEntry) {
                BaseMdiEntry mdiEntry = (BaseMdiEntry) entry;
                return mdiEntry;
            }
            control = control.getParent();
        }
    }
    return null;
}
Also used : PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject)

Example 2 with BaseMdiEntry

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

the class SideBar method showEntry.

@Override
public void showEntry(MdiEntry newEntry) {
    if (tree.isDisposed()) {
        return;
    }
    if (newEntry == null || !newEntry.isSelectable()) {
        return;
    }
    final SideBarEntrySWT oldEntry = (SideBarEntrySWT) currentEntry;
    // System.out.println("showEntry " + newEntry.getId() + "; was " + (oldEntry == null ? "null" : oldEntry.getId()) + " via " + Debug.getCompressedStackTrace());
    if (currentEntry == newEntry) {
        triggerSelectionListener(newEntry, newEntry);
        return;
    }
    // show new
    currentEntry = (MdiEntrySWT) newEntry;
    if (oldEntry != null && oldEntry != newEntry) {
        oldEntry.redraw();
    }
    if (currentEntry != null) {
        ((BaseMdiEntry) currentEntry).show();
    }
    // hide old
    if (oldEntry != null && oldEntry != newEntry) {
        oldEntry.hide();
        oldEntry.redraw();
    }
    // as this code isn't thread safe there is a chance we end up with multiple entries visible
    // (well actually it happens fairly frequently) - this results in other views being rendered
    // during switching which is nasty - hide anything that shouldn't be visible for the moment
    MdiEntrySWT[] entries = getEntriesSWT();
    for (MdiEntrySWT entry : entries) {
        if (entry == null) {
            continue;
        }
        if (entry != currentEntry) {
            SWTSkinObject obj = ((SideBarEntrySWT) entry).getSkinObjectMaster();
            if (obj != null && obj.isVisible()) {
                entry.hide();
                entry.redraw();
            }
        }
    }
    newEntry.redraw();
    triggerSelectionListener(newEntry, oldEntry);
}
Also used : PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT)

Example 3 with BaseMdiEntry

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

the class SubscriptionMDIEntry method refreshView.

protected void refreshView() {
    if (!(mdiEntry instanceof BaseMdiEntry)) {
        return;
    }
    UISWTViewEventListener eventListener = ((BaseMdiEntry) mdiEntry).getEventListener();
    if (eventListener instanceof SubscriptionView) {
        SubscriptionView subsView = (SubscriptionView) eventListener;
        subsView.refreshView();
    }
}
Also used : BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener)

Example 4 with BaseMdiEntry

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

the class UIFunctionsImpl method openPluginView.

// @see UIFunctionsSWT#openPluginView(java.lang.String, java.lang.String, com.biglybt.ui.swt.pif.UISWTViewEventListener, java.lang.Object, boolean)
@Override
public void openPluginView(String sParentID, String sViewID, UISWTViewEventListener l, Object dataSource, boolean bSetFocus) {
    try {
        MultipleDocumentInterfaceSWT mdi = getMDISWT();
        if (mdi != null) {
            String sidebarParentID = null;
            if (UISWTInstance.VIEW_MYTORRENTS.equals(sParentID)) {
                sidebarParentID = SideBar.SIDEBAR_HEADER_TRANSFERS;
            } else if (UISWTInstance.VIEW_MAIN.equals(sParentID)) {
                sidebarParentID = MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS;
            } else {
                System.err.println("Can't find parent " + sParentID + " for " + sViewID);
            }
            MdiEntry entry = mdi.createEntryFromEventListener(sidebarParentID, l, sViewID, true, dataSource, null);
            if (bSetFocus) {
                mdi.showEntryByID(sViewID);
            } else if (entry instanceof BaseMdiEntry) {
                // Some plugins (CVS Updater) want their view's composite initialized
                // on OpenPluginView, otherwise they won't do logic users expect
                // (like check for new snapshots).  So, enforce loading entry.
                ((BaseMdiEntry) entry).build();
            }
        }
    } catch (Exception e) {
        Logger.log(new LogEvent(LOGID, "openPluginView", e));
    }
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)

Aggregations

BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)4 PluginUISWTSkinObject (com.biglybt.ui.swt.pif.PluginUISWTSkinObject)2 LogEvent (com.biglybt.core.logging.LogEvent)1 MdiEntry (com.biglybt.ui.mdi.MdiEntry)1 MdiEntrySWT (com.biglybt.ui.swt.mdi.MdiEntrySWT)1 MultipleDocumentInterfaceSWT (com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)1 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)1