use of eu.esdihumboldt.hale.ui.common.definition.viewer.StyledDefinitionLabelProvider in project hale by halestudio.
the class ViewerEntityTray method createContents.
@Override
protected Control createContents(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().applyTo(page);
// text / description
Label label = new Label(page, SWT.WRAP);
label.setText("An entity that is referenced in a mapping cell cannot be resolved. This may be due to a changed schema, with for instance changed namespaces or property names. To update the cell please select a replacement entity to the left, a candidate may already be selected. Press Skip to leave the cell entity unchanged or Cancel to skip all remaining entities.\n\nBelow is a (inaccurate) reconstruction of the original entity for reference:");
GridDataFactory.swtDefaults().hint(300, SWT.DEFAULT).applyTo(label);
// viewer for dummy entity
TreeViewer viewer = new TreeViewer(page, SWT.BORDER);
viewer.setContentProvider(new EntityContentProvider());
viewer.setLabelProvider(new StyledDefinitionLabelProvider(viewer));
viewer.setInput(Collections.singleton(entity));
viewer.getControl().setEnabled(false);
viewer.expandAll();
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
return page;
}
use of eu.esdihumboldt.hale.ui.common.definition.viewer.StyledDefinitionLabelProvider in project hale by halestudio.
the class SourceListParameterPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
GridLayout layout = GridLayoutFactory.swtDefaults().create();
// Add margin to leave space for control decorations
layout.marginLeft = 5;
layout.marginRight = 5;
page.setLayout(layout);
// input field
textField = createAndLayoutTextField(page);
// let subclasses for example add validation
configure(textField);
addContentProposalProvider(projectVariablesProposalsProvider);
setText(textField, initialValue);
// variables
Label label = new Label(page, SWT.NONE);
label.setText("Available variables (double click to insert)");
label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(4, 12).create());
// variables table
Composite tableComposite = new Composite(page, SWT.NONE);
tableComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 100).create());
TableColumnLayout columnLayout = new TableColumnLayout();
tableComposite.setLayout(columnLayout);
varTable = new TableViewer(tableComposite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
varTable.getTable().setHeaderVisible(true);
TableViewerColumn entityColumn = new TableViewerColumn(varTable, SWT.NONE);
columnLayout.setColumnData(entityColumn.getColumn(), new ColumnWeightData(2, true));
entityColumn.getColumn().setText("Entity");
varTable.setContentProvider(ArrayContentProvider.getInstance());
varTable.setLabelProvider(new StyledDefinitionLabelProvider(varTable) {
@Override
protected Object extractElement(Object element) {
if (element instanceof Entry) {
return ((Entry<?, ?>) element).getKey();
}
return super.extractElement(element);
}
});
varTable.getTable().addMouseListener(new MouseAdapter() {
/**
* @see MouseAdapter#mouseDoubleClick(MouseEvent)
*/
@Override
public void mouseDoubleClick(MouseEvent e) {
ISelection sel = varTable.getSelection();
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection) sel).getFirstElement();
if (selected instanceof Entry) {
selected = ((Entry<?, ?>) selected).getValue();
}
insertTextAtCurrentPos(textField, selected.toString());
}
}
});
// variable name column
TableViewerColumn varColumn = new TableViewerColumn(varTable, SWT.NONE);
columnLayout.setColumnData(varColumn.getColumn(), new ColumnWeightData(1, true));
varColumn.getColumn().setText("Variable");
varColumn.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
if (element instanceof Entry) {
element = ((Entry<?, ?>) element).getValue();
}
cell.setText(element.toString());
}
});
}
use of eu.esdihumboldt.hale.ui.common.definition.viewer.StyledDefinitionLabelProvider in project hale by halestudio.
the class TypeStructureTray method createContents.
@Override
protected Control createContents(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(page);
// retrieve the types
final Collection<? extends TypeDefinition> types = this.types.getTypes();
// heading
Label caption = new Label(page, SWT.NONE);
switch(schemaSpace) {
case SOURCE:
caption.setText("Source structure");
break;
case TARGET:
caption.setText("Target structure");
break;
}
caption.setFont(JFaceResources.getHeaderFont());
// create tree viewer
PatternFilter patternFilter = new SchemaPatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
final FilteredTree filteredTree = new TreePathFilteredTree(page, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
TreeViewer tree = filteredTree.getViewer();
tree.setUseHashlookup(true);
StyledDefinitionLabelProvider labelProvider = new StyledDefinitionLabelProvider(tree);
tree.setLabelProvider(labelProvider);
IContentProvider contentProvider = createContentProvider(tree);
tree.setContentProvider(contentProvider);
GridDataFactory.fillDefaults().grab(true, true).hint(280, 400).applyTo(filteredTree);
tree.setComparator(new DefinitionComparator());
// set input
if (types.size() == 1) {
tree.setInput(types.iterator().next());
} else {
tree.setInput(types);
}
/*
* Groovy specific part
*/
// caption
Label example = new Label(page, SWT.NONE);
switch(schemaSpace) {
case SOURCE:
example.setText("Examples: Access variables");
break;
case TARGET:
example.setText("Example: Build instance");
break;
default:
example.setText("Example");
}
// source viewer
final SourceViewer viewer = new SourceViewer(page, null, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
final IColorManager colorManager = new GroovyColorManager();
SourceViewerConfiguration configuration = new SimpleGroovySourceViewerConfiguration(colorManager, ImmutableList.of(BINDING_TARGET, BINDING_BUILDER, BINDING_INDEX, BINDING_SOURCE, BINDING_SOURCE_TYPES, BINDING_TARGET_TYPE, BINDING_CELL, BINDING_LOG, BINDING_CELL_CONTEXT, BINDING_FUNCTION_CONTEXT, BINDING_TRANSFORMATION_CONTEXT), null);
viewer.configure(configuration);
GridDataFactory.fillDefaults().grab(true, false).hint(200, 130).applyTo(viewer.getControl());
// make sure the color manager is disposed
viewer.getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
colorManager.dispose();
}
});
// react to tree selection changes
tree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IDocument doc = new Document();
GroovySourceViewerUtil.setupDocument(doc);
String example = null;
if (!event.getSelection().isEmpty()) {
switch(schemaSpace) {
case SOURCE:
example = createSourceSample(event.getSelection(), types);
break;
case TARGET:
example = createTargetSample(event.getSelection(), types);
break;
}
}
if (example == null || example.isEmpty()) {
switch(schemaSpace) {
case SOURCE:
doc.set("// Please select schema elements to access");
break;
case TARGET:
doc.set("// Please select which schema elements\n// to include in the instance to build");
break;
default:
doc.set("// Please select one or more schema elements");
}
} else {
doc.set(example);
}
viewer.setDocument(doc);
}
});
tree.setSelection(StructuredSelection.EMPTY);
return page;
}
use of eu.esdihumboldt.hale.ui.common.definition.viewer.StyledDefinitionLabelProvider in project hale by halestudio.
the class JoinParameterPage method createContent.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(new GridLayout(2, false));
Label intro = new Label(page, SWT.NONE);
intro.setText("Select the join order. Focus will happen on the topmost type.");
intro.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false, 2, 1));
table = new TableViewer(page, SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE);
table.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
table.setLabelProvider(new StyledDefinitionLabelProvider(table));
table.setContentProvider(ArrayContentProvider.getInstance());
table.setInput(types);
final Button up = new Button(page, SWT.PUSH);
final Button down = new Button(page, SWT.PUSH);
upIcon = CoreFunctionsUIPlugin.getImageDescriptor("icons/nav_up.gif").createImage();
up.setImage(upIcon);
up.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false));
up.setEnabled(false);
up.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = getCurrentSelection();
if (index > 0) {
swapTypes(index - 1, index);
if (index - 1 == 0)
up.setEnabled(false);
down.setEnabled(true);
}
}
});
downIcon = CoreFunctionsUIPlugin.getImageDescriptor("icons/nav_down.gif").createImage();
down.setImage(downIcon);
down.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false));
down.setEnabled(false);
down.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = getCurrentSelection();
if (index + 1 < types.size()) {
swapTypes(index, index + 1);
if (index + 2 == types.size())
down.setEnabled(false);
up.setEnabled(true);
}
}
});
table.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int index = getCurrentSelection();
if (index < 0) {
down.setEnabled(false);
up.setEnabled(false);
} else {
down.setEnabled(index + 1 < types.size());
up.setEnabled(index > 0);
}
}
});
}
use of eu.esdihumboldt.hale.ui.common.definition.viewer.StyledDefinitionLabelProvider in project hale by halestudio.
the class SpatialJoinParameterPage method createContent.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(new GridLayout(2, false));
Label intro = new Label(page, SWT.NONE);
intro.setText("Select the join order. Focus will happen on the topmost type.");
intro.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false, 2, 1));
table = new TableViewer(page, SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE);
table.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
table.setLabelProvider(new StyledDefinitionLabelProvider(table));
table.setContentProvider(ArrayContentProvider.getInstance());
table.setInput(types);
final Button up = new Button(page, SWT.PUSH);
final Button down = new Button(page, SWT.PUSH);
upIcon = GeometricFunctionsUIPlugin.getImageDescriptor("icons/nav_up.gif").createImage();
up.setImage(upIcon);
up.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false));
up.setEnabled(false);
up.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = getCurrentSelection();
if (index > 0) {
swapTypes(index - 1, index);
if (index - 1 == 0)
up.setEnabled(false);
down.setEnabled(true);
}
}
});
downIcon = GeometricFunctionsUIPlugin.getImageDescriptor("icons/nav_down.gif").createImage();
down.setImage(downIcon);
down.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false));
down.setEnabled(false);
down.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = getCurrentSelection();
if (index + 1 < types.size()) {
swapTypes(index, index + 1);
if (index + 2 == types.size())
down.setEnabled(false);
up.setEnabled(true);
}
}
});
table.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int index = getCurrentSelection();
if (index < 0) {
down.setEnabled(false);
up.setEnabled(false);
} else {
down.setEnabled(index + 1 < types.size());
up.setEnabled(index > 0);
}
}
});
}
Aggregations