use of com.biglybt.ui.swt.views.skin.SkinnedDialog 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.SkinnedDialog 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();
}
use of com.biglybt.ui.swt.views.skin.SkinnedDialog in project BiglyBT by BiglySoftware.
the class TabbedMDI method addMenus.
private void addMenus(TabbedEntry entry, String id) {
PluginManager pm = CoreFactory.getSingleton().getPluginManager();
PluginInterface pi = pm.getDefaultPluginInterface();
UIManager uim = pi.getUIManager();
MenuManager menuManager = uim.getMenuManager();
{
if (!Utils.isAZ2UI()) {
com.biglybt.pif.ui.menus.MenuItem menuItem = menuManager.addMenuItem(id + "._end_", "menu.add.to.dashboard");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addFillListener(new MenuItemFillListener() {
@Override
public void menuWillBeShown(com.biglybt.pif.ui.menus.MenuItem menu, Object data) {
// pick up the right target - due to the confusion of multiple tab instances registering
// the same menu entries the original registerer may well not be the one that should receive the event,
// rather the one specified in the event is
TabbedEntry target = entry;
if (data instanceof Object[]) {
Object[] odata = (Object[]) data;
if (odata.length == 1 && odata[0] instanceof TabbedEntry) {
target = (TabbedEntry) odata[0];
}
}
menu.setVisible(target.canBuildStandAlone());
}
});
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object data) {
TabbedEntry target = entry;
if (data instanceof Object[]) {
Object[] odata = (Object[]) data;
if (odata.length == 1 && odata[0] instanceof TabbedEntry) {
target = (TabbedEntry) odata[0];
}
} else if (data instanceof TabbedEntry) {
target = (TabbedEntry) data;
}
MainMDISetup.getSb_dashboard().addItem(target);
}
});
}
}
{
com.biglybt.pif.ui.menus.MenuItem menuItem = menuManager.addMenuItem(id + "._end_", "menu.pop.out");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addFillListener(new com.biglybt.pif.ui.menus.MenuItemFillListener() {
@Override
public void menuWillBeShown(com.biglybt.pif.ui.menus.MenuItem menu, Object data) {
TabbedEntry target = entry;
if (data instanceof Object[]) {
Object[] odata = (Object[]) data;
if (odata.length == 1 && odata[0] instanceof TabbedEntry) {
target = (TabbedEntry) odata[0];
}
}
menu.setVisible(target.canBuildStandAlone());
}
});
menuItem.addListener(new com.biglybt.pif.ui.menus.MenuItemListener() {
@Override
public void selected(com.biglybt.pif.ui.menus.MenuItem menu, Object data) {
TabbedEntry target = entry;
if (data instanceof Object[]) {
Object[] odata = (Object[]) data;
if (odata.length == 1 && odata[0] instanceof TabbedEntry) {
target = (TabbedEntry) odata[0];
}
} else if (data instanceof TabbedEntry) {
target = (TabbedEntry) data;
}
SkinnedDialog skinnedDialog = new SkinnedDialog("skin3_dlg_sidebar_popout", "shell", // standalone
null, SWT.RESIZE | SWT.MAX | SWT.DIALOG_TRIM);
SWTSkin skin = skinnedDialog.getSkin();
SWTSkinObjectContainer cont = target.buildStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"));
if (cont != null) {
Object ds = target.getDatasource();
if (ds instanceof Object[]) {
Object[] temp = (Object[]) ds;
if (temp.length > 0) {
ds = temp[0];
}
}
String ds_str = "";
if (ds instanceof Download) {
ds_str = ((Download) ds).getName();
} else if (ds instanceof DownloadManager) {
ds_str = ((DownloadManager) ds).getDisplayName();
}
skinnedDialog.setTitle(target.getTitle() + (ds_str.length() == 0 ? "" : (" - " + ds_str)));
skinnedDialog.open();
} else {
skinnedDialog.close();
}
}
});
}
}
use of com.biglybt.ui.swt.views.skin.SkinnedDialog 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