Search in sources :

Example 1 with DeviceManufacturer

use of com.biglybt.core.devices.DeviceManager.DeviceManufacturer in project BiglyBT by BiglySoftware.

the class DeviceManagerUI method addNewDevice.

/**
 * @since 4.1.0.5
 */
protected void addNewDevice() {
    ManufacturerChooser mfChooser = new ManufacturerChooser();
    mfChooser.open(new ManufacturerChooser.ClosedListener() {

        @Override
        public void MfChooserClosed(DeviceManufacturer mf) {
            if (mf == null) {
                return;
            }
            DeviceTemplateChooser deviceTemplateChooser = new DeviceTemplateChooser(mf);
            deviceTemplateChooser.open(new DeviceTemplateChooser.DeviceTemplateClosedListener() {

                @Override
                public void deviceTemplateChooserClosed(DeviceTemplate deviceTemplate) {
                    if (deviceTemplate == null) {
                        return;
                    }
                    Device device;
                    try {
                        device = deviceTemplate.createInstance(deviceTemplate.getName() + " test!");
                        device.requestAttention();
                    } catch (DeviceManagerException e) {
                        Debug.out(e);
                    }
                /*  Don't really need to choose a profile now..
						TranscodeProfile[] profiles = null;// deviceTemplate.getTranscodeProfiles();
						new TranscodeChooser(profiles) {
							public void closed() {
								Utils.openMessageBox(null, 0, "CHOSE", "You chose "
										+ (selectedProfile == null ? "NULL"
												: selectedProfile.getName()));

							}
						};
						*/
                }
            });
        }
    });
}
Also used : DeviceTemplateChooser(com.biglybt.ui.swt.devices.add.DeviceTemplateChooser) UPnPDevice(com.biglybt.net.upnp.UPnPDevice) UnassociatedDevice(com.biglybt.core.devices.DeviceManager.UnassociatedDevice) UPnPRootDevice(com.biglybt.net.upnp.UPnPRootDevice) DeviceManufacturer(com.biglybt.core.devices.DeviceManager.DeviceManufacturer) ManufacturerChooser(com.biglybt.ui.swt.devices.add.ManufacturerChooser)

Example 2 with DeviceManufacturer

use of com.biglybt.core.devices.DeviceManager.DeviceManufacturer 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

DeviceManufacturer (com.biglybt.core.devices.DeviceManager.DeviceManufacturer)2 UnassociatedDevice (com.biglybt.core.devices.DeviceManager.UnassociatedDevice)1 UPnPDevice (com.biglybt.net.upnp.UPnPDevice)1 UPnPRootDevice (com.biglybt.net.upnp.UPnPRootDevice)1 DeviceTemplateChooser (com.biglybt.ui.swt.devices.add.DeviceTemplateChooser)1 ManufacturerChooser (com.biglybt.ui.swt.devices.add.ManufacturerChooser)1 SWTSkin (com.biglybt.ui.swt.skin.SWTSkin)1 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)1 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)1 SkinnedDialog (com.biglybt.ui.swt.views.skin.SkinnedDialog)1 SkinnedDialogClosedListener (com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 RowLayout (org.eclipse.swt.layout.RowLayout)1