Search in sources :

Example 1 with StructuredTypesContentProvider

use of org.obeonetwork.dsl.environment.design.ui.providers.StructuredTypesContentProvider in project InformationSystem by ObeoNetwork.

the class ChooseTypesAndReferencesPage method createControl.

/**
 * Create contents of the wizard.
 * @param parent
 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(2, true));
    Label lblTypes = new Label(container, SWT.NONE);
    lblTypes.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblTypes.setText("Types :");
    Label lblReferences = new Label(container, SWT.NONE);
    lblReferences.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblReferences.setText("References :");
    typesTreeViewer = new CheckboxTreeViewer(container, SWT.BORDER);
    typesTreeViewer.setUseHashlookup(true);
    final Tree typesTree = typesTreeViewer.getTree();
    typesTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    typesTreeViewer.setContentProvider(new StructuredTypesContentProvider(sourceTypeName));
    typesTreeViewer.setLabelProvider(labelProvider);
    typesTreeViewer.setSorter(new ViewerSorter());
    referencesTreeViewer = new CheckboxTreeViewer(container, SWT.BORDER);
    referencesTreeViewer.setUseHashlookup(true);
    Tree referencesTree = referencesTreeViewer.getTree();
    referencesTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    referencesTreeViewer.setContentProvider(new ArrayTreeContentProvider());
    referenceLabelProvider = new ReferenceLabelProvider();
    referencesTreeViewer.setLabelProvider(referenceLabelProvider);
    referencesTreeViewer.setSorter(new ViewerSorter());
    typesTreeViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            // Check/uncheck all subtree
            typesTreeViewer.setSubtreeChecked(event.getElement(), event.getChecked());
            Collection<StructuredType> checkedTypes = getCheckedTypes();
            setPageComplete(!checkedTypes.isEmpty());
            List<Reference> references = referencesServices.getReferencesBetweenTypes(checkedTypes);
            referencesTreeViewer.setInput(references);
        }
    });
    initContents();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ReferenceLabelProvider(org.obeonetwork.dsl.environment.design.ui.providers.ReferenceLabelProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Label(org.eclipse.swt.widgets.Label) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) ArrayTreeContentProvider(org.obeonetwork.dsl.environment.design.ui.providers.ArrayTreeContentProvider) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree) StructuredTypesContentProvider(org.obeonetwork.dsl.environment.design.ui.providers.StructuredTypesContentProvider) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Tree (org.eclipse.swt.widgets.Tree)1 ArrayTreeContentProvider (org.obeonetwork.dsl.environment.design.ui.providers.ArrayTreeContentProvider)1 ReferenceLabelProvider (org.obeonetwork.dsl.environment.design.ui.providers.ReferenceLabelProvider)1 StructuredTypesContentProvider (org.obeonetwork.dsl.environment.design.ui.providers.StructuredTypesContentProvider)1