Search in sources :

Example 16 with UIFunctionsSWT

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

the class TrackerView method initYourTableView.

@Override
public TableViewSWT<TrackerPeerSource> initYourTableView() {
    tv = TableViewFactory.createTableViewSWT(TrackerPeerSource.class, TableManager.TABLE_TORRENT_TRACKERS, getPropertiesPrefix(), basicItems, basicItems[0].getName(), SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    tv.addLifeCycleListener(this);
    tv.addMenuFillListener(this);
    tv.addTableDataSourceChangedListener(this, true);
    tv.addSelectionListener(this, false);
    tv.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.stateMask == 0 && e.keyCode == SWT.DEL) {
                Object[] datasources = tv.getSelectedDataSources().toArray();
                List<TrackerPeerSource> pss = new ArrayList<>();
                String str = "";
                for (Object object : datasources) {
                    TrackerPeerSource ps = (TrackerPeerSource) object;
                    if (ps.canDelete()) {
                        pss.add(ps);
                        str += (str.isEmpty() ? "" : ", ") + ps.getName();
                    }
                }
                if (!pss.isEmpty()) {
                    MessageBoxShell mb = new MessageBoxShell(MessageText.getString("message.confirm.delete.title"), MessageText.getString("message.confirm.delete.text", new String[] { str }), new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 1);
                    mb.open(new UserPrompterResultListener() {

                        @Override
                        public void prompterClosed(int result) {
                            if (result == 0) {
                                for (TrackerPeerSource ps : pss) {
                                    ps.delete();
                                }
                            }
                        }
                    });
                }
                e.doit = false;
            }
        }
    });
    tv.setEnableTabViews(enable_tabs, true, null);
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        registerPluginViews(pluginUI);
    }
    return tv;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) TrackerPeerSource(com.biglybt.core.tracker.TrackerPeerSource) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) ArrayList(java.util.ArrayList) List(java.util.List) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance)

Example 17 with UIFunctionsSWT

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

the class UpdateWindow method finishUpdate.

private void finishUpdate(boolean restartNow, boolean just_close) {
    // When completing, remove the link in mainWindow :
    UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (functionsSWT != null) {
        IMainStatusBar mainStatusBar = functionsSWT.getMainStatusBar();
        if (mainStatusBar != null) {
            mainStatusBar.setUpdateNeeded(null);
        }
    }
    boolean bDisposeUpdateWindow = true;
    if (!just_close) {
        // If restart is required, then restart
        if (restartRequired && restartNow) {
            // this HAS to be done this way around else the restart inherits
            // the instance port listen. However, this is a general problem....
            UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
            if (uiFunctions != null && uiFunctions.dispose(true, false)) {
                bDisposeUpdateWindow = false;
            }
        } else if (hasMandatoryUpdates && !restartRequired) {
            // run a further update check as we can immediately install non-mandatory updates now
            update_monitor.requestRecheck();
        }
    }
    if (bDisposeUpdateWindow) {
        updateWindow.dispose();
    }
}
Also used : IMainStatusBar(com.biglybt.ui.swt.mainwindow.IMainStatusBar) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT)

Example 18 with UIFunctionsSWT

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

the class ConfigListener method checkForUpdates.

/**
 * @since 3.0.5.3
 */
public static void checkForUpdates() {
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        uiFunctions.bringToFront();
    }
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            UpdateMonitor.getSingleton(core).performCheck(true, false, false, null);
        }
    });
}
Also used : CoreRunningListener(com.biglybt.core.CoreRunningListener) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) Core(com.biglybt.core.Core)

Example 19 with UIFunctionsSWT

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

the class DeviceTemplateChooser method createDeviceTemplateList2.

