Search in sources :

Example 1 with UIInputReceiver

use of com.biglybt.pif.ui.UIInputReceiver in project BiglyBT by BiglySoftware.

the class FilesViewMenuUtil method askForRenameFilenameAndExec.

private static void askForRenameFilenameAndExec(final DiskManagerFileInfo fileInfo, final TableView tv) {
    final SimpleTextEntryWindow dialog = new SimpleTextEntryWindow("FilesView.rename.filename.title", "FilesView.rename.filename.text");
    String file_name = fileInfo.getFile(true).getName();
    // false -> it's not "suggested", it's a previous value
    dialog.setPreenteredText(file_name, false);
    int pos = file_name.lastIndexOf('.');
    if (pos > 0) {
        String suffix = fileInfo.getDownloadManager().getDownloadState().getAttribute(DownloadManagerState.AT_INCOMP_FILE_SUFFIX);
        if (suffix != null && file_name.substring(pos).equals(suffix)) {
            pos--;
            while (pos > 0 && file_name.charAt(pos) != '.') {
                pos--;
            }
        }
        if (pos > 0) {
            dialog.selectPreenteredTextRange(new int[] { 0, pos });
        }
    }
    dialog.allowEmptyInput(false);
    dialog.prompt(new UIInputReceiverListener() {

        @Override
        public void UIInputReceiverClosed(UIInputReceiver receiver) {
            if (!receiver.hasSubmittedInput()) {
                return;
            }
            File existing_file = fileInfo.getFile(true);
            File f_target = new File(existing_file.getParentFile(), receiver.getSubmittedInput());
            DownloadManager manager = fileInfo.getDownloadManager();
            boolean needsUnpause = manager.pause();
            moveFile(fileInfo.getDownloadManager(), fileInfo, f_target, false, new Runnable() {

                @Override
                public void run() {
                    if (needsUnpause) {
                        manager.resume();
                    }
                    invalidateRows(tv, Arrays.asList(fileInfo));
                }
            });
        }
    });
}
Also used : SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) File(java.io.File) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 2 with UIInputReceiver

use of com.biglybt.pif.ui.UIInputReceiver in project BiglyBT by BiglySoftware.

the class BuddyUIUtils method createChat.

public static void createChat(Menu parent_menu, ChatCreationListener listener) {
    Menu menu = new Menu(parent_menu.getShell(), SWT.DROP_DOWN);
    org.eclipse.swt.widgets.MenuItem mi = new org.eclipse.swt.widgets.MenuItem(parent_menu, SWT.CASCADE);
    Messages.setLanguageText(mi, "chat.view.create.chat");
    mi.setMenu(menu);
    org.eclipse.swt.widgets.MenuItem mi_pub = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
    mi_pub.setText(MessageText.getString("label.public") + "...");
    mi_pub.addListener(SWT.Selection, (ev) -> {
        SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("chat.view.enter.key.title", "chat.view.enter.key.msg");
        entryWindow.prompt(new UIInputReceiverListener() {

            @Override
            public void UIInputReceiverClosed(UIInputReceiver receiver) {
                if (!receiver.hasSubmittedInput()) {
                    return;
                }
                String key = receiver.getSubmittedInput().trim();
                BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_PUBLIC, key, null);
                listener.chatCreated(null, AENetworkClassifier.AT_PUBLIC + ": " + key);
            }
        });
    });
    org.eclipse.swt.widgets.MenuItem mi_anon = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
    mi_anon.setText(MessageText.getString("label.anon") + "...");
    mi_anon.addListener(SWT.Selection, (ev) -> {
        SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("chat.view.enter.key.title", "chat.view.enter.key.msg");
        entryWindow.prompt(new UIInputReceiverListener() {

            @Override
            public void UIInputReceiverClosed(UIInputReceiver receiver) {
                if (!receiver.hasSubmittedInput()) {
                    return;
                }
                String key = receiver.getSubmittedInput().trim();
                BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_I2P, key, null);
                listener.chatCreated(null, AENetworkClassifier.AT_I2P + ": " + key);
            }
        });
    });
}
Also used : SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) MenuItem(com.biglybt.pif.ui.menus.MenuItem) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) Menu(org.eclipse.swt.widgets.Menu)

