📄 olddonationwindow.java
字号:
enableOk();
}
public void dispose() {
ended = true;
}
}
private void close() {
animator.dispose();
mainFont.dispose();
mediumFont.dispose();
smallFont.dispose();
workingImage.dispose();
shell.dispose();
ImageRepository.unloadImage("donation");
}
private void paint() {
if(shell == null || shell.isDisposed()) return;
if(workingImage == null || workingImage.isDisposed()) return;
GC gcShell = new GC(shell);
gcShell.drawImage(workingImage,0,0);
gcShell.dispose();
}
private void enableOk() {
if(display == null || display.isDisposed()) return;
display.asyncExec(new AERunnable() {
public void runSupport() {
if(shell == null || shell.isDisposed())
return;
ok.setEnabled(true);
}
});
}
private void addControls() {
/*if(display == null || display.isDisposed()) return;
display.asyncExec(new AERunnable() {
public void runSupport() {
if(shell == null || shell.isDisposed())
return; */
FormData formData;
//We're adding the OK button First so that it's on TOP
//Of other controls (Not sure about this, but should be right)
//Gudy :p
ok = new Button(shell,SWT.PUSH);
ok.setEnabled(false);
Messages.setLanguageText(ok,"DonationWindow.ok");
formData = new FormData();
formData.bottom = new FormAttachment(100,-5);
formData.right = new FormAttachment(100,-5);
formData.width = 100;
ok.setLayoutData(formData);
radioDonate = new Button(shell,SWT.RADIO);
Messages.setLanguageText(radioDonate,"DonationWindow.options.donate");
radioDonate.setFont(mainFont);
radioDonate.setBackground(Colors.white);
formData = new FormData();
formData.top = new FormAttachment(65, 0); // added ",0" for Pre 3.0 SWT
formData.left = new FormAttachment(0,140);
formData.right = new FormAttachment(100,-5);
radioDonate.setLayoutData(formData);
final Label textFooter = new Label(shell,SWT.NULL);
textFooter.setFont(smallFont);
textFooter.setText(footerText);
textFooter.setForeground(Colors.black);
textFooter.setBackground(Colors.white);
formData = new FormData();
formData.top = new FormAttachment(radioDonate);
formData.left = new FormAttachment(0,140);
formData.right = new FormAttachment(100,-5);
textFooter.setLayoutData(formData);
radioNoDonate = new Button(shell,SWT.RADIO);
Messages.setLanguageText(radioNoDonate,"DonationWindow.options.nodonate");
radioNoDonate.setFont(mediumFont);
radioNoDonate.setBackground(Colors.white);
formData = new FormData();
formData.top = new FormAttachment(textFooter);
formData.left = new FormAttachment(0,140);
formData.right = new FormAttachment(100,-5);
radioNoDonate.setLayoutData(formData);
radioLater = new Button(shell,SWT.RADIO);
Messages.setLanguageText(radioLater,"DonationWindow.options.later");
radioLater.setFont(mediumFont);
radioLater.setBackground(Colors.white);
formData = new FormData();
formData.top = new FormAttachment(radioNoDonate);
formData.left = new FormAttachment(0,140);
formData.right = new FormAttachment(100,-5);
radioLater.setLayoutData(formData);
radioAlready = new Button(shell,SWT.RADIO);
Messages.setLanguageText(radioAlready,"DonationWindow.options.already");
radioAlready.setFont(mediumFont);
radioAlready.setBackground(Colors.white);
formData = new FormData();
formData.top = new FormAttachment(radioLater);
formData.left = new FormAttachment(0,140);
formData.right = new FormAttachment(100,-5);
radioAlready.setLayoutData(formData);
final Text textForCopy = new Text(shell,SWT.BORDER);
textForCopy.setText(donationUrlShort);
textForCopy.setFont(smallFont);
formData = new FormData();
formData.bottom = new FormAttachment(100,-7);
formData.left = new FormAttachment(0,5);
formData.right = new FormAttachment(ok,-5);
textForCopy.setLayoutData(formData);
//By default, donate is selected (of course)
radioDonate.setSelection(true);
//allow OK from the start
ok.setEnabled(true);
ok.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
handleChoice();
}
});
Listener keyListener = new Listener() {
public void handleEvent(Event e) {
System.out.println(e.character);
if(e.character == SWT.ESC) {
if(ok.getEnabled()) close();
}
}
};
shell.addListener(SWT.KeyUp,keyListener);
textForCopy.addListener(SWT.KeyUp,keyListener);
shell.layout();
}
private void handleChoice() {
if(radioDonate.getSelection()) {
Utils.launch(donationUrl);
}
if(radioAlready.getSelection()) {
thanks();
stopAsking();
}
if(radioNoDonate.getSelection()){
stopAsking();
}
if(!radioDonate.getSelection()) {
close();
}
}
private void thanks() {
MessageBox msgThanks = new MessageBox(shell,SWT.OK);
msgThanks.setText(MessageText.getString("DonationWindow.thanks.title"));
msgThanks.setMessage(MessageText.getString("DonationWindow.thanks.text"));
msgThanks.open();
COConfigurationManager.setParameter("donations.donated",true);
COConfigurationManager.save();
}
private void stopAsking() {
COConfigurationManager.setParameter("donations.nextAskTime",-1);
COConfigurationManager.setParameter("donations.lastVersion",Constants.AZUREUS_VERSION);
COConfigurationManager.save();
}
public static void checkForDonationPopup() {
try{
class_mon.enter();
//Check if user has already donated first
boolean alreadyDonated = COConfigurationManager.getBooleanParameter("donations.donated",false);
if(alreadyDonated)
return;
//Check for last asked version
String lastVersionAsked = COConfigurationManager.getStringParameter("donations.lastVersion","");
long upTime = StatsFactory.getStats().getTotalUpTime();
int hours = (int) (upTime / (60*60)); //secs * mins
//Ask every DONATIONS_ASK_AFTER hours.
int nextAsk = (COConfigurationManager.getIntParameter("donations.nextAskTime",0) + 1) * DONATIONS_ASK_AFTER;
//if donations.nextAskTime == -1 , then no more ask for same version
if(nextAsk == 0) {
if(lastVersionAsked.equals(Constants.AZUREUS_VERSION)) {
return;
}
else {
//Set the re-ask so that we ask in the next %DONATIONS_ASK_AFTER hours
COConfigurationManager.setParameter("donations.nextAskTime",hours / DONATIONS_ASK_AFTER);
COConfigurationManager.save();
return;
}
}
//If we're still under the ask time, return
if(hours < nextAsk)
return;
//Here we've got to ask !!!
COConfigurationManager.setParameter("donations.nextAskTime",hours / DONATIONS_ASK_AFTER);
COConfigurationManager.save();
final Display display = SWTThread.getInstance().getDisplay();
if(display != null && !display.isDisposed()) {
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
if(display != null && !display.isDisposed())
new OldDonationWindow(display).show();
}
});
}
}finally{
class_mon.exit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -