Search in sources :

Example 1 with TableViewImpl

use of com.biglybt.ui.common.table.impl.TableViewImpl in project BiglyBT by BiglySoftware.

the class SBC_TagsOverview method toolBarItemActivated.

// @see com.biglybt.pif.ui.toolbar.UIToolBarActivationListener#toolBarItemActivated(ToolBarItem, long, java.lang.Object)
@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
    // Send to active view.  mostly works
    // except MyTorrentsSubView always takes focus after tag is selected..
    boolean isTableSelected = false;
    if (tv instanceof TableViewImpl) {
        isTableSelected = ((TableViewImpl) tv).isTableSelected();
    }
    if (!isTableSelected) {
        UISWTViewCore active_view = getActiveView();
        if (active_view != null) {
            UIPluginViewToolBarListener l = active_view.getToolBarListener();
            if (l != null && l.toolBarItemActivated(item, activationType, datasource)) {
                return true;
            }
        }
        return false;
    }
    if (tv == null || !tv.isVisible()) {
        return (false);
    }
    if (item.getID().equals("remove")) {
        Object[] datasources = tv.getSelectedDataSources().toArray();
        if (datasources.length > 0) {
            for (Object object : datasources) {
                if (object instanceof Tag) {
                    final Tag tag = (Tag) object;
                    if (tag.getTagType().getTagType() != TagType.TT_DOWNLOAD_MANUAL) {
                        continue;
                    }
                    MessageBoxShell mb = new MessageBoxShell(MessageText.getString("message.confirm.delete.title"), MessageText.getString("message.confirm.delete.text", new String[] { tag.getTagName(true) }), new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 1);
                    mb.open(new UserPrompterResultListener() {

                        @Override
                        public void prompterClosed(int result) {
                            if (result == 0) {
                                tag.removeTag();
                            }
                        }
                    });
                }
            }
            return true;
        }
    }
    return false;
}
Also used : TableViewImpl(com.biglybt.ui.common.table.impl.TableViewImpl) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener)

Example 2 with TableViewImpl

use of com.biglybt.ui.common.table.impl.TableViewImpl in project BiglyBT by BiglySoftware.

the class MyTorrentsView method toolBarItemActivated.

@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
    boolean isTableSelected = false;
    if (tv instanceof TableViewImpl) {
        isTableSelected = ((TableViewImpl) tv).isTableSelected();
    }
    if (!isTableSelected) {
        UISWTViewCore active_view = getActiveView();
        if (active_view != null) {
            UIPluginViewToolBarListener l = active_view.getToolBarListener();
            if (l != null && l.toolBarItemActivated(item, activationType, datasource)) {
                return true;
            }
        }
        return false;
    }
    String itemKey = item.getID();
    if (activationType == UIToolBarActivationListener.ACTIVATIONTYPE_HELD) {
        if (itemKey.equals("up")) {
            moveSelectedTorrentsTop();
            return true;
        }
        if (itemKey.equals("down")) {
            moveSelectedTorrentsEnd();
            return true;
        }
        return false;
    }
    if (activationType != UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL) {
        return false;
    }
    if (itemKey.equals("top")) {
        moveSelectedTorrentsTop();
        return true;
    }
    if (itemKey.equals("bottom")) {
        moveSelectedTorrentsEnd();
        return true;
    }
    if (itemKey.equals("up")) {
        moveSelectedTorrentsUp();
        return true;
    }
    if (itemKey.equals("down")) {
        moveSelectedTorrentsDown();
        return true;
    }
    if (itemKey.equals("run")) {
        TorrentUtil.runDataSources(tv.getSelectedDataSources().toArray());
        return true;
    }
    if (itemKey.equals("start")) {
        TorrentUtil.queueDataSources(tv.getSelectedDataSources().toArray(), true);
        return true;
    }
    if (itemKey.equals("stop")) {
        TorrentUtil.stopDataSources(tv.getSelectedDataSources().toArray());
        return true;
    }
    if (itemKey.equals("startstop")) {
        TorrentUtil.stopOrStartDataSources(tv.getSelectedDataSources().toArray());
        return true;
    }
    if (itemKey.equals("remove")) {
        TorrentUtil.removeDataSources(tv.getSelectedDataSources().toArray());
        return true;
    }
    return false;
}
Also used : TableViewImpl(com.biglybt.ui.common.table.impl.TableViewImpl) UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore)

Aggregations

TableViewImpl (com.biglybt.ui.common.table.impl.TableViewImpl)2 UISWTViewCore (com.biglybt.ui.swt.pifimpl.UISWTViewCore)2 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)1 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)1