Search in sources :

Example 21 with SWTSkinObjectContainer

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

the class ToolBarView method addNonToolBar.

private void addNonToolBar(String skinid, String groupID) {
    SWTSkinObjectContainer soGroup = getGroupSO(groupID);
    Control lastControl = getLastControl(groupID);
    SWTSkinObject so = skin.createSkinObject("toolbar_d" + Math.random(), skinid, soGroup);
    if (so != null) {
        if (lastControl != null) {
            FormData fd = (FormData) so.getControl().getLayoutData();
            fd.left = new FormAttachment(lastControl, fd.left == null ? 0 : fd.left.offset);
        }
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) Control(org.eclipse.swt.widgets.Control) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 22 with SWTSkinObjectContainer

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

the class ToolBarView method getLastControl.

private Control getLastControl(String groupID) {
    SWTSkinObjectContainer groupSO = getGroupSO(groupID);
    SWTSkinObject[] children = groupSO.getChildren();
    if (children == null || children.length == 0) {
        return null;
    }
    return children[children.length - 1].getControl();
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer)

Example 23 with SWTSkinObjectContainer

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

the class TorrentListViewsUtils method _playOrStream.

private static void _playOrStream(final DownloadManager dm, final int file_index, final boolean complete_only, final String referal) {
    if (dm == null) {
        return;
    }
    // if (!canPlay(dm)) {
    // return false;
    // }
    final TOTorrent torrent = dm.getTorrent();
    if (torrent == null) {
        return;
    }
    if (file_index == -1) {
        final int[] playableFileIndexes = PlayUtils.getExternallyPlayableFileIndexes(PluginCoreUtils.wrap(dm), complete_only);
        if (playableFileIndexes.length == 1) {
            int open_result = openInEMP(dm, file_index, complete_only, referal);
            if (open_result == 0) {
                PlatformTorrentUtils.setHasBeenOpened(dm, true);
            }
        } else if (playableFileIndexes.length > 1) {
            VuzeMessageBox mb = new VuzeMessageBox(MessageText.getString("ConfigView.option.dm.dblclick.play"), null, new String[] { MessageText.getString("iconBar.play"), MessageText.getString("Button.cancel") }, 0);
            final Map<Integer, Integer> mapPositionToFileInfo = new HashMap<>();
            final int[] selectedIndex = { // default selection is first entry
            0 };
            mb.setSubTitle(MessageText.getString("play.select.content"));
            mb.setListener(new VuzeMessageBoxListener() {

                @Override
                public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
                    SWTSkin skin = soExtra.getSkin();
                    Composite composite = soExtra.getComposite();
                    final Table table = new Table(composite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.SINGLE);
                    table.setBackground(composite.getBackground());
                    table.addSelectionListener(new SelectionListener() {

                        @Override
                        public void widgetSelected(SelectionEvent e) {
                            selectedIndex[0] = table.getSelectionIndex();
                        }

                        @Override
                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
                    });
                    FormData formData = Utils.getFilledFormData();
                    formData.bottom.offset = -20;
                    Utils.setLayoutData(table, formData);
                    table.setHeaderVisible(false);
                    table.addListener(SWT.MeasureItem, new Listener() {

                        @Override
                        public void handleEvent(Event event) {
                            int w = table.getClientArea().width - 5;
                            if (w == 0) {
                                return;
                            }
                            if (event.width < w) {
                                event.width = w;
                            }
                        }
                    });
                    String prefix = dm.getSaveLocation().toString();
                    int i = 0;
                    DiskManagerFileInfo[] fileInfos = dm.getDiskManagerFileInfoSet().getFiles();
                    for (int fileIndex : playableFileIndexes) {
                        if (fileIndex < 0 || fileIndex >= fileInfos.length) {
                            continue;
                        }
                        File f = fileInfos[fileIndex].getFile(true);
                        String path = f.getParent();
                        if (path.startsWith(prefix)) {
                            path = path.length() > prefix.length() ? path.substring(prefix.length() + 1) : "";
                        }
                        String s = f.getName();
                        if (path.length() > 0) {
                            s += " in " + path;
                        }
                        TableItem item = new TableItem(table, SWT.NONE);
                        item.setText(s);
                        mapPositionToFileInfo.put(i++, fileIndex);
                    }
                    Image alphaImage = Utils.createAlphaImage(table.getDisplay(), 1, 25, (byte) 255);
                    TableItem item = table.getItem(0);
                    item.setImage(alphaImage);
                    item.setImage((Image) null);
                    alphaImage.dispose();
                    table.setSelection(0);
                }
            });
            mb.open(new UserPrompterResultListener() {

                @Override
                public void prompterClosed(int result) {
                    if (result != 0 || selectedIndex[0] < 0) {
                        return;
                    }
                    Integer file_index = mapPositionToFileInfo.get(selectedIndex[0]);
                    if (file_index != null) {
                        int open_result = openInEMP(dm, file_index, complete_only, referal);
                        if (open_result == 0) {
                            PlatformTorrentUtils.setHasBeenOpened(dm, file_index, true);
                        }
                    }
                }
            });
        }
        return;
    }
    if (PlayUtils.canUseEMP(torrent, file_index, complete_only)) {
        debug("Can use EMP");
        int open_result = openInEMP(dm, file_index, complete_only, referal);
        if (open_result == 0) {
            PlatformTorrentUtils.setHasBeenOpened(dm, file_index, true);
            return;
        } else if (open_result == 2) {
            debug("Open in EMP abandoned");
            return;
        } else {
            debug("Open EMP Failed");
        }
    // fallback to normal
    } else {
        debug("Can't use EMP.");
    }
// We used to pop up a dialog saying we didn't know how to play the file
// But now the play toolbar and play 'default' action aren't even enabled
// if we can't use EMP.  So there's no point.
}
Also used : UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Image(org.eclipse.swt.graphics.Image) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormData(org.eclipse.swt.layout.FormData) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) TOTorrent(com.biglybt.core.torrent.TOTorrent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) HashMap(java.util.HashMap) Map(java.util.Map) VuzeFile(com.biglybt.core.vuzefile.VuzeFile) File(java.io.File) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)23 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)15 SWTSkin (com.biglybt.ui.swt.skin.SWTSkin)8 GridLayout (org.eclipse.swt.layout.GridLayout)8 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)4 VuzeMessageBox (com.biglybt.ui.swt.views.skin.VuzeMessageBox)4 VuzeMessageBoxListener (com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener)4 FormData (org.eclipse.swt.layout.FormData)4 GridData (org.eclipse.swt.layout.GridData)4 UISWTViewImpl (com.biglybt.ui.swt.pifimpl.UISWTViewImpl)3 SWTSkinObjectListener (com.biglybt.ui.swt.skin.SWTSkinObjectListener)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 ConfigurationParameterNotFoundException (com.biglybt.core.config.impl.ConfigurationParameterNotFoundException)2 TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)2 UIUpdatable (com.biglybt.ui.common.updater.UIUpdatable)2 UIUpdater (com.biglybt.ui.common.updater.UIUpdater)2 MdiEntryVitalityImage (com.biglybt.ui.mdi.MdiEntryVitalityImage)2 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)2 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2