Search in sources :

Example 1 with UISWTViewImpl

use of com.biglybt.ui.swt.pifimpl.UISWTViewImpl in project BiglyBT by BiglySoftware.

the class UIFunctionsImpl method closePluginView.

/* (non-Javadoc)
	 * @see UIFunctionsSWT#closePluginView(com.biglybt.ui.swt.pifimpl.UISWTViewCore)
	 */
@Override
public void closePluginView(UISWTViewCore view) {
    try {
        MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
        if (mdi == null) {
            return;
        }
        String id;
        if (view instanceof UISWTViewImpl) {
            id = ((UISWTViewImpl) view).getViewID();
        } else {
            id = view.getClass().getName();
            int i = id.lastIndexOf('.');
            if (i > 0) {
                id = id.substring(i + 1);
            }
        }
        mdi.closeEntry(id);
    } catch (Exception e) {
        Logger.log(new LogEvent(LOGID, "closePluginView", e));
    }
}
Also used : UISWTViewImpl(com.biglybt.ui.swt.pifimpl.UISWTViewImpl) LogEvent(com.biglybt.core.logging.LogEvent) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) Point(org.eclipse.swt.graphics.Point)

Example 2 with UISWTViewImpl

use of com.biglybt.ui.swt.pifimpl.UISWTViewImpl in project BiglyBT by BiglySoftware.

the class TabbedEntry method buildStandAlone.

public static SWTSkinObjectContainer buildStandAlone(SWTSkinObjectContainer soParent, String skinRef, SWTSkin skin, String parentID, String id, Object datasource, int controlType, CTabItem 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 = listener_is_new ? original_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;
                    }
                });
                // 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) HashMap(java.util.HashMap) SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) Cursor(org.eclipse.swt.graphics.Cursor) Image(org.eclipse.swt.graphics.Image) 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) Point(org.eclipse.swt.graphics.Point) 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) HashMap(java.util.HashMap) Map(java.util.Map) UISWTViewCoreEventListenerEx(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListenerEx) IViewRequiresPeriodicUpdates(com.biglybt.ui.swt.views.IViewRequiresPeriodicUpdates)

Example 3 with UISWTViewImpl

use of com.biglybt.ui.swt.pifimpl.UISWTViewImpl in project BiglyBT by BiglySoftware.

the class ConfigShell method swt_open.

public void swt_open(String section) {
    if (null != shell && !shell.isDisposed()) {
        configView.selectSection(section, true);
        if (shell.getMinimized()) {
            shell.setMinimized(false);
        }
        shell.forceActive();
        shell.forceFocus();
    } else {
        shell = ShellFactory.createMainShell(SWT.SHELL_TRIM & ~SWT.MIN);
        shell.setLayout(new GridLayout());
        shell.setText(MessageText.getString("ConfigView.title.full"));
        Utils.setShellIcon(shell);
        configView = new ConfigView();
        try {
            swtView = new UISWTViewImpl("ConfigView", null, false);
            swtView.setDatasource(section);
            swtView.setEventListener(configView, true);
        } catch (Exception e1) {
            Debug.out(e1);
        }
        swtView.initialize(shell);
        configView.selectSection(section, true);
        /*
			 * Set default size and centers the shell if it's configuration does not exist yet
			 */
        if (null == COConfigurationManager.getStringParameter("options.rectangle", null)) {
            Rectangle shellBounds = shell.getMonitor().getBounds();
            Point size = new Point(shellBounds.width * 10 / 11, shellBounds.height * 10 / 11);
            if (size.x > 1400) {
                size.x = 1400;
            }
            if (size.y > 700) {
                size.y = 700;
            }
            shell.setSize(size);
            Utils.centerWindowRelativeTo(shell, getMainShell());
        }
        Utils.linkShellMetricsToConfig(shell, "options");
        /*
			 * Auto-save when the shell closes
			 */
        shell.addListener(SWT.Close, new Listener() {

            @Override
            public void handleEvent(Event event) {
                configView.save();
                event.doit = true;
            }
        });
        shell.addTraverseListener(new TraverseListener() {

            @Override
            public void keyTraversed(TraverseEvent e) {
                if (e.detail == SWT.TRAVERSE_ESCAPE) {
                    shell.dispose();
                }
            }
        });
        shell.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent arg0) {
                close();
            }
        });
        shell.open();
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) TraverseListener(org.eclipse.swt.events.TraverseListener) Listener(org.eclipse.swt.widgets.Listener) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) UISWTViewImpl(com.biglybt.ui.swt.pifimpl.UISWTViewImpl) TraverseEvent(org.eclipse.swt.events.TraverseEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Event(org.eclipse.swt.widgets.Event) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent)

Example 4 with UISWTViewImpl

use of com.biglybt.ui.swt.pifimpl.UISWTViewImpl in project BiglyBT by BiglySoftware.

the class MyTorrentsSuperView method createTorrentView.

/**
 * Returns an instance of <code>MyTorrentsView</code>
 * Subclasses my override to return a different instance of MyTorrentsView
 * @param _core
 * @param isSeedingView
 * @param columns
 * @param c
 * @return
 */
protected MyTorrentsView createTorrentView(Core _core, String tableID, boolean isSeedingView, TableColumnCore[] columns, Composite c) {
    MyTorrentsView view = new MyTorrentsView(_core, tableID, isSeedingView, columns, txtFilter, cCats, isSeedingView);
    try {
        UISWTViewImpl swtView = new UISWTViewImpl(tableID, UISWTInstance.VIEW_MAIN, false);
        swtView.setDatasource(ds);
        swtView.setEventListener(view, true);
        swtView.setDelayInitializeToFirstActivate(false);
        swtView.initialize(c);
    } catch (Exception e) {
        Debug.out(e);
    }
    /*
		c.addListener(SWT.Activate, new Listener() {
			public void handleEvent(Event event) {
				viewActivated();
			}
		});
		c.addListener(SWT.Deactivate, new Listener() {
			public void handleEvent(Event event) {
				viewDeactivated();
			}
		});
		*/
    c.layout();
    return view;
}
Also used : UISWTViewImpl(com.biglybt.ui.swt.pifimpl.UISWTViewImpl)

Example 5 with UISWTViewImpl

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

Aggregations

UISWTViewImpl (com.biglybt.ui.swt.pifimpl.UISWTViewImpl)7 GridLayout (org.eclipse.swt.layout.GridLayout)4 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)3 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)3 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)3 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)3 DisposeEvent (org.eclipse.swt.events.DisposeEvent)3 DisposeListener (org.eclipse.swt.events.DisposeListener)3 Point (org.eclipse.swt.graphics.Point)3 UIUpdatable (com.biglybt.ui.common.updater.UIUpdatable)2 UIUpdater (com.biglybt.ui.common.updater.UIUpdater)2 MdiEntryVitalityImage (com.biglybt.ui.mdi.MdiEntryVitalityImage)2 ObfuscateImage (com.biglybt.ui.swt.debug.ObfuscateImage)2 UISWTViewEventListenerEx (com.biglybt.ui.swt.pif.UISWTViewEventListenerEx)2 UISWTViewCoreEventListenerEx (com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListenerEx)2 SWTSkinObjectListener (com.biglybt.ui.swt.skin.SWTSkinObjectListener)2 IViewRequiresPeriodicUpdates (com.biglybt.ui.swt.views.IViewRequiresPeriodicUpdates)2 GridData (org.eclipse.swt.layout.GridData)2 DownloadManager (com.biglybt.core.download.DownloadManager)1 LogEvent (com.biglybt.core.logging.LogEvent)1