Eclipseplugins
DoRefreshCacheHandler.java
1 package com.proalpha.pds.ui.handlers;
2 
3 import java.lang.reflect.InvocationTargetException;
4 
5 import org.eclipse.core.commands.ExecutionEvent;
6 import org.eclipse.core.commands.ExecutionException;
7 import org.eclipse.core.resources.ResourcesPlugin;
8 import org.eclipse.core.runtime.jobs.ISchedulingRule;
9 import org.eclipse.jface.operation.IRunnableContext;
10 import org.eclipse.jface.operation.IRunnableWithProgress;
11 import org.eclipse.ui.PlatformUI;
12 
13 import com.proalpha.pds.exception.ProALPHANotAvailableException;
14 import com.proalpha.pds.paconnector.Activator;
15 import com.proalpha.pds.paconnector.PaProject;
16 import com.proalpha.pds.paconnector.utils.ExceptionUtils;
17 import com.proalpha.pds.ui.AbstractProAlphaHandler;
18 
20 
21  @Override
22  public Object execute(ExecutionEvent event) throws ExecutionException {
23 
24  PaProject paProject;
25  try {
26  paProject = getPaProjectOfEvent(event);
27  runProgram(paProject);
28  } catch (ProALPHANotAvailableException e) {
30  }
31 
32  return null;
33  }
34 
35  private static void runProgram(PaProject paProject) {
36  IRunnableWithProgress runnable = monitor -> {
37  monitor.beginTask("Refresh Cache", 2);
38  monitor.worked(1);
39  paProject.getBridge().refreshChache();
40  monitor.done();
41  };
42 
43  ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
44  IRunnableContext context = PlatformUI.getWorkbench().getProgressService();
45 
46  try {
47  PlatformUI.getWorkbench().getProgressService().runInUI(context, runnable, rule);
48  } catch (InvocationTargetException e) {
50  } catch (InterruptedException e) {
52  Thread.currentThread().interrupt();
53  }
54  }
55 }
static void showAndLogErrorMessage(AbstractUIPlugin plugin, Throwable exception)
PaProject getPaProjectOfEvent(ExecutionEvent event)