Search in sources :

Example 1 with ButtonListenerAdapter

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

the class SBC_TagsOverview method skinObjectInitialShow.

// @see SkinView#skinObjectInitialShow(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    initColumns();
    SWTSkinObjectButton soAddTagButton = (SWTSkinObjectButton) getSkinObject("add-tag");
    if (soAddTagButton != null) {
        soAddTagButton.addSelectionListener(new ButtonListenerAdapter() {

            // @see SWTSkinButtonUtility.ButtonListenerAdapter#pressed(SWTSkinButtonUtility, SWTSkinObject, int)
            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                TagUIUtilsV3.showCreateTagDialog(null);
            }
        });
    }
    new InfoBarUtil(skinObject, "tagsview.infobar", false, "tags.infobar", "tags.view.infobar") {

        @Override
        public boolean allowShow() {
            return true;
        }
    };
    return null;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinButtonUtility(com.biglybt.ui.swt.skin.SWTSkinButtonUtility) SWTSkinObjectButton(com.biglybt.ui.swt.skin.SWTSkinObjectButton) ButtonListenerAdapter(com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter)

Example 2 with ButtonListenerAdapter

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

the class InfoBarUtil method createInfoBar.

protected void createInfoBar() {
    Control control = forSO.getControl();
    if (control == null || control.isDisposed()) {
        return;
    }
    Object ldForSO = control.getLayoutData();
    if (!(ldForSO instanceof FormData)) {
        return;
    }
    FormData fdForSO = (FormData) ldForSO;
    SWTSkinObject parent = forSO.getParent();
    soInfoBar = skin.createSkinObject(skintemplateid + (uniqueNo++), skintemplateid, parent);
    FormData fdInfoBar = (FormData) soInfoBar.getControl().getLayoutData();
    if (fdInfoBar == null) {
        fdInfoBar = Utils.getFilledFormData();
    }
    if (top) {
        if (fdForSO.top.control == null) {
            fdInfoBar.top = new FormAttachment(fdForSO.top.numerator, fdForSO.top.denominator, fdForSO.top.offset);
        } else {
            fdInfoBar.top = new FormAttachment(fdForSO.top.control, fdForSO.top.offset, fdForSO.top.alignment);
        }
        fdInfoBar.bottom = null;
        soInfoBar.getControl().setLayoutData(fdInfoBar);
        fdForSO.top = new FormAttachment(soInfoBar.getControl(), 0, SWT.BOTTOM);
        forSO.getControl().setLayoutData(fdForSO);
    } else {
        if (fdForSO.bottom.control == null) {
            fdInfoBar.bottom = new FormAttachment(fdForSO.bottom.numerator, fdForSO.bottom.denominator, fdForSO.bottom.offset);
        } else {
            fdInfoBar.bottom = new FormAttachment(fdForSO.bottom.control, fdForSO.bottom.offset, fdForSO.bottom.alignment);
        }
        fdInfoBar.top = null;
        soInfoBar.getControl().setLayoutData(fdInfoBar);
        fdForSO.bottom = new FormAttachment(soInfoBar.getControl(), 0, SWT.TOP);
        forSO.getControl().setLayoutData(fdForSO);
    }
    ((SWTSkinObjectContainer) parent).getComposite().layout(true);
    SWTSkinObject soClose = skin.getSkinObject("close", parent);
    if (soClose != null) {
        SWTSkinButtonUtility btnClose = new SWTSkinButtonUtility(soClose);
        btnClose.addSelectionListener(new ButtonListenerAdapter() {

            // @see SWTSkinButtonUtility.ButtonListenerAdapter#pressed(SWTSkinButtonUtility, SWTSkinObject, int)
            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                soInfoBar.setVisible(false);
                RememberedDecisionsManager.setRemembered(stateConfigID, 0);
            }
        });
    }
    soInfoBar.addListener(new SWTSkinObjectListener() {

        @Override
        public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
            if (eventType == EVENT_SHOW) {
                RememberedDecisionsManager.setRemembered(stateConfigID, 1);
            }
            return null;
        }
    });
    SWTSkinObject soText1 = skin.getSkinObject("infobar-title-1", parent);
    if (soText1 instanceof SWTSkinObjectText) {
        SWTSkinObjectText soText = (SWTSkinObjectText) soText1;
        String id = textPrefix + ".text1";
        if (MessageText.keyExists(id)) {
            soText.setTextID(id);
        }
    }
    SWTSkinObject soText2 = skin.getSkinObject("infobar-title-2", parent);
    if (soText2 instanceof SWTSkinObjectText) {
        SWTSkinObjectText soText = (SWTSkinObjectText) soText2;
        String id = textPrefix + ".text2";
        if (MessageText.keyExists(id)) {
            soText.setTextID(id);
        }
    }
    created(parent);
    soInfoBar.setVisible(true);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Control(org.eclipse.swt.widgets.Control) ButtonListenerAdapter(com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with ButtonListenerAdapter

use of com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter 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 4 with ButtonListenerAdapter

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

the class MainWindowImpl method initWidgets2.

private void initWidgets2() {
    SWTSkinObject skinObject = skin.getSkinObject("statusbar");
    if (skinObject != null) {
        final Composite cArea = (Composite) skinObject.getControl();
        statusBar = new MainStatusBar();
        Composite composite = statusBar.initStatusBar(cArea);
        composite.setLayoutData(Utils.getFilledFormData());
    }
    skinObject = skin.getSkinObject("search-text");
    if (skinObject != null) {
        attachSearchBox(skinObject);
    }
    skinObject = skin.getSkinObject("add-torrent");
    if (skinObject instanceof SWTSkinObjectButton) {
        SWTSkinObjectButton btn = (SWTSkinObjectButton) skinObject;
        btn.addSelectionListener(new ButtonListenerAdapter() {

            // @see SWTSkinButtonUtility.ButtonListenerAdapter#pressed(SWTSkinButtonUtility, SWTSkinObject, int)
            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                UIFunctionsManagerSWT.getUIFunctionsSWT().openTorrentWindow();
            }
        });
    }
    skinObject = skin.getSkinObject(SkinConstants.VIEWID_PLUGINBAR);
    if (skinObject != null) {
        Menu topbarMenu = new Menu(shell, SWT.POP_UP);
        if (COConfigurationManager.getIntParameter("User Mode") > 1) {
            MenuItem mi = MainMenuV3.createViewMenuItem(skin, topbarMenu, "v3.MainWindow.menu.view." + SkinConstants.VIEWID_PLUGINBAR, SkinConstants.VIEWID_PLUGINBAR + ".visible", SkinConstants.VIEWID_PLUGINBAR, true, -1);
            if (Utils.isAZ2UI()) {
                // remove any accelerator as it doesn't work on this menu and we don't have a View menu entry
                String str = mi.getText();
                int pos = str.indexOf("\t");
                if (pos != -1) {
                    str = str.substring(0, pos).trim();
                    mi.setText(str);
                }
                mi.setAccelerator(SWT.NULL);
            }
        }
        new MenuItem(topbarMenu, SWT.SEPARATOR);
        final MenuItem itemClipMon = new MenuItem(topbarMenu, SWT.CHECK);
        Messages.setLanguageText(itemClipMon, "label.monitor.clipboard");
        itemClipMon.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                COConfigurationManager.setParameter("Monitor Clipboard For Torrents", itemClipMon.getSelection());
            }
        });
        boolean enabled = COConfigurationManager.getBooleanParameter("Monitor Clipboard For Torrents");
        itemClipMon.setSelection(enabled);
        configMonitorClipboardListener = new ParameterListener() {

            private volatile AEThread2 monitor_thread;

            private Clipboard clipboard;

            private String last_text;

            @Override
            public void parameterChanged(String parameterName) {
                boolean enabled = COConfigurationManager.getBooleanParameter(parameterName);
                if (enabled) {
                    if (clipboard == null) {
                        clipboard = new Clipboard(Display.getDefault());
                    }
                    if (monitor_thread == null) {
                        final AEThread2[] new_thread = { null };
                        monitor_thread = new_thread[0] = new AEThread2("Clipboard Monitor") {

                            @Override
                            public void run() {
                                Runnable checker = new Runnable() {

                                    @Override
                                    public void run() {
                                        if (monitor_thread != new_thread[0] || clipboard == null) {
                                            return;
                                        }
                                        String text = (String) clipboard.getContents(TextTransfer.getInstance());
                                        if (text != null && text.length() <= 2048) {
                                            if (last_text == null || !last_text.equals(text)) {
                                                last_text = text;
                                                TorrentOpener.openTorrentsFromClipboard(text);
                                            }
                                        }
                                    }
                                };
                                while (true) {
                                    try {
                                        Utils.execSWTThread(checker);
                                    } catch (Throwable e) {
                                        Debug.out(e);
                                    } finally {
                                        if (monitor_thread != new_thread[0]) {
                                            break;
                                        } else {
                                            try {
                                                Thread.sleep(500);
                                            } catch (Throwable e) {
                                                Debug.out(e);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        };
                        monitor_thread.start();
                    }
                } else {
                    monitor_thread = null;
                    last_text = null;
                    if (clipboard != null) {
                        clipboard.dispose();
                        clipboard = null;
                    }
                }
            }
        };
        COConfigurationManager.addAndFireParameterListener("Monitor Clipboard For Torrents", configMonitorClipboardListener);
        new MenuItem(topbarMenu, SWT.SEPARATOR);
        SearchUtils.addMenus(topbarMenu);
        addMenuAndNonTextChildren((Composite) skinObject.getControl(), topbarMenu);
        skinObject = skin.getSkinObject(SkinConstants.VIEWID_TOOLBAR);
        if (skinObject != null) {
            addMenuAndNonTextChildren((Composite) skinObject.getControl(), topbarMenu);
        }
    }
}
Also used : SWTRunnable(com.biglybt.ui.swt.utils.SWTRunnable) ParameterListener(com.biglybt.core.config.ParameterListener) ButtonListenerAdapter(com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter) Clipboard(org.eclipse.swt.dnd.Clipboard)

Example 5 with ButtonListenerAdapter

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

the class UIFunctionsImpl method showCoreWaitDlg.

// @see UIFunctionsSWT#showCoreWaitDlg()
@Override
public Shell showCoreWaitDlg() {
    final SkinnedDialog closeDialog = new SkinnedDialog("skin3_dlg_coreloading", "coreloading.body", SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
    closeDialog.setTitle(MessageText.getString("dlg.corewait.title"));
    SWTSkin skin = closeDialog.getSkin();
    SWTSkinObjectButton soButton = (SWTSkinObjectButton) skin.getSkinObject("close");
    final SWTSkinObjectText soWaitTask = (SWTSkinObjectText) skin.getSkinObject("task");
    final SWTSkinObject soWaitProgress = skin.getSkinObject("progress");
    if (soWaitProgress != null) {
        soWaitProgress.getControl().addPaintListener(new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                Control c = (Control) e.widget;
                Point size = c.getSize();
                e.gc.setBackground(ColorCache.getColor(e.display, "#23a7df"));
                Object data = soWaitProgress.getData("progress");
                if (data instanceof Long) {
                    int waitProgress = ((Long) data).intValue();
                    int breakX = size.x * waitProgress / 100;
                    e.gc.fillRectangle(0, 0, breakX, size.y);
                    e.gc.setBackground(ColorCache.getColor(e.display, "#cccccc"));
                    e.gc.fillRectangle(breakX, 0, size.x - breakX, size.y);
                }
            }
        });
    }
    if (!CoreFactory.isCoreRunning()) {
        final Initializer initializer = Initializer.getLastInitializer();
        if (initializer != null) {
            initializer.addListener(new InitializerListener() {

                @Override
                public void reportPercent(final int percent) {
                    Utils.execSWTThread(new AERunnable() {

                        @Override
                        public void runSupport() {
                            if (soWaitProgress != null && !soWaitProgress.isDisposed()) {
                                soWaitProgress.setData("progress", new Long(percent));
                                soWaitProgress.getControl().redraw();
                                soWaitProgress.getControl().update();
                            }
                        }
                    });
                    if (percent > 100) {
                        initializer.removeListener(this);
                    }
                }

                @Override
                public void reportCurrentTask(String currentTask) {
                    if (soWaitTask != null && !soWaitTask.isDisposed()) {
                        soWaitTask.setText(currentTask);
                    }
                }
            });
        }
    }
    if (soButton != null) {
        soButton.addSelectionListener(new ButtonListenerAdapter() {

            @Override
            public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
                closeDialog.close();
            }
        });
    }
    closeDialog.addCloseListener(new SkinnedDialogClosedListener() {

        @Override
        public void skinDialogClosed(SkinnedDialog dialog) {
        }
    });
    closeDialog.open();
    return closeDialog.getShell();
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) TableCellSWTPaintListener(com.biglybt.ui.swt.views.table.TableCellSWTPaintListener) PaintListener(org.eclipse.swt.events.PaintListener) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) PluginInitializer(com.biglybt.pifimpl.local.PluginInitializer) ButtonListenerAdapter(com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter) SkinnedDialogClosedListener(com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener)

