use of eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset in project hale by halestudio.
the class SchemaPresetSelectionDialog method createViewer.
/**
* @see AbstractViewerSelectionDialog#createViewer(Composite)
*/
@Override
protected TreeViewer createViewer(Composite parent) {
PatternFilter patternFilter = new PatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
FilteredTree tree = new FilteredTree(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
tree.getViewer().setComparator(new SchemaPresetComparator());
// set filter to only accept schema selection (must be set after
// pattern filter is created)
setFilters(new ViewerFilter[] { new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof SchemaPreset;
}
} });
return tree.getViewer();
}
use of eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset in project hale by halestudio.
the class PresetsSource method createControls.
/**
* @see ImportSource#createControls(Composite)
*/
@Override
public void createControls(Composite parent) {
GridLayoutFactory parentLayout = GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false);
parentLayout.applyTo(parent);
GridDataFactory labelData = //
GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER);
GridDataFactory controlData = //
GridDataFactory.swtDefaults().align(SWT.FILL, //
SWT.CENTER).grab(true, false);
// preset label
Label label = new Label(parent, SWT.NONE);
label.setText("Select preset:");
labelData.applyTo(label);
// preset selector
selector = new SchemaPresetSelector(parent);
selector.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (description != null) {
SchemaPreset schema = selector.getSelectedObject();
if (schema != null && schema.getDescription() != null) {
description.setText(schema.getDescription());
} else {
description.setText("");
}
}
updateState(true);
}
});
controlData.applyTo(selector.getControl());
// skipper
Composite empty = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().hint(1, 1).applyTo(empty);
// description label
description = new Label(parent, SWT.WRAP);
GridDataFactory.fillDefaults().grab(true, true).applyTo(description);
// preset label
label = new Label(parent, SWT.NONE);
label.setText("Import as");
labelData.applyTo(label);
// create provider combo
ComboViewer providers = createProviders(parent);
controlData.applyTo(providers.getControl());
// prevent selector appearing very small
parent.pack();
// initial state update
updateState(true);
}
use of eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset in project hale by halestudio.
the class SchemaPresetLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
StyledString text = new StyledString();
if (element instanceof SchemaPreset) {
SchemaPreset schema = (SchemaPreset) element;
text.append(schema.getName());
}
if (element instanceof SchemaCategory) {
text.append(((SchemaCategory) element).getName());
}
if (element instanceof SchemaPreset) {
SchemaPreset preset = (SchemaPreset) element;
String version = preset.getVersion();
if (version != null) {
text.append(" " + version, StyledString.COUNTER_STYLER);
}
String tag = preset.getTag();
if (tag != null) {
text.append(" (" + tag + ")", StyledString.DECORATIONS_STYLER);
}
}
// NoObject.NONE)
if (element != null && (text.getString() == null || text.getString().isEmpty())) {
text.append(getText(element));
}
cell.setImage(getImage(element));
cell.setText(text.toString());
cell.setStyleRanges(text.getStyleRanges());
super.update(cell);
}
use of eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset in project hale by halestudio.
the class SchemaPresetLabelProvider method getImage.
@Override
public Image getImage(Object element) {
if (element instanceof SchemaPreset) {
SchemaPreset schema = (SchemaPreset) element;
URL iconURL = schema.getIconURL();
if (iconURL != null) {
String key = iconURL.toString();
Image image = urlImages.get(key);
if (image == null) {
image = ImageDescriptor.createFromURL(iconURL).createImage();
urlImages.put(key, image);
}
return image;
}
return defImage;
}
if (element instanceof SchemaCategory) {
return categoryImage;
}
return null;
}
Aggregations