Search in sources :

Example 31 with SWTSkinObject

use of com.biglybt.ui.swt.skin.SWTSkinObject 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 32 with SWTSkinObject

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

the class TopBarView method buildTopBarViews.

/**
 * @param skinObject
 *
 * @since 3.0.1.1
 */
public void buildTopBarViews() {
    // TODO actually use plugins..
    SWTSkinObject skinObject = skin.getSkinObject("topbar-plugins");
    if (skinObject == null) {
        return;
    }
    try {
        cPluginArea = (Composite) skinObject.getControl();
        final UIUpdatable updatable = new UIUpdatable() {

            @Override
            public void updateUI() {
                Object[] views = topbarViews.toArray();
                for (int i = 0; i < views.length; i++) {
                    try {
                        UISWTViewCore view = (UISWTViewCore) views[i];
                        if (view.getComposite().isVisible()) {
                            view.triggerEvent(UISWTViewEvent.TYPE_REFRESH, null);
                        }
                    } catch (Exception e) {
                        Debug.out(e);
                    }
                }
            }

            @Override
            public String getUpdateUIName() {
                return "TopBar";
            }
        };
        try {
            UIUpdater updater = UIUpdaterSWT.getInstance();
            if (updater != null) {
                updater.addUpdater(updatable);
            }
        } catch (Exception e) {
            Debug.out(e);
        }
        skinObject.getControl().addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                try {
                    UIUpdater updater = UIUpdaterSWT.getInstance();
                    if (updater != null) {
                        updater.removeUpdater(updatable);
                    }
                } catch (Exception ex) {
                    Debug.out(ex);
                }
                Object[] views = topbarViews.toArray();
                topbarViews.clear();
                for (int i = 0; i < views.length; i++) {
                    UISWTViewCore view = (UISWTViewCore) views[i];
                    if (view != null) {
                        view.triggerEvent(UISWTViewEvent.TYPE_DESTROY, null);
                    }
                }
            }
        });
        /*
			SWTSkinObject soPrev = skin.getSkinObject("topbar-plugin-prev");
			if (soPrev != null) {
				SWTSkinButtonUtility btnPrev = new SWTSkinButtonUtility(soPrev);
				btnPrev.addSelectionListener(new ButtonListenerAdapter() {
					public void pressed(SWTSkinButtonUtility buttonUtility,
							SWTSkinObject skinObject, int stateMask) {
						//System.out.println("prev click " + activeTopBar + " ; "
						//		+ topbarViews.size());
						if (activeTopBar == null || topbarViews.size() <= 1) {
							return;
						}
						int i = topbarViews.indexOf(activeTopBar) - 1;
						if (i < 0) {
							i = topbarViews.size() - 1;
						}
						activateTopBar((UISWTViewCore) topbarViews.get(i));
					}
				});
			}

			SWTSkinObject soNext = skin.getSkinObject("topbar-plugin-next");
			if (soNext != null) {
				SWTSkinButtonUtility btnNext = new SWTSkinButtonUtility(soNext);
				btnNext.addSelectionListener(new ButtonListenerAdapter() {
					public void pressed(SWTSkinButtonUtility buttonUtility,
							SWTSkinObject skinObject, int stateMask) {
						//System.out.println("next click");
						if (activeTopBar == null || topbarViews.size() <= 1) {
							return;
						}
						int i = topbarViews.indexOf(activeTopBar) + 1;
						if (i >= topbarViews.size()) {
							i = 0;
						}
						activateTopBar((UISWTViewCore) topbarViews.get(i));
					}
				});
			}

			SWTSkinObject soTitle = skin.getSkinObject("topbar-plugin-title");
			if (soTitle != null) {
				final Composite cTitle = (Composite) soTitle.getControl();
				cTitle.addPaintListener(new PaintListener() {
					public void paintControl(PaintEvent e) {
						e.gc.setAdvanced(true);
						//Font font = new Font(e.gc.getDevice(), "Sans", 8, SWT.NORMAL);
						//e.gc.setFont(font);
						if (e.gc.getAdvanced() && activeTopBar != null) {
							try {
								e.gc.setTextAntialias(SWT.ON);
							} catch (Exception ex) {
								// Ignore ERROR_NO_GRAPHICS_LIBRARY error or any others
							}

							try {
								Transform transform = new Transform(e.gc.getDevice());
								transform.rotate(270);
								e.gc.setTransform(transform);

								String s = activeTopBar.getFullTitle();
								Point size = e.gc.textExtent(s);
								e.gc.drawText(s, -size.x, 0, true);
								//e.gc.drawText(s, 0,0, true);
								transform.dispose();
							} catch (Exception ex) {
								// setTransform can trhow a ERROR_NO_GRAPHICS_LIBRARY error
								// no use trying to draw.. it would look weird
							}
							//font.dispose();
						}
					}
				});
			}
			*/
        SWTSkinObject soList = skin.getSkinObject("topbar-plugin-list");
        if (soList != null) {
            final Composite cList = (Composite) soList.getControl();
            listPlugins = new org.eclipse.swt.widgets.List(cList, SWT.V_SCROLL);
            listPlugins.setLayoutData(Utils.getFilledFormData());
            listPlugins.setBackground(cList.getBackground());
            listPlugins.setForeground(cList.getForeground());
            listPlugins.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String[] selection = listPlugins.getSelection();
                    if (selection.length > 0) {
                        String name = selection[0];
                        for (UISWTViewCore view : topbarViews) {
                            if (getViewName(view).equals(name)) {
                                activateTopBar(view);
                            }
                        }
                    }
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            Messages.setLanguageTooltip(listPlugins, "label.right.click.for.options.tooltip");
            final Menu menu = new Menu(listPlugins);
            listPlugins.setMenu(menu);
            menu.addMenuListener(new MenuListener() {

                @Override
                public void menuShown(MenuEvent e) {
                    for (MenuItem mi : menu.getItems()) {
                        mi.dispose();
                    }
                    for (final UISWTViewCore view : topbarViews) {
                        final String name = getViewName(view);
                        final MenuItem mi = new MenuItem(menu, SWT.CHECK);
                        mi.setText(name);
                        boolean enabled = isEnabled(view);
                        mi.setSelection(enabled);
                        mi.addSelectionListener(new SelectionAdapter() {

                            @Override
                            public void widgetSelected(SelectionEvent e) {
                                boolean enabled = mi.getSelection();
                                setEnabled(view, enabled);
                                if (enabled) {
                                    activateTopBar(view);
                                } else {
                                    listPlugins.remove(name);
                                    activateTopBar(null);
                                }
                                Utils.relayout(cPluginArea);
                            }
                        });
                    }
                }

                @Override
                public void menuHidden(MenuEvent e) {
                }
            });
        }
        skinObject = skin.getSkinObject(SkinConstants.VIEWID_PLUGINBAR);
        if (skinObject != null) {
            Listener l = new Listener() {

                private int mouseDownAt = 0;

                @Override
                public void handleEvent(Event event) {
                    Composite c = (Composite) event.widget;
                    if (event.type == SWT.MouseDown) {
                        Rectangle clientArea = c.getClientArea();
                        if (event.y > clientArea.height - 10) {
                            mouseDownAt = event.y;
                        }
                    } else if (event.type == SWT.MouseUp && mouseDownAt > 0) {
                        int diff = event.y - mouseDownAt;
                        mouseDownAt = 0;
                        FormData formData = (FormData) c.getLayoutData();
                        formData.height += diff;
                        if (formData.height < 50) {
                            formData.height = 50;
                        } else {
                            Rectangle clientArea = c.getShell().getClientArea();
                            int max = clientArea.height - 350;
                            if (formData.height > max) {
                                formData.height = max;
                            }
                        }
                        COConfigurationManager.setParameter("v3.topbar.height", formData.height);
                        Utils.relayout(c);
                    } else if (event.type == SWT.MouseMove) {
                        Rectangle clientArea = c.getClientArea();
                        boolean draggable = (event.y > clientArea.height - 10);
                        c.setCursor(draggable ? c.getDisplay().getSystemCursor(SWT.CURSOR_SIZENS) : null);
                    } else if (event.type == SWT.MouseExit) {
                        c.setCursor(null);
                    }
                }
            };
            Control control = skinObject.getControl();
            control.addListener(SWT.MouseDown, l);
            control.addListener(SWT.MouseUp, l);
            control.addListener(SWT.MouseMove, l);
            control.addListener(SWT.MouseExit, l);
            skinObject.addListener(new SWTSkinObjectListener() {

                @Override
                public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
                    if (eventType == EVENT_SHOW) {
                        int h = COConfigurationManager.getIntParameter("v3.topbar.height");
                        Control control = skinObject.getControl();
                        FormData formData = (FormData) control.getLayoutData();
                        formData.height = h;
                        control.setLayoutData(formData);
                        Utils.relayout(control);
                    }
                    return null;
                }
            });
        }
        UISWTInstanceImpl uiSWTinstance = (UISWTInstanceImpl) UIFunctionsManagerSWT.getUIFunctionsSWT().getUISWTInstance();
        if (uiSWTinstance != null && !registeredCoreSubViews) {
            uiSWTinstance.addView(UISWTInstance.VIEW_TOPBAR, "ViewDownSpeedGraph", new ViewDownSpeedGraph());
            uiSWTinstance.addView(UISWTInstance.VIEW_TOPBAR, "ViewUpSpeedGraph", new ViewUpSpeedGraph());
            uiSWTinstance.addView(UISWTInstance.VIEW_TOPBAR, "ViewQuickConfig", new ViewQuickConfig());
            uiSWTinstance.addView(UISWTInstance.VIEW_TOPBAR, "ViewQuickNetInfo", new ViewQuickNetInfo());
            uiSWTinstance.addView(UISWTInstance.VIEW_TOPBAR, "ViewQuickNotifications", new ViewQuickNotifications());
            registeredCoreSubViews = true;
        }
        if (uiSWTinstance != null) {
            UISWTViewEventListenerHolder[] pluginViews = uiSWTinstance.getViewListeners(UISWTInstance.VIEW_TOPBAR);
            for (UISWTViewEventListenerHolder l : pluginViews) {
                if (l != null) {
                    try {
                        UISWTViewImpl view = new UISWTViewImpl(l.getViewID(), UISWTInstance.VIEW_TOPBAR, false);
                        view.setEventListener(l, true);
                        addTopBarView(view, cPluginArea);
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            }
        }
        String active_view_id = COConfigurationManager.getStringParameter("topbar.active.view.id", "");
        boolean activated = false;
        UISWTViewCore first_enabled = null;
        for (UISWTViewCore view : topbarViews) {
            if (isEnabled(view)) {
                if (first_enabled == null) {
                    first_enabled = view;
                }
                if (active_view_id.equals(view.getViewID())) {
                    activateTopBar(view);
                    activated = true;
                    break;
                }
            }
        }
        if (!activated && first_enabled != null) {
            activateTopBar(first_enabled);
            activated = true;
        }
        if (!activated && topbarViews.size() > 0) {
            UISWTViewCore view = topbarViews.get(0);
            setEnabled(view, true);
            activateTopBar(view);
        }
        if (skinObject != null) {
            skinObject.getControl().getParent().layout(true);
        }
    } catch (Throwable e) {
        Debug.out(e);
    }
}
Also used : SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) Rectangle(org.eclipse.swt.graphics.Rectangle) SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) org.eclipse.swt.widgets(org.eclipse.swt.widgets) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UIUpdatable(com.biglybt.ui.common.updater.UIUpdatable) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UIUpdater(com.biglybt.ui.common.updater.UIUpdater)

