configsectionconnection.java

来自「Azureus is a powerful, full-featured, cr」· Java 代码 · 共 402 行 · 第 1/2 页

JAVA
402
字号
/*
 * File    : ConfigPanelServer.java
 * Created : 11 mar. 2004
 * By      : TuxPaper
 * 
 * Copyright (C) 2004 Aelitis SARL, All rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details ( see the LICENSE file ).
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * AELITIS, SARL au capital de 30,000 euros,
 * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
 */

package org.gudy.azureus2.ui.swt.views.configsections;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Control;

import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.impl.ConfigurationManager;
import org.gudy.azureus2.plugins.ui.config.ConfigSection;
import org.gudy.azureus2.plugins.ui.config.ConfigSectionSWT;
import org.gudy.azureus2.ui.swt.config.*;
import org.gudy.azureus2.ui.swt.Messages;

public class ConfigSectionConnection implements ConfigSectionSWT {
  public String configSectionGetParentSection() {
    return ConfigSection.SECTION_ROOT;
  }

	public String configSectionGetName() {
		return "server";
	}

  public void configSectionSave() {
  }

  public void configSectionDelete() {
  }
  

  public Composite configSectionCreate(final Composite parent) {
    FormData formData;
    FormLayout layout;
    Label label;

    Composite cServer = new Composite(parent, SWT.NULL);

    GridData gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    cServer.setLayoutData(gridData);
    layout = new FormLayout();   
    try {
      layout.spacing = 5;
    } catch (NoSuchFieldError e) {
      /* Ignore for Pre 3.0 SWT.. */
    }
    cServer.setLayout(layout);

 ///////////////////////
    
    IntParameter tcplisten = new IntParameter(cServer, "TCP.Listen.Port", 6881,false);
    formData = new FormData();
    formData.top = new FormAttachment(0, 0);  // 2 params for Pre SWT 3.0
    formData.left = new FormAttachment(0, 0);  // 2 params for Pre SWT 3.0
    formData.width = 40;
    tcplisten.setLayoutData(formData);
    
    label = new Label(cServer, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.serverport");
    formData = new FormData();
    formData.top = new FormAttachment(0,5);
    formData.left = new FormAttachment(tcplisten.getControl());
    label.setLayoutData(formData);
     
    
    
 ///////////////////////
    
    StringParameter bindip = new StringParameter(cServer, "Bind IP", "");
    formData = new FormData();
    formData.top = new FormAttachment(tcplisten.getControl());
    formData.left = new FormAttachment(0, 0);  // 2 params for Pre SWT 3.0
    formData.width = 105;
    bindip.setLayoutData(formData);
    
    label = new Label(cServer, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.bindip");
    formData = new FormData();
    formData.top = new FormAttachment(tcplisten.getControl(),5);
    formData.left = new FormAttachment(bindip.getControl());
    label.setLayoutData(formData);
    
 //////////////////////
    
    IntParameter max_connects = new IntParameter(cServer, "network.max.simultaneous.connect.attempts");
    formData = new FormData();
    formData.top = new FormAttachment(bindip.getControl());
    formData.left = new FormAttachment(0, 0);  // 2 params for Pre SWT 3.0
    formData.width = 20;
    max_connects.setLayoutData(formData);
    
    label = new Label(cServer, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.section.connection.network.max.simultaneous.connect.attempts");
    formData = new FormData();
    formData.top = new FormAttachment(bindip.getControl(),5);
    formData.left = new FormAttachment(max_connects.getControl());
    label.setLayoutData(formData);
    
    
 //////////////////////  PROXY GROUP /////////////////
    
    Group proxy_group = new Group( cServer, SWT.NULL );
    Messages.setLanguageText( proxy_group, "ConfigView.connection.group.proxy" );
    GridLayout proxy_layout = new GridLayout();
    proxy_layout.numColumns = 2;
    proxy_group.setLayout( proxy_layout );
    
    formData = new FormData();
    formData.top = new FormAttachment( max_connects.getControl(), 5 );
    proxy_group.setLayoutData( formData );
    
    GridData grid_data;
    
    
    final BooleanParameter enableProxy = new BooleanParameter(proxy_group, "Enable.Proxy", false, "ConfigView.section.proxy.enable_proxy");
    grid_data = new GridData();
    grid_data.horizontalSpan = 2;
    enableProxy.setLayoutData( grid_data );
    
    
    final BooleanParameter enableSocks = new BooleanParameter(proxy_group, "Enable.SOCKS", false, "ConfigView.section.proxy.enable_socks");
    grid_data = new GridData();
    grid_data.horizontalSpan = 2;
    enableSocks.setLayoutData( grid_data );
    
    
    StringParameter pHost = new StringParameter(proxy_group, "Proxy.Host", "");
    grid_data = new GridData();
    grid_data.widthHint = 105;
    pHost.setLayoutData( grid_data );
    Label lHost = new Label( proxy_group, SWT.NULL );
    Messages.setLanguageText( lHost, "ConfigView.section.proxy.host" );

    
    StringParameter pPort = new StringParameter(proxy_group, "Proxy.Port", "");
    grid_data = new GridData();
    grid_data.widthHint = 40;
    pPort.setLayoutData( grid_data );
    Label lPort = new Label( proxy_group, SWT.NULL );
    Messages.setLanguageText( lPort, "ConfigView.section.proxy.port" );
  

    StringParameter pUser = new StringParameter(proxy_group, "Proxy.Username", "");
    grid_data = new GridData();
    grid_data.widthHint = 105;
    pUser.setLayoutData( grid_data );
    Label lUser = new Label(proxy_group, SWT.NULL);
    Messages.setLanguageText(lUser, "ConfigView.section.proxy.username");


    StringParameter pPass = new StringParameter(proxy_group, "Proxy.Password", "");
    grid_data = new GridData();
    grid_data.widthHint = 105;
    pPass.setLayoutData( grid_data );
    Label lPass = new Label(proxy_group, SWT.NULL);
    Messages.setLanguageText(lPass, "ConfigView.section.proxy.password");


    final BooleanParameter enableSocksPeer = new BooleanParameter(proxy_group, "Proxy.Data.Enable", false, "ConfigView.section.proxy.enable_socks.peer");
    grid_data = new GridData();
    grid_data.horizontalSpan = 2;
    enableSocksPeer.setLayoutData( grid_data );

    
    final BooleanParameter socksPeerInform = new BooleanParameter(proxy_group, "Proxy.Data.SOCKS.inform", true, "ConfigView.section.proxy.peer.informtracker");
    grid_data = new GridData();
    grid_data.horizontalSpan = 2;
    socksPeerInform.setLayoutData( grid_data );
    

    String[] socks_types = { "V4", "V4a", "V5" };
    String dropLabels[] = new String[socks_types.length];
    String dropValues[] = new String[socks_types.length];
    for (int i = 0; i < socks_types.length; i++) {
      dropLabels[i] = socks_types[i];
      dropValues[i] = socks_types[i];

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?