Search in sources :

Example 1 with SWTSkinObjectContainer

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

the class SB_Dashboard method build.

private Composite build(Composite sf, final DashboardItem item, boolean use_tabs) {
    Composite g = use_tabs ? new Composite(sf, SWT.NULL) : new Group(sf, SWT.NULL);
    g.setLayoutData(Utils.getFilledFormData());
    g.setLayout(new GridLayout());
    g.setData(Utils.RELAYOUT_UP_STOP_HERE, true);
    try {
        if (g instanceof Group) {
            ((Group) g).setText(item.getTitle());
        }
        Composite menu_comp = use_tabs ? sf : g;
        Menu menu = new Menu(menu_comp);
        org.eclipse.swt.widgets.MenuItem itemReload = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
        Messages.setLanguageText(itemReload, "Button.reload");
        final Runnable reload_action = new Runnable() {

            public void run() {
                if (Utils.isSWTThread()) {
                    if (!g.isDisposed()) {
                        Utils.disposeComposite(g, false);
                        SkinnedComposite skinned_comp = new SkinnedComposite(g);
                        SWTSkin skin = skinned_comp.getSkin();
                        BaseMdiEntry.importStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"), item.getState(), this);
                        Control c = ((SWTSkinObjectContainer) skin.getSkinObject("content-area")).getControl();
                        c.setLayoutData(Utils.getFilledFormData());
                        g.layout(true, true);
                    }
                } else {
                    Utils.execSWTThread(this);
                }
            }
        };
        sf.setData(reload_action);
        itemReload.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent arg0) {
                reload_action.run();
            }
        });
        org.eclipse.swt.widgets.MenuItem itemPop = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
        Messages.setLanguageText(itemPop, "menu.pop.out");
        itemPop.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent arg0) {
                SkinnedDialog skinnedDialog = new SkinnedDialog("skin3_dlg_sidebar_popout", "shell", // standalone
                null, SWT.RESIZE | SWT.MAX | SWT.DIALOG_TRIM);
                SWTSkin skin = skinnedDialog.getSkin();
                SWTSkinObjectContainer cont = BaseMdiEntry.importStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"), item.getState(), null);
                if (cont != null) {
                    skinnedDialog.setTitle(item.getTitle());
                    skinnedDialog.open();
                } else {
                    skinnedDialog.close();
                }
            }
        });
        new org.eclipse.swt.widgets.MenuItem(menu, SWT.SEPARATOR);
        org.eclipse.swt.widgets.MenuItem itemRemove = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
        Messages.setLanguageText(itemRemove, "MySharesView.menu.remove");
        Utils.setMenuItemImage(itemRemove, "delete");
        itemRemove.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent arg0) {
                item.remove();
            }
        });
        menu_comp.setMenu(menu);
        SkinnedComposite skinned_comp = new SkinnedComposite(g);
        SWTSkin skin = skinned_comp.getSkin();
        BaseMdiEntry.importStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"), item.getState(), reload_action);
        Control c = ((SWTSkinObjectContainer) skin.getSkinObject("content-area")).getControl();
        c.setLayoutData(Utils.getFilledFormData());
        c.addListener(SWT.Show, new Listener() {

            @Override
            public void handleEvent(Event arg0) {
                g.layout(true, true);
            }
        });
    } catch (Throwable e) {
        Debug.out(e);
    }
    return (g);
}
Also used : Group(org.eclipse.swt.widgets.Group) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) MdiListener(com.biglybt.ui.mdi.MdiListener) MdiEntryVitalityImageListener(com.biglybt.ui.mdi.MdiEntryVitalityImageListener) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) PaintListener(org.eclipse.swt.events.PaintListener) ControlListener(org.eclipse.swt.events.ControlListener) Listener(org.eclipse.swt.widgets.Listener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(com.biglybt.pif.ui.menus.MenuItem) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) TimerEvent(com.biglybt.core.util.TimerEvent) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu)

Example 2 with SWTSkinObjectContainer

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

the class ToolBarView method getGroupSO.

private SWTSkinObjectContainer getGroupSO(String groupID) {
    String soID = "toolbar-group-" + groupID;
    SWTSkinObjectContainer soGroup = (SWTSkinObjectContainer) skin.getSkinObjectByID(soID, soMain);
    if (soGroup == null) {
        soGroup = (SWTSkinObjectContainer) skin.createSkinObject(soID, "toolbar.group", soMain);
        FormData fd = (FormData) soGroup.getControl().getLayoutData();
        if (soLastGroup != null) {
            fd.left = new FormAttachment(soLastGroup.getControl(), 0, SWT.RIGHT);
        } else {
            fd.left = new FormAttachment(0, 2);
        }
    }
    soLastGroup = soGroup;
    return soGroup;
}
Also used : FormData(org.eclipse.swt.layout.FormData) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with SWTSkinObjectContainer

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

the class ToolBarView method peekGroupSO.

private SWTSkinObjectContainer peekGroupSO(String groupID) {
    String soID = "toolbar-group-" + groupID;
    SWTSkinObjectContainer soGroup = (SWTSkinObjectContainer) skin.getSkinObjectByID(soID, soMain);
    return (soGroup);
}
Also used : SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer)

Example 4 with SWTSkinObjectContainer

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

the class DeviceTemplateChooser method open.

public void open(DeviceTemplateClosedListener 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.deviceTemplateChooserClosed(selectedDeviceTemplate);
            }
        }
    });
    SWTSkin skin = skinnedDialog.getSkin();
    SWTSkinObject so = skin.getSkinObject("list");
    if (so instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer soList = (SWTSkinObjectContainer) so;
        createDeviceTemplateList2(soList);
    }
    skinnedDialog.open();
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) SkinnedDialog(com.biglybt.ui.swt.views.skin.SkinnedDialog) SkinnedDialogClosedListener(com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin)

Example 5 with SWTSkinObjectContainer

use of com.biglybt.ui.swt.skin.SWTSkinObjectContainer 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)

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