Example 33 with SWTSkinObject

use of com.biglybt.ui.swt.skin.SWTSkinObject 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 34 with SWTSkinObject

use of com.biglybt.ui.swt.skin.SWTSkinObject 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)

Example 35 with SWTSkinObject

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

the class SBC_ActivityView method setViewMode.

public void setViewMode(int viewMode, boolean save) {
    if (viewMode >= modeViewIDs.length || viewMode < 0) {
        viewMode = MODE_DEFAULT;
    }
    if (viewMode == this.viewMode) {
        return;
    }
    int oldViewMode = this.viewMode;
    this.viewMode = viewMode;
    soListArea = getSkinObject(ID + "-area");
    soListArea.getControl().setData("ViewMode", new Long(viewMode));
    if (oldViewMode >= 0 && oldViewMode < modeViewIDs.length) {
        SWTSkinObject soOldViewArea = getSkinObject(modeViewIDs[oldViewMode]);
        if (soOldViewArea != null) {
            soOldViewArea.setVisible(false);
        }
    }
    SWTSkinObject soViewArea = getSkinObject(modeViewIDs[viewMode]);
    if (soViewArea == null) {
        soViewArea = skin.createSkinObject(modeIDs[viewMode], modeIDs[viewMode], soListArea);
        skin.layout();
        soViewArea.setVisible(true);
        soViewArea.getControl().setLayoutData(Utils.getFilledFormData());
    } else {
        soViewArea.setVisible(true);
    }
    if (btnSmallTable != null) {
        btnSmallTable.getSkinObject().switchSuffix(viewMode == MODE_SMALLTABLE ? "-selected" : "");
    }
    if (btnBigTable != null) {
        btnBigTable.getSkinObject().switchSuffix(viewMode == MODE_BIGTABLE ? "-selected" : "");
    }
    if (save) {
        COConfigurationManager.setParameter(ID + ".viewmode", viewMode);
    }
    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
    MdiEntry entry = mdi.getEntry(SideBar.SIDEBAR_SECTION_ACTIVITIES);
    if (entry != null) {
        entry.setLogID(SideBar.SIDEBAR_SECTION_ACTIVITIES + "-" + viewMode);
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Aggregations

SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)53 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)15 GridLayout (org.eclipse.swt.layout.GridLayout)8 SWTSkinObjectListener (com.biglybt.ui.swt.skin.SWTSkinObjectListener)7 SWTSkinButtonUtility (com.biglybt.ui.swt.skin.SWTSkinButtonUtility)5 SWTSkinObjectText (com.biglybt.ui.swt.skin.SWTSkinObjectText)5 SWTSkinObjectTextbox (com.biglybt.ui.swt.skin.SWTSkinObjectTextbox)5 GridData (org.eclipse.swt.layout.GridData)5 CoreRunningListener (com.biglybt.core.CoreRunningListener)4 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)4 FormAttachment (org.eclipse.swt.layout.FormAttachment)4 FormData (org.eclipse.swt.layout.FormData)4 Core (com.biglybt.core.Core)3 ToolBarItem (com.biglybt.ui.common.ToolBarItem)3 UIUpdatable (com.biglybt.ui.common.updater.UIUpdatable)3 UIUpdater (com.biglybt.ui.common.updater.UIUpdater)3 MdiEntry (com.biglybt.ui.mdi.MdiEntry)3 PluginUISWTSkinObject (com.biglybt.ui.swt.pif.PluginUISWTSkinObject)3 Control (org.eclipse.swt.widgets.Control)3 ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)2