Search in sources :

Example 16 with LinkLabel

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

the class ConfigSectionStartShutdown method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    GridData gridData;
    GridLayout layout;
    Label label;
    final Composite cDisplay = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(cDisplay, gridData);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cDisplay.setLayout(layout);
    final PlatformManager platform = PlatformManagerFactory.getPlatformManager();
    int userMode = COConfigurationManager.getIntParameter("User Mode");
    // ***** start group
    boolean can_ral = platform.hasCapability(PlatformManagerCapabilities.RunAtLogin);
    if (can_ral || userMode > 0) {
        Group gStartStop = new Group(cDisplay, SWT.NULL);
        Messages.setLanguageText(gStartStop, "ConfigView.label.start");
        layout = new GridLayout(2, false);
        gStartStop.setLayout(layout);
        Utils.setLayoutData(gStartStop, new GridData(GridData.FILL_HORIZONTAL));
        if (can_ral) {
            gridData = new GridData();
            gridData.horizontalSpan = 2;
            BooleanParameter start_on_login = new BooleanParameter(gStartStop, "Start On Login", "ConfigView.label.start.onlogin");
            try {
                start_on_login.setSelected(platform.getRunAtLogin());
                start_on_login.addChangeListener(new ParameterChangeAdapter() {

                    @Override
                    public void booleanParameterChanging(Parameter p, boolean toValue) {
                        try {
                            platform.setRunAtLogin(toValue);
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                    }
                });
            } catch (Throwable e) {
                start_on_login.setEnabled(false);
                Debug.out(e);
            }
            start_on_login.setLayoutData(gridData);
        }
        if (userMode > 0) {
            gridData = new GridData();
            gridData.horizontalSpan = 2;
            BooleanParameter start_in_lr_mode = new BooleanParameter(gStartStop, "Start In Low Resource Mode", "ConfigView.label.start.inlrm");
            start_in_lr_mode.setLayoutData(gridData);
            Composite lr_comp = new Composite(gStartStop, SWT.NULL);
            gridData = new GridData();
            gridData.horizontalSpan = 2;
            gridData.horizontalIndent = 20;
            Utils.setLayoutData(lr_comp, gridData);
            layout = new GridLayout(3, false);
            lr_comp.setLayout(layout);
            BooleanParameter lr_ui = new BooleanParameter(lr_comp, "LRMS UI", "lrms.deactivate.ui");
            BooleanParameter lr_udp_net = new BooleanParameter(lr_comp, "LRMS UDP Peers", "lrms.udp.peers");
            BooleanParameter lr_dht_sleep = new BooleanParameter(lr_comp, "LRMS DHT Sleep", "lrms.dht.sleep");
            // start_in_lr_mode.setAdditionalActionPerformer( new ChangeSelectionActionPerformer( lr_ui ));
            // this must always be selected as it is coming out of the deactivated UI mode that enable the others as well
            lr_ui.setEnabled(false);
            start_in_lr_mode.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(lr_udp_net));
            start_in_lr_mode.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(lr_dht_sleep));
        }
    }
    if (platform.hasCapability(PlatformManagerCapabilities.PreventComputerSleep)) {
        Group gSleep = new Group(cDisplay, SWT.NULL);
        Messages.setLanguageText(gSleep, "ConfigView.label.sleep");
        layout = new GridLayout(2, false);
        gSleep.setLayout(layout);
        Utils.setLayoutData(gSleep, new GridData(GridData.FILL_HORIZONTAL));
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        label = new Label(gSleep, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.label.sleep.info");
        Utils.setLayoutData(label, gridData);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter no_sleep_dl = new BooleanParameter(gSleep, "Prevent Sleep Downloading", "ConfigView.label.sleep.download");
        no_sleep_dl.setLayoutData(gridData);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter no_sleep_se = new BooleanParameter(gSleep, "Prevent Sleep FP Seeding", "ConfigView.label.sleep.fpseed");
        no_sleep_se.setLayoutData(gridData);
        TagManager tm = TagManagerFactory.getTagManager();
        if (tm.isEnabled()) {
            List<Tag> tag_list = tm.getTagType(TagType.TT_DOWNLOAD_MANUAL).getTags();
            String[] tags = new String[tag_list.size() + 1];
            tags[0] = "";
            for (int i = 0; i < tag_list.size(); i++) {
                tags[i + 1] = tag_list.get(i).getTagName(true);
            }
            label = new Label(gSleep, SWT.NULL);
            Messages.setLanguageText(label, "ConfigView.label.sleep.tag");
            new StringListParameter(gSleep, "Prevent Sleep Tag", "", tags, tags);
        }
    }
    if (userMode > 0) {
        Group gPR = new Group(cDisplay, SWT.NULL);
        Messages.setLanguageText(gPR, "ConfigView.label.pauseresume");
        layout = new GridLayout(2, false);
        gPR.setLayout(layout);
        Utils.setLayoutData(gPR, new GridData(GridData.FILL_HORIZONTAL));
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter pauseOnExit = new BooleanParameter(gPR, "Pause Downloads On Exit", "ConfigView.label.pause.downloads.on.exit");
        pauseOnExit.setLayoutData(gridData);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter resumeOnStart = new BooleanParameter(gPR, "Resume Downloads On Start", "ConfigView.label.resume.downloads.on.start");
        resumeOnStart.setLayoutData(gridData);
    }
    if (userMode >= 0) {
        Group gStop = new Group(cDisplay, SWT.NULL);
        Messages.setLanguageText(gStop, "ConfigView.label.stop");
        layout = new GridLayout(5, false);
        gStop.setLayout(layout);
        Utils.setLayoutData(gStop, new GridData(GridData.FILL_HORIZONTAL));
        // done downloading
        addDoneDownloadingOption(gStop, true);
        // done seeding
        addDoneSeedingOption(gStop, true);
        // reset on trigger
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter resetOnTrigger = new BooleanParameter(gStop, "Stop Triggers Auto Reset", "!" + MessageText.getString("ConfigView.label.stop.autoreset", new String[] { MessageText.getString("ConfigView.label.stop.Nothing") }) + "!");
        resetOnTrigger.setLayoutData(gridData);
        // prompt to allow abort
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter enablePrompt = new BooleanParameter(gStop, "Prompt To Abort Shutdown", "ConfigView.label.prompt.abort");
        enablePrompt.setLayoutData(gridData);
    }
    if (userMode > 0) {
        Group gRestart = new Group(cDisplay, SWT.NULL);
        Messages.setLanguageText(gRestart, "label.restart");
        layout = new GridLayout(2, false);
        gRestart.setLayout(layout);
        Utils.setLayoutData(gRestart, new GridData(GridData.FILL_HORIZONTAL));
        label = new Label(gRestart, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.label.restart.auto");
        new IntParameter(gRestart, "Auto Restart When Idle", 0, 100000);
    }
    if (userMode > 0 && platform.hasCapability(PlatformManagerCapabilities.AccessExplicitVMOptions)) {
        Group gJVM = new Group(cDisplay, SWT.NULL);
        Messages.setLanguageText(gJVM, "ConfigView.label.jvm");
        layout = new GridLayout(2, false);
        gJVM.setLayout(layout);
        Utils.setLayoutData(gJVM, new GridData(GridData.FILL_HORIZONTAL));
        // wiki link
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        LinkLabel link = new LinkLabel(gJVM, gridData, "ConfigView.label.please.visit.here", Constants.URL_WIKI + "w/Java_VM_memory_usage");
        // info
        label = new Label(gJVM, SWT.NULL);
        Messages.setLanguageText(label, "jvm.info");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(label, gridData);
        try {
            final File option_file = platform.getVMOptionFile();
            final Group gJVMOptions = new Group(gJVM, SWT.NULL);
            layout = new GridLayout(3, false);
            gJVMOptions.setLayout(layout);
            gridData = new GridData(GridData.FILL_HORIZONTAL);
            gridData.horizontalSpan = 2;
            Utils.setLayoutData(gJVMOptions, gridData);
            buildOptions(cDisplay, platform, gJVMOptions, false);
            // show option file
            label = new Label(gJVM, SWT.NULL);
            Messages.setLanguageText(label, "jvm.show.file", new String[] { option_file.getAbsolutePath() });
            Button show_folder_button = new Button(gJVM, SWT.PUSH);
            Messages.setLanguageText(show_folder_button, "MyTorrentsView.menu.explore");
            show_folder_button.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    ManagerUtils.open(option_file);
                }
            });
            label = new Label(gJVM, SWT.NULL);
            Messages.setLanguageText(label, "jvm.reset");
            Button reset_button = new Button(gJVM, SWT.PUSH);
            Messages.setLanguageText(reset_button, "Button.reset");
            reset_button.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    try {
                        platform.setExplicitVMOptions(new String[0]);
                        buildOptions(cDisplay, platform, gJVMOptions, true);
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
        } catch (Throwable e) {
            Debug.out(e);
            label = new Label(gJVM, SWT.NULL);
            Messages.setLanguageText(label, "jvm.error", new String[] { Debug.getNestedExceptionMessage(e) });
            gridData = new GridData();
            gridData.horizontalSpan = 2;
            Utils.setLayoutData(label, gridData);
        }
    }
    return cDisplay;
}
Also used : PlatformManager(com.biglybt.platform.PlatformManager) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) GridLayout(org.eclipse.swt.layout.GridLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TagManager(com.biglybt.core.tag.TagManager) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) GridData(org.eclipse.swt.layout.GridData) Tag(com.biglybt.core.tag.Tag) File(java.io.File)

Aggregations

LinkLabel (com.biglybt.ui.swt.components.LinkLabel)16 GridData (org.eclipse.swt.layout.GridData)11 GridLayout (org.eclipse.swt.layout.GridLayout)11 Composite (org.eclipse.swt.widgets.Composite)8 Label (org.eclipse.swt.widgets.Label)8 MessageText (com.biglybt.core.internat.MessageText)6 Point (org.eclipse.swt.graphics.Point)4 UIInputReceiverListener (com.biglybt.pif.ui.UIInputReceiverListener)3 UIManagerEvent (com.biglybt.pif.ui.UIManagerEvent)3 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)3 BufferedLabel (com.biglybt.ui.swt.components.BufferedLabel)3 StyledText (org.eclipse.swt.custom.StyledText)3 Control (org.eclipse.swt.widgets.Control)3 AERunnable (com.biglybt.core.util.AERunnable)2 PluginInterface (com.biglybt.pif.PluginInterface)2 PlatformManager (com.biglybt.platform.PlatformManager)2 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2