Search in sources :

Example 6 with BaseSwtParameter

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

the class ConfigSectionConnectionProxySWT method configSectionCreate.

@Override
public void configSectionCreate(Composite parent, Map<ParameterImpl, BaseSwtParameter> mapParamToSwtParam) {
    BooleanParameterImpl enableProxy = (BooleanParameterImpl) getPluginParam(BCFG_ENABLE_PROXY);
    BooleanParameterImpl enableSocks = (BooleanParameterImpl) getPluginParam(BCFG_ENABLE_SOCKS);
    StringParameterImpl pHost = (StringParameterImpl) getPluginParam(SCFG_PROXY_HOST);
    IntParameterImpl pPort = (IntParameterImpl) getPluginParam(SCFG_PROXY_PORT);
    StringParameterImpl pUser = (StringParameterImpl) getPluginParam(SCFG_PROXY_USERNAME);
    StringParameterImpl pPass = (StringParameterImpl) getPluginParam(SCFG_PROXY_PASSWORD);
    BooleanParameterImpl trackerDNSKill = (BooleanParameterImpl) getPluginParam(BCFG_PROXY_SOCKS_TRACKER_DNS_DISABLE);
    ParameterImpl paramButtonTest = getPluginParam(ConfigSectionConnectionProxy.ID_BTN_TEST);
    ParameterImpl[] socks_params = { enableProxy, enableSocks, pHost, pPort, pUser, pPass, trackerDNSKill };
    ParameterListener socks_adapter = param -> {
        boolean enabled = enableProxy.getValue() && enableSocks.getValue() && pHost.getValue().trim().length() > 0 && pPort.getValue() > 0;
        boolean socks_enabled = enableProxy.getValue() && enableSocks.getValue();
        trackerDNSKill.setEnabled(socks_enabled);
        if (enabled) {
            try {
                NetworkAdminSocksProxy nasp = NetworkAdmin.getSingleton().createSocksProxy(pHost.getValue(), pPort.getValue(), pUser.getValue(), pPass.getValue());
                synchronized (test_proxy) {
                    test_proxy[0] = nasp;
                }
            } catch (Throwable e) {
                enabled = false;
            }
        }
        if (!enabled) {
            synchronized (test_proxy) {
                test_proxy[0] = null;
            }
        }
        final boolean f_enabled = enabled;
        Utils.execSWTThread(() -> paramButtonTest.setEnabled(f_enabled));
    };
    for (ParameterImpl socks_param : socks_params) {
        socks_param.addListener(socks_adapter);
    }
    // init settings
    socks_adapter.parameterChanged(null);
}
Also used : IntParameterImpl(com.biglybt.pifimpl.local.ui.config.IntParameterImpl) ParameterImpl(com.biglybt.pifimpl.local.ui.config.ParameterImpl) TextViewerWindow(com.biglybt.ui.swt.TextViewerWindow) BooleanParameterImpl(com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl) MessageText(com.biglybt.core.internat.MessageText) ConfigSectionConnectionProxy(com.biglybt.ui.config.ConfigSectionConnectionProxy) Connection(com.biglybt.core.config.ConfigKeys.Connection) StringParameterImpl(com.biglybt.pifimpl.local.ui.config.StringParameterImpl) Debug(com.biglybt.core.util.Debug) Utils(com.biglybt.ui.swt.Utils) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) ParameterListener(com.biglybt.pif.ui.config.ParameterListener) NetworkAdmin(com.biglybt.core.networkmanager.admin.NetworkAdmin) AESemaphore(com.biglybt.core.util.AESemaphore) NetworkAdminSocksProxy(com.biglybt.core.networkmanager.admin.NetworkAdminSocksProxy) BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter) AEThread2(com.biglybt.core.util.AEThread2) IntParameterImpl(com.biglybt.pifimpl.local.ui.config.IntParameterImpl) ParameterImpl(com.biglybt.pifimpl.local.ui.config.ParameterImpl) BooleanParameterImpl(com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl) StringParameterImpl(com.biglybt.pifimpl.local.ui.config.StringParameterImpl) IntParameterImpl(com.biglybt.pifimpl.local.ui.config.IntParameterImpl) NetworkAdminSocksProxy(com.biglybt.core.networkmanager.admin.NetworkAdminSocksProxy) StringParameterImpl(com.biglybt.pifimpl.local.ui.config.StringParameterImpl) ParameterListener(com.biglybt.pif.ui.config.ParameterListener) BooleanParameterImpl(com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl)

