Search in sources :

Example 6 with UIUpdater

use of com.biglybt.ui.common.updater.UIUpdater in project BiglyBT by BiglySoftware.

the class MiniBarManager method register.

public void register(MiniBar bar) {
    shellManager.addWindow(bar.getShell());
    try {
        minibars_mon.enter();
        minibars.add(bar);
        if (!global) {
            global_instance.register(bar);
        }
    } finally {
        minibars_mon.exit();
    }
    if (minibars.size() == 1) {
        try {
            UIUpdater updater = UIUpdaterSWT.getInstance();
            if (updater != null) {
                updater.addUpdater(this);
            }
        } catch (Exception e) {
            Debug.out(e);
        }
    }
}
Also used : UIUpdater(com.biglybt.ui.common.updater.UIUpdater)

Example 7 with UIUpdater

use of com.biglybt.ui.common.updater.UIUpdater in project BiglyBT by BiglySoftware.

the class SideBar method skinObjectCreated.

// @see SWTSkinObjectAdapter#skinObjectCreated(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectCreated(SWTSkinObject skinObject, Object params) {
    super.skinObjectCreated(skinObject, params);
    skin = skinObject.getSkin();
    soSideBarContents = (SWTSkinObjectContainer) skin.getSkinObject("sidebar-contents");
    soSideBarList = skin.getSkinObject("sidebar-list");
    soSideBarPopout = skin.getSkinObject("sidebar-pop");
    SWTSkinObjectContainer soSideBarPluginsArea = (SWTSkinObjectContainer) skin.getSkinObject("sidebar-plugins");
    if (soSideBarPluginsArea != null) {
        Composite composite = soSideBarPluginsArea.getComposite();
        cPluginsArea = new Composite(composite, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.marginHeight = layout.marginWidth = 0;
        layout.verticalSpacing = layout.horizontalSpacing = 0;
        cPluginsArea.setLayout(layout);
        cPluginsArea.setLayoutData(Utils.getFilledFormData());
    }
    addGeneralMenus();
    createSideBar();
    try {
        // don't think this is required as the SideBar constructor (well SkinView) registers it
        UIUpdater updater = UIUpdaterSWT.getInstance();
        if (updater != null && !updater.isAdded(this)) {
            updater.addUpdater(this);
        }
    } catch (Throwable e) {
        Debug.out(e);
    }
    Display.getDefault().addFilter(SWT.KeyDown, new Listener() {

        @Override
        public void handleEvent(Event event) {
            // F7 works on both
            if (event.keyCode == SWT.F9 || event.keyCode == SWT.F7 || (event.keyCode == 116 && event.stateMask == (SWT.COMMAND | SWT.ALT))) {
                event.doit = false;
                event.keyCode = 0;
                event.character = '\0';
                flipSideBarVisibility();
            } else if (event.keyCode == SWT.F4 && event.stateMask == SWT.CTRL) {
                MdiEntry entry = getCurrentEntry();
                if (entry instanceof SideBarEntrySWT && entry.isCloseable()) {
                    ((SideBarEntrySWT) entry).getTreeItem().dispose();
                }
            }
        }
    });
    return null;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) ParameterListener(com.biglybt.core.config.ParameterListener) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener) SWTViewListener(com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl.SWTViewListener) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) UIUpdater(com.biglybt.ui.common.updater.UIUpdater)

Example 8 with UIUpdater

use of com.biglybt.ui.common.updater.UIUpdater in project BiglyBT by BiglySoftware.

the class SideBar method skinObjectDestroyed.

@Override
public Object skinObjectDestroyed(SWTSkinObject skinObject, Object params) {
    try {
        UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
        if (uiFunctions != null) {
            UIUpdater uiUpdater = uiFunctions.getUIUpdater();
            if (uiUpdater != null) {
                uiUpdater.removeUpdater(this);
            }
        }
    } catch (Exception e) {
        Debug.out(e);
    }
    COConfigurationManager.removeParameterListener("Show Side Bar", configShowSideBarListener);
    COConfigurationManager.removeParameterListener("config.skin.color.sidebar.bg", configBGColorListener);
    if (swtViewListener != null) {
        try {
            UISWTInstanceImpl uiSWTinstance = (UISWTInstanceImpl) UIFunctionsManagerSWT.getUIFunctionsSWT().getUISWTInstance();
            uiSWTinstance.removeSWTViewListener(swtViewListener);
        } catch (Throwable ignore) {
        }
    }
    return super.skinObjectDestroyed(skinObject, params);
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions) UIUpdater(com.biglybt.ui.common.updater.UIUpdater) UISWTInstanceImpl(com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl)

Example 9 with UIUpdater

use of com.biglybt.ui.common.updater.UIUpdater 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 10 with UIUpdater

use of com.biglybt.ui.common.updater.UIUpdater in project BiglyBT by BiglySoftware.

the class SkinView method skinObjectDestroyed.

// @see SWTSkinObjectAdapter#skinObjectDestroyed(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectDestroyed(SWTSkinObject skinObject, Object params) {
    disposed = true;
    SkinViewManager.remove(this);
    if (this instanceof UIUpdatable) {
        UIUpdatable updateable = (UIUpdatable) this;
        try {
            UIUpdater updater = UIUpdaterSWT.getInstance();
            if (updater != null) {
                updater.removeUpdater(updateable);
            }
        } catch (Exception e) {
            Debug.out(e);
        }
    }
    return null;
}
Also used : UIUpdatable(com.biglybt.ui.common.updater.UIUpdatable) UIUpdater(com.biglybt.ui.common.updater.UIUpdater)

Aggregations

UIUpdater (com.biglybt.ui.common.updater.UIUpdater)10 UIUpdatable (com.biglybt.ui.common.updater.UIUpdatable)5 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)3 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)3 SWTSkinObjectListener (com.biglybt.ui.swt.skin.SWTSkinObjectListener)3 GridData (org.eclipse.swt.layout.GridData)3 CoreRunningListener (com.biglybt.core.CoreRunningListener)2 ParameterListener (com.biglybt.core.config.ParameterListener)2 UIFunctions (com.biglybt.ui.UIFunctions)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 UISWTViewImpl (com.biglybt.ui.swt.pifimpl.UISWTViewImpl)2 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)2 IViewRequiresPeriodicUpdates (com.biglybt.ui.swt.views.IViewRequiresPeriodicUpdates)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2