Search in sources :

Example 26 with SWTSkinObject

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

the class TopBarView method skinObjectInitialShow.

@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    this.skin = skinObject.getSkin();
    skin.addListener("topbar-plugins", new SWTSkinObjectListener() {

        @Override
        public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
            if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
                skin.removeListener("topbar-plugins", this);
                // building needs UISWTInstance, which needs core.
                CoreFactory.addCoreRunningListener(new CoreRunningListener() {

                    @Override
                    public void coreRunning(Core core) {
                        Utils.execSWTThreadLater(0, new AERunnable() {

                            @Override
                            public void runSupport() {
                                buildTopBarViews();
                            }
                        });
                    }
                });
            }
            return null;
        }
    });
    // trigger autobuild and hook in events
    skin.getSkinObject("topbar-area-plugin").addListener(new SWTSkinObjectListener() {

        @Override
        public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
            if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
                if (activeTopBar != null) {
                    activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
                }
            } else if (eventType == SWTSkinObjectListener.EVENT_HIDE) {
                if (activeTopBar != null) {
                    activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null);
                }
            }
            return (null);
        }
    });
    return null;
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) CoreRunningListener(com.biglybt.core.CoreRunningListener) SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) Core(com.biglybt.core.Core)

Example 27 with SWTSkinObject

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

the class SBC_DevicesView method skinObjectInitialShow.

// @see SkinView#skinObjectInitialShow(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            initColumns(core);
        }
    });
    device_manager = DeviceManagerFactory.getSingleton();
    transcode_manager = device_manager.getTranscodeManager();
    transcode_queue = transcode_manager.getQueue();
    MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
    if (mdi != null) {
        mdiEntry = mdi.getCurrentEntrySWT();
        Object ds = mdiEntry.getDatasource();
        if (!(ds instanceof Device)) {
            return (null);
        }
        device = (Device) ds;
    }
    if (device instanceof TranscodeTarget) {
        transTarget = (TranscodeTarget) device;
    }
    if (device == null) {
        new InfoBarUtil(skinObject, "devicesview.infobar", false, "DeviceView.infobar", "v3.deviceview.infobar") {

            @Override
            public boolean allowShow() {
                return true;
            }
        };
    } else if (device instanceof DeviceMediaRenderer) {
        DeviceMediaRenderer renderer = (DeviceMediaRenderer) device;
        int species = renderer.getRendererSpecies();
        String speciesID = null;
        switch(species) {
            case DeviceMediaRenderer.RS_ITUNES:
                speciesID = "itunes";
                break;
            case DeviceMediaRenderer.RS_PS3:
                speciesID = "ps3";
                break;
            case DeviceMediaRenderer.RS_XBOX:
                speciesID = "xbox";
                break;
            case DeviceMediaRenderer.RS_OTHER:
                {
                    String classification = renderer.getClassification();
                    if (classification.equals("sony.PSP")) {
                        speciesID = "psp";
                    } else if (classification.startsWith("tivo.")) {
                        speciesID = "tivo";
                    } else if (classification.toLowerCase().contains("android")) {
                        speciesID = "android";
                    }
                }
            default:
                break;
        }
        if (speciesID != null) {
            final String fSpeciesID = speciesID;
            new InfoBarUtil(skinObject, "devicesview.infobar", false, "DeviceView.infobar." + speciesID, "v3.deviceview.infobar") {

                @Override
                public boolean allowShow() {
                    return true;
                }

                // @see InfoBarUtil#created(SWTSkinObject)
                @Override
                protected void created(SWTSkinObject parent) {
                    SWTSkinObjectText soLine1 = (SWTSkinObjectText) skin.getSkinObject("line1", parent);
                    soLine1.setTextID("v3.deviceview.infobar.line1.generic", new String[] { device.getName() });
                    SWTSkinObjectText soLine2 = (SWTSkinObjectText) skin.getSkinObject("line2", parent);
                    soLine2.setTextID("v3.deviceview.infobar.line2." + fSpeciesID);
                }
            };
        }
    }
    SWTSkinObject soAdvInfo = getSkinObject("advinfo");
    if (soAdvInfo != null) {
        initAdvInfo(soAdvInfo);
    }
    if (device != null) {
        device_name = device.getName();
        SWTSkinObject soTitle = getSkinObject("title");
        if (soTitle instanceof SWTSkinObjectText) {
            ((SWTSkinObjectText) soTitle).setTextID("device.view.heading", new String[] { device_name });
        }
    }
    return null;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) CoreRunningListener(com.biglybt.core.CoreRunningListener) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) InfoBarUtil(com.biglybt.ui.swt.views.skin.InfoBarUtil) Core(com.biglybt.core.Core)

Example 28 with SWTSkinObject

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

the class SBC_DevicesView method deviceChanged.

@Override
public void deviceChanged(Device device) {
    String name = device.getName();
    if (!name.equals(device_name)) {
        device_name = name;
        // ensure name is up to date
        SWTSkinObject soTitle = getSkinObject("title");
        if (soTitle instanceof SWTSkinObjectText) {
            ((SWTSkinObjectText) soTitle).setTextID("device.view.heading", new String[] { name });
        }
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText)

Example 29 with SWTSkinObject

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

Example 30 with SWTSkinObject

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

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