Example 7 with BaseSwtParameter

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

the class ConfigSectionInterfaceColorSWT method configSectionCreate.

@Override
public void configSectionCreate(Composite parent, Map<ParameterImpl, BaseSwtParameter> mapParamToSwtParam) {
    boolean isAZ3 = COConfigurationManager.getStringParameter("ui").equals("az3");
    if (!isAZ3) {
        return;
    }
    BaseSwtParameter pg = mapParamToSwtParam.get(getPluginParam("ConfigView.section.style.colorOverrides"));
    if (pg == null) {
        return;
    }
    Composite cColorOverride = (Composite) pg.getMainControl();
    Display display = cColorOverride.getDisplay();
    Label label;
    GridData gridData;
    // These keys are referenced in skin properties (skin3_constants)
    String[][] override_keys_blocks = { { // Doesn't require restart
    "config.skin.color.sidebar.bg" }, { // Requires Restart
    "config.skin.color.library.header" } };
    SkinColorValueProcessor skinColorValueProcessor = new SkinColorValueProcessor(display);
    for (int i = 0; i < override_keys_blocks.length; i++) {
        if (i == 1) {
            label = new Label(cColorOverride, SWT.NULL);
            gridData = new GridData(GridData.FILL_HORIZONTAL);
            gridData.horizontalSpan = 2;
            label.setLayoutData(gridData);
            label = new Label(cColorOverride, SWT.NULL);
            Messages.setLanguageText(label, "restart.required.for.following");
            gridData = new GridData(GridData.FILL_HORIZONTAL);
            gridData.horizontalSpan = 2;
            label.setLayoutData(gridData);
        }
        String[] override_keys = override_keys_blocks[i];
        for (final String key : override_keys) {
            new ColorSwtParameter(cColorOverride, key, key, null, true, skinColorValueProcessor);
        }
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ColorSwtParameter(com.biglybt.ui.swt.config.ColorSwtParameter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter) Display(org.eclipse.swt.widgets.Display)

Example 8 with BaseSwtParameter

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

the class ConfigSectionInterfaceLanguageSWT method configSectionCreate.

@Override
public void configSectionCreate(Composite parent, Map<ParameterImpl, BaseSwtParameter> mapParamToSwtParam) {
    // Hack to get Language list to fill visible area and overflow vertically
    ParameterImpl paramLocale = getPluginParam(UI.SCFG_LOCALE);
    BaseSwtParameter swtParamLocale = mapParamToSwtParam.get(paramLocale);
    if (swtParamLocale == null) {
        return;
    }
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.minimumHeight = 50;
    swtParamLocale.getMainControl().setLayoutData(gridData);
}
Also used : ParameterImpl(com.biglybt.pifimpl.local.ui.config.ParameterImpl) GridData(org.eclipse.swt.layout.GridData) BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter)

Aggregations

BaseSwtParameter (com.biglybt.ui.swt.config.BaseSwtParameter)8 ParameterImpl (com.biglybt.pifimpl.local.ui.config.ParameterImpl)2 IntSwtParameter (com.biglybt.ui.swt.config.IntSwtParameter)2 TabbedEntry (com.biglybt.ui.swt.mdi.TabbedEntry)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 Connection (com.biglybt.core.config.ConfigKeys.Connection)1 MessageText (com.biglybt.core.internat.MessageText)1 NetworkAdmin (com.biglybt.core.networkmanager.admin.NetworkAdmin)1 NetworkAdminSocksProxy (com.biglybt.core.networkmanager.admin.NetworkAdminSocksProxy)1 AESemaphore (com.biglybt.core.util.AESemaphore)1 AEThread2 (com.biglybt.core.util.AEThread2)1 Debug (com.biglybt.core.util.Debug)1 ParameterListener (com.biglybt.pif.ui.config.ParameterListener)1 BooleanParameterImpl (com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl)1 IntParameterImpl (com.biglybt.pifimpl.local.ui.config.IntParameterImpl)1 StringParameterImpl (com.biglybt.pifimpl.local.ui.config.StringParameterImpl)1