import java.util.ArrayList;
import java.util.List;
+import org.apache.log4j.Logger;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+import org.springframework.security.core.GrantedAuthority;
+import eu.etaxonomy.cdm.config.ICdmSource;
import eu.etaxonomy.cdm.database.ICdmDataSource;
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
import eu.etaxonomy.taxeditor.model.ContextListenerAdapter;
*/
public class CdmDataSourceViewPart extends ViewPart{
+ private static final Logger logger = Logger.getLogger(CdmDataSourceViewPart.class);
+
private class ContextListener extends ContextListenerAdapter{
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.model.IContextListener#contextAboutToStop(org.eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
private class DataSourceJob extends Job{
- private List<ICdmDataSource> dataSources;
+ private List<ICdmSource> cdmSources;
/**
* @param name
*/
- public DataSourceJob(String title, List<ICdmDataSource> dataSources) {
+ public DataSourceJob(String title, List<ICdmSource> cdmSources) {
super(title);
- this.dataSources = dataSources;
+ this.cdmSources = cdmSources;
}
/* (non-Javadoc)
@Override
public IStatus run(final IProgressMonitor monitor) {
try{
- monitor.beginTask("Retrieving datasources", dataSources.size());
-
- List<ICdmDataSource> dataSources = CdmDataSourceRepository.getAll();
+ logger.debug("Begin of eclipse core runtime Job to Retrieve datasources");
+ monitor.beginTask("Retrieving datasources", cdmSources.size() + 1);
final List<CdmMetaDataAwareDataSourceContainer> containers = new ArrayList<CdmMetaDataAwareDataSourceContainer>();
- for(ICdmDataSource dataSource : dataSources){
- containers.add(new CdmMetaDataAwareDataSourceContainer(dataSource, CdmDataSourceViewPart.this));
- monitor.worked(1);
+ for(ICdmSource cdmSource : cdmSources){
+ containers.add(new CdmMetaDataAwareDataSourceContainer(cdmSource));
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
viewer.setInput(containers);
}
- });
-// viewer.setInput(containers);
+ });
+ monitor.worked(1);
+
+ for(final CdmMetaDataAwareDataSourceContainer container : containers){
+
+
+ if(logger.isDebugEnabled()) logger.debug(" #" + container.hashCode() + " : next DataSourceContainer");
+ container.getMetaDataFromDataSource();
+ if(logger.isDebugEnabled()) logger.debug(" #" + container.hashCode() + " : metadata retrieved, creating new runnable ...");
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if(logger.isDebugEnabled()) logger.debug(" #" + container.hashCode() + " starting sub thread to update ...");
+ viewer.update(container, null);
+ if(logger.isDebugEnabled()) logger.debug(" #" + container.hashCode() + " end of sub thread to update ...");
+ }
+ });
+ if(logger.isDebugEnabled()) logger.debug(" #" + container.hashCode() + " done");
+ monitor.worked(1);
+ }
}finally{
monitor.done();
* <p>refresh</p>
*/
public void refresh(){
- getService().schedule(new DataSourceJob("Loading datasources", CdmDataSourceRepository.getAll()), Job.SHORT);
+ getService().schedule(new DataSourceJob("Loading datasources", CdmDataSourceRepository.getAll()), Job.LONG);
}
/** {@inheritDoc} */