Search in sources :

Example 1 with SkinView

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

the class DeviceManagerUI method uiAttachedAndCoreRunning.

private void uiAttachedAndCoreRunning(Core core) {
    Utils.execSWTThread(new AERunnable() {

        @Override
        public void runSupport() {
            MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
            if (mdi != null) {
                setupUI(mdi);
            } else {
                SkinViewManager.addListener(new SkinViewManagerListener() {

                    @Override
                    public void skinViewAdded(SkinView skinview) {
                        if (skinview instanceof SideBar) {
                            setupUI((SideBar) skinview);
                            SkinViewManager.RemoveListener(this);
                        }
                    }
                });
            }
        }
    });
    canCloseListener = new canCloseListener() {

        @Override
        public boolean canClose() {
            try {
                if (device_manager == null) {
                    return (true);
                }
                if (!device_manager.isTranscodeManagerInitialized()) {
                    return true;
                }
                final TranscodeJob job = device_manager.getTranscodeManager().getQueue().getCurrentJob();
                if (job == null || job.getState() != TranscodeJob.ST_RUNNING) {
                    return (true);
                }
                if (job.getTranscodeFile().getDevice().isHidden()) {
                    return (true);
                }
                String title = MessageText.getString("device.quit.transcoding.title");
                String text = MessageText.getString("device.quit.transcoding.text", new String[] { job.getName(), job.getTarget().getDevice().getName(), String.valueOf(job.getPercentComplete()) });
                MessageBoxShell mb = new MessageBoxShell(title, text, new String[] { MessageText.getString("UpdateWindow.quit"), MessageText.getString("Content.alert.notuploaded.button.abort") }, 1);
                mb.open(null);
                mb.waitUntilClosed();
                return mb.getResult() == 0;
            } catch (Throwable e) {
                Debug.out(e);
                return true;
            }
        }
    };
    UIExitUtilsSWT.addListener(canCloseListener);
}
Also used : SkinViewManagerListener(com.biglybt.ui.swt.views.skin.SkinViewManager.SkinViewManagerListener) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) SkinView(com.biglybt.ui.swt.views.skin.SkinView) SideBar(com.biglybt.ui.swt.views.skin.sidebar.SideBar) UIExitUtilsSWT.canCloseListener(com.biglybt.ui.swt.UIExitUtilsSWT.canCloseListener)

Example 2 with SkinView

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

the class BaseMDI method getEntryBySkinView.

/**
 * @param skinView
 * @return
 *
 * @since 3.1.1.1
 */
@Override
public MdiEntry getEntryBySkinView(Object skinView) {
    SWTSkinObject so = ((SkinView) skinView).getMainSkinObject();
    BaseMdiEntry[] sideBarEntries = getEntries(new BaseMdiEntry[0]);
    for (int i = 0; i < sideBarEntries.length; i++) {
        BaseMdiEntry entry = sideBarEntries[i];
        SWTSkinObject entrySO = entry.getSkinObject();
        SWTSkinObject entrySOParent = entrySO == null ? entrySO : entrySO.getParent();
        if (entrySO == so || entrySO == so.getParent() || entrySOParent == so) {
            return entry;
        }
    }
    return null;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SkinView(com.biglybt.ui.swt.views.skin.SkinView)

Example 3 with SkinView

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

the class SWTSkinObjectBasic method triggerListeners.

@Override
public void triggerListeners(final int eventType, final Object params) {
    if (SWTSkin.DEBUG_VISIBILITIES) {
        if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
            System.out.println("Show " + this + " via " + Debug.getCompressedStackTrace());
        }
    }
    // delay show and hide events while not initialized
    if (eventType == SWTSkinObjectListener.EVENT_SHOW || eventType == SWTSkinObjectListener.EVENT_HIDE) {
        if (!initialized) {
            // System.out.println("NOT INITIALIZED! " + SWTSkinObjectBasic.this + ";;;" + Debug.getCompressedStackTrace());
            return;
        }
        if (eventType == SWTSkinObjectListener.EVENT_SHOW && !isVisible()) {
            if (SWTSkin.DEBUG_VISIBILITIES) {
                System.out.println("Warning: Show Event when not visible " + this + " via " + Debug.getCompressedStackTrace());
            }
            return;
        } else if (eventType == SWTSkinObjectListener.EVENT_HIDE && isVisible()) {
            if (SWTSkin.DEBUG_VISIBILITIES) {
                System.out.println("Warning: Hide Event when visible " + this + " via " + Debug.getCompressedStackTrace());
            }
            return;
        }
    } else if (eventType == SWTSkinObjectListener.EVENT_CREATED) {
        // System.out.println("INITIALIZED! " + SWTSkinObjectBasic.this + ";;;" + Debug.getCompressedStackTrace());
        initialized = true;
    } else if (eventType == SWTSkinObjectListener.EVENT_DATASOURCE_CHANGED) {
        datasource = params;
    } else if (eventType == SWTSkinObjectListener.EVENT_DESTROY && isVisible == 1) {
        triggerListenersRaw(SWTSkinObjectListener.EVENT_HIDE, null);
    }
    triggerListenersRaw(eventType, params);
    if (eventType == SWTSkinObjectListener.EVENT_CREATED && isVisible >= 0) {
        triggerListeners(isVisible() ? SWTSkinObjectListener.EVENT_SHOW : SWTSkinObjectListener.EVENT_HIDE);
    }
    if (eventType == SWTSkinObjectListener.EVENT_SHOW && skinView == null) {
        String initClass = properties.getStringValue(sConfigID + ".onshow.skinviewclass");
        if (initClass != null) {
            try {
                String[] initClassItems = Constants.PAT_SPLIT_COMMA.split(initClass);
                ClassLoader claLoader = this.getClass().getClassLoader();
                if (initClassItems.length > 1) {
                    try {
                        PluginInterface pi = PluginInitializer.getDefaultInterface().getPluginManager().getPluginInterfaceByID(initClassItems[1]);
                        if (pi != null) {
                            claLoader = pi.getPluginClassLoader();
                        }
                    } catch (Exception e) {
                        Debug.out(e);
                    }
                }
                Class<SkinView> cla = (Class<SkinView>) Class.forName(initClassItems[0], true, claLoader);
                setSkinView(cla.newInstance());
                skinView.setMainSkinObject(this);
                // this will fire created and show for us
                addListener(skinView);
            } catch (Throwable e) {
                Debug.out(e);
            }
        }
    }
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface) SkinView(com.biglybt.ui.swt.views.skin.SkinView)

Aggregations

SkinView (com.biglybt.ui.swt.views.skin.SkinView)3 PluginInterface (com.biglybt.pif.PluginInterface)1 UIExitUtilsSWT.canCloseListener (com.biglybt.ui.swt.UIExitUtilsSWT.canCloseListener)1 MultipleDocumentInterfaceSWT (com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)1 SkinViewManagerListener (com.biglybt.ui.swt.views.skin.SkinViewManager.SkinViewManagerListener)1 SideBar (com.biglybt.ui.swt.views.skin.sidebar.SideBar)1