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()));
}
};
*/
}
});
}
});
}
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();
}
Aggregations