📄 updatewindow.java
字号:
item.setText(2, DisplayFormatters.formatByteCountToBase10KBEtc(totalLength));
item.setChecked(true);
if (table.getItemCount() == 1)
{
table.select(0);
rowSelected();
}
checkRestartNeeded();
if (COConfigurationManager.getBooleanParameter("update.opendialog") || check_instance.getType() != 2)
{
show();
} else
{
UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (functionsSWT != null)
{
MainStatusBar mainStatusBar = functionsSWT.getMainStatusBar();
if (mainStatusBar != null)
mainStatusBar.setUpdateNeeded(UpdateWindow.this);
}
}
}
{
this$0 = UpdateWindow.this;
update = update1;
super();
}
});
}
protected void updateAdditionComplete()
{
if (display == null || display.isDisposed())
{
return;
} else
{
display.asyncExec(new AERunnable() {
final UpdateWindow this$0;
public void runSupport()
{
if (btnOk == null || btnOk.isDisposed())
{
return;
} else
{
btnOk.setEnabled(true);
return;
}
}
{
this$0 = UpdateWindow.this;
super();
}
});
return;
}
}
public void show()
{
if (updateWindow == null || updateWindow.isDisposed())
{
return;
} else
{
Utils.centreWindow(updateWindow);
updateWindow.open();
updateWindow.forceActive();
return;
}
}
private void checkMandatory()
{
TableItem items[] = table.getItems();
for (int i = 0; i < items.length; i++)
{
Update update = (Update)items[i].getData();
if (update.isMandatory())
items[i].setChecked(true);
}
}
private void checkRestartNeeded()
{
restartRequired = false;
boolean restartMaybeRequired = false;
TableItem items[] = table.getItems();
for (int i = 0; i < items.length; i++)
{
if (!items[i].getChecked())
continue;
Update update = (Update)items[i].getData();
int required = update.getRestartRequired();
if (required == 3)
{
restartMaybeRequired = true;
continue;
}
if (required == 2)
restartRequired = true;
}
if (restartRequired)
status.setText(MessageText.getString("UpdateWindow.status.restartNeeded"));
else
if (restartMaybeRequired)
status.setText(MessageText.getString("UpdateWindow.status.restartMaybeNeeded"));
else
status.setText("");
}
private void update()
{
btnOk.setEnabled(false);
Messages.setLanguageText(btnCancel, "UpdateWindow.cancel");
table.setEnabled(false);
link_area.reset();
if (browser != null)
browser.setVisible(false);
link_area.getComponent().setVisible(true);
TableItem items[] = table.getItems();
totalDownloadSize = 0L;
downloaders = new ArrayList();
for (int i = 0; i < items.length; i++)
{
if (!items[i].getChecked())
continue;
Update update = (Update)items[i].getData();
ResourceDownloader rds[] = update.getDownloaders();
for (int j = 0; j < rds.length; j++)
{
downloaders.add(rds[j]);
try
{
totalDownloadSize += rds[j].getSize();
}
catch (Exception e)
{
link_area.addLine((new StringBuilder()).append(MessageText.getString("UpdateWindow.no_size")).append(rds[j].getName()).toString());
}
}
}
downloadersToData = new HashMap();
iterDownloaders = downloaders.iterator();
nextUpdate();
}
private void nextUpdate()
{
if (iterDownloaders.hasNext())
{
ResourceDownloader downloader = (ResourceDownloader)iterDownloaders.next();
downloader.addListener(this);
downloader.asyncDownload();
} else
{
switchToRestart();
}
}
private void switchToRestart()
{
if (display == null || display.isDisposed())
{
return;
} else
{
display.asyncExec(new AERunnable() {
final UpdateWindow this$0;
public void runSupport()
{
checkRestartNeeded();
progress.setSelection(100);
status.setText(MessageText.getString("UpdateWindow.status.done"));
btnOk.removeListener(13, lOk);
btnOk.setEnabled(true);
btnOk.addListener(13, new Listener() {
final 11 this$1;
public void handleEvent(Event e)
{
finishUpdate(true);
}
{
this$1 = 11.this;
super();
}
});
if (restartRequired)
{
Messages.setLanguageText(btnOk, "UpdateWindow.restart");
btnCancel.removeListener(13, lCancel);
Messages.setLanguageText(btnCancel, "UpdateWindow.restartLater");
btnCancel.addListener(13, new Listener() {
final 11 this$1;
public void handleEvent(Event e)
{
finishUpdate(false);
}
{
this$1 = 11.this;
super();
}
});
updateWindow.layout();
} else
{
Messages.setLanguageText(btnOk, "UpdateWindow.close");
btnCancel.setEnabled(false);
updateWindow.layout();
}
}
{
this$0 = UpdateWindow.this;
super();
}
});
return;
}
}
public void reportPercentComplete(ResourceDownloader downloader, int percentage)
{
setProgressSelection(percentage);
}
public void reportAmountComplete(ResourceDownloader resourcedownloader, long l)
{
}
private void setProgressSelection(final int percent)
{
if (display == null || display.isDisposed())
{
return;
} else
{
display.asyncExec(new AERunnable() {
final int val$percent;
final UpdateWindow this$0;
public void runSupport()
{
if (progress != null && !progress.isDisposed())
progress.setSelection(percent);
}
{
this$0 = UpdateWindow.this;
percent = i;
super();
}
});
return;
}
}
public boolean completed(ResourceDownloader downloader, InputStream data)
{
downloadersToData.put(downloader, data);
downloader.removeListener(this);
setProgressSelection(0);
nextUpdate();
return true;
}
public void failed(ResourceDownloader downloader, ResourceDownloaderException e)
{
downloader.removeListener(this);
setStatusText(MessageText.getString("UpdateWindow.status.failed"));
String msg = (new StringBuilder()).append(downloader.getName()).append(" : ").append(e).toString();
if (e.getCause() != null)
msg = (new StringBuilder()).append(msg).append(" [").append(e.getCause()).append("]").toString();
appendDetails(msg);
}
public void reportActivity(ResourceDownloader downloader, String activity)
{
setStatusText(activity.trim());
appendDetails(activity);
}
private void setStatusText(final String text)
{
if (display == null || display.isDisposed())
{
return;
} else
{
display.asyncExec(new AERunnable() {
final String val$text;
final UpdateWindow this$0;
public void runSupport()
{
if (status != null && !status.isDisposed())
status.setText(text);
}
{
this$0 = UpdateWindow.this;
text = s;
super();
}
});
return;
}
}
private void appendDetails(final String text)
{
if (display == null || display.isDisposed())
{
return;
} else
{
display.asyncExec(new AERunnable() {
final String val$text;
final UpdateWindow this$0;
public void runSupport()
{
link_area.addLine(text);
}
{
this$0 = UpdateWindow.this;
text = s;
super();
}
});
return;
}
}
private void finishUpdate(boolean restartNow)
{
UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (functionsSWT != null)
{
MainStatusBar mainStatusBar = functionsSWT.getMainStatusBar();
if (mainStatusBar != null)
mainStatusBar.setUpdateNeeded(null);
}
boolean bDisposeUpdateWindow = true;
if (restartRequired && restartNow)
{
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null && uiFunctions.dispose(true, false))
bDisposeUpdateWindow = false;
} else
if (hasMandatoryUpdates && !restartRequired)
update_monitor.requestRecheck();
if (bDisposeUpdateWindow)
updateWindow.dispose();
}
protected boolean isDisposed()
{
return display == null || display.isDisposed() || updateWindow == null || updateWindow.isDisposed();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -