Search in sources :

Example 11 with SWTSkinObjectContainer

use of com.biglybt.ui.swt.skin.SWTSkinObjectContainer in project BiglyBT by BiglySoftware.

the class BaseMdiEntry method show.

public void show() {
    if (skinObject == null) {
        return;
    }
    SelectedContentManager.clearCurrentlySelectedContent();
    UIFunctionsSWT uif = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uif != null) {
        // uif.refreshIconBar(); // needed?
        uif.refreshTorrentMenu();
    }
    SWTSkinObject skinObject = getSkinObjectMaster();
    skinObject.setVisible(true);
    if (skinObject instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer container = (SWTSkinObjectContainer) skinObject;
        Composite composite = container.getComposite();
        if (composite != null && !composite.isDisposed()) {
            composite.setVisible(true);
            composite.moveAbove(null);
            // composite.setFocus();
            // container.getParent().relayout();
            composite.getParent().layout();
        }
    // This causes double show because createSkinObject already calls show
    // container.triggerListeners(SWTSkinObjectListener.EVENT_SHOW);
    }
    Composite c = getComposite();
    if (c != null && !c.isDisposed()) {
        c.setData("BaseMDIEntry", this);
        c.setVisible(true);
        c.getParent().layout();
    }
    try {
        // In theory, c.setVisible() will trigger TYPE_FOCUSGAINED, but let's
        // call it anyway (it will be ignored if focus is already gained)
        triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
    } catch (Exception e) {
        Debug.out(e);
    }
    setToolbarVisibility(hasToolbarEnableers());
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) ConfigurationParameterNotFoundException(com.biglybt.core.config.impl.ConfigurationParameterNotFoundException)

Example 12 with SWTSkinObjectContainer

use of com.biglybt.ui.swt.skin.SWTSkinObjectContainer in project BiglyBT by BiglySoftware.

the class SBC_SearchResultsView method showDownloadFTUX.

protected static void showDownloadFTUX(SearchSubsResultBase entry, final UserPrompterResultListener listener) {
    if (entry instanceof SBC_SubscriptionResult) {
        listener.prompterClosed(0);
        return;
    }
    if (RememberedDecisionsManager.getRememberedDecision("searchsubs.dl.ftux") == 1) {
        listener.prompterClosed(0);
        return;
    }
    final VuzeMessageBox box = new VuzeMessageBox(MessageText.getString("searchsubs.dl.ftux.title"), null, new String[] { MessageText.getString("Button.ok"), MessageText.getString("Button.cancel") }, 0);
    box.setSubTitle(MessageText.getString("searchsubs.dl.ftux.heading"));
    final boolean[] check_state = new boolean[] { true };
    box.setListener(new VuzeMessageBoxListener() {

        @Override
        public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
            SWTSkin skin = soExtra.getSkin();
            addResourceBundle(skin, "com/biglybt/ui/swt/columns/searchsubs/", "skin3_dl_ftux");
            String id = "searchsubs.dlftux.shell";
            skin.createSkinObject(id, id, soExtra);
            final SWTSkinObjectCheckbox cb = (SWTSkinObjectCheckbox) skin.getSkinObject("agree-checkbox");
            cb.setChecked(true);
            cb.addSelectionListener(new SWTSkinCheckboxListener() {

                @Override
                public void checkboxChanged(SWTSkinObjectCheckbox so, boolean checked) {
                    check_state[0] = checked;
                }
            });
        }
    });
    box.open(new UserPrompterResultListener() {

        @Override
        public void prompterClosed(int result) {
            if (result == 0 && check_state[0]) {
                RememberedDecisionsManager.setRemembered("searchsubs.dl.ftux", 1);
            }
            listener.prompterClosed(result);
        }
    });
}
Also used : SWTSkinCheckboxListener(com.biglybt.ui.swt.skin.SWTSkinCheckboxListener) SWTSkinObjectCheckbox(com.biglybt.ui.swt.skin.SWTSkinObjectCheckbox) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) Shell(org.eclipse.swt.widgets.Shell) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) VuzeMessageBox(com.biglybt.ui.swt.views.skin.VuzeMessageBox) SBC_SubscriptionResult(com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)

Example 13 with SWTSkinObjectContainer

use of com.biglybt.ui.swt.skin.SWTSkinObjectContainer in project BiglyBT by BiglySoftware.

the class SBC_SearchResultsView method initTable.

