Search in sources :

Example 16 with SWTSkinObjectContainer

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

the class SBC_LibraryTableView method initShow.

public void initShow(Core core) {
    Object data = soParent.getControl().getData("TorrentFilterMode");
    if (data instanceof Long) {
        torrentFilterMode = (int) ((Long) data).longValue();
    }
    data = soParent.getControl().getData("DataSource");
    boolean useBigTable = useBigTable();
    SWTSkinObjectTextbox soFilter = (SWTSkinObjectTextbox) skin.getSkinObject("library-filter", soParent.getParent());
    Text txtFilter = soFilter == null ? null : soFilter.getTextControl();
    SWTSkinObjectContainer soCats = (SWTSkinObjectContainer) skin.getSkinObject("library-categories", soParent.getParent());
    Composite cCats = soCats == null ? null : soCats.getComposite();
    // columns not needed for small mode, all torrents
    TableColumnCore[] columns = useBigTable || torrentFilterMode != SBC_LibraryView.TORRENTS_ALL ? getColumns() : null;
    if (null != columns) {
        TableColumnManager tcManager = TableColumnManager.getInstance();
        tcManager.addColumns(columns);
    }
    if (useBigTable) {
        if (torrentFilterMode == SBC_LibraryView.TORRENTS_COMPLETE || torrentFilterMode == SBC_LibraryView.TORRENTS_INCOMPLETE || torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
            swtViewListener = torrentView = new MyTorrentsView_Big(core, torrentFilterMode, columns, txtFilter, cCats);
        } else {
            swtViewListener = torrentView = new MyTorrentsView_Big(core, torrentFilterMode, columns, txtFilter, cCats);
        }
    } else {
        String tableID = SB_Transfers.getTableIdFromFilterMode(torrentFilterMode, false);
        if (torrentFilterMode == SBC_LibraryView.TORRENTS_COMPLETE) {
            swtViewListener = torrentView = new MyTorrentsView(core, tableID, true, columns, txtFilter, cCats, true);
        } else if (torrentFilterMode == SBC_LibraryView.TORRENTS_INCOMPLETE) {
            swtViewListener = torrentView = new MyTorrentsView(core, tableID, false, columns, txtFilter, cCats, true);
        } else if (torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
            swtViewListener = torrentView = new MyTorrentsView(core, tableID, true, columns, txtFilter, cCats, true) {

                @Override
                public boolean isOurDownloadManager(DownloadManager dm) {
                    if (PlatformTorrentUtils.getHasBeenOpened(dm)) {
                        return false;
                    }
                    return super.isOurDownloadManager(dm);
                }
            };
        } else {
            swtViewListener = new MyTorrentsSuperView(txtFilter, cCats) {

                @Override
                public void initializeDone() {
                    MyTorrentsView seedingview = getSeedingview();
                    if (seedingview != null) {
                        seedingview.overrideDefaultSelected(new TableSelectionAdapter() {

                            @Override
                            public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
                                doDefaultClick(rows, stateMask, false, origin);
                            }
                        });
                        MyTorrentsView torrentview = getTorrentview();
                        if (torrentview != null) {
                            torrentview.overrideDefaultSelected(new TableSelectionAdapter() {

                                @Override
                                public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
                                    doDefaultClick(rows, stateMask, false, origin);
                                }
                            });
                        }
                    }
                }
            };
        }
        if (torrentView != null) {
            torrentView.overrideDefaultSelected(new TableSelectionAdapter() {

                @Override
                public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
                    doDefaultClick(rows, stateMask, false, origin);
                }
            });
        }
    }
    if (torrentView != null) {
        tv = torrentView.getTableView();
        if (torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
            torrentView.setRebuildListOnFocusGain(true);
        }
    }
    try {
        view = new UISWTViewImpl(ID + torrentFilterMode, UISWTInstance.VIEW_MAIN, false);
        view.setDatasource(data);
        view.setEventListener(swtViewListener, true);
    } catch (Exception e) {
        Debug.out(e);
    }
    SWTSkinObjectContainer soContents = new SWTSkinObjectContainer(skin, skin.getSkinProperties(), getUpdateUIName(), "", soMain);
    skin.layout();
    viewComposite = soContents.getComposite();
    viewComposite.setLayoutData(Utils.getFilledFormData());
    GridLayout gridLayout = new GridLayout();
    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
    viewComposite.setLayout(gridLayout);
    view.initialize(viewComposite);
    SWTSkinObject soSizeSlider = skin.getSkinObject("table-size-slider", soParent.getParent());
    if (soSizeSlider instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer so = (SWTSkinObjectContainer) soSizeSlider;
        if (tv != null && !tv.enableSizeSlider(so.getComposite(), 16, 100)) {
            so.setVisible(false);
        }
    }
    if (torrentFilterMode == SBC_LibraryView.TORRENTS_ALL && tv != null) {
        tv.addRefreshListener(new TableRowRefreshListener() {

            @Override
            public void rowRefresh(TableRow row) {
                TableRowSWT rowCore = (TableRowSWT) row;
                Object ds = rowCore.getDataSource(true);
                if (!(ds instanceof DownloadManager)) {
                    return;
                }
                DownloadManager dm = (DownloadManager) ds;
                boolean changed = false;
                boolean assumedComplete = dm.getAssumedComplete();
                if (!assumedComplete) {
                    changed |= rowCore.setAlpha(160);
                } else if (!PlatformTorrentUtils.getHasBeenOpened(dm)) {
                    changed |= rowCore.setAlpha(255);
                } else {
                    changed |= rowCore.setAlpha(255);
                }
            }
        });
    }
    viewComposite.getParent().layout(true);
}
Also used : TableSelectionAdapter(com.biglybt.ui.common.table.TableSelectionAdapter) TableRowSWT(com.biglybt.ui.swt.views.table.TableRowSWT) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) DownloadManager(com.biglybt.core.download.DownloadManager) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) TableRowCore(com.biglybt.ui.common.table.TableRowCore) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) SWTSkinObjectTextbox(com.biglybt.ui.swt.skin.SWTSkinObjectTextbox) MyTorrentsSuperView(com.biglybt.ui.swt.views.MyTorrentsSuperView) Composite(org.eclipse.swt.widgets.Composite) TableRowRefreshListener(com.biglybt.pif.ui.tables.TableRowRefreshListener) Text(org.eclipse.swt.widgets.Text) MyTorrentsView(com.biglybt.ui.swt.views.MyTorrentsView) UISWTViewImpl(com.biglybt.ui.swt.pifimpl.UISWTViewImpl) TableRow(com.biglybt.pif.ui.tables.TableRow) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 17 with SWTSkinObjectContainer

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

