Search in sources :

Example 6 with SWTSkinObjectContainer

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

the class BaseMdiEntry method swt_hide.

protected void swt_hide() {
    SWTSkinObject skinObjectMaster = getSkinObjectMaster();
    if (skinObjectMaster instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer container = (SWTSkinObjectContainer) skinObjectMaster;
        Control oldComposite = container.getControl();
        container.setVisible(false);
        if (oldComposite != null && !oldComposite.isDisposed()) {
            oldComposite.getShell().update();
        }
    }
    Composite oldComposite = getComposite();
    if (oldComposite != null && !oldComposite.isDisposed()) {
        oldComposite.setVisible(false);
        oldComposite.getShell().update();
    }
    try {
        triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null);
    } catch (Exception e) {
        Debug.out(e);
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) ConfigurationParameterNotFoundException(com.biglybt.core.config.impl.ConfigurationParameterNotFoundException)

Example 7 with SWTSkinObjectContainer

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

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

the class TabbedEntry method swt_build.

public boolean swt_build() {
    if (swtItem == null) {
        buildonSWTItemSet = true;
        return true;
    }
    buildonSWTItemSet = false;
    Control control = swtItem.getControl();
    if (control == null || control.isDisposed()) {
        Composite parent = swtItem.getParent();
        if (parent.isDisposed()) {
            return false;
        }
        SWTSkinObject soParent = (SWTSkinObject) parent.getData("SkinObject");
        String skinRef = getSkinRef();
        if (skinRef != null) {
            Shell shell = parent.getShell();
            Cursor cursor = shell.getCursor();
            try {
                shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
                // SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject(
                // "MdiContents." + uniqueNumber++, "mdi.content.item",
                // soParent, getSkinRefParams());
                // skin.addSkinObject(soContents);
                SWTSkinObject skinObject = skin.createSkinObject(id, skinRef, soParent, getDatasourceCore());
                control = skinObject.getControl();
                control.setLayoutData(Utils.getFilledFormData());
                control.getParent().layout(true);
                // swtItem.setControl will set the control's visibility based on
                // whether the control is selected.  To ensure it doesn't set
                // our control invisible, set selection now
                CTabItem oldSelection = swtItem.getParent().getSelection();
                swtItem.getParent().setSelection(swtItem);
                swtItem.setControl(control);
                if (oldSelection != null) {
                    swtItem.getParent().setSelection(oldSelection);
                }
                setPluginSkinObject(skinObject);
                setSkinObjectMaster(skinObject);
                initialize((Composite) control);
            } finally {
                shell.setCursor(cursor);
            }
        } else {
            // XXX: This needs to be merged into BaseMDIEntry.initialize
            try {
                SWTSkinObjectContainer soContents = (SWTSkinObjectContainer) skin.createSkinObject("MdiIView." + uniqueNumber++, "mdi.content.item", soParent);
                parent.setBackgroundMode(SWT.INHERIT_NONE);
                Composite viewComposite = soContents.getComposite();
                // viewComposite.setBackground(Colors.getSystemColor(parent.getDisplay(), SWT.COLOR_WIDGET_BACKGROUND));
                // viewComposite.setForeground(Colors.getSystemColor(parent.getDisplay(), SWT.COLOR_WIDGET_FOREGROUND));
                boolean doGridLayout = true;
                if (getControlType() == CONTROLTYPE_SKINOBJECT) {
                    doGridLayout = false;
                }
                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);
                Composite iviewComposite = getComposite();
                control = iviewComposite;
                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);
                    }
                }
                CTabItem oldSelection = swtItem.getParent().getSelection();
                swtItem.getParent().setSelection(swtItem);
                swtItem.setControl(viewComposite);
                if (oldSelection != null) {
                    swtItem.getParent().setSelection(oldSelection);
                }
                setSkinObjectMaster(soContents);
            } catch (Exception e) {
                Debug.out("Error creating sidebar content area for " + id, e);
                try {
                    setEventListener(null, false);
                } catch (UISWTViewEventCancelledException e1) {
                }
                close(true);
            }
        }
        if (control != null && !control.isDisposed()) {
            control.setData("BaseMDIEntry", this);
        /**
         * XXX Removed this because we can dispose of the control and still
         * want the tab (ie. destroy on focus lost, rebuild on focus gain)
         *				control.addDisposeListener(new DisposeListener() {
         *					public void widgetDisposed(DisposeEvent e) {
         *						close(true);
         *					}
         *				});
         */
        } else {
            return false;
        }
    }
    return true;
}
Also used : UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException) Cursor(org.eclipse.swt.graphics.Cursor) CTabItem(org.eclipse.swt.custom.CTabItem) SWTException(org.eclipse.swt.SWTException) UISWTViewEventCancelledException(com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException) 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 9 with SWTSkinObjectContainer

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