Example 3 with UIInputReceiver

use of com.biglybt.pif.ui.UIInputReceiver in project BiglyBT by BiglySoftware.

the class BuddyUIUtils method createChat.

public static void createChat(MenuManager menu_manager, MenuItem menu, boolean immediate, ChatCreationListener _listener) {
    ChatCreationListener listener = new ChatCreationListener() {

        Object lock = new Object();

        TimerEventPeriodic timer;

        public void chatCreated(Object target, String name) {
            _listener.chatCreated(target, name);
        }

        public void chatAvailable(Object target, ChatInstance chat) {
            synchronized (lock) {
                if (timer != null) {
                    return;
                }
                long start = SystemTime.getMonotonousTime();
                timer = SimpleTimer.addPeriodicEvent("availcheck", 1000, (ev) -> {
                    if (chat.isAvailable()) {
                        if (!chat.isDestroyed()) {
                            _listener.chatAvailable(target, chat);
                        }
                        synchronized (lock) {
                            timer.cancel();
                        }
                    }
                    if (SystemTime.getMonotonousTime() - start > 3 * 60 * 1000) {
                        Debug.out("Gave up waiting for " + chat.getNetAndKey() + " to become available");
                        synchronized (lock) {
                            timer.cancel();
                        }
                    }
                });
            }
        }
    };
    Runnable build = () -> {
        MenuItem mi = menu_manager.addMenuItem(menu, "!" + MessageText.getString("label.public") + "...!");
        mi.addMultiListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("chat.view.enter.key.title", "chat.view.enter.key.msg");
                // if we don't do this then the fancy-menu will stay open...
                entryWindow.setParentShell(Utils.findAnyShell(true));
                entryWindow.prompt(new UIInputReceiverListener() {

                    @Override
                    public void UIInputReceiverClosed(UIInputReceiver receiver) {
                        if (!receiver.hasSubmittedInput()) {
                            return;
                        }
                        String key = receiver.getSubmittedInput().trim();
                        listener.chatCreated(target, AENetworkClassifier.AT_PUBLIC + ": " + key);
                        BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_PUBLIC, key, (chat) -> {
                            listener.chatAvailable(target, chat);
                        });
                    }
                });
            }
        });
        mi = menu_manager.addMenuItem(menu, "!" + MessageText.getString("label.anon") + "...!");
        mi.addMultiListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                if (BuddyPluginUtils.getBetaPlugin().isI2PAvailable()) {
                    SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("chat.view.enter.key.title", "chat.view.enter.key.msg");
                    // if we don't do this then the fancy-menu will stay open...
                    entryWindow.setParentShell(Utils.findAnyShell(true));
                    entryWindow.prompt(new UIInputReceiverListener() {

                        @Override
                        public void UIInputReceiverClosed(UIInputReceiver receiver) {
                            if (!receiver.hasSubmittedInput()) {
                                return;
                            }
                            String key = receiver.getSubmittedInput().trim();
                            listener.chatCreated(target, AENetworkClassifier.AT_I2P + ": " + key);
                            BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_I2P, key, (chat) -> {
                                if (chat != null) {
                                    listener.chatAvailable(target, chat);
                                }
                            });
                        }
                    });
                } else {
                    I2PHelpers.installI2PHelper(null, null, null);
                }
            }
        });
        if (I2PHelpers.isInstallingI2PHelper()) {
            mi.setEnabled(false);
            mi.setText(mi.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
        }
    };
    if (immediate) {
        build.run();
    } else {
        menu.addFillListener(new com.biglybt.pif.ui.menus.MenuItemFillListener() {

            @Override
            public void menuWillBeShown(MenuItem menu, Object data) {
                menu.removeAllChildItems();
                build.run();
            }
        });
    }
}
Also used : TimerEventPeriodic(com.biglybt.core.util.TimerEventPeriodic) SystemTime(com.biglybt.core.util.SystemTime) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) TimerEventPeriodic(com.biglybt.core.util.TimerEventPeriodic) Messages(com.biglybt.ui.swt.Messages) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) MenuManager(com.biglybt.pif.ui.menus.MenuManager) I2PHelpers(com.biglybt.plugin.I2PHelpers) MessageText(com.biglybt.core.internat.MessageText) ChatInstance(com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance) Debug(com.biglybt.core.util.Debug) Utils(com.biglybt.ui.swt.Utils) SimpleTimer(com.biglybt.core.util.SimpleTimer) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) SWT(org.eclipse.swt.SWT) MenuItem(com.biglybt.pif.ui.menus.MenuItem) Menu(org.eclipse.swt.widgets.Menu) AENetworkClassifier(com.biglybt.core.util.AENetworkClassifier) BuddyPluginUtils(com.biglybt.plugin.net.buddy.BuddyPluginUtils) ChatInstance(com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance) MenuItem(com.biglybt.pif.ui.menus.MenuItem) SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener)

