use of com.biglybt.ui.swt.views.skin.SkinnedDialog in project BiglyBT by BiglySoftware.
the class SideBar method addGeneralMenus.
/**
* @since 3.1.0.1
*/
private void addGeneralMenus() {
PluginManager pm = CoreFactory.getSingleton().getPluginManager();
PluginInterface pi = pm.getDefaultPluginInterface();
UIManager uim = pi.getUIManager();
MenuManager menuManager = uim.getMenuManager();
{
MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.add.to.dashboard");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
if (sbe != null && sbe.getId().equals(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD)) {
menu.setVisible(false);
} else {
menu.setVisible(sbe != null && sbe.canBuildStandAlone());
}
}
});
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
if (sbe != null) {
MainMDISetup.getSb_dashboard().addItem(sbe);
}
}
});
}
{
MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.pop.out");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
menu.setVisible(sbe != null && sbe.canBuildStandAlone());
}
});
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
if (sbe != null) {
SkinnedDialog skinnedDialog = new SkinnedDialog("skin3_dlg_sidebar_popout", "shell", // standalone
null, SWT.RESIZE | SWT.MAX | SWT.DIALOG_TRIM);
SWTSkin skin = skinnedDialog.getSkin();
SWTSkinObjectContainer cont = sbe.buildStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"));
if (cont != null) {
skinnedDialog.setTitle(sbe.getTitle());
skinnedDialog.open();
} else {
skinnedDialog.close();
}
}
}
});
}
}
use of com.biglybt.ui.swt.views.skin.SkinnedDialog 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 in project BiglyBT by BiglySoftware.
the class OpenTorrentOptionsWindow method swt_addTorrent.
protected void swt_addTorrent(HashWrapper hash, TorrentOpenOptions torrentOptions) {
final TorrentManagerImpl t_man = TorrentManagerImpl.getSingleton();
try {
if (dlg == null) {
dlg = new SkinnedDialog("skin3_dlg_opentorrent_options", "shell", SWT.RESIZE | SWT.MAX | SWT.DIALOG_TRIM);
final SWTSkin skin_outter = dlg.getSkin();
SWTSkinObject so;
if (COConfigurationManager.hasParameter(ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS, true)) {
so = skin_outter.getSkinObject("showagain-area");
if (so != null) {
so.setVisible(false);
}
}
SWTSkinObject soButtonArea = skin_outter.getSkinObject("button-area");
if (soButtonArea instanceof SWTSkinObjectContainer) {
buttonsArea = new StandardButtonsArea() {
@Override
protected void clicked(int intValue) {
if (intValue == SWT.OK) {
okPressed();
} else {
cancelPressed();
}
}
};
buttonsArea.setButtonIDs(new String[] { MessageText.getString("Button.ok"), MessageText.getString("Button.cancel") });
buttonsArea.setButtonVals(new Integer[] { SWT.OK, SWT.CANCEL });
buttonsArea.swt_createButtons(((SWTSkinObjectContainer) soButtonArea).getComposite());
}
sash_object = (SWTSkinObjectSash) skin_outter.getSkinObject("multi-sash");
SWTSkinObjectContainer select_area = (SWTSkinObjectContainer) skin_outter.getSkinObject("torrents-table");
setupTVTorrents(select_area.getComposite());
SWTSkinObjectContainer torrents_info = (SWTSkinObjectContainer) skin_outter.getSkinObject("torrents-info");
Composite info_area = torrents_info.getComposite();
info_area.setLayout(new GridLayout());
torrents_info_label = new Label(info_area, SWT.NULL);
Utils.setLayoutData(torrents_info_label, new GridData(GridData.FILL_HORIZONTAL));
sash_object.setVisible(false);
sash_object.setAboveVisible(false);
so = skin_outter.getSkinObject("expand-area");
expand_stack_area = ((SWTSkinObjectContainer) so).getComposite();
expand_stack = new StackLayout();
expand_stack_area.setLayout(expand_stack);
Composite expand_area = new Composite(expand_stack_area, SWT.NULL);
expand_area.setLayout(new FormLayout());
expand_stack.topControl = expand_area;
OpenTorrentInstance instance = new OpenTorrentInstance(hash, expand_area, torrentOptions, optionListener);
addInstance(instance);
selected_instances.add(instance);
UIUpdaterSWT.getInstance().addUpdater(this);
setupShowAgainOptions(skin_outter);
/*
* The bring-to-front logic for torrent addition is controlled by other parts of the code so we don't
* want the dlg to override this behaviour (main example here is torrents passed from, say, a browser,
* and the user has disabled the 'show vuze on external torrent add' feature)
*/
dlg.open("otow", false);
synchronized (active_windows) {
int num_active_windows = active_windows.size();
Shell shell = dlg.getShell();
if (num_active_windows > 1) {
int max_x = 0;
int max_y = 0;
for (OpenTorrentOptionsWindow window : active_windows.values()) {
if (window == this || !window.isInitialised()) {
continue;
}
Rectangle rect = window.getBounds();
max_x = Math.max(max_x, rect.x);
max_y = Math.max(max_y, rect.y);
}
Rectangle rect = shell.getBounds();
rect.x = max_x + 16;
rect.y = max_y + 16;
shell.setBounds(rect);
}
// String before = "disp="+shell.getDisplay().getBounds()+",shell=" + shell.getBounds();
Utils.verifyShellRect(shell, true);
// Debug.outNoStack( "Opening torrent options dialog: " + before + " -> " + shell.getBounds());
}
dlg.addCloseListener(new SkinnedDialog.SkinnedDialogClosedListener() {
@Override
public void skinDialogClosed(SkinnedDialog dialog) {
try {
dispose();
} finally {
synchronized (active_windows) {
Iterator<OpenTorrentOptionsWindow> it = active_windows.values().iterator();
while (it.hasNext()) {
OpenTorrentOptionsWindow window = it.next();
if (window == OpenTorrentOptionsWindow.this) {
it.remove();
}
}
TorrentManagerImpl t_man = TorrentManagerImpl.getSingleton();
for (OpenTorrentInstance inst : open_instances) {
inst.cancelPressed();
t_man.optionsRemoved(inst.getOptions());
}
}
}
}
});
window_initialised = true;
} else {
Composite expand_area = new Composite(expand_stack_area, SWT.NULL);
expand_area.setLayout(new FormLayout());
OpenTorrentInstance instance = new OpenTorrentInstance(hash, expand_area, torrentOptions, optionListener);
addInstance(instance);
if (!sash_object.isVisible()) {
sash_object.setVisible(true);
sash_object.setAboveVisible(true);
Utils.execSWTThreadLater(0, new Runnable() {
@Override
public void run() {
tvTorrents.processDataSourceQueueSync();
List<TableRowCore> rows = new ArrayList<>();
for (OpenTorrentInstance instance : selected_instances) {
TableRowCore row = tvTorrents.getRow(instance);
if (row != null) {
rows.add(row);
}
}
if (rows.size() > 0) {
tvTorrents.setSelectedRows(rows.toArray(new TableRowCore[rows.size()]));
}
}
});
}
}
} catch (Throwable e) {
Debug.out(e);
synchronized (active_windows) {
active_windows.remove(hash);
torrentOptions.cancel();
t_man.optionsRemoved(torrentOptions);
}
}
}
use of com.biglybt.ui.swt.views.skin.SkinnedDialog 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 in project BiglyBT by BiglySoftware.
the class SearchUtils method showCreateSubscriptionDialog.
public static void showCreateSubscriptionDialog(final long engineID, final String searchTerm, final Map optionalFilters) {
final SkinnedDialog dialog = new SkinnedDialog("skin3_dlg_create_search_subscription", "shell", SWT.DIALOG_TRIM);
SWTSkin skin = dialog.getSkin();
final SWTSkinObjectTextbox tb = (SWTSkinObjectTextbox) skin.getSkinObject("sub-name");
final SWTSkinObjectCheckbox cbShare = (SWTSkinObjectCheckbox) skin.getSkinObject("sub-share");
final SWTSkinObjectCheckbox cbAutoDL = (SWTSkinObjectCheckbox) skin.getSkinObject("sub-autodl");
SWTSkinObject soEngineArea = skin.getSkinObject("sub-engine-area");
final SWTSkinObjectCombo soEngines = (SWTSkinObjectCombo) skin.getSkinObject("sub-engine");
if (tb == null || cbShare == null || cbAutoDL == null) {
return;
}
boolean hasEngineID = engineID >= 0;
soEngineArea.setVisible(!hasEngineID);
final Map<Integer, Engine> mapEngines = new HashMap<>();
if (!hasEngineID) {
Engine[] engines = MetaSearchManagerFactory.getSingleton().getMetaSearch().getEngines(true, false);
List<String> list = new ArrayList<>();
int pos = 0;
for (Engine engine : engines) {
mapEngines.put(pos++, engine);
list.add(engine.getName());
}
soEngines.setList(list.toArray(new String[list.size()]));
}
cbShare.setChecked(COConfigurationManager.getBooleanParameter("sub.sharing.default.checked"));
cbAutoDL.setChecked(COConfigurationManager.getBooleanParameter("sub.autodl.default.checked"));
SWTSkinObject soButtonArea = skin.getSkinObject("bottom-area");
if (soButtonArea instanceof SWTSkinObjectContainer) {
StandardButtonsArea buttonsArea = new StandardButtonsArea() {
// @see StandardButtonsArea#clicked(int)
@Override
protected void clicked(int buttonValue) {
if (buttonValue == SWT.OK) {
String name = tb.getText().trim();
boolean isShared = cbShare.isChecked();
boolean autoDL = cbAutoDL.isChecked();
long realEngineID = engineID;
if (engineID <= 0) {
int engineIndex = soEngines.getComboControl().getSelectionIndex();
if (engineIndex < 0) {
// TODO: Flicker combobox
return;
}
realEngineID = mapEngines.get(engineIndex).getId();
}
Map<String, Object> payload = new HashMap<>();
payload.put("engine_id", realEngineID);
payload.put("search_term", searchTerm);
Map<String, Object> mapSchedule = new HashMap<>();
mapSchedule.put("days", Collections.EMPTY_LIST);
// minutes
mapSchedule.put("interval", 120);
payload.put("schedule", mapSchedule);
Map<String, Object> mapOptions = new HashMap<>();
mapOptions.put("auto_dl", autoDL);
payload.put("options", mapOptions);
Map<String, Object> mapFilters = new HashMap<>();
if (optionalFilters != null) {
mapFilters.putAll(optionalFilters);
}
payload.put("filters", mapFilters);
try {
Subscription subs;
subs = SubscriptionManagerFactory.getSingleton().create(name, isShared, JSONUtils.encodeToJSON(payload));
subs.getHistory().setDetails(true, autoDL);
subs.requestAttention();
} catch (SubscriptionException e) {
}
}
dialog.close();
}
};
buttonsArea.setButtonIDs(new String[] { MessageText.getString("Button.add"), MessageText.getString("Button.cancel") });
buttonsArea.setButtonVals(new Integer[] { SWT.OK, SWT.CANCEL });
buttonsArea.swt_createButtons(((SWTSkinObjectContainer) soButtonArea).getComposite());
}
dialog.open();
}
Aggregations