the class SideBarEntrySWT method buildStandAlone.

public static SWTSkinObjectContainer buildStandAlone(SWTSkinObjectContainer soParent, String skinRef, SWTSkin skin, String parentID, String id, Object datasource, int controlType, TreeItem swtItem, UISWTViewEventListener original_event_listener, boolean listener_is_new) {
    Control control = null;
    // SWTSkin skin = soParent.getSkin();
    Composite parent = soParent.getComposite();
    if (skinRef != null) {
        Shell shell = parent.getShell();
        Cursor cursor = shell.getCursor();
        try {
            shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
            // wrap skinRef with a container that we control visibility of
            // (invisible by default)
            SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiContents." + uniqueNumber++, SO_ID_ENTRY_WRAPPER, soParent, null);
            SWTSkinObject skinObject = skin.createSkinObject(id, skinRef, soContents, datasource);
            control = skinObject.getControl();
            control.setLayoutData(Utils.getFilledFormData());
            control.getParent().layout(true, true);
            soContents.setVisible(true);
            return (soContents);
        } finally {
            shell.setCursor(cursor);
        }
    } else {
        if ((original_event_listener instanceof UISWTViewCoreEventListenerEx && ((UISWTViewCoreEventListenerEx) original_event_listener).isCloneable()) || (original_event_listener instanceof UISWTViewEventListenerEx)) {
            final UISWTViewImpl view = new UISWTViewImpl(id, parentID, true);
            final UISWTViewEventListener event_listener = original_event_listener instanceof UISWTViewEventListenerEx ? ((UISWTViewEventListenerEx) original_event_listener).getClone() : ((UISWTViewCoreEventListenerEx) original_event_listener).getClone();
            try {
                view.setEventListener(event_listener, false);
            } catch (Throwable e) {
                // shouldn't happen as we aren't asking for 'create' to occur which means it can't fail
                Debug.out(e);
            }
            view.setDatasource(datasource);
            try {
                SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiIView." + uniqueNumber++, SO_ID_ENTRY_WRAPPER, soParent);
                parent.setBackgroundMode(SWT.INHERIT_NONE);
                final Composite viewComposite = soContents.getComposite();
                boolean doGridLayout = true;
                if (controlType == CONTROLTYPE_SKINOBJECT) {
                    doGridLayout = false;
                }
                // SWT.COLOR_WIDGET_FOREGROUND));
                if (doGridLayout) {
                    GridLayout gridLayout = new GridLayout();
                    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
                    viewComposite.setLayout(gridLayout);
                    viewComposite.setLayoutData(Utils.getFilledFormData());
                }
                view.setPluginSkinObject(soContents);
                view.initialize(viewComposite);
                // without this some views get messed up layouts (chat view for example)
                viewComposite.setData(Utils.RELAYOUT_UP_STOP_HERE, true);
                soContents.addListener(new SWTSkinObjectListener() {

                    @Override
                    public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
                        if (eventType == SWTSkinObjectListener.EVENT_OBFUSCATE) {
                            Map data = new HashMap();
                            data.put("image", (Image) params);
                            data.put("obfuscateTitle", false);
                            view.triggerEvent(UISWTViewEvent.TYPE_OBFUSCATE, data);
                        }
                        return null;
                    }
                });
                if (PAINT_BG) {
                    if (swtItem != null) {
                        swtItem.setText(view.getFullTitle());
                    }
                }
                Composite iviewComposite = view.getComposite();
                control = iviewComposite;
                // that instead of form)
                if (doGridLayout) {
                    Object existingLayoutData = iviewComposite.getLayoutData();
                    Object existingParentLayoutData = iviewComposite.getParent().getLayoutData();
                    if (existingLayoutData == null || !(existingLayoutData instanceof GridData) && (existingParentLayoutData instanceof GridLayout)) {
                        GridData gridData = new GridData(GridData.FILL_BOTH);
                        iviewComposite.setLayoutData(gridData);
                    }
                }
                parent.layout(true, true);
                final UIUpdater updater = UIUpdaterSWT.getInstance();
                if (updater != null) {
                    updater.addUpdater(new UIUpdatable() {

                        @Override
                        public void updateUI() {
                            if (viewComposite.isDisposed()) {
                                updater.removeUpdater(this);
                            } else {
                                view.triggerEvent(UISWTViewEvent.TYPE_REFRESH, null);
                            }
                        }

                        @Override
                        public String getUpdateUIName() {
                            return ("popout");
                        }
                    });
                    if (event_listener instanceof IViewRequiresPeriodicUpdates) {
                        updater.addPeriodicUpdater(new UIUpdatable() {

                            @Override
                            public void updateUI() {
                                if (viewComposite.isDisposed()) {
                                    updater.removePeriodicUpdater(this);
                                } else {
                                    event_listener.eventOccurred(new UISWTViewEvent() {

                                        @Override
                                        public UISWTView getView() {
                                            return null;
                                        }

                                        @Override
                                        public int getType() {
                                            return (StatsView.EVENT_PERIODIC_UPDATE);
                                        }

                                        @Override
                                        public Object getData() {
                                            return null;
                                        }
                                    });
                                }
                            }

                            @Override
                            public String getUpdateUIName() {
                                return ("popout");
                            }
                        });
                    }
                }
                soContents.setVisible(true);
                view.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
                iviewComposite.addDisposeListener(new DisposeListener() {

                    @Override
                    public void widgetDisposed(DisposeEvent arg0) {
                        view.triggerEvent(UISWTViewEvent.TYPE_DESTROY, null);
                    }
                });
                return (soContents);
            } catch (Throwable e) {
                Debug.out(e);
            }
        }
    }
    return (null);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) MdiEntryVitalityImage(com.biglybt.ui.mdi.MdiEntryVitalityImage) ObfuscateImage(com.biglybt.ui.swt.debug.ObfuscateImage) DisposeEvent(org.eclipse.swt.events.DisposeEvent) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) UISWTViewEventListenerEx(com.biglybt.ui.swt.pif.UISWTViewEventListenerEx) UIUpdatable(com.biglybt.ui.common.updater.UIUpdatable) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener) UISWTViewImpl(com.biglybt.ui.swt.pifimpl.UISWTViewImpl) GridData(org.eclipse.swt.layout.GridData) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UIUpdater(com.biglybt.ui.common.updater.UIUpdater) UISWTViewCoreEventListenerEx(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListenerEx) IViewRequiresPeriodicUpdates(com.biglybt.ui.swt.views.IViewRequiresPeriodicUpdates)

