⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systemoptionshell.java

📁 用java实现的
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		// banner
		Label loginBanner = new Label(login, SWT.NONE);
		loginBanner.setBackground(bannerBackground);
		loginBanner.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
		FormData fd = new FormData();
		fd.left = fd.top = new FormAttachment(0, 0);
		fd.right = new FormAttachment(100, 0);
		fd.bottom = new FormAttachment(0, 24);
		loginBanner.setLayoutData(fd);
		loginBanner.addPaintListener(new BannerPaintListener(LumaQQ.getResourceString("sys.opt.banner.login")));
		// 登陆方式标签
		Label lblMethod = new Label(login, SWT.NONE);
		lblMethod.setBackground(panelBackground);
		lblMethod.setText(LumaQQ.getResourceString("sys.opt.login.method"));
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(25, 0);
		fd.top = new FormAttachment(loginBanner, 5, SWT.BOTTOM);
		lblMethod.setLayoutData(fd);
		// 登陆方式下拉框
		comboMethod = new CCombo(login, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
		comboMethod.setBackground(panelBackground);
		comboMethod.add(LumaQQ.getResourceString("sys.opt.login.method.udp"));
		comboMethod.add(LumaQQ.getResourceString("sys.opt.login.method.tcp"));
		fd = new FormData();
		fd.left = new FormAttachment(lblMethod, 3, SWT.RIGHT);
		fd.right = new FormAttachment(70, 0);
		fd.top = new FormAttachment(loginBanner, 5, SWT.BOTTOM);
		comboMethod.setLayoutData(fd);
		comboMethod.addSelectionListener(
			new SelectionAdapter() {
				public void widgetSelected(SelectionEvent e) {
					comboServer.removeAll();
					if(comboMethod.getSelectionIndex() == 0) 
						fillUdpServers();
					else
						fillTcpServers();
					comboServer.select(0);
				}
			}
		);
		// 登陆服务器标签
		Label lblServer = new Label(login, SWT.NONE);
		lblServer.setBackground(panelBackground);
		lblServer.setText(LumaQQ.getResourceString("sys.opt.login.server"));
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(25, 0);
		fd.top = new FormAttachment(loginBanner, 30, SWT.BOTTOM);
		lblServer.setLayoutData(fd);
		// 登陆服务器下拉框
		comboServer = new CCombo(login, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
		comboServer.setBackground(panelBackground);
		fd = new FormData();
		fd.left = new FormAttachment(lblServer, 3, SWT.RIGHT);
		fd.right = new FormAttachment(70, 0);
		fd.top = new FormAttachment(loginBanner, 30, SWT.BOTTOM);
		comboServer.setLayoutData(fd);
		// 自动选择check box
		chkAutoSelect = new Button(login, SWT.CHECK);
		chkAutoSelect.setBackground(panelBackground);
		chkAutoSelect.setText(LumaQQ.getResourceString("sys.opt.login.server.auto"));
		fd = new FormData();
		fd.left = new FormAttachment(comboServer, 5, SWT.RIGHT);
		fd.right = new FormAttachment(100, 0);
		fd.top = new FormAttachment(loginBanner, 30, SWT.BOTTOM);
		chkAutoSelect.setLayoutData(fd);
		// 使用代理服务器check box
		chkUseProxy = new Button(login, SWT.CHECK);
		chkUseProxy.setBackground(panelBackground);
		chkUseProxy.setText(LumaQQ.getResourceString("sys.opt.login.use.proxy"));
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.top = new FormAttachment(loginBanner, 55, SWT.BOTTOM);
		chkUseProxy.setLayoutData(fd);		
		// separator
		Label separator = new Label(login, SWT.SEPARATOR | SWT.HORIZONTAL);
		separator.setBackground(panelBackground);
		fd = new FormData();
		fd.top = new FormAttachment(chkUseProxy, 5, SWT.TOP);
		fd.left = new FormAttachment(chkUseProxy, 5, SWT.RIGHT);
		fd.right = new FormAttachment(100, -5);
		separator.setLayoutData(fd);
		// 代理服务器类型标签
		Label lblProxyType = new Label(login, SWT.NONE);
		lblProxyType.setBackground(panelBackground);
		lblProxyType.setText(LumaQQ.getResourceString("sys.opt.login.proxy.type"));
		fd = new FormData();
		fd.top = new FormAttachment(chkUseProxy, 5, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		lblProxyType.setLayoutData(fd);
		// 代理服务器类型下拉框
		comboProxyType = new CCombo(login, SWT.BORDER | SWT.READ_ONLY);
		comboProxyType.setBackground(panelBackground);
		fd = new FormData();
		fd.top = new FormAttachment(lblProxyType, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(50, -5);
		comboProxyType.setLayoutData(fd);
		comboProxyType.add("Socks5");
		comboProxyType.add("Http");
		comboProxyType.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                if(comboProxyType.getSelectionIndex() == 0)
                    fillSocks5Proxy();
                else
                    fillHttpProxy();
            }
		});
		// 代理服务器地址标签
		Label lblProxyAddress = new Label(login, SWT.NONE);
		lblProxyAddress.setBackground(panelBackground);
		lblProxyAddress.setText(LumaQQ.getResourceString("sys.opt.login.proxy.address"));
		fd = new FormData();
		fd.top = new FormAttachment(comboProxyType, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		lblProxyAddress.setLayoutData(fd);
		// 代理服务器地址文本框
		textProxyAddress = new Text(login, SWT.SINGLE | SWT.BORDER);
		textProxyAddress.setBackground(controlBackground);
		fd = new FormData();
		fd.top = new FormAttachment(lblProxyAddress, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(50, -5);
		textProxyAddress.setLayoutData(fd);
		textProxyAddress.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                if(Character.isSpaceChar(e.character))
                    e.doit = false;
            }
		});
		// 代理服务器端口标签
		Label lblProxyPort = new Label(login, SWT.NONE);
		lblProxyPort.setBackground(panelBackground);
		lblProxyPort.setText(LumaQQ.getResourceString("sys.opt.login.proxy.port"));
		fd = new FormData();
		fd.top = new FormAttachment(textProxyAddress, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		lblProxyPort.setLayoutData(fd);
		// 代理服务器端口文本框
		textProxyPort = new Text(login, SWT.SINGLE | SWT.BORDER);
		textProxyPort.setBackground(controlBackground);
		textProxyPort.setTextLimit(5);
		fd = new FormData();
		fd.top = new FormAttachment(lblProxyPort, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(50, -5);
		textProxyPort.setLayoutData(fd);
		textProxyPort.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                if(Character.isDigit(e.character) || 
                   e.character == SWT.DEL ||
                   e.character == SWT.BS ||
                   e.keyCode == SWT.LEFT ||
                   e.keyCode == SWT.RIGHT ||
                   e.keyCode == SWT.DOWN ||
                   e.keyCode == SWT.UP)
                    e.doit = true;
                else
                    e.doit = false;
            } 
		});
		// 代理服务器校验用户名标签
		Label lblProxyUsername = new Label(login, SWT.NONE);
		lblProxyUsername.setBackground(panelBackground);
		lblProxyUsername.setText(LumaQQ.getResourceString("sys.opt.login.proxy.username"));
		fd = new FormData();
		fd.top = new FormAttachment(textProxyPort, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		lblProxyUsername.setLayoutData(fd);
		// 代理服务器用户名文本框
		textProxyUsername = new Text(login, SWT.SINGLE | SWT.BORDER);
		textProxyUsername.setBackground(controlBackground);
		fd = new FormData();
		fd.top = new FormAttachment(lblProxyUsername, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(50, -5);
		textProxyUsername.setLayoutData(fd);
		// 代理服务器校验密码标签
		Label lblProxyPassword = new Label(login, SWT.NONE);
		lblProxyPassword.setBackground(panelBackground);
		lblProxyPassword.setText(LumaQQ.getResourceString("sys.opt.login.proxy.password"));
		fd = new FormData();
		fd.top = new FormAttachment(textProxyUsername, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		lblProxyPassword.setLayoutData(fd);
		// 代理服务器校验密码文本框
		textProxyPassword = new Text(login, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
		textProxyPassword.setBackground(controlBackground);
		fd = new FormData();
		fd.top = new FormAttachment(lblProxyPassword, 1, SWT.BOTTOM);
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(50, -5);
		textProxyPassword.setLayoutData(fd);
		// 代理列表标签
		Label lblProxyList = new Label(login, SWT.NONE);
		lblProxyList.setBackground(panelBackground);
		lblProxyList.setText(LumaQQ.getResourceString("sys.opt.login.proxy.list"));
		fd = new FormData();
		fd.top = new FormAttachment(chkUseProxy, 5, SWT.BOTTOM);
		fd.left = new FormAttachment(50, 5);
		lblProxyList.setLayoutData(fd);
		// 代理列表
		proxyList = new List(login, SWT.SINGLE | SWT.BORDER);
		fd = new FormData();
		fd.top = new FormAttachment(lblProxyList, 1, SWT.BOTTOM);
		fd.bottom = new FormAttachment(textProxyUsername, 0, SWT.BOTTOM);
		fd.left = new FormAttachment(50, 5);
		fd.right = new FormAttachment(100, -5);
		proxyList.setLayoutData(fd);
		proxyList.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                int index = proxyList.getSelectionIndex();
                if(index != -1) {
                    if(comboProxyType.getSelectionIndex() == 0) {
                        Socks5Proxy proxy = proxies.getSocksProxy(index);
                        textProxyAddress.setText(proxy.getServer());
                        textProxyPort.setText(proxy.getPort());
                        textProxyUsername.setText(proxy.getUsername());
                        textProxyPassword.setText(proxy.getPassword());
                    } else {
                        HttpProxy proxy = proxies.getHttpProxy(index);
                        textProxyAddress.setText(proxy.getServer());
                        textProxyPort.setText(proxy.getPort());
                        textProxyUsername.setText(proxy.getUsername());
                        textProxyPassword.setText(proxy.getPassword());
                    }
                }
            }
		});
		// 验证按钮
		btnVerify = new Button(login, SWT.PUSH);
		btnVerify.setText(LumaQQ.getResourceString("sys.opt.button.verify"));
		fd = new FormData();
		fd.top = new FormAttachment(proxyList, 5, SWT.BOTTOM);
		fd.left = new FormAttachment(50, 5);
		btnVerify.setLayoutData(fd);
		btnVerify.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                startVerify();
            }
		});
		// 添加按钮
		Button btnAdd = new Button(login, SWT.PUSH);
		btnAdd.setText(LumaQQ.getResourceString("sys.opt.button.add"));
		fd = new FormData();
		fd.top = new FormAttachment(proxyList, 5, SWT.BOTTOM);
		fd.left = new FormAttachment(btnVerify, 5, SWT.RIGHT);
		btnAdd.setLayoutData(fd);
		btnAdd.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                if(checkProxy()) {
                    if(comboProxyType.getSelectionIndex() == 0) {
                        Socks5Proxy proxy = new Socks5ProxyImpl();
                        proxy.setServer(textProxyAddress.getText());
                        proxy.setPort(textProxyPort.getText());
                        proxy.setUsername(textProxyUsername.getText());
                        proxy.setPassword(textProxyPassword.getText());
                        proxies.addSocks5Proxy(proxy);
                        addSocks5Proxy(new StringBuffer(), proxy);
                    } else {
                        HttpProxy proxy = new HttpProxyImpl();
                        proxy.setServer(textProxyAddress.getText());
                        proxy.setPort(textProxyPort.getText());
                        proxy.setUsername(textProxyUsername.getText());
                        proxy.setPassword(textProxyPassword.getText());
                        proxies.addHttpProxy(proxy);
                        addHttpProxy(new StringBuffer(), proxy);
                    }
                }
            }
		});
		// 删除按钮
		Button btnDelete = new Button(login, SWT.PUSH);
		btnDelete.setText(LumaQQ.getResourceString("sys.opt.button.del"));
		fd = new FormData();
		fd.top = new FormAttachment(proxyList, 5, SWT.BOTTOM);
		fd.left = new FormAttachment(btnAdd, 5, SWT.RIGHT);
		btnDelete.setLayoutData(fd);
		btnDelete.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                int index = proxyList.getSelectionIndex();
                if(index == -1) {
                    MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
                    box.setText(LumaQQ.getResourceString("message.box.common.warning.title"));
                    box.setMessage(LumaQQ.getResourceString("message.box.please.select.proxy"));
                    box.open();
                } else {
                    proxyList.remove(index);
                    if(comboProxyType.getSelectionIndex() == 0)
                        proxies.removeSocks5Proxy(index);
                    else
                        proxies.removeHttpProxy(index);
                }
            }
		});
		// 初始化值
		chkAutoSelect.setSelection(options.isAutoSelect());
		if(options.isUseTcp()) {
			comboMethod.select(1);
			fillTcpServers();
		} else {
			comboMethod.select(0);
			fillUdpServers();
		}
		comboServer.setText(options.getServer());
		chkUseProxy.setSelection(!(options.getProxyType().equalsIgnoreCase("None") || options.getProxyType().equals("")));
	    if(options.getProxyType().equalsIgnoreCase("Http")) {
	        comboProxyType.select(1);
	        fillHttpProxy();
	    } else {
	        comboProxyType.select(0);
	        fillSocks5Proxy();
	    }
	    textProxyAddress.setText(options.getProxyServer());
	    textProxyPort.setText(String.valueOf(options.getProxyPort()));
	    textProxyUsername.setText(options.getProxyUsername());
	    textProxyPassword.setText(options.getProxyPassword());

⌨️ 快捷键说明

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