Search in sources :

Example 1 with VuzeMessageBoxListener

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

the class DebugMenuHelper method createDebugMenuItem.

/**
 * Creates the Debug menu and its children
 * NOTE: This is a development only menu and so it's not modularized into separate menu items
 * because this menu is always rendered in its entirety
 * @param menu
 * @param mainWindow
 * @return
 */
public static MenuItem createDebugMenuItem(final Menu menuDebug) {
    MenuItem item;
    final UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (null == uiFunctions) {
        throw new IllegalStateException("UIFunctionsManagerSWT.getUIFunctionsSWT() is returning null");
    }
    item = new MenuItem(menuDebug, SWT.CASCADE);
    item.setText("Run GC");
    item.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            System.gc();
        }
    });
    item = new MenuItem(menuDebug, SWT.PUSH);
    item.setText("&CoreReq");
    item.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    new MessageBoxShell(0, "Done", "Core Now Avail").open(null);
                }
            });
        }
    });
    /*
		item = new MenuItem(menuDebug, SWT.CASCADE);
		item.setText("Subscriptions");
		Menu menuSubscriptions = new Menu(menuDebug.getParent(), SWT.DROP_DOWN);
		item.setMenu(menuSubscriptions);

		item = new MenuItem(menuSubscriptions, SWT.NONE);
		item.setText("Create RSS Feed");
		item.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				final Shell shell = new Shell(uiFunctions.getMainShell());
				shell.setLayout(new FormLayout());

				Label label = new Label(shell,SWT.NONE);
				label.setText("RSS Feed URL :");
				final Text urlText = new Text(shell,SWT.BORDER);
				urlText.setText(Utils.getLinkFromClipboard(shell.getDisplay(),false));
				Label separator = new Label(shell,SWT.SEPARATOR | SWT.HORIZONTAL);
				Button cancel = new Button(shell,SWT.PUSH);
				cancel.setText("Cancel");
				Button ok = new Button(shell,SWT.PUSH);
				ok.setText("Ok");

				FormData data;

				data = new FormData();
				data.left = new FormAttachment(0,5);
				data.right = new FormAttachment(100,-5);
				data.top = new FormAttachment(0,5);
				label.setLayoutData(data);

				data = new FormData();
				data.left = new FormAttachment(0,5);
				data.right = new FormAttachment(100,-5);
				data.top = new FormAttachment(label);
				data.width = 400;
				urlText.setLayoutData(data);

				data = new FormData();
				data.left = new FormAttachment(0,5);
				data.right = new FormAttachment(100,-5);
				data.top = new FormAttachment(urlText);
				separator.setLayoutData(data);

				data = new FormData();
				data.right = new FormAttachment(ok);
				data.width = 100;
				data.top = new FormAttachment(separator);
				cancel.setLayoutData(data);

				data = new FormData();
				data.right = new FormAttachment(100,-5);
				data.width = 100;
				data.top = new FormAttachment(separator);
				ok.setLayoutData(data);

				cancel.addListener(SWT.Selection, new Listener() {
					public void handleEvent(Event arg0) {
						shell.dispose();
					}
				});

				ok.addListener(SWT.Selection, new Listener() {
					public void handleEvent(Event arg0) {
						String url_str = urlText.getText();
						shell.dispose();

						try{
							URL	url = new URL( url_str );

							SubscriptionManagerFactory.getSingleton().createSingletonRSS( url_str, url, 120, true );

						}catch( Throwable e ){

							Debug.printStackTrace(e);
						}
					}
				});

				shell.pack();


				Utils.centerWindowRelativeTo(shell, uiFunctions.getMainShell());

				shell.open();
				shell.setFocus();
				urlText.setFocus();


			}
		});
		 */
    item = new MenuItem(menuDebug, SWT.CASCADE);
    item.setText("DW");
    Menu menuBrowserTB = new Menu(menuDebug.getParent(), SWT.DROP_DOWN);
    item.setMenu(menuBrowserTB);
    item = new MenuItem(menuBrowserTB, SWT.NONE);
    item.setText("popup check");
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean oldDebug = DonationWindow.DEBUG;
            DonationWindow.DEBUG = true;
            DonationWindow.checkForDonationPopup();
            DonationWindow.DEBUG = oldDebug;
        }
    });
    item = new MenuItem(menuBrowserTB, SWT.NONE);
    item.setText("show");
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean oldDebug = DonationWindow.DEBUG;
            DonationWindow.DEBUG = true;
            DonationWindow.open(true, "debug");
            DonationWindow.DEBUG = oldDebug;
        }
    });
    item = new MenuItem(menuDebug, SWT.NONE);
    item.setText("Alerts");
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String text = "This is a  long message with lots of information and " + "stuff you really should read.  Are you still reading? Good, because " + "reading <a href=\"http://moo.com\">stimulates</a> the mind.\n\nYeah Baby.";
            LogAlert logAlert = new LogAlert(true, LogAlert.AT_INFORMATION, "Simple");
            Logger.log(logAlert);
            logAlert = new LogAlert(true, LogAlert.AT_WARNING, text);
            logAlert.details = "Details: \n\n" + text;
            Logger.log(logAlert);
            logAlert = new LogAlert(true, LogAlert.AT_ERROR, "ShortText");
            logAlert.details = "Details";
            Logger.log(logAlert);
        }
    });
    item = new MenuItem(menuDebug, SWT.NONE);
    item.setText("MsgBox");
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            VuzeMessageBox box = new VuzeMessageBox("Title", "Text", new String[] { "Ok", "Cancel" }, 0);
            box.setListener(new VuzeMessageBoxListener() {

                @Override
                public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
                    SWTSkin skin = soExtra.getSkin();
                    skin.createSkinObject("dlg.generic.test", "dlg.generic.test", soExtra);
                    skin.layout(soExtra);
                    shell.layout(true, true);
                }
            });
            box.open(null);
        }
    });
    item = new MenuItem(menuDebug, SWT.CASCADE);
    item.setText("Size");
    Menu menuSize = new Menu(menuDebug.getParent(), SWT.DROP_DOWN);
    item.setMenu(menuSize);
    int[] sizes = { 640, 430, 800, 550, 1024, 718, 1280, 700, 1440, 850, 1600, 1050, 1920, 1150 };
    for (int i = 0; i < sizes.length; i += 2) {
        final int x = sizes[i];
        final int y = sizes[i + 1];
        item = new MenuItem(menuSize, SWT.NONE);
        item.setText("" + x + "," + y);
        item.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                UIFunctionsManagerSWT.getUIFunctionsSWT().getMainShell().setSize(x, y);
            }
        });
    }
    item = new MenuItem(menuDebug, SWT.NONE);
    item.setText("Obfuscated Shell Image");
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            Display display = Display.getCurrent();
            java.util.List<Image> shell_images = UIDebugGenerator.getShellImages();
            Image biggest_image = null;
            long biggest_area = 0;
            for (Image image : shell_images) {
                Shell shell2 = new Shell(display);
                Rectangle bounds = image.getBounds();
                long area = bounds.width * bounds.height;
                if (area > biggest_area) {
                    biggest_image = image;
                }
                Point size = shell2.computeSize(bounds.width, bounds.height);
                shell2.setSize(size);
                shell2.setBackgroundImage(image);
                shell2.open();
            }
            if (biggest_image != null) {
                new Clipboard(display).setContents(new Object[] { biggest_image.getImageData() }, new Transfer[] { ImageTransfer.getInstance() });
            }
        }
    });
    return item;
}
Also used : VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) ObfuscateShell(com.biglybt.ui.swt.debug.ObfuscateShell) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) CoreRunningListener(com.biglybt.core.CoreRunningListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Core(com.biglybt.core.Core) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) Transfer(org.eclipse.swt.dnd.Transfer) ImageTransfer(org.eclipse.swt.dnd.ImageTransfer) SelectionEvent(org.eclipse.swt.events.SelectionEvent) VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) Clipboard(org.eclipse.swt.dnd.Clipboard) VuzeMessageBox(com.biglybt.ui.swt.views.skin.VuzeMessageBox)

