use of eu.esdihumboldt.hale.ui.function.FunctionWizard in project hale by halestudio.
the class AbstractWizardAction method run.
/**
* @see Action#run()
*/
@Override
public void run() {
FunctionWizard wizard = createWizard();
if (wizard != null) {
// initialize the wizard
wizard.init();
HaleWizardDialog dialog = new HaleWizardDialog(Display.getCurrent().getActiveShell(), wizard);
if (dialog.open() == WizardDialog.OK) {
MutableCell cell = wizard.getResult();
handleResult(cell);
}
}
}
use of eu.esdihumboldt.hale.ui.function.FunctionWizard in project hale by halestudio.
the class FunctionWizardNode method createWizard.
/**
* @see AbstractWizardNode#createWizard()
*/
@Override
protected FunctionWizard createWizard() {
FunctionWizard result = null;
List<FunctionWizardDescriptor<?>> factories = FunctionWizardExtension.getInstance().getFactories(new FactoryFilter<FunctionWizardFactory, FunctionWizardDescriptor<?>>() {
@Override
public boolean acceptFactory(FunctionWizardDescriptor<?> factory) {
return factory.getFunctionId().equals(function.getId());
}
@Override
public boolean acceptCollection(ExtensionObjectFactoryCollection<FunctionWizardFactory, FunctionWizardDescriptor<?>> collection) {
return true;
}
});
if (!factories.isEmpty()) {
// create registered wizard
FunctionWizardDescriptor<?> fwd = factories.get(0);
result = fwd.createNewWizard(initialSelection);
}
if (result == null) {
// create generic wizard
if (function instanceof TypeFunction) {
result = new GenericTypeFunctionWizard(initialSelection, function.getId());
} else {
result = new GenericPropertyFunctionWizard(initialSelection, function.getId());
}
}
// initialize wizard
result.init();
return result;
}
use of eu.esdihumboldt.hale.ui.function.FunctionWizard in project hale by halestudio.
the class EditRelationHandler method execute.
/**
* @see IHandler#execute(ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
Object selected = ((IStructuredSelection) selection).getFirstElement();
if (selected instanceof Cell) {
final Cell originalCell = (Cell) selected;
FunctionWizard wizard = null;
List<FunctionWizardDescriptor<?>> factories = FunctionWizardExtension.getInstance().getFactories(new FactoryFilter<FunctionWizardFactory, FunctionWizardDescriptor<?>>() {
@Override
public boolean acceptFactory(FunctionWizardDescriptor<?> factory) {
return factory.getFunctionId().equals(originalCell.getTransformationIdentifier());
}
@Override
public boolean acceptCollection(ExtensionObjectFactoryCollection<FunctionWizardFactory, FunctionWizardDescriptor<?>> collection) {
return true;
}
});
if (!factories.isEmpty()) {
// create registered wizard
FunctionWizardDescriptor<?> fwd = factories.get(0);
wizard = fwd.createEditWizard(originalCell);
}
if (wizard == null) {
FunctionDefinition<?> function = FunctionUtil.getFunction(originalCell.getTransformationIdentifier(), HaleUI.getServiceProvider());
if (function == null) {
log.userError(MessageFormat.format("Function with identifier ''{0}'' is unknown.", originalCell.getTransformationIdentifier()));
return null;
}
// create generic wizard
if (function instanceof TypeFunction) {
wizard = new GenericTypeFunctionWizard(originalCell);
} else {
wizard = new GenericPropertyFunctionWizard(originalCell);
}
}
// initialize wizard
wizard.init();
HaleWizardDialog dialog = new HaleWizardDialog(HandlerUtil.getActiveShell(event), wizard);
if (dialog.open() == WizardDialog.OK) {
MutableCell cell = wizard.getResult();
AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
// remove the original cell
// and add the new cell
alignmentService.replaceCell(originalCell, cell);
}
}
}
return null;
}
use of eu.esdihumboldt.hale.ui.function.FunctionWizard 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;
}
Aggregations