Search in sources :

Example 36 with AdapterFactoryLabelProvider

use of org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider in project InformationSystem by ObeoNetwork.

the class NativeTypePropertiesEditionPartImpl method createSpecEMFComboViewer.

protected Composite createSpecEMFComboViewer(Composite parent) {
    createDescription(parent, TypeslibraryViewsRepository.NativeType.Properties.spec, TypeslibraryMessages.NativeTypePropertiesEditionPart_SpecLabel);
    spec = new EMFComboViewer(parent);
    spec.setContentProvider(new ArrayContentProvider());
    spec.setLabelProvider(new AdapterFactoryLabelProvider(EEFRuntimePlugin.getDefault().getAdapterFactory()));
    GridData specData = new GridData(GridData.FILL_HORIZONTAL);
    spec.getCombo().setLayoutData(specData);
    spec.addSelectionChangedListener(new ISelectionChangedListener() {

        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
         */
        public void selectionChanged(SelectionChangedEvent event) {
            if (propertiesEditionComponent != null)
                propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(NativeTypePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.NativeType.Properties.spec, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, getSpec()));
        }
    });
    spec.setID(TypeslibraryViewsRepository.NativeType.Properties.spec);
    // $NON-NLS-1$
    SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(TypeslibraryViewsRepository.NativeType.Properties.spec, TypeslibraryViewsRepository.SWT_KIND), null);
    // End of user code
    return parent;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) EMFComboViewer(org.eclipse.emf.eef.runtime.ui.widgets.EMFComboViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)

Example 37 with AdapterFactoryLabelProvider

use of org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider in project InformationSystem by ObeoNetwork.

the class NativeTypePropertiesEditionPartImpl method createMapsToFlatComboViewer.

/**
 * @param parent the parent composite
 */
protected Composite createMapsToFlatComboViewer(Composite parent) {
    createDescription(parent, TypeslibraryViewsRepository.NativeType.Properties.mapsTo, TypeslibraryMessages.NativeTypePropertiesEditionPart_MapsToLabel);
    mapsTo = new EObjectFlatComboViewer(parent, !propertiesEditionComponent.isRequired(TypeslibraryViewsRepository.NativeType.Properties.mapsTo, TypeslibraryViewsRepository.SWT_KIND));
    mapsTo.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
    mapsTo.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(NativeTypePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.NativeType.Properties.mapsTo, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SET, null, getMapsTo()));
        }
    });
    GridData mapsToData = new GridData(GridData.FILL_HORIZONTAL);
    mapsTo.setLayoutData(mapsToData);
    mapsTo.setID(TypeslibraryViewsRepository.NativeType.Properties.mapsTo);
    // $NON-NLS-1$
    SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(TypeslibraryViewsRepository.NativeType.Properties.mapsTo, TypeslibraryViewsRepository.SWT_KIND), null);
    // End of user code
    return parent;
}
Also used : EObjectFlatComboViewer(org.eclipse.emf.eef.runtime.ui.widgets.EObjectFlatComboViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)

Example 38 with AdapterFactoryLabelProvider

use of org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider in project InformationSystem by ObeoNetwork.

the class TypeInstancePropertiesEditionPartImpl method createTypeEMFComboViewer.

protected Composite createTypeEMFComboViewer(Composite parent) {
    createDescription(parent, TypeslibraryViewsRepository.TypeInstance.Properties.type, TypeslibraryMessages.TypeInstancePropertiesEditionPart_TypeLabel);
    type = new EMFComboViewer(parent);
    GridData typeData = new GridData(GridData.FILL_HORIZONTAL);
    type.getCombo().setLayoutData(typeData);
    type.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
    type.addSelectionChangedListener(new ISelectionChangedListener() {

        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
         */
        public void selectionChanged(SelectionChangedEvent event) {
            if (propertiesEditionComponent != null)
                propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(TypeInstancePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.TypeInstance.Properties.type, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, getType()));
        }
    });
    type.setContentProvider(new EMFListContentProvider());
    EditingUtils.setID(type.getCombo(), TypeslibraryViewsRepository.TypeInstance.Properties.type);
    // $NON-NLS-1$
    EditingUtils.setEEFtype(type.getCombo(), "eef::Combo");
    // $NON-NLS-1$
    SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(TypeslibraryViewsRepository.TypeInstance.Properties.type, TypeslibraryViewsRepository.SWT_KIND), null);
    // End of user code
    return parent;
}
Also used : EMFListContentProvider(org.eclipse.emf.eef.runtime.ui.providers.EMFListContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) EMFComboViewer(org.eclipse.emf.eef.runtime.ui.widgets.EMFComboViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)

Example 39 with AdapterFactoryLabelProvider

use of org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider in project InformationSystem by ObeoNetwork.

the class TypeInstancePropertiesEditionPartImpl method createLiteralsMultiValuedEditor.

