Search in sources :

Example 1 with SWTSkinButtonUtility

use of com.biglybt.ui.swt.skin.SWTSkinButtonUtility in project BiglyBT by BiglySoftware.

the class SBC_DevicesView method initAdvInfo.

/**
 * @param soAdvInfo
 *
 * @since 4.1.0.5
 */
private void initAdvInfo(SWTSkinObject soAdvInfo) {
    SWTSkinButtonUtility btnAdvInfo = new SWTSkinButtonUtility(soAdvInfo);
    btnAdvInfo.addSelectionListener(new ButtonListenerAdapter() {

        @Override
        public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
            SWTSkinObject soArea = getSkinObject("advinfo-area");
            if (soArea != null) {
                boolean newVisibility = !soArea.isVisible();
                setAdditionalInfoTitle(newVisibility);
            }
        }
    });
    setAdditionalInfoTitle(false);
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinButtonUtility(com.biglybt.ui.swt.skin.SWTSkinButtonUtility) ButtonListenerAdapter(com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter)

Example 2 with SWTSkinButtonUtility

use of com.biglybt.ui.swt.skin.SWTSkinButtonUtility in project BiglyBT by BiglySoftware.

the class ToolBarView method initSO.

private void initSO(Map<UIToolBarItem, ToolBarItemSO> newMap, SWTSkinObject so, ToolBarItemSO itemSO) {
    ToolBarItem item = itemSO.getBase();
    itemSO.setSO(so);
    String toolTip = item.getToolTip();
    if (toolTip != null) {
        so.setTooltipID("!" + toolTip + "!");
    } else {
        so.setTooltipID(item.getToolTipID());
    }
    so.setData("toolbaritem", item);
    SWTSkinButtonUtility btn = (SWTSkinButtonUtility) so.getData("btn");
    if (btn == null) {
        btn = new SWTSkinButtonUtility(so, "toolbar-item-image");
        so.setData("btn", btn);
    }
    btn.setImage(item.getImageID());
    btn.addSelectionListener(buttonListener);
    itemSO.setSkinButton(btn);
    SWTSkinObject soTitle = skin.getSkinObject("toolbar-item-title", so);
    if (soTitle instanceof SWTSkinObjectText) {
        ((SWTSkinObjectText) soTitle).setTextID(item.getTextID());
        itemSO.setSkinTitle((SWTSkinObjectText) soTitle);
    }
    newMap.put(item, itemSO);
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinButtonUtility(com.biglybt.ui.swt.skin.SWTSkinButtonUtility) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) ToolBarItem(com.biglybt.ui.common.ToolBarItem)

Example 3 with SWTSkinButtonUtility

use of com.biglybt.ui.swt.skin.SWTSkinButtonUtility in project BiglyBT by BiglySoftware.

the class ManagerUtils method locateFilesSupport.

