Search in sources :

Example 1 with WorkspacePage

use of bndtools.editor.pages.WorkspacePage in project bndtools by bndtools.

the class BndEditorContentOutlinePage method createControl.

@Override
public void createControl(Composite parent) {
    super.createControl(parent);
    TreeViewer viewer = getTreeViewer();
    viewer.setAutoExpandLevel(2);
    viewer.setContentProvider(new BndEditorContentOutlineProvider(viewer));
    viewer.setLabelProvider(new BndEditorContentOutlineLabelProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            Object element = selection.getFirstElement();
            if (element instanceof String) {
                if (BndEditorContentOutlineProvider.EXPORTS.equals(element)) {
                    editor.setActivePage(BndEditor.CONTENT_PAGE);
                } else if (BndEditorContentOutlineProvider.IMPORT_PATTERNS.equals(element)) {
                    editor.setActivePage(BndEditor.CONTENT_PAGE);
                } else if (BndEditorContentOutlineProvider.PRIVATE_PKGS.equals(element)) {
                    editor.setActivePage(BndEditor.CONTENT_PAGE);
                } else if (BndEditorContentOutlineProvider.PLUGINS.equals(element)) {
                    editor.setActivePage(BndEditor.WORKSPACE_PAGE);
                } else {
                    editor.setActivePage((String) element);
                }
            } else if (element instanceof ExportedPackage) {
                BundleContentPage contentsPage = (BundleContentPage) editor.setActivePage(BndEditor.CONTENT_PAGE);
                if (contentsPage != null) {
                    contentsPage.setSelectedExport((ExportedPackage) element);
                }
            } else if (element instanceof PrivatePkg) {
                BundleContentPage contentsPage = (BundleContentPage) editor.setActivePage(BndEditor.CONTENT_PAGE);
                if (contentsPage != null) {
                    contentsPage.setSelectedPrivatePkg(((PrivatePkg) element).pkg);
                }
            } else if (element instanceof ImportPattern) {
                BundleContentPage contentsPage = (BundleContentPage) editor.setActivePage(BndEditor.CONTENT_PAGE);
                if (contentsPage != null) {
                    contentsPage.setSelectedImport((ImportPattern) element);
                }
            } else if (element instanceof PluginClause) {
                WorkspacePage workspacePage = (WorkspacePage) editor.setActivePage(BndEditor.WORKSPACE_PAGE);
                if (workspacePage != null)
                    workspacePage.setSelectedPlugin(((PluginClause) element).header);
            }
        }
    });
    viewer.setInput(model);
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ImportPattern(aQute.bnd.build.model.clauses.ImportPattern) BundleContentPage(bndtools.editor.pages.BundleContentPage) ExportedPackage(aQute.bnd.build.model.clauses.ExportedPackage) WorkspacePage(bndtools.editor.pages.WorkspacePage)

Aggregations

ExportedPackage (aQute.bnd.build.model.clauses.ExportedPackage)1 ImportPattern (aQute.bnd.build.model.clauses.ImportPattern)1 BundleContentPage (bndtools.editor.pages.BundleContentPage)1 WorkspacePage (bndtools.editor.pages.WorkspacePage)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1