Example 18 with SWTSkinObjectContainer

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

the class SideBarEntrySWT method swt_build.

public boolean swt_build() {
    if (swtItem == null) {
        buildonSWTItemSet = true;
        return true;
    }
    buildonSWTItemSet = false;
    if (getSkinObject() == null) {
        Control control = null;
        Composite parent = soParent == null ? Utils.findAnyShell() : soParent.getComposite();
        String skinRef = getSkinRef();
        if (skinRef != null) {
            Shell shell = parent.getShell();
            Cursor cursor = shell.getCursor();
            try {
                shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
                // wrap skinRef with a container that we control visibility of
                // (invisible by default)
                SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiContents." + uniqueNumber++, SO_ID_ENTRY_WRAPPER, getParentSkinObject(), null);
                SWTSkinObject skinObject = skin.createSkinObject(id, skinRef, soContents, getDatasourceCore());
                control = skinObject.getControl();
                control.setLayoutData(Utils.getFilledFormData());
                control.getParent().layout(true, true);
                setPluginSkinObject(skinObject);
                initialize((Composite) control);
                setSkinObjectMaster(soContents);
            } finally {
                shell.setCursor(cursor);
            }
        } else {
            // XXX: This needs to be merged into BaseMDIEntry.initialize
            try {
                SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiIView." + uniqueNumber++, SO_ID_ENTRY_WRAPPER, getParentSkinObject());
                parent.setBackgroundMode(SWT.INHERIT_NONE);
                Composite viewComposite = soContents.getComposite();
                boolean doGridLayout = true;
                if (getControlType() == CONTROLTYPE_SKINOBJECT) {
                    doGridLayout = false;
                }
                // SWT.COLOR_WIDGET_FOREGROUND));
                if (doGridLayout) {
                    GridLayout gridLayout = new GridLayout();
                    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
                    viewComposite.setLayout(gridLayout);
                    viewComposite.setLayoutData(Utils.getFilledFormData());
                }
                setPluginSkinObject(soContents);
                initialize(viewComposite);
                String fullTitle = getFullTitle();
                if (fullTitle != null && PAINT_BG) {
                    swtItem.setText(getFullTitle());
                }
                Composite iviewComposite = getComposite();
                control = iviewComposite;
                // that instead of form)
                if (doGridLayout) {
                    Object existingLayoutData = iviewComposite.getLayoutData();
                    Object existingParentLayoutData = iviewComposite.getParent().getLayoutData();
                    if (existingLayoutData == null || !(existingLayoutData instanceof GridData) && (existingParentLayoutData instanceof GridLayout)) {
                        GridData gridData = new GridData(GridData.FILL_BOTH);
                        iviewComposite.setLayoutData(gridData);
                    }
                }
                parent.layout(true, true);
                setSkinObjectMaster(soContents);
            } catch (Exception e) {
                Debug.out("Error creating sidebar content area for " + id, e);
                close(true);
            }
        }
        if (control != null && !control.isDisposed()) {
            control.setData("BaseMDIEntry", this);
            control.addDisposeListener(new DisposeListener() {

                @Override
                public void widgetDisposed(DisposeEvent e) {
                    close(true);
                }
            });
        } else {
            return false;
        }
    }
    return true;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) GridData(org.eclipse.swt.layout.GridData) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 19 with SWTSkinObjectContainer

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

