Java tutorial
/******************************************************************************* * Copyright (c) 2014,2015 Hideki Yatomi * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ package net.yatomiya.nicherry.ui.preference; import org.eclipse.jface.preference.*; import org.eclipse.swt.*; import net.yatomiya.e4.ui.preference.*; import net.yatomiya.nicherry.*; class NetworkPage extends StructuredFieldEditorPreferencePage { GroupField proxyGroup; NetworkPage() { super("?"); } @Override public void createFieldEditors() { CompositeField rootField = getRootCompositeField(); rootField.addField(new StringFieldEditor(NPreferences.NETWORK_HTTP_USER_AGENT, "", rootField.getControl())); rootField.addField(new SpinnerFieldEditor(NPreferences.BBS_NETWORK_CONNECT_INTERVAL_PER_HOST, "BBS?????", rootField.getControl(), 0, 1000 * 60, 1, 1000)); rootField.addField(LabelField.createSeparatorField(rootField.getControl())); rootField.addField(new BooleanFieldEditor(NPreferences.NETWORK_PROXY_ENABLE, "?", rootField.getControl()) { @Override protected void valueChanged(boolean oldValue, boolean newValue) { updateProxyGroupEnable(); } }); { proxyGroup = new GroupField(this, rootField.getControl(), SWT.NONE, ""); rootField.addField(proxyGroup); proxyGroup.addField( new StringFieldEditor(NPreferences.NETWORK_PROXY_HOST, "", proxyGroup.getControl())); proxyGroup.addField( new IntegerFieldEditor(NPreferences.NETWORK_PROXY_PORT, "?", proxyGroup.getControl())); proxyGroup.addField(new StringFieldEditor(NPreferences.NETWORK_PROXY_BASIC_USERNAME, "?", proxyGroup.getControl())); proxyGroup.addField(new StringFieldEditor(NPreferences.NETWORK_PROXY_BASIC_PASSWORD, "", proxyGroup.getControl())); proxyGroup.setEnable(Boolean.valueOf(NUtils.getPreference(NPreferences.NETWORK_PROXY_ENABLE))); } } private void updateProxyGroupEnable() { boolean enable = ((BooleanFieldEditor) getField(NPreferences.NETWORK_PROXY_ENABLE)).getBooleanValue(); proxyGroup.setEnable(enable); } }