use of eu.esdihumboldt.hale.ui.io.action.IOWizardAction in project hale by halestudio.
the class ClassificationMappingParameterPage method createFromFileTabControl.
private Control createFromFileTabControl(Composite tabParent) {
// Parent composite for fromFileTab
Composite item2Content = new Composite(tabParent, SWT.NONE);
item2Content.setLayout(new GridLayout());
// Label to descripe what the user should do
Label l = new Label(item2Content, SWT.NONE);
l.setText("Select the project lookup table resource you want to use for the classification:");
// Get the Lookuptable Service
final LookupService lookupService = HaleUI.getServiceProvider().getService(LookupService.class);
// Composite for comboViewerComposite and Button
Composite parent = new Composite(item2Content, SWT.NONE);
parent.setLayout(new GridLayout(2, false));
parent.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
// Description Label
description = new Label(item2Content, SWT.WRAP);
description.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
description.setText("");
description.setVisible(false);
// label with warning message
Composite warnComp = new Composite(item2Content, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(warnComp);
GridDataFactory.fillDefaults().grab(true, false).applyTo(warnComp);
Label warnImage = new Label(warnComp, SWT.NONE);
warnImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(warnImage);
Label warn = new Label(warnComp, SWT.WRAP);
warn.setText("Classifications from a file resource will not function in another project where the alignment with the classification is imported or used as a base alignment.\n" + "If unsure, use the 'Explicit' mode instead and use the option to load the classification from a file.");
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false).hint(300, SWT.DEFAULT).applyTo(warn);
// Composite for ComboViewer
Composite viewerComposite = new Composite(parent, SWT.NONE);
viewerComposite.setLayout(new FillLayout());
GridData layoutData = new GridData(SWT.FILL, SWT.NONE, true, false);
viewerComposite.setLayoutData(GridDataFactory.copyData(layoutData));
// ComboViewer
lookupTableComboViewer = new ComboViewer(viewerComposite, SWT.READ_ONLY);
lookupTableComboViewer.setContentProvider(ArrayContentProvider.getInstance());
lookupTableComboViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof String) {
return lookupService.getTable((String) element).getName();
}
return null;
}
});
lookupTableComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// Show the description for the selected lookupTable
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
String desc = lookupService.getTable(selection.getFirstElement().toString()).getDescription();
if (desc != null) {
description.setText("Description: " + desc);
} else {
description.setText("");
}
if (!description.isVisible()) {
description.setVisible(true);
}
}
});
lookupTableComboViewer.setInput(lookupService.getTableIDs());
if (selectedLookupTableID != null) {
lookupTableComboViewer.setSelection(new StructuredSelection(selectedLookupTableID), true);
}
// Button to load a lookupTable if no one is loaded
final Button browseButton = new Button(parent, SWT.PUSH);
browseButton.setText("Add...");
browseButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
IOWizardAction action = new IOWizardAction("eu.esdihumboldt.hale.lookup.import");
action.run();
action.dispose();
// Refresh the viewer
lookupTableComboViewer.setInput(lookupService.getTableIDs());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// nothing to do here
}
});
return item2Content;
}
use of eu.esdihumboldt.hale.ui.io.action.IOWizardAction in project hale by halestudio.
the class ImportAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
if (Display.getCurrent() == null) {
// execute in display thread
PlatformUI.getWorkbench().getDisplay().asyncExec(this);
return;
}
if (actionId == null)
return;
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
IOWizardAction action = new IOWizardAction(actionId);
if (action.isEnabled()) {
action.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (IAction.RESULT.equals(event.getProperty()))
notifyResult((Boolean) event.getNewValue());
}
});
action.run();
} else {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Action disabled", action.getFactory().getDisabledReason());
notifyResult(false);
}
action.dispose();
}
Aggregations