the class ToolBarView method bulkSetupItems.

private void bulkSetupItems(String groupID, String templatePrefix) {
    String[] idsByGroupAll = tbm.getToolBarIDsByGroup(groupID);
    SWTSkinObjectContainer groupSO = peekGroupSO(groupID);
    if (groupSO != null) {
        SWTSkinObject[] children = groupSO.getChildren();
        for (SWTSkinObject so : children) {
            so.dispose();
        }
    }
    List<String> idsByGroup = new ArrayList<>();
    for (String id : idsByGroupAll) {
        if (visible_items.contains(id)) {
            idsByGroup.add(id);
        }
    }
    int size = idsByGroup.size();
    if (size > 0) {
        // only peeked above, create now as group is required
        groupSO = getGroupSO(groupID);
        for (int i = 0; i < size; i++) {
            String itemID = idsByGroup.get(i);
            UIToolBarItem item = tbm.getToolBarItem(itemID);
            if (item instanceof ToolBarItem) {
                int position = 0;
                if (size == 1) {
                    position = SWT.SINGLE;
                } else if (i == 0) {
                    position = SWT.LEFT;
                } else if (i == size - 1) {
                    addSeperator(groupID);
                    position = SWT.RIGHT;
                } else {
                    addSeperator(groupID);
                }
                createItemSO((ToolBarItem) item, templatePrefix, position);
            }
        }
        addNonToolBar("toolbar.area.sitem.left2", groupID);
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) ToolBarItem(com.biglybt.ui.common.ToolBarItem)

Example 20 with SWTSkinObjectContainer

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

the class ToolBarView method addSeperator.

private void addSeperator(String id, String groupID) {
    SWTSkinObjectContainer soGroup = getGroupSO(groupID);
    Control lastControl = getLastControl(groupID);
    SWTSkinObject so = skin.createSkinObject("toolbar_sep" + Math.random(), id, soGroup);
    if (so != null) {
        if (lastControl != null) {
            FormData fd = (FormData) so.getControl().getLayoutData();
            fd.left = new FormAttachment(lastControl, fd.left == null ? 0 : fd.left.offset);
        }
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) Control(org.eclipse.swt.widgets.Control) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) FormAttachment(org.eclipse.swt.layout.FormAttachment)

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