private static void locateFilesSupport(final DownloadManager[] dms, final DiskManagerFileInfo[][] dm_files, Shell shell) {
    ClassLoader loader = null;
    if (Constants.isCVSVersion()) {
        try {
            // allow skin file reloading to test
            File file = new File("C:\\Users\\Paul\\git\\BiglyBT\\uis\\src");
            if (file.exists()) {
                URL[] urls = { file.toURI().toURL() };
                loader = new URLClassLoader(urls);
            }
        } catch (Throwable e) {
            Debug.out(e);
        }
    }
    final SkinnedDialog dialog = new SkinnedDialog(loader, "skin3_dlg_findfiles", "shell", shell, SWT.DIALOG_TRIM | SWT.RESIZE);
    SWTSkin skin = dialog.getSkin();
    SWTSkinObjectList so_def_locs = (SWTSkinObjectList) skin.getSkinObject("roots-list");
    org.eclipse.swt.widgets.List def_locs = so_def_locs.getListControl();
    List<String> roots = COConfigurationManager.getStringListParameter("find.files.search.roots");
    if (!roots.isEmpty()) {
        def_locs.setItems(roots.toArray(new String[roots.size()]));
    }
    SWTSkinObjectTextbox so_exp_text = (SWTSkinObjectTextbox) skin.getSkinObject("exp-text");
    SWTSkinObjectButton so_exp_but = (SWTSkinObjectButton) skin.getSkinObject("exp-but");
    SWTSkinObjectButton so_add_but = (SWTSkinObjectButton) skin.getSkinObject("add-but");
    SWTSkinObjectCheckbox so_use_def = (SWTSkinObjectCheckbox) skin.getSkinObject("use-def");
    SWTSkinObjectContainer so_mode = (SWTSkinObjectContainer) skin.getSkinObject("mode");
    SWTSkinObjectCheckbox so_include_skipped = (SWTSkinObjectCheckbox) skin.getSkinObject("skip-inc");
    Composite c_mode = so_mode.getComposite();
    c_mode.setLayoutData(Utils.getFilledFormData());
    FormLayout layout = new FormLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    c_mode.setLayout(layout);
    // mode
    Combo mode_combo = new Combo(c_mode, SWT.READ_ONLY);
    FormData fd = new FormData();
    fd.top = new FormAttachment(c_mode, 0);
    fd.bottom = new FormAttachment(100);
    mode_combo.setLayoutData(fd);
    mode_combo.setItems(// shitty layout doesn't give sufficient width for all options
    MessageText.getString("label.link") + "    ", MessageText.getString("label.copy") + "    ", MessageText.getString("label.move") + "    ", MessageText.getString("Peers.column.piece") + "    ");
    // link mode
    Combo link_combo = new Combo(c_mode, SWT.READ_ONLY);
    fd = new FormData();
    fd.top = new FormAttachment(c_mode, 0);
    fd.bottom = new FormAttachment(100);
    fd.left = new FormAttachment(mode_combo, 2);
    link_combo.setLayoutData(fd);
    link_combo.setItems("    ", // shitty layout doesn't give sufficient width for all options
    MessageText.getString("tag.type.internal") + "    ", MessageText.getString("label.hard") + "    ");
    Utils.setTT(link_combo, MessageText.getString("label.link.type"));
    // tolerance
    CLabel tolerance = new CLabel(c_mode, SWT.CENTER);
    fd = new FormData();
    fd.top = new FormAttachment(c_mode, 0);
    fd.bottom = new FormAttachment(100, -2);
    fd.left = new FormAttachment(link_combo);
    tolerance.setLayoutData(fd);
    tolerance.setText(MessageText.getString("label.tolerance.pct"));
    Spinner spinner = new Spinner(c_mode, SWT.BORDER | SWT.RIGHT);
    fd = new FormData();
    fd.top = new FormAttachment(c_mode, 0);
    fd.bottom = new FormAttachment(100);
    fd.left = new FormAttachment(tolerance, 2);
    fd.right = new FormAttachment(100);
    spinner.setLayoutData(fd);
    spinner.setMinimum(0);
    spinner.setMaximum(10);
    SWTSkinObjectContainer soButtonArea = (SWTSkinObjectContainer) skin.getSkinObject("bottom-area");
    StandardButtonsArea buttonsArea = new StandardButtonsArea() {

        @Override
        protected void clicked(int buttonValue) {
            if (buttonValue == SWT.OK) {
                String[] roots;
                if (so_use_def.isChecked()) {
                    roots = def_locs.getItems();
                } else {
                    roots = new String[] { so_exp_text.getText().trim() };
                }
                int mode = mode_combo.getSelectionIndex();
                int link_type = link_combo.getSelectionIndex();
                int tolerance = spinner.getSelection();
                boolean include_skipped = so_include_skipped.isChecked();
                dialog.close();
                Utils.execSWTThreadLater(1, new Runnable() {

                    public void run() {
                        locateFiles(dms, dm_files, shell, roots, mode, link_type, tolerance, include_skipped);
                    }
                });
            } else {
                dialog.close();
            }
        }
    };
    buttonsArea.setButtonIDs(new String[] { MessageText.getString("Button.search"), MessageText.getString("Button.cancel") });
    buttonsArea.setButtonVals(new Integer[] { SWT.OK, SWT.CANCEL });
    buttonsArea.swt_createButtons(((SWTSkinObjectContainer) soButtonArea).getComposite());
    Runnable state_changed = new Runnable() {

        public void run() {
            String exp_text = so_exp_text.getText().trim();
            boolean is_explicit = !exp_text.isEmpty();
            boolean has_default = def_locs.getItemCount() > 0;
            boolean can_search = is_explicit || has_default;
            so_use_def.setEnabled(has_default);
            if (is_explicit) {
                so_use_def.setChecked(false);
            } else {
                if (has_default) {
                    so_use_def.setChecked(true);
                }
            }
            so_add_but.getButton().setEnabled(is_explicit && !Arrays.asList(def_locs.getItems()).contains(exp_text));
            buttonsArea.setButtonEnabled(SWT.OK, can_search);
            int mode = COConfigurationManager.getIntParameter("find.files.search.mode", LOCATE_MODE_LINK);
            mode_combo.select(mode);
            int link_mode = COConfigurationManager.getIntParameter("find.files.search.mode.link", LOCATE_MODE_LINK_INTERNAL);
            boolean link_enabled = mode == LOCATE_MODE_LINK;
            link_combo.select(link_enabled ? link_mode : LOCATE_MODE_LINK_BLANK);
            link_combo.setEnabled(link_enabled);
        }
    };
    state_changed.run();
    final Menu menu = new Menu(def_locs);
    def_locs.setMenu(menu);
    menu.addMenuListener(new MenuListener() {

        @Override
        public void menuShown(MenuEvent arg0) {
            MenuItem[] items = menu.getItems();
            for (int i = 0; i < items.length; i++) {
                items[i].dispose();
            }
            String[] selected = def_locs.getSelection();
            MenuItem mi = new MenuItem(menu, SWT.PUSH);
            Messages.setLanguageText(mi, "MySharesView.menu.remove");
            Utils.setMenuItemImage(mi, "delete");
            mi.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    List<String> temp = new ArrayList<>(Arrays.asList(def_locs.getItems()));
                    temp.removeAll(Arrays.asList(selected));
                    def_locs.setItems(temp.toArray(new String[temp.size()]));
                    COConfigurationManager.setParameter("find.files.search.roots", temp);
                    state_changed.run();
                }
            });
            mi.setEnabled(selected.length > 0);
        }

        public void menuHidden(MenuEvent arg0) {
        }
    });
    def_locs.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.stateMask == 0 && event.keyCode == SWT.DEL) {
                String[] selected = def_locs.getSelection();
                if (selected.length > 0) {
                    List<String> temp = new ArrayList<>(Arrays.asList(def_locs.getItems()));
                    temp.removeAll(Arrays.asList(selected));
                    def_locs.setItems(temp.toArray(new String[temp.size()]));
                    COConfigurationManager.setParameter("find.files.search.roots", temp);
                    state_changed.run();
                }
            } else {
                int key = event.character;
                if (key <= 26 && key > 0) {
                    key += 'a' - 1;
                }
                if (event.stateMask == SWT.MOD1) {
                    switch(key) {
                        case 'a':
                            {
                                // CTRL+A select all Torrents
                                def_locs.selectAll();
                                event.doit = false;
                                break;
                            }
                    }
                }
            }
        }
    });
    mode_combo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int index = mode_combo.getSelectionIndex();
            COConfigurationManager.setParameter("find.files.search.mode", index);
            state_changed.run();
        }
    });
    link_combo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int index = link_combo.getSelectionIndex();
            if (index == LOCATE_MODE_LINK_BLANK) {
                index = LOCATE_MODE_LINK_INTERNAL;
            }
            COConfigurationManager.setParameter("find.files.search.mode.link", index);
            state_changed.run();
        }
    });
    spinner.addListener(SWT.Selection, (e) -> {
        int value = spinner.getSelection();
        if (value != 0) {
            int index = mode_combo.getSelectionIndex();
            if (index == LOCATE_MODE_LINK) {
                index = LOCATE_MODE_COPY;
                mode_combo.select(index);
                COConfigurationManager.setParameter("find.files.search.mode", index);
                state_changed.run();
            }
        }
    });
    so_exp_text.getTextControl().addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            state_changed.run();
        }
    });
    so_exp_but.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

        @Override
        public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
            DirectoryDialog dd = new DirectoryDialog(shell);
            dd.setFilterPath(TorrentOpener.getFilterPathData());
            dd.setText(MessageText.getString("MyTorrentsView.menu.locatefiles.dialog"));
            String path = dd.open();
            if (path != null) {
                TorrentOpener.setFilterPathData(path);
                so_exp_text.setText(new File(path).getAbsolutePath());
                state_changed.run();
            }
        }
    });
    so_add_but.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

        @Override
        public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
            String loc = so_exp_text.getText().trim();
            String[] existing = def_locs.getItems();
            String[] locs = new String[existing.length + 1];
            int pos = 0;
            for (String e : existing) {
                if (loc.equals(e)) {
                    return;
                }
                locs[pos++] = e;
            }
            locs[pos] = loc;
            def_locs.setItems(locs);
            COConfigurationManager.setParameter("find.files.search.roots", Arrays.asList(locs));
            state_changed.run();
        }
    });
    so_use_def.addSelectionListener(new SWTSkinCheckboxListener() {

        @Override
        public void checkboxChanged(SWTSkinObjectCheckbox so, boolean checked) {
            if (checked) {
                so_exp_text.setText("");
            }
            state_changed.run();
        }
    });
    so_include_skipped.setChecked(COConfigurationManager.getBooleanParameter("find.files.include.skipped"));
    so_include_skipped.addSelectionListener(new SWTSkinCheckboxListener() {

        @Override
        public void checkboxChanged(SWTSkinObjectCheckbox so, boolean checked) {
            COConfigurationManager.setParameter("find.files.include.skipped", checked);
        }
    });
    dialog.open();
}
Also used : KeyAdapter(org.eclipse.swt.events.KeyAdapter) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SWTSkinObjectList(com.biglybt.ui.swt.skin.SWTSkinObjectList) List(java.util.List) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) SWTSkinObjectCheckbox(com.biglybt.ui.swt.skin.SWTSkinObjectCheckbox) SWTSkinObjectButton(com.biglybt.ui.swt.skin.SWTSkinObjectButton) SWTSkinObjectList(com.biglybt.ui.swt.skin.SWTSkinObjectList) TOTorrentFile(com.biglybt.core.torrent.TOTorrentFile) CLabel(org.eclipse.swt.custom.CLabel) SWTSkinCheckboxListener(com.biglybt.ui.swt.skin.SWTSkinCheckboxListener) ModifyListener(org.eclipse.swt.events.ModifyListener) MenuListener(org.eclipse.swt.events.MenuListener) org.eclipse.swt.widgets(org.eclipse.swt.widgets) URL(java.net.URL) KeyEvent(org.eclipse.swt.events.KeyEvent) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectTextbox(com.biglybt.ui.swt.skin.SWTSkinObjectTextbox) URLClassLoader(java.net.URLClassLoader) MenuEvent(org.eclipse.swt.events.MenuEvent) FormLayout(org.eclipse.swt.layout.FormLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) SWTSkinButtonUtility(com.biglybt.ui.swt.skin.SWTSkinButtonUtility) URLClassLoader(java.net.URLClassLoader) SkinnedDialog(com.biglybt.ui.swt.views.skin.SkinnedDialog) StandardButtonsArea(com.biglybt.ui.swt.views.skin.StandardButtonsArea)

