use of eu.esdihumboldt.hale.io.xsd.model.XmlElement in project hale by halestudio.
the class RootElementPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(new GridLayout(1, false));
// add filter text
filterText = new Text(page, SWT.SINGLE | SWT.BORDER);
filterText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
// $NON-NLS-1$
filterText.setText("");
// add filtered list
list = new ListViewer(page, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
list.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XmlElement) {
QName name = ((XmlElement) element).getName();
return name.getLocalPart() + " (" + name.getNamespaceURI() + ")";
}
if (element instanceof Definition) {
return ((Definition<?>) element).getDisplayName();
}
return super.getText(element);
}
});
list.setContentProvider(ArrayContentProvider.getInstance());
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
layoutData.widthHint = SWT.DEFAULT;
layoutData.heightHint = 8 * list.getList().getItemHeight();
list.getControl().setLayoutData(layoutData);
// page status update
list.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
setPageComplete(!selection.isEmpty());
}
});
list.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (canFlipToNextPage()) {
getContainer().showPage(getNextPage());
return;
}
}
});
// search filter & update
list.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
String filter = filterText.getText();
// handle empty filter
if (filter == null || filter.isEmpty()) {
return true;
}
if (element instanceof Definition) {
Definition<?> def = (Definition<?>) element;
filter = filter.toLowerCase();
if (def.getDisplayName().toLowerCase().contains(filter)) {
return true;
}
}
return false;
}
});
list.setComparator(new ViewerComparator());
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
// refilter
list.refresh();
}
});
updateList();
}
use of eu.esdihumboldt.hale.io.xsd.model.XmlElement in project hale by halestudio.
the class RootElementPage method loadPreSelection.
/**
* @see eu.esdihumboldt.hale.ui.io.IOWizardPage#loadPreSelection(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)
*/
@Override
public void loadPreSelection(IOConfiguration conf) {
String name = conf.getProviderConfiguration().get(StreamGmlWriter.PARAM_ROOT_ELEMENT_NAME).getStringRepresentation();
String namespace = conf.getProviderConfiguration().get(StreamGmlWriter.PARAM_ROOT_ELEMENT_NAMESPACE).getStringRepresentation();
String elementName = namespace + "/" + name;
SchemaSpace schemas = getWizard().getProvider().getTargetSchema();
XmlIndex index = StreamGmlWriter.getXMLIndex(schemas);
for (XmlElement element : index.getElements().values()) {
if (element.getIdentifier().equals(elementName)) {
list.setSelection(new StructuredSelection(element), true);
}
}
}
Aggregations