private void initTable(Composite control) {
    tv_subs_results = TableViewFactory.createTableViewSWT(SBC_SearchResult.class, TABLE_SR, TABLE_SR, new TableColumnCore[0], ColumnSearchSubResultName.COLUMN_ID, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    TableColumnManager tableManager = TableColumnManager.getInstance();
    tableManager.setDefaultColumnNames(TABLE_SR, new String[] { ColumnSearchSubResultType.COLUMN_ID, ColumnSearchSubResultName.COLUMN_ID, ColumnSearchSubResultActions.COLUMN_ID, ColumnSearchSubResultSize.COLUMN_ID, ColumnSearchSubResultSeedsPeers.COLUMN_ID, ColumnSearchSubResultRatings.COLUMN_ID, ColumnSearchSubResultAge.COLUMN_ID, ColumnSearchSubResultRank.COLUMN_ID, ColumnSearchSubResultCategory.COLUMN_ID, ColumnSearchResultSite.COLUMN_ID });
    tableManager.setDefaultSortColumnName(TABLE_SR, ColumnSearchSubResultRank.COLUMN_ID);
    if (txtFilter != null) {
        tv_subs_results.enableFilterCheck(txtFilter, this);
    }
    tv_subs_results.setRowDefaultHeight(COConfigurationManager.getIntParameter("Search Subs Row Height"));
    SWTSkinObject soSizeSlider = getSkinObject("table-size-slider");
    if (soSizeSlider instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer so = (SWTSkinObjectContainer) soSizeSlider;
        if (!tv_subs_results.enableSizeSlider(so.getComposite(), 16, 100)) {
            so.setVisible(false);
        }
    }
    table_parent = new Composite(control, SWT.NONE);
    table_parent.setLayoutData(Utils.getFilledFormData());
    GridLayout layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = layout.verticalSpacing = layout.horizontalSpacing = 0;
    table_parent.setLayout(layout);
    tv_subs_results.addSelectionListener(new TableSelectionListener() {

        @Override
        public void selected(TableRowCore[] _rows) {
            updateSelectedContent();
        }

        @Override
        public void mouseExit(TableRowCore row) {
        }

        @Override
        public void mouseEnter(TableRowCore row) {
        }

        @Override
        public void focusChanged(TableRowCore focus) {
            UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
            if (uiFunctions != null) {
                uiFunctions.refreshIconBar();
            }
        }

        @Override
        public void deselected(TableRowCore[] rows) {
            updateSelectedContent();
        }

        @Override
        public void defaultSelected(TableRowCore[] rows, int stateMask) {
            if (rows.length == 1) {
                SBC_SearchResult rc = (SBC_SearchResult) rows[0].getDataSource();
                downloadAction(rc);
            }
        }

        private void updateSelectedContent() {
            TableRowCore[] rows = tv_subs_results.getSelectedRows();
            ArrayList<ISelectedContent> valid = new ArrayList<>();
            last_selected_content.clear();
            for (int i = 0; i < rows.length; i++) {
                SBC_SearchResult rc = (SBC_SearchResult) rows[i].getDataSource();
                last_selected_content.add(rc);
                byte[] hash = rc.getHash();
                if (hash != null && hash.length > 0) {
                    SelectedContent sc = new SelectedContent(Base32.encode(hash), rc.getName());
                    sc.setDownloadInfo(new DownloadUrlInfo(getDownloadURI(rc)));
                    valid.add(sc);
                }
            }
            ISelectedContent[] sels = valid.toArray(new ISelectedContent[valid.size()]);
            SelectedContentManager.changeCurrentlySelectedContent("IconBarEnabler", sels, tv_subs_results);
            UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
            if (uiFunctions != null) {
                uiFunctions.refreshIconBar();
            }
        }
    }, false);
    tv_subs_results.addMenuFillListener(new TableViewSWTMenuFillListener() {

        @Override
        public void fillMenu(String sColumnName, Menu menu) {
            Object[] _related_content = tv_subs_results.getSelectedDataSources().toArray();
            final SBC_SearchResult[] results = new SBC_SearchResult[_related_content.length];
            System.arraycopy(_related_content, 0, results, 0, results.length);
            MenuItem item = new MenuItem(menu, SWT.PUSH);
            item.setText(MessageText.getString("label.copy.url.to.clip"));
            item.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    StringBuffer buffer = new StringBuffer(1024);
                    for (SBC_SearchResult result : results) {
                        if (buffer.length() > 0) {
                            buffer.append("\r\n");
                        }
                        buffer.append(getDownloadURI(result));
                    }
                    ClipboardCopy.copyToClipBoard(buffer.toString());
                }
            });
            item.setEnabled(results.length > 0);
            SearchSubsUtils.addMenu(results, menu);
            new MenuItem(menu, SWT.SEPARATOR);
            if (results.length == 1) {
                if (SearchSubsUtils.addMenu(results[0], menu)) {
                    new MenuItem(menu, SWT.SEPARATOR);
                }
            }
        }

        @Override
        public void addThisColumnSubMenu(String columnName, Menu menuThisColumn) {
        }
    });
    tv_subs_results.initialize(table_parent);
    control.layout(true);
}
Also used : DownloadUrlInfo(com.biglybt.ui.selectedcontent.DownloadUrlInfo) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) UIFunctions(com.biglybt.ui.UIFunctions) Menu(org.eclipse.swt.widgets.Menu) SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) Composite(org.eclipse.swt.widgets.Composite) MenuItem(org.eclipse.swt.widgets.MenuItem)