Example 4 with SWTSkinButtonUtility

use of com.biglybt.ui.swt.skin.SWTSkinButtonUtility in project BiglyBT by BiglySoftware.

the class SBC_ActivityView method skinObjectInitialShow.

// @see SkinView#showSupport(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    soListArea = getSkinObject(ID + "-area");
    SWTSkinObject so;
    so = getSkinObject(ID + "-button-smalltable");
    if (so != null) {
        btnSmallTable = new SWTSkinButtonUtility(so);
        btnSmallTable.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                setViewMode(MODE_SMALLTABLE, true);
            }
        });
    }
    so = getSkinObject(ID + "-button-bigtable");
    if (so != null) {
        btnBigTable = new SWTSkinButtonUtility(so);
        btnBigTable.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                setViewMode(MODE_BIGTABLE, true);
            }
        });
    }
    so = getSkinObject(ID + "-button-right");
    if (so != null) {
        so.setVisible(true);
        SWTSkinButtonUtility btnReadAll = new SWTSkinButtonUtility(so);
        btnReadAll.setTextID("v3.activity.button.readall");
        btnReadAll.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
                for (ActivitiesEntry entry : allEntries) {
                    entry.setRead(true);
                }
            }
        });
    }
    setViewMode(COConfigurationManager.getIntParameter(ID + ".viewmode", MODE_DEFAULT), false);
    return null;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinButtonUtility(com.biglybt.ui.swt.skin.SWTSkinButtonUtility) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) List(java.util.List)