protected Composite createLiteralsMultiValuedEditor(Composite parent) {
    literals = SWTUtils.createScrollableText(parent, SWT.BORDER | SWT.READ_ONLY);
    GridData literalsData = new GridData(GridData.FILL_HORIZONTAL);
    literalsData.horizontalSpan = 2;
    literals.setLayoutData(literalsData);
    EditingUtils.setID(literals, TypeslibraryViewsRepository.TypeInstance.Properties.literals);
    // $NON-NLS-1$
    EditingUtils.setEEFtype(literals, "eef::MultiValuedEditor::field");
    editLiterals = new Button(parent, SWT.NONE);
    editLiterals.setText(getDescription(TypeslibraryViewsRepository.TypeInstance.Properties.literals, TypeslibraryMessages.TypeInstancePropertiesEditionPart_LiteralsLabel));
    GridData editLiteralsData = new GridData();
    editLiterals.setLayoutData(editLiteralsData);
    editLiterals.addSelectionListener(new SelectionAdapter() {

        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
            EEFFeatureEditorDialog dialog = new EEFFeatureEditorDialog(// $NON-NLS-1$
            literals.getShell(), // $NON-NLS-1$
            "TypeInstance", // $NON-NLS-1$
            new AdapterFactoryLabelProvider(adapterFactory), literalsList, TypesLibraryPackage.eINSTANCE.getTypeInstance_Literals().getEType(), null, false, true, null, null);
            if (dialog.open() == Window.OK) {
                literalsList = dialog.getResult();
                if (literalsList == null) {
                    literalsList = new BasicEList();
                }
                literals.setText(literalsList.toString());
                propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(TypeInstancePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.TypeInstance.Properties.literals, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, new BasicEList(literalsList)));
                setHasChanged(true);
            }
        }
    });
    EditingUtils.setID(editLiterals, TypeslibraryViewsRepository.TypeInstance.Properties.literals);
    // $NON-NLS-1$
    EditingUtils.setEEFtype(editLiterals, "eef::MultiValuedEditor::browsebutton");
    // End of user code
    return parent;
}
Also used : Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) BasicEList(org.eclipse.emf.common.util.BasicEList) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent) EEFFeatureEditorDialog(org.eclipse.emf.eef.runtime.ui.widgets.EEFFeatureEditorDialog)

Example 40 with AdapterFactoryLabelProvider

use of org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider in project InformationSystem by ObeoNetwork.

the class TypesLibraryEditor method createPages.

/**
 * This is the method used by the framework to install your own controls.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void createPages() {
    // Creates the model from the editor input
    // 
    createModel();
    // 
    if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
        // Create a page for the selection tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), TypesLibraryEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            selectionViewer = (TreeViewer) viewerPane.getViewer();
            selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            selectionViewer.setInput(editingDomain.getResourceSet());
            selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
            selectionViewer.addDoubleClickListener(new OpenWizardOnDoubleClick(editingDomain, adapterFactory));
            viewerPane.setTitle(editingDomain.getResourceSet());
            new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
            createContextMenuFor(selectionViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_SelectionPage_label"));
        }
        // Create a page for the parent tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), TypesLibraryEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            parentViewer = (TreeViewer) viewerPane.getViewer();
            parentViewer.setAutoExpandLevel(30);
            parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
            parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(parentViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ParentPage_label"));
        }
        // This is the page for the list viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), TypesLibraryEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new ListViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            listViewer = (ListViewer) viewerPane.getViewer();
            listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(listViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ListPage_label"));
        }
        // This is the page for the tree viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), TypesLibraryEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewer = (TreeViewer) viewerPane.getViewer();
            treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
            createContextMenuFor(treeViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreePage_label"));
        }
        // This is the page for the table viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), TypesLibraryEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TableViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            tableViewer = (TableViewer) viewerPane.getViewer();
            Table table = tableViewer.getTable();
            TableLayout layout = new TableLayout();
            table.setLayout(layout);
            table.setHeaderVisible(true);
            table.setLinesVisible(true);
            TableColumn objectColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(3, 100, true));
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            TableColumn selfColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(2, 100, true));
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            tableViewer.setColumnProperties(new String[] { "a", "b" });
            tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(tableViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TablePage_label"));
        }
        // This is the page for the table tree viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), TypesLibraryEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewerWithColumns = (TreeViewer) viewerPane.getViewer();
            Tree tree = treeViewerWithColumns.getTree();
            tree.setLayoutData(new FillLayout());
            tree.setHeaderVisible(true);
            tree.setLinesVisible(true);
            TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            objectColumn.setWidth(250);
            TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            selfColumn.setWidth(200);
            treeViewerWithColumns.setColumnProperties(new String[] { "a", "b" });
            treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(treeViewerWithColumns);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
        }
        getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                setActivePage(0);
            }
        });
    }
    // Ensures that this editor will only display the page's tab
    // area if there are more than one page
    // 
    getContainer().addControlListener(new ControlAdapter() {

        boolean guard = false;

        @Override
        public void controlResized(ControlEvent event) {
            if (!guard) {
                guard = true;
                hideTabs();
                guard = false;
            }
        }
    });
    getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            updateProblemIndication();
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) ControlAdapter(org.eclipse.swt.events.ControlAdapter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) OpenWizardOnDoubleClick(org.eclipse.emf.eef.runtime.ui.notify.OpenWizardOnDoubleClick) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) TableLayout(org.eclipse.jface.viewers.TableLayout) ListViewer(org.eclipse.jface.viewers.ListViewer) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ViewerPane(org.eclipse.emf.common.ui.ViewerPane) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) ControlEvent(org.eclipse.swt.events.ControlEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)208 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)147 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)147 GridData (org.eclipse.swt.layout.GridData)136 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)134 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)134 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)66 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)65 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)62 EObjectFlatComboViewer (org.eclipse.emf.eef.runtime.ui.widgets.EObjectFlatComboViewer)60 Composite (org.eclipse.swt.widgets.Composite)52 EMFComboViewer (org.eclipse.emf.eef.runtime.ui.widgets.EMFComboViewer)50 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)35 TreeViewer (org.eclipse.jface.viewers.TreeViewer)32 Tree (org.eclipse.swt.widgets.Tree)32 AdapterFactoryTreeEditor (org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor)31 IMenuManager (org.eclipse.jface.action.IMenuManager)30 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)30 IToolBarManager (org.eclipse.jface.action.IToolBarManager)30 ControlAdapter (org.eclipse.swt.events.ControlAdapter)30