Search in sources :

Example 1 with MdiEntry

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

the class SideBar method createHeader.

@Override
public MdiEntry createHeader(String id, String titleID, String preferredAfterID) {
    MdiEntry oldEntry = getEntry(id);
    if (oldEntry != null) {
        return oldEntry;
    }
    SideBarEntrySWT entry = new SideBarEntrySWT(this, skin, id, null);
    entry.setSelectable(false);
    entry.setPreferredAfterID(preferredAfterID);
    entry.setTitleID(titleID);
    setupNewEntry(entry, id, true, false);
    return entry;
}
Also used : BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry)

Example 2 with MdiEntry

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

the class SideBar method removeItem.

@Override
public void removeItem(MdiEntry entry) {
    super.removeItem(entry);
    if (Utils.isDisplayDisposed()) {
        return;
    }
    if (entry instanceof SideBarEntrySWT) {
        MdiEntry current = getCurrentEntry();
        SideBarEntrySWT next = null;
        synchronized (stack) {
            stack.remove(entry);
            if (current == null || current == entry) {
                while (!stack.isEmpty()) {
                    next = stack.pop();
                    if (next.isDisposed()) {
                        next = null;
                    } else {
                        break;
                    }
                }
            }
        }
        if (next != null) {
            showEntry(next);
        }
    }
}
Also used : BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry)

Example 3 with MdiEntry

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

the class SideBarEntrySWT method widgetDisposed.

@Override
public void widgetDisposed(DisposeEvent e) {
    ImageLoader imageLoader = ImageLoader.getInstance();
    if (imageLoader != null) {
        imageLoader.releaseImage("image.sidebar.closeitem");
        imageLoader.releaseImage("image.sidebar.closeitem-selected");
    }
    setDisposed(true);
    final TreeItem treeItem = (TreeItem) e.widget;
    if (treeItem != swtItem) {
        Debug.out("Warning: TreeItem changed for sidebar " + id);
        return;
    }
    if (swtItem == null) {
        return;
    }
    if (swtItem != null && !Constants.isOSX) {
        // In theory, the disposal of swtItem will trigger the disposal of the
        // children.  Let's force it just in case
        // On OSX this will cause disposal confusion in SWT, and possibly result
        // in a SIGSEGV crash.
        TreeItem[] children = swtItem.getItems();
        for (TreeItem child : children) {
            if (child.isDisposed()) {
                continue;
            }
            MdiEntry entry = (MdiEntry) child.getData("MdiEntry");
            if (entry != null) {
                entry.close(true);
            }
        }
    }
    final Tree tree = sidebar.getTree();
    if (tree.isDisposed() || (swtItem != null && swtItem.isDisposed()) || tree.getShell().isDisposed()) {
        return;
    }
    setTreeItem(null);
    mdi.removeItem(SideBarEntrySWT.this);
    SWTThread instance = SWTThread.getInstance();
    boolean user = instance != null && !instance.isTerminated();
    if (user) {
        // It's not a user close if the parent is making the children (this entry)
        // close.  parent will be marked disposed, so use that as a check.
        String parentID = getParentID();
        if (parentID != null) {
            MdiEntry entry = mdi.getEntry(parentID);
            if (entry != null && entry.isDisposed()) {
                user = false;
            }
        }
    }
    triggerCloseListeners(user);
    SWTSkinObject so = getSkinObject();
    if (so != null) {
        setSkinObjectMaster(null);
        so.getSkin().removeSkinObject(so);
    }
    for (SideBarVitalityImageSWT vitalityImage : listVitalityImages) {
        vitalityImage.dispose();
    }
    listVitalityImages.clear();
    // delay saving of removing of auto-open flag.  If after the delay, we are
    // still alive, it's assumed the user invoked the close, and we should
    // remove the auto-open flag
    Utils.execSWTThreadLater(0, new SWTRunnable() {

        @Override
        public void runWithDisplay(Display display) {
            // opposed to closing  the sidebar)
            if (tree.isDisposed()) {
                return;
            }
            try {
                COConfigurationManager.removeParameter("SideBar.AutoOpen." + id);
                // Force selection
                if (Constants.isOSX && !tree.isDisposed() && tree.getSelectionCount() == 0) {
                    String parentid = getParentID();
                    if (parentid != null && mdi.getEntry(parentid) != null) {
                        mdi.showEntryByID(parentid);
                    } else {
                        mdi.showEntryByID(SideBar.SIDEBAR_SECTION_LIBRARY);
                    }
                }
            } catch (Exception e2) {
                Debug.out(e2);
            }
            // See if this entry has been replaced by another in the meantime. This happens when we are
            // moving an entry in the sidebar by removing it and then re-adding it. We assume that the
            // auto-open properties of the replacement are the same as those of the initial entry
            boolean replaced = false;
            String my_id = SideBarEntrySWT.this.getId();
            if (my_id != null) {
                MdiEntry entry = mdi.getEntry(my_id);
                if (entry != null && entry != SideBarEntrySWT.this) {
                    replaced = true;
                }
            }
            if (!replaced) {
                mdi.removeEntryAutoOpen(id);
            }
        }
    });
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) SWTRunnable(com.biglybt.ui.swt.utils.SWTRunnable) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) SWTThread(com.biglybt.ui.swt.mainwindow.SWTThread)

