📄 modepanel.java
字号:
/*
* File : ModePanel.java Created : 30 sept. 2003 01:51:05 By : Olivier
*
* Azureus - a Java Bittorrent client
*
* 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
*/
package org.gudy.azureus2.ui.swt.maketorrent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.tracker.host.TRHost;
import org.gudy.azureus2.core3.tracker.util.TRTrackerUtils;
import org.gudy.azureus2.core3.util.Constants;
import org.gudy.azureus2.core3.util.TrackersUtil;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;
import org.gudy.azureus2.ui.swt.wizard.AbstractWizardPanel;
import org.gudy.azureus2.ui.swt.wizard.IWizardPanel;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
/**
* @author Olivier
*
*/
public class ModePanel extends AbstractWizardPanel {
private Button bSingle;
private Button bDirectory;
private Combo tracker;
public ModePanel(NewTorrentWizard wizard, AbstractWizardPanel previous) {
super(wizard, previous);
}
/*
* (non-Javadoc)
*
* @see org.gudy.azureus2.ui.swt.maketorrent.IWizardPanel#show()
*/
public void show() {
final NewTorrentWizard wizard = (NewTorrentWizard)this.wizard;
wizard.setTitle(MessageText.getString("wizard.mode"));
wizard.setCurrentInfo(MessageText.getString("wizard.singlefile.help"));
Composite rootPanel = wizard.getPanel();
GridLayout layout = new GridLayout();
layout.numColumns = 1;
rootPanel.setLayout(layout);
Composite panel = new Composite(rootPanel, SWT.NO_RADIO_GROUP);
GridData gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL);
panel.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 4;
panel.setLayout(layout);
//Line :
// O use embedded tracker []Use SSL
final Button btnLocalTracker = new Button(panel, SWT.RADIO);
Messages.setLanguageText(btnLocalTracker, "wizard.tracker.local");
gridData = new GridData();
gridData.horizontalSpan = 2;
btnLocalTracker.setLayoutData(gridData);
final Button btnSSL = new Button(panel, SWT.CHECK);
Messages.setLanguageText(btnSSL, "wizard.tracker.ssl");
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
gridData.horizontalSpan = 2;
btnSSL.setLayoutData( gridData );
//Line :
//Announce URL : <local announce>
final String localTrackerHost = COConfigurationManager.getStringParameter("Tracker IP", "");
final int localTrackerPort = COConfigurationManager.getIntParameter("Tracker Port", TRHost.DEFAULT_PORT );
final int localTrackerPortSSL = COConfigurationManager.getIntParameter("Tracker Port SSL", TRHost.DEFAULT_PORT_SSL );
final boolean SSLEnabled = COConfigurationManager.getBooleanParameter("Tracker Port SSL Enable", false );
final String[] localTrackerUrl = new String[1];
// there's a potential oversize issue with the howToLocal string, and attemtping to force wrap has no effect -
// therefore, provide more room and remove extraneous labeling
final boolean showLocal = TRTrackerUtils.isTrackerEnabled();
final Label labelLocalAnnounce = (showLocal) ? new Label(panel, SWT.NULL) : null;
final Label localTrackerValue = new Label(panel, SWT.NULL);
if ( showLocal ){
Messages.setLanguageText(labelLocalAnnounce, "wizard.announceUrl");
localTrackerUrl[0] = "http://" + localTrackerHost + ":" + localTrackerPort + "/announce";
localTrackerValue.setText(localTrackerUrl[0]);
btnSSL.setEnabled( SSLEnabled );
gridData = new GridData();
gridData.horizontalSpan = 3;
} else {
localTrackerUrl[0] = "";
Messages.setLanguageText(localTrackerValue, "wizard.tracker.howToLocal");
btnLocalTracker.setSelection(false);
btnSSL.setEnabled(false);
btnLocalTracker.setEnabled(false);
localTrackerValue.setEnabled(true);
if ( wizard.getTrackerType() == NewTorrentWizard.TT_LOCAL ){
wizard.setTrackerType( NewTorrentWizard.TT_EXTERNAL );
}
gridData = new GridData();
gridData.horizontalSpan = 4;
}
localTrackerValue.setLayoutData(gridData);
int tracker_type = wizard.getTrackerType();
if (tracker_type == NewTorrentWizard.TT_LOCAL) {
setTrackerUrl(localTrackerUrl[0]);
}else if ( tracker_type == NewTorrentWizard.TT_EXTERNAL ){
setTrackerUrl( NewTorrentWizard.TT_EXTERNAL_DEFAULT );
}else{
setTrackerUrl( NewTorrentWizard.TT_DECENTRAL_DEFAULT );
}
//Line:
// O use external Tracker
final Button btnExternalTracker = new Button(panel, SWT.RADIO);
Messages.setLanguageText(btnExternalTracker, "wizard.tracker.external");
gridData = new GridData();
gridData.horizontalSpan = 4;
btnExternalTracker.setLayoutData(gridData);
//Line:
// [External Tracker Url ]V
final Label labelExternalAnnounce = new Label(panel, SWT.NULL);
Messages.setLanguageText(labelExternalAnnounce, "wizard.announceUrl");
btnLocalTracker.setSelection(tracker_type==NewTorrentWizard.TT_LOCAL);
if(showLocal) localTrackerValue.setEnabled(tracker_type==NewTorrentWizard.TT_LOCAL);
btnSSL.setEnabled(SSLEnabled&&tracker_type==NewTorrentWizard.TT_LOCAL);
btnExternalTracker.setSelection(tracker_type==NewTorrentWizard.TT_EXTERNAL);
labelExternalAnnounce.setEnabled(tracker_type==NewTorrentWizard.TT_EXTERNAL);
tracker = new Combo(panel, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
tracker.setLayoutData(gridData);
List trackers = TrackersUtil.getInstance().getTrackersList();
Iterator iter = trackers.iterator();
while (iter.hasNext()) {
tracker.add((String) iter.next());
}
tracker.addModifyListener(new ModifyListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/
public void modifyText(ModifyEvent arg0) {
String text = tracker.getText();
setTrackerUrl(text);
boolean valid = true;
String errorMessage = "";
try {
new URL(text);
} catch (MalformedURLException e) {
valid = false;
errorMessage = MessageText.getString("wizard.invalidurl");
}
wizard.setErrorMessage(errorMessage);
wizard.setNextEnabled(valid);
}
});
tracker.addListener(SWT.Selection,new Listener() {
public void handleEvent(Event e) {
String text = tracker.getText();
setTrackerUrl(text);
boolean valid = true;
String errorMessage = "";
try {
new URL(text);
} catch (MalformedURLException ex) {
valid = false;
errorMessage = MessageText.getString("wizard.invalidurl");
}
wizard.setErrorMessage(errorMessage);
wizard.setNextEnabled(valid);
}
});
updateTrackerURL();
tracker.setEnabled( tracker_type == NewTorrentWizard.TT_EXTERNAL );
new Label(panel,SWT.NULL);
// O decentral tracking
// has to be on same no-radio-group panel otherwise weird things happen regarding selection of
// "external tracker" button *even if* we set it up so that "dht tracker" should be selected....
final Button btnDHTTracker = new Button(panel, SWT.RADIO);
Messages.setLanguageText(btnDHTTracker, "wizard.tracker.dht");
gridData = new GridData();
gridData.horizontalSpan = 4;
btnDHTTracker.setLayoutData(gridData);
btnDHTTracker.setSelection(tracker_type==NewTorrentWizard.TT_DECENTRAL);
// add another panel due to control oversize issues
panel = new Composite(rootPanel, SWT.NO_RADIO_GROUP);
gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL);
panel.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -