use of eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog in project hale by halestudio.
the class NewRelationPage method createViewer.
/**
* @see ViewerWizardSelectionPage#createViewer(Composite)
*/
@Override
protected Pair<StructuredViewer, Control> createViewer(Composite parent) {
PatternFilter filter = new PatternFilter();
filter.setIncludeLeadingWildcard(true);
FilteredTree tree = new FilteredTree(parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
viewer = tree.getViewer();
viewer.setContentProvider(new FunctionWizardNodeContentProvider(getContainer(), initialSelection, selectionMatcher));
viewer.setLabelProvider(new FunctionWizardNodeLabelProvider());
// no input needed, but we have to set something
viewer.setInput(Boolean.TRUE);
// set focus on viewer control to prevent odd behavior
viewer.getControl().setFocus();
// expand selection
viewer.expandAll();
// selection context
contextProvider = new HALEContextProvider(viewer, null);
// help update on page shown
if (getContainer() instanceof IPageChangeProvider) {
((IPageChangeProvider) getContainer()).addPageChangedListener(changeListener = new IPageChangedListener() {
@Override
public void pageChanged(PageChangedEvent event) {
if (event.getSelectedPage() == NewRelationPage.this) {
// update the help button
if (getContainer() instanceof HaleWizardDialog) {
((HaleWizardDialog) getContainer()).setHelpButtonEnabled(getHelpContext() != null);
}
}
}
});
}
// help update on selection change
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IContext context = getHelpContext();
// update the help button
if (getContainer() instanceof HaleWizardDialog) {
((HaleWizardDialog) getContainer()).setHelpButtonEnabled(context != null);
}
// update the help
if (context != null) {
TrayDialog trayDialog = (TrayDialog) getContainer();
if (trayDialog.getTray() != null) {
// if the tray is already open, update the help
performHelp();
}
}
}
});
// load page configuration
// XXX would be better if called from outside
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
restore(ps.getConfigurationService());
return new Pair<StructuredViewer, Control>(viewer, tree);
}
use of eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog in project hale by halestudio.
the class IOWizardAction method run.
/**
* @see Action#run()
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void run() {
try {
// retrieve action ID
final String actionId = getFactory().getActionID();
// find associated advisor
IOAdvisor<?> advisor = IOAdvisorExtension.getInstance().findAdvisor(actionId, HaleUI.getServiceProvider());
checkState(advisor != null, "No advisor for action found");
// create wizard
IOWizard<?> wizard = getFactory().createExtensionObject();
// set advisor and action ID
((IOWizard) wizard).setAdvisor(advisor, actionId);
Shell shell = Display.getCurrent().getActiveShell();
HaleWizardDialog dialog = new HaleWizardDialog(shell, wizard);
notifyResult(dialog.open() == Window.OK);
} catch (Exception e) {
log.error("Could not launch I/O wizard for advisor " + getFactory().getIdentifier(), e);
}
}
use of eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog in project hale by halestudio.
the class SchemaUpdateComponent method updateSelectedSchema.
/**
*/
protected void updateSelectedSchema() {
ISelection sel = tableViewer.getSelection();
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
final IOConfiguration selected = (IOConfiguration) ((IStructuredSelection) sel).getFirstElement();
SchemaImportWizard wizard = new SchemaImportWizard() {
@Override
public boolean performFinish() {
if (!applyConfiguration()) {
return false;
}
IOConfiguration configuration = new IOConfiguration();
configuration.setActionId(getActionId());
configuration.setProviderId(getProviderFactory().getIdentifier());
getProvider().storeConfiguration(configuration.getProviderConfiguration());
// replace the previously selected I/O configuration
int index = configurations.indexOf(selected);
configurations.set(index, configuration);
// refresh table viewer to reflect the changes
tableViewer.refresh(true);
return true;
}
};
// configure advisor
// FIXME
SchemaImportAdvisor advisor = new SchemaImportAdvisor(SchemaSpaceID.TARGET);
advisor.setServiceProvider(HaleUI.getServiceProvider());
advisor.setActionId(SchemaIO.ACTION_LOAD_TARGET_SCHEMA);
wizard.setAdvisor(advisor, actionId);
// open wizard
Shell shell = Display.getCurrent().getActiveShell();
HaleWizardDialog dialog = new HaleWizardDialog(shell, wizard);
dialog.open();
}
}
use of eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog in project hale by halestudio.
the class TransformDataWizardSourcePage method createControl.
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
Composite content = new Composite(parent, SWT.NONE);
content.setLayout(GridLayoutFactory.swtDefaults().create());
final ListViewer listViewer = new ListViewer(content);
listViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
if (!useProjectData) {
Button addButton = new Button(content, SWT.PUSH);
addButton.setText("Add source file");
addButton.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).create());
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
InstanceImportWizard importWizard = new InstanceImportWizard();
TransformDataImportAdvisor advisor = new TransformDataImportAdvisor();
// specifying null as actionId results in no call to
// ProjectService.rememberIO
importWizard.setAdvisor(advisor, null);
if (new HaleWizardDialog(getShell(), importWizard).open() == Dialog.OK) {
if (advisor.getInstances() != null) {
sourceCollections.add(advisor.getInstances());
listViewer.add(advisor.getLocation());
getContainer().updateButtons();
}
}
}
});
} else {
// initialize project source data
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Prepare data sources", IProgressMonitor.UNKNOWN);
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
final List<URI> locations = new ArrayList<>();
for (Resource resource : ps.getResources()) {
if (InstanceIO.ACTION_LOAD_SOURCE_DATA.equals(resource.getActionId())) {
// resource is source data
IOConfiguration conf = resource.copyConfiguration(true);
TransformDataImportAdvisor advisor = new TransformDataImportAdvisor();
ProjectResourcesUtil.executeConfiguration(conf, advisor, false, null);
if (advisor.getInstances() != null) {
sourceCollections.add(advisor.getInstances());
locations.add(advisor.getLocation());
}
}
}
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
for (URI location : locations) {
listViewer.add(location);
}
}
});
monitor.done();
}
};
try {
ThreadProgressMonitor.runWithProgressDialog(op, false);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
setControl(content);
}
use of eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog in project hale by halestudio.
the class FunctionWizardUtil method addRelationForTarget.
/**
* Launches a wizard for mapping to a specific target entity.
*
* @param target the target entity
* @param source the source entities the target should be mapped from, or
* <code>null</code>
* @return the created cell or <code>null</code>
*/
public static Cell addRelationForTarget(EntityDefinition target, Iterable<EntityDefinition> source) {
DefaultSchemaSelection initialSelection = new DefaultSchemaSelection();
initialSelection.addTargetItem(target);
if (source != null) {
for (EntityDefinition sourceEntity : source) {
initialSelection.addSourceItem(sourceEntity);
}
}
SchemaSelectionFunctionMatcher selectionMatcher;
if (source == null) {
// ignore source
selectionMatcher = new SchemaSelectionFunctionMatcher(true, false);
} else {
// respect source
selectionMatcher = new SchemaSelectionFunctionMatcher(false, false);
}
NewRelationWizard wizard = new NewRelationWizard(initialSelection, selectionMatcher);
wizard.setWindowTitle("Map to " + target.getDefinition().getDisplayName());
Shell shell = Display.getCurrent().getActiveShell();
HaleWizardDialog dialog = new HaleWizardDialog(shell, wizard);
if (dialog.open() == Window.OK) {
return wizard.getCreatedCell();
} else {
return null;
}
}
Aggregations