Example 4 with UIInputReceiver

use of com.biglybt.pif.ui.UIInputReceiver in project BiglyBT by BiglySoftware.

the class BuddyPluginViewBetaChat method buildStatus.

private void buildStatus(Composite main_component, Composite component) {
    boolean public_chat = !chat.isPrivateChat();
    final Label menu_drop = new Label(component, SWT.NULL);
    Messages.setLanguageTooltip(menu_drop, "TagSettingsView.title");
    FontData fontData = menu_drop.getFont().getFontData()[0];
    Display display = menu_drop.getDisplay();
    italic_font = new Font(display, new FontData(fontData.getName(), fontData.getHeight(), SWT.ITALIC));
    bold_font = new Font(display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
    big_font = new Font(display, new FontData(fontData.getName(), (int) (fontData.getHeight() * 1.5), SWT.BOLD));
    small_font = new Font(display, new FontData(fontData.getName(), (int) (fontData.getHeight() * 0.5), SWT.BOLD));
    boolean dark = Utils.isDarkAppearanceNative();
    if (dark) {
        Color bg = Colors.getSystemColor(display, SWT.COLOR_WIDGET_BACKGROUND);
        Color fg = Colors.getSystemColor(display, SWT.COLOR_WIDGET_FOREGROUND);
        ftux_dark_bg = new Color(display, bg.getRGB());
        ftux_dark_fg = new Color(display, fg.getRGB());
        ftux_light_bg = new Color(display, bg.getRGB());
    } else {
        ftux_dark_bg = new Color(display, 183, 200, 212);
        ftux_dark_fg = new Color(display, 0, 81, 134);
        ftux_light_bg = new Color(display, 236, 242, 246);
    }
    component.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent arg0) {
            Font[] fonts = { italic_font, bold_font, big_font, small_font };
            for (Font f : fonts) {
                if (f != null) {
                    f.dispose();
                }
            }
            Color[] colours = { ftux_dark_bg, ftux_dark_fg, ftux_light_bg };
            for (Color c : colours) {
                if (c != null) {
                    c.dispose();
                }
            }
            if (drop_targets != null) {
                for (DropTarget dt : drop_targets) {
                    dt.dispose();
                }
            }
            closed();
        }
    });
    status = new BufferedLabel(component, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    GridData grid_data = new GridData(GridData.FILL_HORIZONTAL);
    status.setLayoutData(grid_data);
    status.setText(MessageText.getString("PeersView.state.pending"));
    BubbleTextBox bubbleTextBox = new BubbleTextBox(component, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL | SWT.SINGLE);
    Text bubbleTextWidget = bubbleTextBox.getTextWidget();
    GridData gridData = new GridData();
    gridData.widthHint = 100;
    bubbleTextBox.setMessageAndLayout(MessageText.getString("Button.search") + "...", gridData);
    bubbleTextWidget.addModifyListener((e) -> {
        String text = bubbleTextWidget.getText();
        search(text.trim());
    });
    bubbleTextWidget.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == '\r') {
                search("\n");
            } else if (e.keyCode == SWT.ESC) {
                bubbleTextWidget.setText("");
            }
        }
    });
    Image image = ImageLoader.getInstance().getImage("cog_down");
    menu_drop.setImage(image);
    grid_data = new GridData();
    grid_data.widthHint = image.getBounds().width;
    grid_data.heightHint = image.getBounds().height;
    menu_drop.setLayoutData(grid_data);
    menu_drop.setCursor(menu_drop.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    Control status_control = status.getControl();
    final Menu status_menu = new Menu(status_control);
    status.getControl().setMenu(status_menu);
    menu_drop.setMenu(status_menu);
    menu_drop.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent event) {
            try {
                Point p = status_menu.getDisplay().map(menu_drop, null, event.x, event.y);
                status_menu.setLocation(p);
                status_menu.setVisible(true);
            } catch (Throwable e) {
                Debug.out(e);
            }
        }
    });
    if (public_chat) {
        Menu status_clip_menu = new Menu(component.getShell(), SWT.DROP_DOWN);
        MenuItem status_clip_item = new MenuItem(status_menu, SWT.CASCADE);
        status_clip_item.setMenu(status_clip_menu);
        status_clip_item.setText(MessageText.getString("label.copy.to.clipboard"));
        MenuItem status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.channel.key"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard(chat.getKey());
            }
        });
        status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.channel.url"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard(chat.getURL());
            }
        });
        status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.rss.url"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard("azplug:?id=azbuddy&arg=" + UrlUtils.encode(chat.getURL() + "&format=rss"));
            }
        });
        status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.channel.pk"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard(Base32.encode(chat.getPublicKey()));
            }
        });
        status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.channel.export"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard(chat.export());
            }
        });
        if (!chat.isManaged()) {
            Menu status_channel_menu = new Menu(component.getShell(), SWT.DROP_DOWN);
            MenuItem status_channel_item = new MenuItem(status_menu, SWT.CASCADE);
            status_channel_item.setMenu(status_channel_menu);
            status_channel_item.setText(MessageText.getString("azbuddy.dchat.rchans"));
            // Managed channel
            status_mi = new MenuItem(status_channel_menu, SWT.PUSH);
            status_mi.setText(MessageText.getString("azbuddy.dchat.rchans.managed"));
            status_mi.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    try {
                        ChatInstance inst = chat.getManagedChannel();
                        BuddyPluginViewBetaChat.createChatWindow(view, plugin, inst);
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
            // RO channel
            status_mi = new MenuItem(status_channel_menu, SWT.PUSH);
            status_mi.setText(MessageText.getString("azbuddy.dchat.rchans.ro"));
            status_mi.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    try {
                        ChatInstance inst = chat.getReadOnlyChannel();
                        createChatWindow(view, plugin, inst);
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
            // Random sub-channel
            status_mi = new MenuItem(status_channel_menu, SWT.PUSH);
            status_mi.setText(MessageText.getString("azbuddy.dchat.rchans.rand"));
            status_mi.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    try {
                        byte[] rand = new byte[20];
                        RandomUtils.nextSecureBytes(rand);
                        ChatInstance inst = beta.getChat(chat.getNetwork(), chat.getKey() + " {" + Base32.encode(rand) + "}");
                        createChatWindow(view, plugin, inst);
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
            if (beta.isI2PAvailable()) {
                status_mi = new MenuItem(status_channel_menu, SWT.PUSH);
                status_mi.setText(MessageText.getString(chat.getNetwork() == AENetworkClassifier.AT_I2P ? "azbuddy.dchat.rchans.pub" : "azbuddy.dchat.rchans.anon"));
                status_mi.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent event) {
                        try {
                            ChatInstance inst = beta.getChat(chat.getNetwork() == AENetworkClassifier.AT_I2P ? AENetworkClassifier.AT_PUBLIC : AENetworkClassifier.AT_I2P, chat.getKey());
                            createChatWindow(view, plugin, inst);
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                    }
                });
            }
        }
        final MenuItem fave_mi = new MenuItem(status_menu, SWT.CHECK);
        fave_mi.setText(MessageText.getString("label.fave"));
        fave_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setFavourite(fave_mi.getSelection());
            }
        });
        final MenuItem sis_mi = new MenuItem(status_menu, SWT.PUSH);
        sis_mi.setText(MessageText.getString(Utils.isAZ2UI() ? "label.show.in.tab" : "label.show.in.sidebar"));
        sis_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                BuddyPluginUI.openChat(chat.getNetwork(), chat.getKey());
            }
        });
        addFriendsMenu(status_menu);
        // advanced
        final Menu advanced_menu = new Menu(status_menu.getShell(), SWT.DROP_DOWN);
        MenuItem advanced_menu_item = new MenuItem(status_menu, SWT.CASCADE);
        advanced_menu_item.setMenu(advanced_menu);
        advanced_menu_item.setText(MessageText.getString("MyTorrentsView.menu.advancedmenu"));
        // rename
        final MenuItem rename_mi = new MenuItem(advanced_menu, SWT.PUSH);
        rename_mi.setText(MessageText.getString("MyTorrentsView.menu.rename"));
        rename_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                String name = chat.getDisplayName();
                if (name == null) {
                    name = chat.getName();
                }
                UISWTInputReceiver entry = new SimpleTextEntryWindow();
                entry.setPreenteredText(name, false);
                entry.maintainWhitespace(false);
                entry.allowEmptyInput(false);
                entry.setLocalisedTitle(MessageText.getString("label.rename", new String[] { name }));
                entry.prompt(new UIInputReceiverListener() {

                    @Override
                    public void UIInputReceiverClosed(UIInputReceiver entry) {
                        if (!entry.hasSubmittedInput()) {
                            return;
                        }
                        String input = entry.getSubmittedInput().trim();
                        if (input.length() > 0) {
                            try {
                                chat.setDisplayName(input);
                            } catch (Throwable e) {
                                Debug.printStackTrace(e);
                            }
                        }
                    }
                });
            }
        });
        // view type
        final Menu vt_menu = new Menu(status_menu.getShell(), SWT.DROP_DOWN);
        MenuItem vt_menu_item = new MenuItem(advanced_menu, SWT.CASCADE);
        vt_menu_item.setMenu(vt_menu);
        vt_menu_item.setText(MessageText.getString("menu.view.options"));
        SelectionAdapter listener = new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                int vt = -1;
                for (MenuItem mi : vt_menu.getItems()) {
                    if (mi.getSelection()) {
                        vt = (Integer) mi.getData();
                    }
                }
                if (vt != -1) {
                    chat.setViewType(vt);
                    buildSupport(main_component);
                    main_component.layout(true, true);
                }
            }
        };
        MenuItem vt_mi = new MenuItem(vt_menu, SWT.RADIO);
        vt_mi.setText(MessageText.getString("label.full"));
        vt_mi.setData(BuddyPluginBeta.VIEW_TYPE_DEFAULT);
        vt_mi.addSelectionListener(listener);
        vt_mi = new MenuItem(vt_menu, SWT.RADIO);
        vt_mi.setText(MessageText.getString("ConfigView.section.sharing"));
        vt_mi.setData(BuddyPluginBeta.VIEW_TYPE_SHARING);
        if (chat.isReadOnly()) {
            vt_mi.setEnabled(false);
        }
        vt_mi.addSelectionListener(listener);
        vt_menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuShown(MenuEvent e) {
                int vt = chat.getViewType();
                for (MenuItem mi : vt_menu.getItems()) {
                    mi.setSelection(vt == (Integer) mi.getData());
                }
            }
        });
        // persist messages
        final MenuItem persist_mi = new MenuItem(advanced_menu, SWT.CHECK);
        persist_mi.setText(MessageText.getString("azbuddy.dchat.save.messages"));
        persist_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setSaveMessages(persist_mi.getSelection());
            }
        });
        final MenuItem log_mi = new MenuItem(advanced_menu, SWT.CHECK);
        log_mi.setText(MessageText.getString("azbuddy.dchat.log.messages"));
        log_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setLogMessages(log_mi.getSelection());
            }
        });
        final MenuItem automute_mi = new MenuItem(advanced_menu, SWT.CHECK);
        automute_mi.setText(MessageText.getString("azbuddy.dchat.auto.mute"));
        automute_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setAutoMute(automute_mi.getSelection());
            }
        });
        final MenuItem postnotifications_mi = new MenuItem(advanced_menu, SWT.CHECK);
        postnotifications_mi.setText(MessageText.getString("azbuddy.dchat.post.to.notifcations"));
        postnotifications_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setEnableNotificationsPost(postnotifications_mi.getSelection());
            }
        });
        final MenuItem disableindicators_mi = new MenuItem(advanced_menu, SWT.CHECK);
        disableindicators_mi.setText(MessageText.getString("azbuddy.dchat.disable.msg.indicators"));
        disableindicators_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setDisableNewMsgIndications(disableindicators_mi.getSelection());
            }
        });
        // setup menu
        status_menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuShown(MenuEvent e) {
                fave_mi.setSelection(chat.isFavourite());
                persist_mi.setSelection(chat.getSaveMessages());
                log_mi.setSelection(chat.getLogMessages());
                automute_mi.setSelection(chat.getAutoMute());
                postnotifications_mi.setSelection(chat.getEnableNotificationsPost());
                boolean disable_indications = chat.getDisableNewMsgIndications();
                disableindicators_mi.setSelection(disable_indications);
                postnotifications_mi.setEnabled(!disable_indications);
            }
        });
    } else {
        final Menu status_priv_menu = new Menu(component.getShell(), SWT.DROP_DOWN);
        MenuItem status_priv_item = new MenuItem(status_menu, SWT.CASCADE);
        status_priv_item.setMenu(status_priv_menu);
        status_priv_item.setText(MessageText.getString("label.private.chat"));
        SelectionAdapter listener = new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                beta.setPrivateChatState((Integer) ((MenuItem) e.widget).getData());
            }
        };
        MenuItem status_mi = new MenuItem(status_priv_menu, SWT.RADIO);
        status_mi.setText(MessageText.getString("label.enabled"));
        status_mi.setData(BuddyPluginBeta.PRIVATE_CHAT_ENABLED);
        status_mi.addSelectionListener(listener);
        status_mi = new MenuItem(status_priv_menu, SWT.RADIO);
        status_mi.setText(MessageText.getString("label.pinned.only"));
        status_mi.setData(BuddyPluginBeta.PRIVATE_CHAT_PINNED_ONLY);
        status_mi.addSelectionListener(listener);
        status_mi = new MenuItem(status_priv_menu, SWT.RADIO);
        status_mi.setText(MessageText.getString("label.disabled"));
        status_mi.setData(BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
        status_mi.addSelectionListener(listener);
        status_priv_menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuShown(MenuEvent e) {
                int pc_state = beta.getPrivateChatState();
                for (MenuItem mi : status_priv_menu.getItems()) {
                    mi.setSelection(pc_state == (Integer) mi.getData());
                }
            }
        });
        addFriendsMenu(status_menu);
        final MenuItem keep_alive_mi = new MenuItem(status_menu, SWT.CHECK);
        keep_alive_mi.setText(MessageText.getString("label.keep.alive"));
        status_menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuShown(MenuEvent e) {
                keep_alive_mi.setSelection(chat.getUserData("AC:KeepAlive") != null);
            }
        });
        keep_alive_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ChatInstance clone = (ChatInstance) chat.getUserData("AC:KeepAlive");
                if (clone != null) {
                    clone.destroy();
                    clone = null;
                } else {
                    try {
                        clone = chat.getClone();
                    } catch (Throwable f) {
                    }
                }
                chat.setUserData("AC:KeepAlive", clone);
            }
        });
        final MenuItem sis_mi = new MenuItem(status_menu, SWT.PUSH);
        sis_mi.setText(MessageText.getString(Utils.isAZ2UI() ? "label.show.in.tab" : "label.show.in.sidebar"));
        sis_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                BuddyPluginUI.openChat(chat.getNetwork(), chat.getKey());
            }
        });
    }
}
Also used : BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) BubbleTextBox(com.biglybt.ui.swt.components.BubbleTextBox) UISWTInputReceiver(com.biglybt.ui.swt.pif.UISWTInputReceiver) MessageText(com.biglybt.core.internat.MessageText) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener)

