use of org.eclipse.jface.viewers.ISelectionChangedListener in project hale by halestudio.
the class AbstractSelectionProvider method fireSelectionChange.
/**
* Fires a selection change and sets the last selection to the given
* selection.
*
* @param newSelection the new selection
*/
protected void fireSelectionChange(ISelection newSelection) {
this.lastSelection = newSelection;
SelectionChangedEvent event = new SelectionChangedEvent(this, newSelection);
for (ISelectionChangedListener listener : listeners) {
listener.selectionChanged(event);
}
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project hale by halestudio.
the class ViewerWizardSelectionPage method createControl.
/**
* @see IDialogPage#createControl(Composite)
*/
@Override
public void createControl(Composite parent) {
Font font = parent.getFont();
// create composite for page.
Composite outerContainer = new Composite(parent, SWT.NONE);
outerContainer.setLayout(new GridLayout());
outerContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
outerContainer.setFont(font);
Pair<StructuredViewer, Control> viewerControl = createViewer(outerContainer);
viewer = viewerControl.getFirst();
viewerControl.getSecond().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, getViewerHeightHint()).create());
// wire viewer
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
viewerSelectionChanged(event.getSelection());
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
doubleClicked(event);
}
});
Dialog.applyDialogFont(outerContainer);
// apply the initial selection
viewerSelectionChanged(viewer.getSelection());
setControl(outerContainer);
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project hale by halestudio.
the class AlignmentView method createViewControl.
/**
* @see eu.esdihumboldt.hale.ui.views.mapping.AbstractMappingView#createViewControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createViewControl(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
page.setLayout(GridLayoutFactory.fillDefaults().create());
// create type relation selection control
sourceTargetSelector = new SourceTargetTypeSelector(page);
sourceTargetSelector.getControl().setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());
sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
getViewer().setInput(sourceTargetSelector.getSelectedCell());
if (deactivatedCellFilterAction != null) {
deactivatedCellFilterAction.setEnabled(sourceTargetSelector.isCellSelected());
if (!sourceTargetSelector.isCellSelected())
deactivatedCellFilterAction.setChecked(true);
}
refreshGraph();
}
});
// typeRelations = new ComboViewer(page, SWT.DROP_DOWN | SWT.READ_ONLY);
// typeRelations.setContentProvider(ArrayContentProvider.getInstance());
// typeRelations.setLabelProvider(new LabelProvider() {
//
// @Override
// public Image getImage(Object element) {
// if (element instanceof Cell) {
// // use function image if possible
// Cell cell = (Cell) element;
// String functionId = cell.getTransformationIdentifier();
// AbstractFunction<?> function = FunctionUtil.getFunction(functionId);
// if (function != null) {
// return functionLabels.getImage(function);
// }
// return null;
// }
//
// return super.getImage(element);
// }
//
// @Override
// public String getText(Object element) {
// if (element instanceof Cell) {
// Cell cell = (Cell) element;
//
// return CellUtil.getCellDescription(cell);
// }
//
// return super.getText(element);
// }
//
// });
// typeRelations.addSelectionChangedListener(new ISelectionChangedListener() {
//
// @Override
// public void selectionChanged(SelectionChangedEvent event) {
// updateGraph();
// }
// });
// typeRelations.getControl().setLayoutData(
// GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
// .create());
// create viewer
Composite viewerContainer = new Composite(page, SWT.NONE);
viewerContainer.setLayout(new FillLayout());
viewerContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
super.createViewControl(viewerContainer);
updateLayout(false);
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
// update();
as.addListener(alignmentListener = new AlignmentServiceAdapter() {
@Override
public void alignmentCleared() {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
}
});
}
@Override
public void cellsRemoved(Iterable<Cell> cells) {
if (sourceTargetSelector.isCellSelected() && Iterables.contains(cells, sourceTargetSelector.getSelectedCell()))
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
refreshGraph();
}
@Override
public void cellsReplaced(Map<? extends Cell, ? extends Cell> cells) {
if (sourceTargetSelector.isCellSelected() && cells.keySet().contains(sourceTargetSelector.getSelectedCell()))
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
refreshGraph();
}
@Override
public void cellsAdded(Iterable<Cell> cells) {
refreshGraph();
}
@Override
public void alignmentChanged() {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
}
});
}
@Override
public void cellsPropertyChanged(Iterable<Cell> cells, String propertyName) {
refreshGraph();
}
@Override
public void customFunctionsChanged() {
refreshGraph();
}
});
TaskService taskService = PlatformUI.getWorkbench().getService(TaskService.class);
taskService.addListener(tasksListener = new TaskServiceListener() {
@Override
public void tasksRemoved(Iterable<Task<?>> tasks) {
refreshGraph();
}
@Override
public void tasksAdded(Iterable<Task<?>> tasks) {
refreshGraph();
}
@Override
public void taskUserDataChanged(ResolvedTask<?> task) {
refreshGraph();
}
});
// initialize compatibility checkup and display
CompatibilityService cs = PlatformUI.getWorkbench().getService(CompatibilityService.class);
cs.addListener(compListener = new ExclusiveExtensionListener<CompatibilityMode, CompatibilityModeFactory>() {
@Override
public void currentObjectChanged(final CompatibilityMode arg0, final CompatibilityModeFactory arg1) {
refreshGraph();
}
});
// listen on SchemaSelections
getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (!(selection instanceof SchemaSelection)) {
// only react on schema selections
return;
}
if (part != AlignmentView.this) {
updateRelation((SchemaSelection) selection);
}
}
});
// select type cell, if it is double clicked
getViewer().addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() == 1) {
Object selected = selection.getFirstElement();
if (selected instanceof Cell && AlignmentUtil.isTypeCell((Cell) selected))
sourceTargetSelector.setSelection(selection);
}
}
});
// listen on size changes
getViewer().getControl().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
updateLayout(true);
}
});
getViewer().setInput(new DefaultCell());
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project hale by halestudio.
the class URLTarget method createControls.
/**
* @see eu.esdihumboldt.hale.ui.io.ExportTarget#createControls(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControls(Composite parent) {
parent.setLayout(new GridLayout(3, false));
// source file
targetURL = new URLTargetURIFieldEditor("targetURL", "Target URL", parent) {
@Override
protected void onHistorySelected(URI location) {
updateState();
}
};
targetURL.setPage(getPage());
targetURL.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FieldEditor.IS_VALID)) {
getPage().setMessage(null);
updateState();
} else if (event.getProperty().equals(FieldEditor.VALUE)) {
getPage().setMessage(null);
updateState();
}
}
});
// content type selection
// label
Label typesLabel = new Label(parent, SWT.NONE);
typesLabel.setText("Content type");
// types combo
Composite group = new Composite(parent, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
types = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY);
types.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
types.setContentProvider(ArrayContentProvider.getInstance());
types.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IContentType) {
return ((IContentType) element).getName();
}
return super.getText(element);
}
});
// process selection changes
types.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// update content type
ISelection sel = event.getSelection();
if (sel.isEmpty() || !(sel instanceof IStructuredSelection)) {
setContentType(null);
} else {
setContentType((IContentType) ((IStructuredSelection) sel).getFirstElement());
}
}
});
}
use of org.eclipse.jface.viewers.ISelectionChangedListener in project hale by halestudio.
the class InstanceViewPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
Composite page = new Composite(parent, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(1).applyTo(page);
GridDataFactory.fillDefaults().grab(true, true).applyTo(page);
// current sampler settings
samplerSettings.clear();
for (Entry<String, Sampler> entry : InstanceViewPreferences.SAMPLERS.entrySet()) {
Value settings = ps.getConfigurationService().getProperty(InstanceViewPreferences.KEY_SETTINGS_PREFIX + entry.getKey());
if (settings.isEmpty()) {
settings = entry.getValue().getDefaultSettings();
}
samplerSettings.put(entry.getKey(), settings);
}
// sampler group
samplerGroup = new Group(page, SWT.NONE);
samplerGroup.setText("Instance sampling");
GridDataFactory.fillDefaults().grab(true, false).applyTo(samplerGroup);
GridLayoutFactory.swtDefaults().applyTo(samplerGroup);
// enabled button
enabled = new Button(samplerGroup, SWT.CHECK);
enabled.setText("Use a sub-set of the imported source data as specified below:");
enabled.setSelection(ps.getConfigurationService().getBoolean(InstanceViewPreferences.KEY_ENABLED, InstanceViewPreferences.ENABLED_DEFAULT));
enabled.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
changed = true;
}
});
// sampler selector
samplers = new ComboViewer(samplerGroup);
samplers.setContentProvider(ArrayContentProvider.getInstance());
samplers.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof Sampler) {
return ((Sampler) element).getDisplayName(Value.NULL);
}
return super.getText(element);
}
});
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false);
samplers.setInput(InstanceViewPreferences.SAMPLERS.values());
samplers.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
updateEditor(null);
} else {
if (selection instanceof IStructuredSelection) {
updateEditor((Sampler) ((IStructuredSelection) selection).getFirstElement());
}
}
changed = true;
}
});
// restore the selected sampler
String samplerId = ps.getConfigurationService().get(InstanceViewPreferences.KEY_SAMPLER, InstanceViewPreferences.SAMPLER_FIRST);
Sampler selectedSampler = InstanceViewPreferences.SAMPLERS.get(samplerId);
if (selectedSampler != null) {
samplers.setSelection(new StructuredSelection(selectedSampler));
changed = false;
}
// occurring values group
Group ovGroup = new Group(page, SWT.NONE);
ovGroup.setText("Occurring values");
GridDataFactory.fillDefaults().grab(true, false).applyTo(ovGroup);
GridLayoutFactory.swtDefaults().applyTo(ovGroup);
// occurring values button
occurringValuesComplete = new Button(ovGroup, SWT.CHECK);
occurringValuesComplete.setText("Always use complete source data to determine occurring values (ignore sampling)");
occurringValuesComplete.setSelection(ps.getConfigurationService().getBoolean(InstanceViewPreferences.KEY_OCCURRING_VALUES_USE_EXTERNAL, InstanceViewPreferences.OCCURRING_VALUES_EXTERNAL_DEFAULT));
occurringValuesComplete.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ov_changed = true;
}
});
return page;
}
Aggregations