Aggregations

ButtonListenerAdapter (com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter)8 ParameterListener (com.biglybt.core.config.ParameterListener)2 SWTSkinButtonUtility (com.biglybt.ui.swt.skin.SWTSkinButtonUtility)2 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)2 SkinnedDialogClosedListener (com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener)2 PaintEvent (org.eclipse.swt.events.PaintEvent)2 PaintListener (org.eclipse.swt.events.PaintListener)2 FormData (org.eclipse.swt.layout.FormData)2 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 GlobalManagerListener (com.biglybt.core.global.GlobalManagerListener)1 MessageText (com.biglybt.core.internat.MessageText)1 PluginInterface (com.biglybt.pif.PluginInterface)1 PluginInitializer (com.biglybt.pifimpl.local.PluginInitializer)1 MdiEntryLogIdListener (com.biglybt.ui.mdi.MdiEntryLogIdListener)1 MdiListener (com.biglybt.ui.mdi.MdiListener)1 ObfuscateImage (com.biglybt.ui.swt.debug.ObfuscateImage)1 MultipleDocumentInterfaceSWT (com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)1 URLInfo (com.biglybt.ui.swt.shells.GCStringPrinter.URLInfo)1 SWTSkinObjectButton (com.biglybt.ui.swt.skin.SWTSkinObjectButton)1 SWTRunnable (com.biglybt.ui.swt.utils.SWTRunnable)1