Example 2 with VuzeMessageBoxListener

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

the class PlayerInstallWindow method open.

public void open() {
    box = new VuzeMessageBox("", "", null, 0);
    box.setSubTitle(MessageText.getString("dlg.player.install.subtitle"));
    box.addResourceBundle(PlayerInstallWindow.class, SkinPropertiesImpl.PATH_SKIN_DEFS, "skin3_dlg_register");
    box.setIconResource("image.player.dlg.header");
    this.progressText = MessageText.getString("dlg.player.install.description");
    box.setListener(new VuzeMessageBoxListener() {

        @Override
        public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
            SWTSkin skin = soExtra.getSkin();
            skin.createSkinObject("dlg.register.install", "dlg.register.install", soExtra);
            SWTSkinObjectContainer soProgressBar = (SWTSkinObjectContainer) skin.getSkinObject("progress-bar");
            if (soProgressBar != null) {
                progressBar = new ProgressBar(soProgressBar.getComposite(), SWT.HORIZONTAL);
                progressBar.setMinimum(0);
                progressBar.setMaximum(100);
                progressBar.setLayoutData(Utils.getFilledFormData());
            }
            soInstallPct = (SWTSkinObjectText) skin.getSkinObject("install-pct");
            soProgressText = (SWTSkinObjectText) skin.getSkinObject("progress-text");
            if (soProgressText != null && progressText != null) {
                soProgressText.setText(progressText);
            }
        }
    });
    box.open(new UserPrompterResultListener() {

        @Override
        public void prompterClosed(int result) {
            installer.setListener(null);
            installer.cancel();
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) VuzeMessageBox(com.biglybt.ui.swt.views.skin.VuzeMessageBox) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) ProgressBar(org.eclipse.swt.widgets.ProgressBar)

Example 3 with VuzeMessageBoxListener

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

the class SBC_SearchResultsView method showDownloadFTUX.

protected static void showDownloadFTUX(SearchSubsResultBase entry, final UserPrompterResultListener listener) {
    if (entry instanceof SBC_SubscriptionResult) {
        listener.prompterClosed(0);
        return;
    }
    if (RememberedDecisionsManager.getRememberedDecision("searchsubs.dl.ftux") == 1) {
        listener.prompterClosed(0);
        return;
    }
    final VuzeMessageBox box = new VuzeMessageBox(MessageText.getString("searchsubs.dl.ftux.title"), null, new String[] { MessageText.getString("Button.ok"), MessageText.getString("Button.cancel") }, 0);
    box.setSubTitle(MessageText.getString("searchsubs.dl.ftux.heading"));
    final boolean[] check_state = new boolean[] { true };
    box.setListener(new VuzeMessageBoxListener() {

        @Override
        public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
            SWTSkin skin = soExtra.getSkin();
            addResourceBundle(skin, "com/biglybt/ui/swt/columns/searchsubs/", "skin3_dl_ftux");
            String id = "searchsubs.dlftux.shell";
            skin.createSkinObject(id, id, soExtra);
            final SWTSkinObjectCheckbox cb = (SWTSkinObjectCheckbox) skin.getSkinObject("agree-checkbox");
            cb.setChecked(true);
            cb.addSelectionListener(new SWTSkinCheckboxListener() {

                @Override
                public void checkboxChanged(SWTSkinObjectCheckbox so, boolean checked) {
                    check_state[0] = checked;
                }
            });
        }
    });
    box.open(new UserPrompterResultListener() {

        @Override
        public void prompterClosed(int result) {
            if (result == 0 && check_state[0]) {
                RememberedDecisionsManager.setRemembered("searchsubs.dl.ftux", 1);
            }
            listener.prompterClosed(result);
        }
    });
}
Also used : SWTSkinCheckboxListener(com.biglybt.ui.swt.skin.SWTSkinCheckboxListener) SWTSkinObjectCheckbox(com.biglybt.ui.swt.skin.SWTSkinObjectCheckbox) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) Shell(org.eclipse.swt.widgets.Shell) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) VuzeMessageBox(com.biglybt.ui.swt.views.skin.VuzeMessageBox) SBC_SubscriptionResult(com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)