Example 4 with MdiEntry

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

the class TabbedMDI method createEntryFromSkinRef.

private MdiEntry createEntryFromSkinRef(String parentID, String id, String configID, String title, ViewTitleInfo titleInfo, Object params, boolean closeable, int index) {
    MdiEntry oldEntry = getEntry(id);
    if (oldEntry != null) {
        return oldEntry;
    }
    TabbedEntry entry = new TabbedEntry(this, skin, id, null);
    entry.setTitle(title);
    entry.setSkinRef(configID, params);
    entry.setViewTitleInfo(titleInfo);
    setupNewEntry(entry, id, index, closeable);
    return entry;
}
Also used : MdiEntry(com.biglybt.ui.mdi.MdiEntry)

Example 5 with MdiEntry

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

the class TabbedMDI method createEntryFromEventListener.

@Override
public MdiEntry createEntryFromEventListener(String parentEntryID, String parentViewID, UISWTViewEventListener l, String id, boolean closeable, Object datasource, String preferredAfterID) {
    if (isEntryClosedByUser(id)) {
        return null;
    }
    MdiEntry oldEntry = getEntry(id);
    if (oldEntry != null) {
        return oldEntry;
    }
    TabbedEntry entry = new TabbedEntry(this, skin, id, parentViewID);
    if (datasource == null && l instanceof UISWTViewEventListenerHolder) {
        datasource = ((UISWTViewEventListenerHolder) l).getInitialDataSource();
    }
    try {
        // hack - seteventlistener will create view it needs to have item available now, not a little later
        addItem(entry);
        entry.setEventListener(l, true);
    } catch (UISWTViewEventCancelledException e) {
        entry.close(true);
        removeItem(entry, false);
        return null;
    }
    entry.setDatasource(datasource);
    entry.setPreferredAfterID(preferredAfterID);
    setupNewEntry(entry, id, -1, closeable);
    addMenus(entry, id);
    if (l instanceof IViewAlwaysInitialize) {
        entry.build();
    }
    return entry;
}
Also used : UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException) MdiEntry(com.biglybt.ui.mdi.MdiEntry) IViewAlwaysInitialize(com.biglybt.ui.swt.views.IViewAlwaysInitialize) UISWTViewEventListenerHolder(com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder)

Aggregations

MdiEntry (com.biglybt.ui.mdi.MdiEntry)40 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)13 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)11 MenuItem (com.biglybt.pif.ui.menus.MenuItem)4 ViewTitleInfo (com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)4 MdiCloseListener (com.biglybt.ui.mdi.MdiCloseListener)4 MultipleDocumentInterfaceSWT (com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)4 ParameterListener (com.biglybt.core.config.ParameterListener)3 PluginInterface (com.biglybt.pif.PluginInterface)3 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)3 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)3 DownloadManager (com.biglybt.core.download.DownloadManager)2 UIManager (com.biglybt.pif.ui.UIManager)2 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)2 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)2 MenuManager (com.biglybt.pif.ui.menus.MenuManager)2 UIFunctions (com.biglybt.ui.UIFunctions)2 UIUpdater (com.biglybt.ui.common.updater.UIUpdater)2 MdiEntryDropListener (com.biglybt.ui.mdi.MdiEntryDropListener)2 MdiListener (com.biglybt.ui.mdi.MdiListener)2