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

📄 generaltab.java

📁 JMule是一个基于Java开发
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  JMule - Java file sharing client *  Copyright (C) 2007-2008 JMule team ( jmule@jmule.org / http://jmule.org ) * *  Any parts of this program derived from other projects, or contributed *  by third-party developers are copyrighted by their respective authors. * *  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, or (at your option) any later version. * *  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. * *  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. * */package org.jmule.ui.swt.settingswindow;import org.eclipse.swt.SWT;import org.eclipse.swt.events.SelectionAdapter;import org.eclipse.swt.events.SelectionEvent;import org.eclipse.swt.graphics.Image;import org.eclipse.swt.layout.GridData;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Composite;import org.eclipse.swt.widgets.Event;import org.eclipse.swt.widgets.Group;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.widgets.Listener;import org.eclipse.swt.widgets.Spinner;import org.eclipse.swt.widgets.Text;import org.jmule.core.JMConstants;import org.jmule.core.JMuleCore;import org.jmule.core.configmanager.ConfigurationManager;import org.jmule.ui.localizer._;import org.jmule.ui.swt.SWTImageRepository;import org.jmule.ui.swt.SWTPreferences;/** * Created on Aug 19, 2008 * @author binary256 * @version $Revision: 1.3 $ * Last changed by $Author: binary256_ $ on $Date: 2008/10/16 18:20:02 $ */public class GeneralTab extends AbstractTab {	private Text nick_name_text;	private Button prompt_on_exit_check, server_list_update;	private Button show_nightly_build_warning = null;	private Button connect_at_startup = null;		private ConfigurationManager config_manager;	private SWTPreferences swt_preferences;		private int EDIT_FIELD_WIDTH = 60;		private Spinner tcp_port, udp_port;	private Button enable_udp, kbit_button, kbyte_button, enable_download_limit, enable_upload_limit, startup_update_check;	private Text download_limit, upload_limit, download_capacity, upload_capacity;		private boolean kbyte_selected = true;		public GeneralTab(Composite parent, JMuleCore core) {		super(parent, core);			Listener number_filter = new Listener() {			public void handleEvent(Event e) {		        String text = e.text;		        char[] chars = new char[text.length()];		        text.getChars(0, chars.length, chars, 0);		        for (int i = 0; i < chars.length; i++) {		          if (!('0' <= chars[i] && chars[i] <= '9')) {			            e.doit = false;			            return;		          }				}			}		};				GridData layout_data;		GridLayout layout;		Composite container;				config_manager = _core.getConfigurationManager();		swt_preferences = SWTPreferences.getInstance();				content.setLayout(new GridLayout(2,false));		Label label;				label = new Label(content,SWT.NONE);		label.setFont(skin.getLabelFont());		label.setText(_._("settingswindow.tab.general.label.nickname") + " : ");		label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));				nick_name_text = new Text(content,SWT.BORDER);		nick_name_text.setFont(skin.getDefaultFont());		layout_data = new GridData(GridData.FILL_HORIZONTAL);		nick_name_text.setLayoutData(layout_data);				nick_name_text.setText(_core.getConfigurationManager().getNickName());				prompt_on_exit_check = new Button(content,SWT.CHECK);		prompt_on_exit_check.setText(_._("settingswindow.tab.general.checkbox.prompt_on_exit"));		prompt_on_exit_check.setSelection(swt_preferences.promptOnExit());				layout_data = new GridData(GridData.FILL_HORIZONTAL);		layout_data.horizontalSpan = 2;		prompt_on_exit_check.setLayoutData(layout_data);				server_list_update = new Button(content,SWT.CHECK);		server_list_update.setText(_._("settingswindow.tab.general.checkbox.update_server_list"));		layout_data = new GridData(GridData.FILL_HORIZONTAL);		layout_data.horizontalSpan = 2;		server_list_update.setLayoutData(layout_data);		boolean update = config_manager.getBooleanParameter(ConfigurationManager.SERVER_LIST_UPDATE_ON_CONNECT_KEY, false);		server_list_update.setSelection(update);		startup_update_check = new Button(content,SWT.CHECK);		startup_update_check.setText(_._("settingswindow.tab.general.checkbox.startup_update_check"));		layout_data = new GridData(GridData.FILL_HORIZONTAL);		layout_data.horizontalSpan = 2;		startup_update_check.setLayoutData(layout_data);		startup_update_check.setSelection(swt_preferences.updateCheckAtStartup());				connect_at_startup = new Button(content,SWT.CHECK);		connect_at_startup.setText(_._("settingswindow.tab.general.checkbox.connect_at_startup"));		layout_data = new GridData(GridData.FILL_HORIZONTAL);		layout_data.horizontalSpan = 2;		connect_at_startup.setLayoutData(layout_data);		connect_at_startup.setSelection(swt_preferences.isConnectAtStartup());						if (JMConstants.IS_NIGHTLY_BUILD) {			show_nightly_build_warning = new Button(content,SWT.CHECK);			show_nightly_build_warning.setText(_._("settingswindow.tab.general.checkbox.show_nightly_build_warning"));			layout_data = new GridData(GridData.FILL_HORIZONTAL);			layout_data.horizontalSpan = 2;			show_nightly_build_warning.setLayoutData(layout_data);			show_nightly_build_warning.setSelection(swt_preferences.isNightlyBuildWarning());		}				Group ports = new Group(content,SWT.NONE);		ports.setText(_._("settingswindow.tab.general.group.ports"));		layout_data = new GridData(GridData.FILL_HORIZONTAL);		layout_data.horizontalSpan = 2;		ports.setLayoutData(layout_data);				ports.setLayout(new GridLayout(2,false));				label = new Label(ports,SWT.NONE);		label.setFont(skin.getDefaultFont());		label.setForeground(skin.getDefaultColor());		label.setText(_._("settingswindow.tab.connection.label.tcp_port") + " : ");		label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));				tcp_port = new Spinner (ports, SWT.BORDER);		tcp_port.setMinimum(1);		tcp_port.setMaximum(65535);		tcp_port.setSelection(config_manager.getTCP());		tcp_port.setIncrement(1);		tcp_port.setPageIncrement(100);		label = new Label(ports,SWT.NONE);		label.setFont(skin.getDefaultFont());		label.setForeground(skin.getDefaultColor());		label.setText(_._("settingswindow.tab.connection.label.udp_port") + " : ");		label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));				Composite container1 = new Composite(ports,SWT.NONE);		container1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));		layout = new GridLayout(2,false);		layout.marginWidth=0;		layout.marginHeight=0;		container1.setLayout(layout);				udp_port = new Spinner (container1, SWT.BORDER);		udp_port.setMinimum(1);		udp_port.setMaximum(65535);		udp_port.setSelection(config_manager.getUDP());		udp_port.setIncrement(1);		udp_port.setPageIncrement(100);				enable_udp = new Button(container1,SWT.CHECK);		enable_udp.setText(_._("settingswindow.tab.connection.button.enabled"));		enable_udp.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(SelectionEvent event) {				updateUDPControls();			}					});		enable_udp.setSelection(config_manager.isUDPEnabled());				updateUDPControls();				Group limits = new Group(content,SWT.NONE);		limits.setText(_._("settingswindow.tab.general.group.limits"));		layout_data = new GridData(GridData.FILL_HORIZONTAL);		layout_data.horizontalSpan = 2;		limits.setLayoutData(layout_data);		limits.setLayout(new GridLayout(2,false));				label = new Label(limits,SWT.NONE);		label.setFont(skin.getDefaultFont());		label.setForeground(skin.getDefaultColor());		label.setText(_._("settingswindow.tab.connection.label.download_limit") + " : ");		label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));				Composite container2 = new Composite(limits,SWT.NONE);		layout_data = new GridData(GridData.FILL_HORIZONTAL);		container2.setLayoutData(layout_data);		layout = new GridLayout(3,false);		layout.marginWidth = 0;		layout.marginHeight = 0;		container2.setLayout(layout);				download_limit = new Text(container2,SWT.BORDER );		download_limit.addListener(SWT.Verify, number_filter);		layout_data = new GridData();		layout_data.widthHint = EDIT_FIELD_WIDTH;		download_limit.setLayoutData(layout_data);		download_limit.setText((config_manager.getDownloadLimit()/1024)+"");				new Label(container2,SWT.NONE).setText(_._("settingswindow.tab.connection.label.kb_s"));				enable_download_limit = new Button(container2,SWT.CHECK);		enable_download_limit.setText(_._("settingswindow.tab.connection.button.enabled"));		enable_download_limit.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(SelectionEvent event) {				updateDownloadLimitControls();			}

⌨️ 快捷键说明

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