Example 4 with VuzeMessageBoxListener

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

the class SimplePluginInstallWindow method open.

public void open() {
    box = new VuzeMessageBox("", "", null, 0);
    box.setSubTitle(MessageText.getString(resource_prefix + ".subtitle"));
    box.addResourceBundle(SimplePluginInstallWindow.class, SkinPropertiesImpl.PATH_SKIN_DEFS, "skin3_dlg_register");
    box.setIconResource(resource_prefix + ".image");
    this.progressText = MessageText.getString(resource_prefix + ".description");
    box.setListener(new VuzeMessageBoxListener() {

        @Override
        public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
            SWTSkin skin = soExtra.getSkin();
            skin.createSkinObject("dlg.register.install", "dlg.register.install", soExtra);
            SWTSkinObjectContainer soProgressBar = (SWTSkinObjectContainer) skin.getSkinObject("progress-bar");
            if (soProgressBar != null) {
                progressBar = new ProgressBar(soProgressBar.getComposite(), SWT.HORIZONTAL);
                progressBar.setMinimum(0);
                progressBar.setMaximum(100);
                progressBar.setLayoutData(Utils.getFilledFormData());
            }
            soInstallPct = (SWTSkinObjectText) skin.getSkinObject("install-pct");
            soProgressText = (SWTSkinObjectText) skin.getSkinObject("progress-text");
            if (soProgressText != null && progressText != null) {
                soProgressText.setText(progressText);
            }
        }
    });
    box.open(new UserPrompterResultListener() {

        @Override
        public void prompterClosed(int result) {
            installer.setListener(null);
            try {
                installer.cancel();
            } catch (Exception e) {
                Debug.out(e);
            }
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) VuzeMessageBox(com.biglybt.ui.swt.views.skin.VuzeMessageBox) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) ProgressBar(org.eclipse.swt.widgets.ProgressBar)

Aggregations

SWTSkin (com.biglybt.ui.swt.skin.SWTSkin)4 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)4 VuzeMessageBox (com.biglybt.ui.swt.views.skin.VuzeMessageBox)4 VuzeMessageBoxListener (com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener)4 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)3 Shell (org.eclipse.swt.widgets.Shell)3 SWTSkinObjectText (com.biglybt.ui.swt.skin.SWTSkinObjectText)2 ProgressBar (org.eclipse.swt.widgets.ProgressBar)2 Core (com.biglybt.core.Core)1 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)1 ObfuscateShell (com.biglybt.ui.swt.debug.ObfuscateShell)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 SWTSkinCheckboxListener (com.biglybt.ui.swt.skin.SWTSkinCheckboxListener)1 SWTSkinObjectCheckbox (com.biglybt.ui.swt.skin.SWTSkinObjectCheckbox)1 SBC_SubscriptionResult (com.biglybt.ui.swt.subscriptions.SBC_SubscriptionResult)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 ImageTransfer (org.eclipse.swt.dnd.ImageTransfer)1 Transfer (org.eclipse.swt.dnd.Transfer)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1