Example 14 with SWTSkinObjectContainer

use of com.biglybt.ui.swt.skin.SWTSkinObjectContainer in project BiglyBT by BiglySoftware.

the class SimplePluginInstallWindow method open.

public void open() {
    box = new VuzeMessageBox("", "", null, 0);
    box.setSubTitle(MessageText.getString(resource_prefix + ".subtitle"));
    box.addResourceBundle(SimplePluginInstallWindow.class, SkinPropertiesImpl.PATH_SKIN_DEFS, "skin3_dlg_register");
    box.setIconResource(resource_prefix + ".image");
    this.progressText = MessageText.getString(resource_prefix + ".description");
    box.setListener(new VuzeMessageBoxListener() {

        @Override
        public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
            SWTSkin skin = soExtra.getSkin();
            skin.createSkinObject("dlg.register.install", "dlg.register.install", soExtra);
            SWTSkinObjectContainer soProgressBar = (SWTSkinObjectContainer) skin.getSkinObject("progress-bar");
            if (soProgressBar != null) {
                progressBar = new ProgressBar(soProgressBar.getComposite(), SWT.HORIZONTAL);
                progressBar.setMinimum(0);
                progressBar.setMaximum(100);
                progressBar.setLayoutData(Utils.getFilledFormData());
            }
            soInstallPct = (SWTSkinObjectText) skin.getSkinObject("install-pct");
            soProgressText = (SWTSkinObjectText) skin.getSkinObject("progress-text");
            if (soProgressText != null && progressText != null) {
                soProgressText.setText(progressText);
            }
        }
    });
    box.open(new UserPrompterResultListener() {

        @Override
        public void prompterClosed(int result) {
            installer.setListener(null);
            try {
                installer.cancel();
            } catch (Exception e) {
                Debug.out(e);
            }
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) VuzeMessageBox(com.biglybt.ui.swt.views.skin.VuzeMessageBox) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) ProgressBar(org.eclipse.swt.widgets.ProgressBar)

Example 15 with SWTSkinObjectContainer

use of com.biglybt.ui.swt.skin.SWTSkinObjectContainer in project BiglyBT by BiglySoftware.

the class SBC_ActivityTableView method skinObjectInitialShow.

// @see SkinView#skinObjectInitialShow(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    skinObject.addListener(new SWTSkinObjectListener() {

        @Override
        public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
            if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
                SelectedContentManager.changeCurrentlySelectedContent(tableID, getCurrentlySelectedContent(), view);
            } else if (eventType == SWTSkinObjectListener.EVENT_HIDE) {
                SelectedContentManager.changeCurrentlySelectedContent(tableID, null, view);
            }
            return null;
        }
    });
    SWTSkinObject soParent = skinObject.getParent();
    Object data = soParent.getControl().getData("ViewMode");
    if (data instanceof Long) {
        viewMode = (int) ((Long) data).longValue();
    }
    boolean big = viewMode == SBC_ActivityView.MODE_BIGTABLE;
    tableID = big ? TableManager.TABLE_ACTIVITY_BIG : TableManager.TABLE_ACTIVITY;
    TableColumnCore[] columns = big ? TableColumnCreatorV3.createActivityBig(tableID) : TableColumnCreatorV3.createActivitySmall(tableID);
    view = TableViewFactory.createTableViewSWT(ActivitiesEntry.class, tableID, tableID, columns, "name", SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    view.setRowDefaultHeightEM(big ? 3 : 2);
    view.addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                removeSelected();
            } else if (e.keyCode == SWT.F5) {
                if ((e.stateMask & SWT.SHIFT) != 0) {
                    ActivitiesManager.resetRemovedEntries();
                }
                if ((e.stateMask & SWT.CONTROL) != 0) {
                    System.out.println("pull all vuze news entries");
                    ActivitiesManager.clearLastPullTimes();
                    ActivitiesManager.pullActivitiesNow(0, "^F5", true);
                } else {
                    System.out.println("pull latest vuze news entries");
                    ActivitiesManager.pullActivitiesNow(0, "F5", true);
                }
            }
        }
    });
    view.addSelectionListener(new TableSelectionAdapter() {

        // @see TableSelectionAdapter#selected(TableRowCore[])
        @Override
        public void selected(TableRowCore[] rows) {
            selectionChanged();
            for (int i = 0; i < rows.length; i++) {
                ActivitiesEntry entry = (ActivitiesEntry) rows[i].getDataSource(true);
                if (entry != null && !entry.isRead() && entry.canFlipRead()) {
                    entry.setRead(true);
                }
            }
        }

        @Override
        public void defaultSelected(TableRowCore[] rows, int stateMask) {
            if (rows.length == 1) {
                ActivitiesEntry ds = (ActivitiesEntry) rows[0].getDataSource();
                if (ds.getTypeID().equals(ActivitiesConstants.TYPEID_LOCALNEWS)) {
                    String[] actions = ds.getActions();
                    if (actions.length == 1) {
                        ds.invokeCallback(actions[0]);
                    }
                } else {
                    TorrentListViewsUtils.playOrStreamDataSource(ds, false);
                }
            }
        }

        @Override
        public void deselected(TableRowCore[] rows) {
            selectionChanged();
        }

        public void selectionChanged() {
            Utils.execSWTThread(new AERunnable() {

                @Override
                public void runSupport() {
                    ISelectedContent[] contents = getCurrentlySelectedContent();
                    if (soMain.isVisible()) {
                        SelectedContentManager.changeCurrentlySelectedContent(tableID, contents, view);
                    }
                }
            });
        }
    }, false);
    view.addLifeCycleListener(new TableLifeCycleListener() {

        @Override
        public void tableLifeCycleEventOccurred(TableView tv, int eventType, Map<String, Object> data) {
            switch(eventType) {
                case EVENT_TABLELIFECYCLE_INITIALIZED:
                    view.addDataSources(ActivitiesManager.getAllEntries().toArray(new ActivitiesEntry[0]));
                    ActivitiesManager.addListener(SBC_ActivityTableView.this);
                    break;
                case EVENT_TABLELIFECYCLE_DESTROYED:
                    ActivitiesManager.removeListener(SBC_ActivityTableView.this);
                    break;
            }
        }
    });
    SWTSkinObjectContainer soContents = new SWTSkinObjectContainer(skin, skin.getSkinProperties(), getUpdateUIName(), "", soMain);
    skin.layout();
    viewComposite = soContents.getComposite();
    viewComposite.setBackground(Colors.getSystemColor(viewComposite.getDisplay(), SWT.COLOR_WIDGET_BACKGROUND));
    viewComposite.setForeground(Colors.getSystemColor(viewComposite.getDisplay(), SWT.COLOR_WIDGET_FOREGROUND));
    viewComposite.setLayoutData(Utils.getFilledFormData());
    GridLayout gridLayout = new GridLayout();
    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
    viewComposite.setLayout(gridLayout);
    view.initialize(viewComposite);
    return null;
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) KeyEvent(org.eclipse.swt.events.KeyEvent) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) KeyListener(org.eclipse.swt.events.KeyListener)

Aggregations

SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)23 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)15 SWTSkin (com.biglybt.ui.swt.skin.SWTSkin)8 GridLayout (org.eclipse.swt.layout.GridLayout)8 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)4 VuzeMessageBox (com.biglybt.ui.swt.views.skin.VuzeMessageBox)4 VuzeMessageBoxListener (com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener)4 FormData (org.eclipse.swt.layout.FormData)4 GridData (org.eclipse.swt.layout.GridData)4 UISWTViewImpl (com.biglybt.ui.swt.pifimpl.UISWTViewImpl)3 SWTSkinObjectListener (com.biglybt.ui.swt.skin.SWTSkinObjectListener)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 ConfigurationParameterNotFoundException (com.biglybt.core.config.impl.ConfigurationParameterNotFoundException)2 TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)2 UIUpdatable (com.biglybt.ui.common.updater.UIUpdatable)2 UIUpdater (com.biglybt.ui.common.updater.UIUpdater)2 MdiEntryVitalityImage (com.biglybt.ui.mdi.MdiEntryVitalityImage)2 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)2 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2