Example 5 with SWTSkinButtonUtility

use of com.biglybt.ui.swt.skin.SWTSkinButtonUtility in project BiglyBT by BiglySoftware.

the class ToolBarView method initSO.

private void initSO(SWTSkinObject so, ToolBarItemSO itemSO) {
    ToolBarItem item = itemSO.getBase();
    itemSO.setSO(so);
    String toolTip = item.getToolTip();
    if (toolTip != null) {
        so.setTooltipID("!" + toolTip + "!");
    } else {
        so.setTooltipID(item.getToolTipID());
    }
    so.setData("toolbaritem", item);
    SWTSkinButtonUtility btn = (SWTSkinButtonUtility) so.getData("btn");
    if (btn == null) {
        btn = new SWTSkinButtonUtility(so, "toolbar-item-image");
        so.setData("btn", btn);
    }
    btn.setImage(item.getImageID());
    btn.addSelectionListener(buttonListener);
    itemSO.setSkinButton(btn);
    SWTSkinObject soTitle = skin.getSkinObject("toolbar-item-title", so);
    if (soTitle instanceof SWTSkinObjectText) {
        ((SWTSkinObjectText) soTitle).setTextID(item.getTextID());
        itemSO.setSkinTitle((SWTSkinObjectText) soTitle);
    }
    synchronized (mapToolBarItemToSO) {
        mapToolBarItemToSO.put(item, itemSO);
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinButtonUtility(com.biglybt.ui.swt.skin.SWTSkinButtonUtility) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) ToolBarItem(com.biglybt.ui.common.ToolBarItem)

Aggregations

SWTSkinButtonUtility (com.biglybt.ui.swt.skin.SWTSkinButtonUtility)6 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)6 ToolBarItem (com.biglybt.ui.common.ToolBarItem)2 SWTSkinObjectText (com.biglybt.ui.swt.skin.SWTSkinObjectText)2 List (java.util.List)2 ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)1 Tag (com.biglybt.core.tag.Tag)1 TagType (com.biglybt.core.tag.TagType)1 TOTorrentFile (com.biglybt.core.torrent.TOTorrentFile)1 SWTSkin (com.biglybt.ui.swt.skin.SWTSkin)1 ButtonListenerAdapter (com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter)1 SWTSkinCheckboxListener (com.biglybt.ui.swt.skin.SWTSkinCheckboxListener)1 SWTSkinObjectButton (com.biglybt.ui.swt.skin.SWTSkinObjectButton)1 SWTSkinObjectCheckbox (com.biglybt.ui.swt.skin.SWTSkinObjectCheckbox)1 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)1 SWTSkinObjectList (com.biglybt.ui.swt.skin.SWTSkinObjectList)1 SWTSkinObjectTextbox (com.biglybt.ui.swt.skin.SWTSkinObjectTextbox)1 SkinnedDialog (com.biglybt.ui.swt.views.skin.SkinnedDialog)1 StandardButtonsArea (com.biglybt.ui.swt.views.skin.StandardButtonsArea)1 URL (java.net.URL)1