use of com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener in project BiglyBT by BiglySoftware.
the class DeviceTemplateChooser method open.
public void open(DeviceTemplateClosedListener 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.deviceTemplateChooserClosed(selectedDeviceTemplate);
}
}
});
SWTSkin skin = skinnedDialog.getSkin();
SWTSkinObject so = skin.getSkinObject("list");
if (so instanceof SWTSkinObjectContainer) {
SWTSkinObjectContainer soList = (SWTSkinObjectContainer) so;
createDeviceTemplateList2(soList);
}
skinnedDialog.open();
}
use of com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener in project BiglyBT by BiglySoftware.
the class UIFunctionsImpl method showCoreWaitDlg.
// @see UIFunctionsSWT#showCoreWaitDlg()
@Override
public Shell showCoreWaitDlg() {
final SkinnedDialog closeDialog = new SkinnedDialog("skin3_dlg_coreloading", "coreloading.body", SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
closeDialog.setTitle(MessageText.getString("dlg.corewait.title"));
SWTSkin skin = closeDialog.getSkin();
SWTSkinObjectButton soButton = (SWTSkinObjectButton) skin.getSkinObject("close");
final SWTSkinObjectText soWaitTask = (SWTSkinObjectText) skin.getSkinObject("task");
final SWTSkinObject soWaitProgress = skin.getSkinObject("progress");
if (soWaitProgress != null) {
soWaitProgress.getControl().addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
Control c = (Control) e.widget;
Point size = c.getSize();
e.gc.setBackground(ColorCache.getColor(e.display, "#23a7df"));
Object data = soWaitProgress.getData("progress");
if (data instanceof Long) {
int waitProgress = ((Long) data).intValue();
int breakX = size.x * waitProgress / 100;
e.gc.fillRectangle(0, 0, breakX, size.y);
e.gc.setBackground(ColorCache.getColor(e.display, "#cccccc"));
e.gc.fillRectangle(breakX, 0, size.x - breakX, size.y);
}
}
});
}
if (!CoreFactory.isCoreRunning()) {
final Initializer initializer = Initializer.getLastInitializer();
if (initializer != null) {
initializer.addListener(new InitializerListener() {
@Override
public void reportPercent(final int percent) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
if (soWaitProgress != null && !soWaitProgress.isDisposed()) {
soWaitProgress.setData("progress", new Long(percent));
soWaitProgress.getControl().redraw();
soWaitProgress.getControl().update();
}
}
});
if (percent > 100) {
initializer.removeListener(this);
}
}
@Override
public void reportCurrentTask(String currentTask) {
if (soWaitTask != null && !soWaitTask.isDisposed()) {
soWaitTask.setText(currentTask);
}
}
});
}
}
if (soButton != null) {
soButton.addSelectionListener(new ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
closeDialog.close();
}
});
}
closeDialog.addCloseListener(new SkinnedDialogClosedListener() {
@Override
public void skinDialogClosed(SkinnedDialog dialog) {
}
});
closeDialog.open();
return closeDialog.getShell();
}
use of com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener in project BiglyBT by BiglySoftware.
the class RemotePairingWindow method _open.
private void _open() {
alreadyTested = false;
pairingManager = PairingManagerFactory.getSingleton();
PluginInterface piWebUI = getWebUI();
boolean showFTUX = piWebUI == null || !pairingManager.isEnabled();
if (skinnedDialog == null || skinnedDialog.isDisposed()) {
skinnedDialog = new SkinnedDialog("skin3_dlg_remotepairing", "shell", SWT.DIALOG_TRIM);
skin = skinnedDialog.getSkin();
soCodeArea = skin.getSkinObject("code-area");
control = soCodeArea.getControl();
soEnablePairing = (SWTSkinObjectButton) skin.getSkinObject("enable-pairing");
soEnablePairing.addSelectionListener(new ButtonListenerAdapter() {
// @see SWTSkinButtonUtility.ButtonListenerAdapter#pressed(SWTSkinButtonUtility, SWTSkinObject, int)
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
skinObject.getControl().setEnabled(false);
if (!pairingManager.isEnabled()) {
// enabling will automatically get access code and trigger
// somethingChanged
pairingManager.setEnabled(true);
if (SHOW_SPEW) {
System.out.println("PAIR] SetEnabled");
}
} else {
// picked up
if (SHOW_SPEW) {
System.out.println("PAIR] AlreadyEnabled");
}
somethingChanged(pairingManager);
}
if (getWebUI() == null) {
installWebUI();
} else {
switchToCode();
}
}
});
soFTUX = skin.getSkinObject("pairing-ftux");
soCode = skin.getSkinObject("pairing-code");
soQR = (SWTSkinObjectImage) skin.getSkinObject("pairing-qr");
if (accessCode != null) {
setupQR(accessCode);
}
soStatusText = (SWTSkinObjectText) skin.getSkinObject("status-text");
soStatusText.addUrlClickedListener(new SWTSkinObjectText_UrlClickedListener() {
@Override
public boolean urlClicked(URLInfo urlInfo) {
if (urlInfo.url.equals("retry")) {
if (DEBUG) {
testPairingClass.inc();
}
alreadyTested = false;
testPairing(false);
return true;
}
return false;
}
});
pairingManager.addListener(this);
Font font = control.getFont();
GC gc = new GC(control);
fontCode = FontUtils.getFontWithHeight(font, gc, Constants.isWindows ? 20 : 18, SWT.BOLD);
gc.dispose();
control.setFont(fontCode);
control.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
Color oldColor = e.gc.getForeground();
Rectangle printArea = ((Composite) e.widget).getClientArea();
printArea.y += 10;
printArea.height -= 20;
int fullWidth = printArea.width;
int fullHeight = printArea.height;
GCStringPrinter sp = new GCStringPrinter(e.gc, MessageText.getString("remote.pairing.accesscode"), printArea, false, false, SWT.NONE);
sp.calculateMetrics();
Point sizeAccess = sp.getCalculatedSize();
String drawAccessCode = accessCode == null ? " " : accessCode;
int numBoxes = drawAccessCode.length();
int boxSize = 25;
int boxSizeAndPadding = 30;
int allBoxesWidth = numBoxes * boxSizeAndPadding;
int textPadding = 15;
printArea.y = (fullHeight - boxSizeAndPadding - sizeAccess.y + textPadding) / 2;
sp.printString(e.gc, printArea, SWT.CENTER | SWT.TOP);
e.gc.setBackground(Colors.white);
e.gc.setForeground(Colors.blue);
int xStart = (fullWidth - allBoxesWidth) / 2;
int yStart = printArea.y + sizeAccess.y + textPadding;
for (int i = 0; i < numBoxes; i++) {
Rectangle r = new Rectangle(xStart + (i * boxSizeAndPadding), yStart, boxSize, boxSize);
e.gc.fillRectangle(r);
e.gc.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
e.gc.drawRectangle(r);
if (isCodeVisible()) {
e.gc.setForeground(oldColor);
GCStringPrinter.printString(e.gc, "" + drawAccessCode.charAt(i), r, false, false, SWT.CENTER);
}
}
}
});
soToClipboard = (SWTSkinObjectText) skin.getSkinObject("pair-clipboard");
soToClipboard.addUrlClickedListener(new SWTSkinObjectText_UrlClickedListener() {
@Override
public boolean urlClicked(URLInfo urlInfo) {
if (urlInfo.url.equals("new")) {
try {
accessCode = pairingManager.getReplacementAccessCode();
} catch (PairingException e) {
// ignore.. if error, lastErrorUpdates will trigger
}
control.redraw();
setupQR(accessCode);
String s = soToClipboard.getText();
int i = s.indexOf("|");
if (i > 0) {
soToClipboard.setText(s.substring(0, i - 1));
}
} else if (urlInfo.url.equals("clip")) {
ClipboardCopy.copyToClipBoard(accessCode);
}
return true;
}
});
SWTSkinButtonUtility btnToClipboard = new SWTSkinButtonUtility(soToClipboard);
btnToClipboard.addSelectionListener(new ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
}
});
skinnedDialog.addCloseListener(new SkinnedDialogClosedListener() {
@Override
public void skinDialogClosed(SkinnedDialog dialog) {
skinnedDialog = null;
pairingManager.removeListener(RemotePairingWindow.this);
Utils.disposeSWTObjects(new Object[] { fontCode });
if (pairingTest != null) {
pairingTest.cancel();
}
}
});
if (showFTUX) {
soFTUX.getControl().moveAbove(null);
}
}
setCodeVisible(false);
skinnedDialog.open();
if (showFTUX) {
switchToFTUX();
} else {
switchToCode();
}
}
use of com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener 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