import org.eclipse.ui.internal.Workbench;
import org.springframework.remoting.RemoteAccessException;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IContextListener;
import eu.etaxonomy.taxeditor.model.MementoHelper;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
*
* @author n.hoffmann
* @created Sep 30, 2010
- * @version 1.0
*/
public class ContextManager implements IWorkbenchListener{
- private final ListenerList contextListeners = new ListenerList();
+ private final ListenerList<IContextListener> contextListeners = new ListenerList<>();
private IMemento memento;
}
}
- /**
- * <p>addContextListener</p>
- *
- * @param listener a {@link eu.etaxonomy.taxeditor.model.IContextListener} object.
- */
public void addContextListener(IContextListener listener){
contextListeners.add(listener);
}
- /**
- * <p>removeContextListener</p>
- *
- * @param listener a {@link eu.etaxonomy.taxeditor.model.IContextListener} object.
- */
public void removeContextListener(IContextListener listener) {
contextListeners.remove(listener);
}
((IContextListener) listener).contextStart(memento, monitor);
}
}
- /**
- * <p>notifyContextStart</p>
- * @throws Throwable
- */
+
public void notifyContextStart() throws RemoteAccessException {
MessagingUtils.info("Notifying context listeners, that the context has started.");
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(StoreUtil.getShell());
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(AbstractUtility.getShell());
try {
dialog.run(false, false, new IRunnableWithProgress() {
- /* (non-Javadoc)
- * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
- */
+
@Override
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
}
}
-
- /**
- *
- */
public void notifyContextRefresh() {
MessagingUtils.info("Notifying context listeners, that the context needs to be refreshed.");
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(StoreUtil.getShell());
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(AbstractUtility.getShell());
try {
dialog.run(false, false, new IRunnableWithProgress() {
- /* (non-Javadoc)
- * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
- */
+
@Override
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
}
}
- /**
- * <p>notifyContextAboutToStop</p>
- *
- * @param monitor a {@link org.eclipse.core.runtime.IProgressMonitor} object.
- */
public void notifyContextAboutToStop(final IProgressMonitor monitor){
- IProgressMonitor subMonitor = StoreUtil.getSubProgressMonitor(monitor, 1);
+ IProgressMonitor subMonitor = AbstractUtility.getSubProgressMonitor(monitor, 1);
subMonitor.beginTask("Stoping context", contextListeners.size());
// we are creating the memento here; even if the context is not stopped
subMonitor.done();
}
- /**
- * <p>notifyContextStop</p>
- *
- * @param monitor a {@link org.eclipse.core.runtime.IProgressMonitor} object.
- */
public void notifyContextStop(IProgressMonitor monitor) {
- IProgressMonitor subMonitor = StoreUtil.getSubProgressMonitor(monitor, 1);
+ IProgressMonitor subMonitor = AbstractUtility.getSubProgressMonitor(monitor, 1);
subMonitor.beginTask("Stoping context", contextListeners.size());
MessagingUtils.info("Notifying context listeners, that the context has stopped.");
subMonitor.done();
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchListener#preShutdown(org.eclipse.ui.IWorkbench, boolean)
- */
- /** {@inheritDoc} */
@Override
public boolean preShutdown(IWorkbench workbench, boolean forced) {
return true;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchListener#postShutdown(org.eclipse.ui.IWorkbench)
- */
- /** {@inheritDoc} */
@Override
public void postShutdown(IWorkbench workbench) {
-
-
}
-
private void readMemento(){
try {
memento = MementoHelper.readMementoFromFile(getStateFileForCurrentDatabase());
} else {
MessagingUtils.info("Not storing state data, because no DataSource present.");
}
-
}
private boolean saveMemento(){
return MementoHelper.saveMementoToFile(memento, getStateFileForCurrentDatabase()) != null;
}
- /**
- * <p>getStateFileForCurrentDatabase</p>
- *
- * @return a {@link java.io.File} object.
- */
protected File getStateFileForCurrentDatabase() {
if(CdmStore.getActiveCdmSource() == null){
return null;
path = path.append("editor_state_" + CdmStore.getActiveCdmSource().getName() + ".xml");
return path.toFile();
}
-
}