use of com.biglybt.ui.swt.views.skin.StandardButtonsArea 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.StandardButtonsArea 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();
}
use of com.biglybt.ui.swt.views.skin.StandardButtonsArea in project BiglyBT by BiglySoftware.
the class TagUIUtilsV3 method showCreateTagDialog.
public static void showCreateTagDialog(final UIFunctions.TagReturner tagReturner) {
final SkinnedDialog dialog = new SkinnedDialog("skin3_dlg_addtag", "shell", SWT.DIALOG_TRIM);
SWTSkin skin = dialog.getSkin();
final SWTSkinObjectTextbox tb = (SWTSkinObjectTextbox) skin.getSkinObject("tag-name");
final SWTSkinObjectCheckbox cb = (SWTSkinObjectCheckbox) skin.getSkinObject("tag-share");
final SWTSkinObjectCheckbox ss = (SWTSkinObjectCheckbox) skin.getSkinObject("tag-customize");
if (tb == null || cb == null) {
return;
}
SWTSkinObjectContainer soGroupBox = (SWTSkinObjectContainer) skin.getSkinObject("tag-group-area");
final SWTSkinObjectCombo soGroup = (SWTSkinObjectCombo) skin.getSkinObject("tag-group");
if (soGroupBox != null && soGroup != null) {
List<String> listGroups = new ArrayList<>();
TagManager tagManager = TagManagerFactory.getTagManager();
TagType tt = tagManager.getTagType(TagType.TT_DOWNLOAD_MANUAL);
List<Tag> tags = tt.getTags();
for (Tag tag : tags) {
String group = tag.getGroup();
if (group != null && group.length() > 0 && !listGroups.contains(group)) {
listGroups.add(group);
}
}
soGroupBox.setVisible(listGroups.size() > 0);
soGroup.setList(listGroups.toArray(new String[0]));
}
cb.setChecked(COConfigurationManager.getBooleanParameter("tag.sharing.default.checked"));
if (ss != null) {
ss.setChecked(COConfigurationManager.getBooleanParameter("tag.add.customize.default.checked"));
ss.addSelectionListener(new SWTSkinCheckboxListener() {
@Override
public void checkboxChanged(SWTSkinObjectCheckbox so, boolean checked) {
COConfigurationManager.setParameter("tag.add.customize.default.checked", 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 tag_name = tb.getText().trim();
TagType tt = TagManagerFactory.getTagManager().getTagType(TagType.TT_DOWNLOAD_MANUAL);
Tag tag = tt.getTag(tag_name, true);
if (tag == null) {
try {
tag = tt.createTag(tag_name, true);
tag.setPublic(cb.isChecked());
if (soGroup != null) {
String group = soGroup.getText();
if (group != null && group.length() > 0) {
tag.setGroup(group);
}
}
} catch (TagException e) {
Debug.out(e);
}
}
// they forgot they already had one
if (tagReturner != null && tag != null) {
tagReturner.returnedTags(new Tag[] { tag });
}
if (ss.isChecked()) {
tag.setTransientProperty(Tag.TP_SETTINGS_REQUESTED, true);
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TAGS);
}
}
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();
}
use of com.biglybt.ui.swt.views.skin.StandardButtonsArea in project BiglyBT by BiglySoftware.
the class OpenTorrentWindow method swt_createWindow.
private void swt_createWindow() {
dlg = new SkinnedDialog("skin3_dlg_opentorrent", "shell", SWT.RESIZE | SWT.DIALOG_TRIM);
shellForChildren = dlg.getShell();
SWTSkin skin = dlg.getSkin();
SWTSkinObject soTopBar = skin.getSkinObject("add-buttons");
if (soTopBar instanceof SWTSkinObjectContainer) {
swt_addButtons(((SWTSkinObjectContainer) soTopBar).getComposite());
}
soTextArea = (SWTSkinObjectTextbox) skin.getSkinObject("text-area");
Text tb = ((Text) soTextArea.getControl());
Clipboard clipboard = new Clipboard(Display.getDefault());
String sClipText = (String) clipboard.getContents(TextTransfer.getInstance());
if (sClipText != null && !sClipText.trim().isEmpty()) {
sClipText = sClipText.trim();
if (addTorrentsFromTextList(sClipText, true) > 0) {
tb.setText(sClipText);
tb.setSelection(0, sClipText.length());
}
}
tb.setFocus();
tb.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
int userMode = COConfigurationManager.getIntParameter("User Mode");
if (userMode > 0) {
if (soReferArea != null) {
String text = ((Text) e.widget).getText();
boolean hasURL = UrlUtils.parseTextForURL(text, false, true) != null;
soReferArea.setVisible(hasURL);
}
}
}
});
SWTSkinObject so;
so = skin.getSkinObject("show-advanced");
if (so instanceof SWTSkinObjectCheckbox) {
soShowAdvanced = (SWTSkinObjectCheckbox) so;
soShowAdvanced.setChecked(COConfigurationManager.getBooleanParameter(ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS));
}
soReferArea = skin.getSkinObject("refer-area");
last_referrer = COConfigurationManager.getStringParameter(CONFIG_REFERRER_DEFAULT, "");
if (last_referrer == null) {
last_referrer = "";
}
so = skin.getSkinObject("refer-combo");
if (so instanceof SWTSkinObjectContainer) {
referrer_combo = new Combo(((SWTSkinObjectContainer) so).getComposite(), SWT.BORDER);
referrer_combo.setLayoutData(Utils.getFilledFormData());
referrers = COConfigurationManager.getStringListParameter("url_open_referrers");
if (!last_referrer.isEmpty()) {
referrer_combo.add(last_referrer);
}
for (String referrer : referrers) {
if (!referrer.equals(last_referrer)) {
referrer_combo.add(referrer);
}
}
}
SWTSkinObject soButtonArea = skin.getSkinObject("button-area");
if (soButtonArea instanceof SWTSkinObjectContainer) {
buttonsArea = new StandardButtonsArea() {
@Override
protected void clicked(int intValue) {
String referrer = null;
if (referrer_combo != null) {
referrer = referrer_combo.getText().trim();
}
if (dlg != null) {
dlg.close();
}
if (intValue == SWT.OK && soTextArea != null && soTextArea.getText().length() > 0) {
openTorrent(soTextArea.getText(), referrer);
}
}
};
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());
}
UIUpdaterSWT.getInstance().addUpdater(this);
/*
* 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("otw", false);
dlg.addCloseListener(new SkinnedDialog.SkinnedDialogClosedListener() {
@Override
public void skinDialogClosed(SkinnedDialog dialog) {
dispose();
}
});
}
Aggregations