Search in sources :

Example 1 with Documentation

use of eu.esdihumboldt.hale.ui.util.bbr.Documentation in project hale by halestudio.

the class AbstractDocumentationTextSection method refresh.

/**
 * @see AbstractPropertySection#refresh()
 */
@Override
public void refresh() {
    DocumentationService ds = PlatformUI.getWorkbench().getService(DocumentationService.class);
    Documentation doc = ds.getDocumentation(getDefinition());
    String desc = (doc == null) ? (null) : (getDocumentationText(doc));
    if (desc == null) {
        desc = "";
    }
    descriptionText.setText(desc);
}
Also used : DocumentationService(eu.esdihumboldt.hale.ui.util.bbr.DocumentationService) Documentation(eu.esdihumboldt.hale.ui.util.bbr.Documentation)

Example 2 with Documentation

use of eu.esdihumboldt.hale.ui.util.bbr.Documentation in project hale by halestudio.

the class AbstractDocumentationFilter method isFiltered.

@Override
public boolean isFiltered(Definition<?> input) {
    if (!input.getName().getNamespaceURI().equals(DocumentationServiceImpl.NS_URI_AGEOBW)) {
        // namespace does not match
        return true;
    }
    DocumentationService ds = PlatformUI.getWorkbench().getService(DocumentationService.class);
    Documentation doc = ds.getDocumentation(input);
    if (doc == null) {
        return true;
    }
    return !accept(doc);
}
Also used : DocumentationService(eu.esdihumboldt.hale.ui.util.bbr.DocumentationService) Documentation(eu.esdihumboldt.hale.ui.util.bbr.Documentation)

Example 3 with Documentation

use of eu.esdihumboldt.hale.ui.util.bbr.Documentation in project hale by halestudio.

the class ValuesSection method refresh.

/**
 * @see AbstractPropertySection#refresh()
 */
@Override
public void refresh() {
    DocumentationService ds = PlatformUI.getWorkbench().getService(DocumentationService.class);
    Documentation doc = ds.getDocumentation(getDefinition());
    if (doc != null) {
        values.setInput(doc.getValues());
        if (!doc.getValues().isEmpty()) {
            // select the first entry
            values.setSelection(new StructuredSelection(doc.getValues().iterator().next()));
        }
    } else {
        values.setInput(null);
    }
}
Also used : DocumentationService(eu.esdihumboldt.hale.ui.util.bbr.DocumentationService) Documentation(eu.esdihumboldt.hale.ui.util.bbr.Documentation) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with Documentation

use of eu.esdihumboldt.hale.ui.util.bbr.Documentation in project hale by halestudio.

the class ValuesSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    descriptionText = // $NON-NLS-1$
    getWidgetFactory().createText(// $NON-NLS-1$
    composite, // $NON-NLS-1$
    "", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
    descriptionText.setEditable(false);
    data = new FormData();
    data.width = 100;
    data.height = 100;
    // STANDARD_LABEL_WIDTH);
    data.left = new FormAttachment(0, 250);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
    descriptionText.setLayoutData(data);
    values = new ListViewer(getWidgetFactory().createList(composite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL));
    data = new FormData();
    data.height = 100;
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(descriptionText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(descriptionText, 0, SWT.TOP);
    values.getControl().setLayoutData(data);
    values.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof Documentation) {
                Documentation doc = (Documentation) element;
                StringBuilder result = new StringBuilder();
                boolean usable = (doc.isInUse() && !doc.getUseDiffers()) || (!doc.isInUse() && doc.getUseDiffers());
                if (usable) {
                    result.append(doc.getCode());
                } else {
                    // display values that are not in use in brackets
                    result.append('(');
                    result.append(doc.getCode());
                    result.append(')');
                }
                /*
					 * Mark use conflict with an asterisk. Only a conflict if
					 * something is wrongly classified as not in use.
					 */
                if (!doc.isInUse() && doc.getUseDiffers()) {
                    result.append('*');
                }
                return result.toString();
            }
            return super.getText(element);
        }
    });
    values.setContentProvider(ArrayContentProvider.getInstance());
    values.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            // display documentation on selected value
            ISelection sel = event.getSelection();
            if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
                Documentation doc = (Documentation) ((IStructuredSelection) sel).getFirstElement();
                String text = getDocumentationText(doc);
                if (text != null) {
                    descriptionText.setText(text);
                } else {
                    descriptionText.setText("");
                }
                descriptionText.setEnabled(text != null);
            } else {
                descriptionText.setText("");
                descriptionText.setEnabled(false);
            }
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) Documentation(eu.esdihumboldt.hale.ui.util.bbr.Documentation) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

Documentation (eu.esdihumboldt.hale.ui.util.bbr.Documentation)4 DocumentationService (eu.esdihumboldt.hale.ui.util.bbr.DocumentationService)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 ListViewer (org.eclipse.jface.viewers.ListViewer)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 Composite (org.eclipse.swt.widgets.Composite)1