use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class NewRelationWizard method performFinish.
/**
* @see MultiWizard#performFinish()
*/
@Override
public boolean performFinish() {
// performFinish of the function wizard was called first
FunctionWizard functionWizard = getSelectionPage().getFunctionWizard();
if (functionWizard == null) {
return false;
}
MutableCell cell = functionWizard.getResult();
if (cell != null) {
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
as.addCell(cell);
}
createdCell = cell;
// save page configuration
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
getSelectionPage().store(ps.getConfigurationService());
return true;
}
use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class RemoveResourceHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof Resource) {
Resource resource = (Resource) element;
// retrieve action UI advisor
ActionUI actionUI = ActionUIExtension.getInstance().findActionUI(resource.getActionId());
if (actionUI != null) {
IOAction action = IOActionExtension.getInstance().get(resource.getActionId());
ActionUIAdvisor<?> advisor = actionUI.getUIAdvisor();
if (advisor != null && advisor.supportsRemoval()) {
String name = null;
if (resource.getSource() != null) {
String location = resource.getSource().toString();
int index = location.lastIndexOf('/');
if (index > 0 && index < location.length()) {
name = location.substring(index + 1);
}
}
String resourceType = null;
if (action != null) {
resourceType = action.getResourceName();
}
if (resourceType == null) {
resourceType = "resource";
}
String message;
if (name == null) {
message = MessageFormat.format("Do you really want to remove this {0}?", resourceType);
} else {
message = MessageFormat.format("Do you really want to remove the {0} {1}?", resourceType, name);
}
if (MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Remove resource", message)) {
// do the actual removal
String id = resource.getResourceId();
if (advisor.removeResource(id)) {
// removal succeeded, so remove from project as
// well
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
ps.removeResource(id);
}
}
} else {
log.userError("Removing this resource is not supported.");
}
}
}
}
return null;
}
use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class AlignmentImportAdvisor method prepareProvider.
/**
* @see AbstractIOAdvisor#prepareProvider(IOProvider)
*/
@Override
public void prepareProvider(AlignmentReader provider) {
super.prepareProvider(provider);
SchemaService ss = getService(SchemaService.class);
provider.setSourceSchema(ss.getSchemas(SchemaSpaceID.SOURCE));
provider.setTargetSchema(ss.getSchemas(SchemaSpaceID.TARGET));
ProjectService ps = getService(ProjectService.class);
// XXX uses the same path updater as the project
// If someone edited the project file and referenced an alignment file,
// which isn't in the project directory this won't work.
provider.setPathUpdater(ps.getLocationUpdater());
}
use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class BaseAlignmentImportAdvisor method prepareProvider.
/**
* @see eu.esdihumboldt.hale.common.core.io.impl.DefaultIOAdvisor#prepareProvider(eu.esdihumboldt.hale.common.core.io.IOProvider)
*/
@Override
public void prepareProvider(BaseAlignmentReader provider) {
super.prepareProvider(provider);
// XXX reader still needs MutableAlignment!
SchemaService ss = getService(SchemaService.class);
provider.setSourceSchema(ss.getSchemas(SchemaSpaceID.SOURCE));
provider.setTargetSchema(ss.getSchemas(SchemaSpaceID.TARGET));
ProjectService ps = getService(ProjectService.class);
provider.setProjectLocation(ps.getLoadLocation());
}
use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.
the class SaveConfigurationInstanceExportPage method update.
/**
* Update the page state.
*/
protected void update() {
if (fileFormats.getSelection().isEmpty()) {
setErrorMessage("Please select a format");
setPageComplete(false);
return;
}
String confName = name.getText();
if (confName == null || confName.isEmpty()) {
setErrorMessage("Please provide a name for the preset to easily identify it");
setPageComplete(false);
return;
}
setErrorMessage(null);
// configuration with that name already present?
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
IOConfiguration conf = ps.getExportConfiguration(confName);
if (conf == null) {
setMessage(null);
} else {
setMessage("Overrides an existing configuration with the same name", DialogPage.WARNING);
}
setPageComplete(true);
}
Aggregations