/**
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
// TODO change to RunnableWithProgress and add cancel Button
IProgressService service = window.getWorkbench().getProgressService();
// Now build the search index
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
try {
URL url = new URL(store.getString(PreferenceConstants.P_CARDLIST_URL));
StandardTournament factory = new StandardTournament();
monitor.beginTask("Updating...", 2);
String[] restrictedCards = StringUtils.parseToStringArray( store.getString(PreferenceConstants.P_RESTRICTED_CARDS));
factory.read(url, store.getString(PreferenceConstants.P_REGEX_CARD), restrictedCards );
monitor.worked(1);
factory.save();
monitor.worked(1);
} catch (MalformedURLException e) {
MessageDialog.openInformation(
window.getShell(),
"FactOrFiction Tournament Format Plug-in",
"Could not open '" + store.getString(PreferenceConstants.P_CARDLIST_URL) + "'.");
} catch (IOException e) {
MessageDialog.openInformation(
window.getShell(),
"FactOrFiction Tournament Format Plug-in",
"Error reading from '" + store.getString(PreferenceConstants.P_CARDLIST_URL) + "'.");
}
};
};
try {
service.busyCursorWhile(runnable);
} catch (InvocationTargetException e) {
e.getMessage();
return;
} catch (InterruptedException e) {
return;
}
// and now the cardpool has to be re-read!
IRunnableWithProgress runnableCardPool = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
CardPool.instance().initFromPlugins(monitor, true);
}
};
try {
service.run(false, false, runnableCardPool);
} catch (InvocationTargetException e) {
e.getMessage();
} catch (InterruptedException e) {
e.getMessage();
}