Search in sources :

Example 41 with SWTSkinObject

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

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

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

the class SideBarEntrySWT method setToolbarVisibility.

// @see BaseMdiEntry#setToolbarVisibility(boolean)
@Override
protected void setToolbarVisibility(boolean visible) {
    if (toolBarInfoBar != null) {
        if (visible) {
            toolBarInfoBar.show();
        } else {
            toolBarInfoBar.hide(false);
        }
        return;
    }
    SWTSkinObject soMaster = getSkinObjectMaster();
    if (soMaster == null) {
        return;
    }
    SWTSkinObject so = getSkinObject();
    if (so == null) {
        return;
    }
    SWTSkinObject soToolbar = skin.getSkinObject(SkinConstants.VIEWID_VIEW_TOOLBAR, soMaster);
    if (soToolbar == null && visible) {
        toolBarInfoBar = new InfoBarUtil(so, SO_ID_TOOLBAR, true, "", "") {

            @Override
            public boolean allowShow() {
                return true;
            }
        };
    } else if (soToolbar != null) {
        soToolbar.setVisible(visible);
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) InfoBarUtil(com.biglybt.ui.swt.views.skin.InfoBarUtil)

Example 44 with SWTSkinObject

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

the class SBC_LibraryView method setupView.

private void setupView(Core core, SWTSkinObject skinObject) {
    torrentFilter = skinObject.getSkinObjectID();
    if (torrentFilter.equalsIgnoreCase(SideBar.SIDEBAR_SECTION_LIBRARY_DL)) {
        torrentFilterMode = TORRENTS_INCOMPLETE;
    } else if (torrentFilter.equalsIgnoreCase(SideBar.SIDEBAR_SECTION_LIBRARY_CD)) {
        torrentFilterMode = TORRENTS_COMPLETE;
    } else if (torrentFilter.equalsIgnoreCase(SideBar.SIDEBAR_SECTION_LIBRARY_UNOPENED)) {
        torrentFilterMode = TORRENTS_UNOPENED;
    }
    if (datasource instanceof Tag) {
        Tag tag = (Tag) datasource;
        TagType tagType = tag.getTagType();
        if (tagType.getTagType() == TagType.TT_DOWNLOAD_STATE) {
            // see GlobalManagerImp.tag_*
            int tagID = tag.getTagID();
            if (tagID == 1 || tagID == 3 || tagID == 11) {
                torrentFilterMode = TORRENTS_INCOMPLETE;
            } else if (tagID == 2 || tagID == 4 || tagID == 10) {
                torrentFilterMode = TORRENTS_COMPLETE;
            }
        }
    }
    soListArea = getSkinObject(ID + "-area");
    soListArea.getControl().setData("TorrentFilterMode", new Long(torrentFilterMode));
    soListArea.getControl().setData("DataSource", datasource);
    setViewMode(COConfigurationManager.getIntParameter(torrentFilter + ".viewmode"), false);
    SWTSkinObject so;
    so = getSkinObject(ID + "-button-smalltable");
    if (so != null) {
        btnSmallTable = new SWTSkinButtonUtility(so);
        btnSmallTable.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                setViewMode(MODE_SMALLTABLE, true);
            }
        });
    }
    so = getSkinObject(ID + "-button-bigtable");
    if (so != null) {
        btnBigTable = new SWTSkinButtonUtility(so);
        btnBigTable.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                setViewMode(MODE_BIGTABLE, true);
            }
        });
    }
    SB_Transfers sb_t = MainMDISetup.getSb_transfers();
    if (sb_t != null) {
        sb_t.setupViewTitleWithCore(core);
    }
}
Also used : TagType(com.biglybt.core.tag.TagType) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinButtonUtility(com.biglybt.ui.swt.skin.SWTSkinButtonUtility) Tag(com.biglybt.core.tag.Tag) Point(org.eclipse.swt.graphics.Point)

Example 45 with SWTSkinObject

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

the class SkinViewManager method remove.

public static void remove(SkinView skinView) {
    if (skinView == null) {
        return;
    }
    mon_skinViews.enter();
    try {
        List<SkinView> list = mapSkinViews.get(skinView.getClass());
        if (list != null) {
            list.remove(skinView);
            if (list.isEmpty()) {
                mapSkinViews.remove(skinView.getClass());
            }
        }
    } finally {
        mon_skinViews.exit();
    }
    SWTSkinObject mainSkinObject = skinView.getMainSkinObject();
    if (mainSkinObject != null) {
        skinIDs.remove(mainSkinObject.getSkinObjectID());
        skinViewIDs.remove(mainSkinObject.getViewID());
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

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