the class PlayerInstallWindow method open.

public void open() {
    box = new VuzeMessageBox("", "", null, 0);
    box.setSubTitle(MessageText.getString("dlg.player.install.subtitle"));
    box.addResourceBundle(PlayerInstallWindow.class, SkinPropertiesImpl.PATH_SKIN_DEFS, "skin3_dlg_register");
    box.setIconResource("image.player.dlg.header");
    this.progressText = MessageText.getString("dlg.player.install.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);
            installer.cancel();
        }
    });
}
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 10 with SWTSkinObjectContainer

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

the class ManufacturerChooser method open.

public void open(ClosedListener l) {
    this.listener = l;
    skinnedDialog = new SkinnedDialog("skin3_dlg_deviceadd_mfchooser", "shell", SWT.TITLE | SWT.BORDER);
    skinnedDialog.addCloseListener(new SkinnedDialogClosedListener() {

        @Override
        public void skinDialogClosed(SkinnedDialog dialog) {
            if (listener != null) {
                listener.MfChooserClosed(chosenMF);
            }
        }
    });
    SWTSkin skin = skinnedDialog.getSkin();
    SWTSkinObject so = skin.getSkinObject("list");
    if (so instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer soList = (SWTSkinObjectContainer) so;
        Composite parent = soList.getComposite();
        Canvas centerCanvas = new Canvas(parent, SWT.NONE);
        FormData fd = Utils.getFilledFormData();
        fd.bottom = null;
        fd.height = 0;
        centerCanvas.setLayoutData(fd);
        Composite area = new Composite(parent, SWT.NONE);
        RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
        rowLayout.fill = true;
        Utils.setLayout(area, rowLayout);
        fd = Utils.getFilledFormData();
        fd.left = new FormAttachment(centerCanvas, 50, SWT.CENTER);
        fd.right = null;
        area.setLayoutData(fd);
        Listener btnListener = new Listener() {

            @Override
            public void handleEvent(Event event) {
                chosenMF = (DeviceManufacturer) event.widget.getData("mf");
                skinnedDialog.close();
            }
        };
        DeviceManager deviceManager = DeviceManagerFactory.getSingleton();
        DeviceManufacturer[] mfs = deviceManager.getDeviceManufacturers(Device.DT_MEDIA_RENDERER);
        for (DeviceManufacturer mf : mfs) {
            DeviceTemplate[] deviceTemplates = mf.getDeviceTemplates();
            boolean hasNonAuto = false;
            for (DeviceTemplate deviceTemplate : deviceTemplates) {
                if (!deviceTemplate.isAuto()) {
                    hasNonAuto = true;
                    break;
                }
            }
            if (!hasNonAuto) {
                continue;
            }
            Button button = new Button(area, SWT.PUSH);
            button.setText(mf.getName());
            button.setData("mf", mf);
            button.addListener(SWT.MouseUp, btnListener);
        }
    }
    skinnedDialog.getShell().pack();
    skinnedDialog.open();
}
Also used : FormData(org.eclipse.swt.layout.FormData) SkinnedDialogClosedListener(com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) RowLayout(org.eclipse.swt.layout.RowLayout) DeviceManufacturer(com.biglybt.core.devices.DeviceManager.DeviceManufacturer) SkinnedDialog(com.biglybt.ui.swt.views.skin.SkinnedDialog) SkinnedDialogClosedListener(com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener) 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