use of eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesLabelProvider in project hale by halestudio.
the class ResourcesView method createViewControl.
@Override
protected void createViewControl(Composite parent) {
viewer = new TreeViewer(parent);
viewer.setContentProvider(new ResourcesContentProvider());
viewer.setLabelProvider(new ResourcesLabelProvider());
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
ps.addListener(projectServiceListener = new ProjectServiceAdapter() {
@Override
public void resourceAdded(String actionId, Resource resource) {
updateInDisplayThread();
}
@Override
public void resourcesRemoved(String actionId, List<Resource> resources) {
updateInDisplayThread();
}
@Override
public void afterLoad(ProjectService projectService) {
updateInDisplayThread();
}
@Override
public void projectInfoChanged(ProjectInfo info) {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
viewer.update(ProjectToken.TOKEN, null);
updateInDisplayThread();
}
});
}
});
viewer.setUseHashlookup(true);
viewer.setAutoExpandLevel(3);
update();
new ViewerMenu(getSite(), viewer);
getSite().setSelectionProvider(viewer);
// adding listener to refresh the resource view when any schema,
// instance is added or cleared.
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
ssListener = new SchemaServiceListener() {
@Override
public void schemaRemoved(SchemaSpaceID spaceID) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
@Override
public void schemasCleared(final SchemaSpaceID spaceID) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
@Override
public void schemaAdded(final SchemaSpaceID spaceID, Schema schema) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
@Override
public void mappableTypesChanged(final SchemaSpaceID spaceID, Collection<? extends TypeDefinition> types) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
};
ss.addSchemaServiceListener(ssListener);
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
is.addListener(isa = new InstanceServiceAdapter() {
@Override
public void datasetChanged(DataSet type) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
});
}
Aggregations