Example 5 with UIInputReceiver

use of com.biglybt.pif.ui.UIInputReceiver in project BiglyBT by BiglySoftware.

the class TorrentUtil method repositionManual.

public static void repositionManual(final TableView<DownloadManager> tv, final DownloadManager[] dms, final Shell shell, final boolean isSeedingView) {
    SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("MyTorrentsView.dialog.setPosition.title", "MyTorrentsView.dialog.setPosition.text");
    entryWindow.prompt(new UIInputReceiverListener() {

        @Override
        public void UIInputReceiverClosed(UIInputReceiver entryWindow) {
            if (!entryWindow.hasSubmittedInput()) {
                return;
            }
            String sReturn = entryWindow.getSubmittedInput();
            if (sReturn == null)
                return;
            int newPosition = -1;
            try {
                newPosition = Integer.valueOf(sReturn).intValue();
            } catch (NumberFormatException er) {
            // Ignore
            }
            Core core = CoreFactory.getSingleton();
            if (core == null) {
                return;
            }
            if (newPosition <= 0) {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setText(MessageText.getString("MyTorrentsView.dialog.NumberError.title"));
                mb.setMessage(MessageText.getString("MyTorrentsView.dialog.NumberError.text"));
                mb.open();
                return;
            }
            moveSelectedTorrentsTo(tv, dms, newPosition);
        }
    });
}
Also used : UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) Core(com.biglybt.core.Core) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Aggregations

UIInputReceiver (com.biglybt.pif.ui.UIInputReceiver)38 UIInputReceiverListener (com.biglybt.pif.ui.UIInputReceiverListener)36 SimpleTextEntryWindow (com.biglybt.ui.swt.SimpleTextEntryWindow)21 List (java.util.List)11 DownloadManager (com.biglybt.core.download.DownloadManager)9 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)7 TrackerEditorListener (com.biglybt.ui.swt.maketorrent.TrackerEditorListener)7 Point (org.eclipse.swt.graphics.Point)7 CoreRunningListener (com.biglybt.core.CoreRunningListener)6 File (java.io.File)6 MenuEvent (org.eclipse.swt.events.MenuEvent)6 ParameterListener (com.biglybt.core.config.ParameterListener)5 MessageText (com.biglybt.core.internat.MessageText)5 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)5 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)5 TableViewSWTMenuFillListener (com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener)5 DisposeEvent (org.eclipse.swt.events.DisposeEvent)5 DisposeListener (org.eclipse.swt.events.DisposeListener)5