private void createDeviceTemplateList2(SWTSkinObjectContainer soList) {
    DeviceTemplate[] devices = mf.getDeviceTemplates();
    if (devices.length == 0) {
        noDevices();
        return;
    }
    Arrays.sort(devices, new Comparator<DeviceTemplate>() {

        @Override
        public int compare(DeviceTemplate o1, DeviceTemplate o2) {
            return o1.getName().compareToIgnoreCase(o2.getName());
        }
    });
    Composite parent = soList.getComposite();
    if (parent.getChildren().length > 0) {
        Utils.disposeComposite(parent, false);
    }
    SWTSkin skin = skinnedDialog.getSkin();
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.spacing = 0;
    layout.marginLeft = layout.marginRight = 0;
    layout.wrap = true;
    layout.justify = true;
    layout.fill = true;
    parent.setLayout(layout);
    Listener clickListener = new Listener() {

        boolean down = false;

        @Override
        public void handleEvent(Event event) {
            if (event.type == SWT.MouseDown) {
                down = true;
            } else if (event.type == SWT.MouseUp && down) {
                Widget widget = (event.widget instanceof Label) ? ((Label) event.widget).getParent() : event.widget;
                selectedDeviceTemplate = (DeviceTemplate) widget.getData("obj");
                if (selectedDeviceTemplate == null) {
                    Debug.out("selectedDeviceTemplate is null!");
                }
                skinnedDialog.close();
                down = false;
            }
        }
    };
    for (DeviceTemplate deviceTemplate : devices) {
        if (deviceTemplate.isAuto()) {
            continue;
        }
        // deviceTemplate.getIconURL();
        String iconURL = null;
        TranscodeChooser.addImageBox(parent, clickListener, null, deviceTemplate, iconURL, deviceTemplate.getName());
    }
    SWTSkinObjectText soTitle = (SWTSkinObjectText) skin.getSkinObject("title");
    if (soTitle != null) {
        soTitle.setTextID("devices.choose.device.title");
    }
    SWTSkinObjectText soSubTitle = (SWTSkinObjectText) skin.getSkinObject("subtitle");
    if (soSubTitle != null) {
        soSubTitle.setTextID("label.clickone");
    }
    Shell shell = skinnedDialog.getShell();
    Point computeSize = shell.computeSize(shell.getSize().x, SWT.DEFAULT, true);
    shell.setSize(computeSize);
    UIFunctionsSWT uiFunctionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctionsSWT != null) {
        Shell mainShell = uiFunctionsSWT.getMainShell();
        Utils.centerWindowRelativeTo(shell, mainShell);
    }
}
Also used : SkinnedDialogClosedListener(com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) Point(org.eclipse.swt.graphics.Point) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) DeviceTemplate(com.biglybt.core.devices.DeviceTemplate) RowLayout(org.eclipse.swt.layout.RowLayout)

Example 20 with UIFunctionsSWT

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

the class BaseMdiEntry method show.

public void show() {
    if (skinObject == null) {
        return;
    }
    SelectedContentManager.clearCurrentlySelectedContent();
    UIFunctionsSWT uif = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uif != null) {
        // uif.refreshIconBar(); // needed?
        uif.refreshTorrentMenu();
    }
    SWTSkinObject skinObject = getSkinObjectMaster();
    skinObject.setVisible(true);
    if (skinObject instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer container = (SWTSkinObjectContainer) skinObject;
        Composite composite = container.getComposite();
        if (composite != null && !composite.isDisposed()) {
            composite.setVisible(true);
            composite.moveAbove(null);
            // composite.setFocus();
            // container.getParent().relayout();
            composite.getParent().layout();
        }
    // This causes double show because createSkinObject already calls show
    // container.triggerListeners(SWTSkinObjectListener.EVENT_SHOW);
    }
    Composite c = getComposite();
    if (c != null && !c.isDisposed()) {
        c.setData("BaseMDIEntry", this);
        c.setVisible(true);
        c.getParent().layout();
    }
    try {
        // In theory, c.setVisible() will trigger TYPE_FOCUSGAINED, but let's
        // call it anyway (it will be ignored if focus is already gained)
        triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
    } catch (Exception e) {
        Debug.out(e);
    }
    setToolbarVisibility(hasToolbarEnableers());
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) ConfigurationParameterNotFoundException(com.biglybt.core.config.impl.ConfigurationParameterNotFoundException)

Aggregations

UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)33 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)10 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)6 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 DownloadManager (com.biglybt.core.download.DownloadManager)3 UIFunctions (com.biglybt.ui.UIFunctions)3 Composite (org.eclipse.swt.widgets.Composite)3 ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)2 Core (com.biglybt.core.Core)2 CoreRunningListener (com.biglybt.core.CoreRunningListener)2 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)2 PEPeer (com.biglybt.core.peer.PEPeer)2 AERunnable (com.biglybt.core.util.AERunnable)2 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)2 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)2 TabbedMdiMaximizeListener (com.biglybt.ui.swt.mdi.TabbedMdiMaximizeListener)2 UISWTViewEventListenerWrapper (com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper)2