Search in sources :

Example 1 with DrillDownAdapter

use of org.eclipse.ui.part.DrillDownAdapter in project linuxtools by eclipse.

the class PerfProfileView method createPartControl.

/**
 * This is a callback that will allow us
 * to create the viewer and initialize it.
 */
@Override
public void createPartControl(Composite parent) {
    viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    drillDownAdapter = new DrillDownAdapter(viewer);
    viewer.setContentProvider(new PerfViewContentProvider());
    viewer.setLabelProvider(new PerfViewLabelProvider());
    viewer.setComparator(new NameComparator());
    // Create the help context id for the viewer's control
    // $NON-NLS-1$
    PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.eclipse.linuxtools.internal.perf.viewer");
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 2 with DrillDownAdapter

use of org.eclipse.ui.part.DrillDownAdapter in project erlide_eclipse by erlang.

the class CoverStatsView method createPartControl.

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.
 */
@Override
public void createPartControl(final Composite parent) {
    // layout
    final GridLayout containerLayout = new GridLayout(1, false);
    containerLayout.marginWidth = 0;
    containerLayout.marginHeight = 0;
    containerLayout.verticalSpacing = 3;
    parent.setLayout(containerLayout);
    viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    drillDownAdapter = new DrillDownAdapter(viewer);
    viewer.setContentProvider(new StatsViewContentProvider(getViewSite()));
    viewer.setLabelProvider(new StatsViewLabelProvider());
    viewer.setComparator(new StatsNameSorter());
    viewer.setInput(getViewSite());
    viewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    viewer.addSelectionChangedListener(viewerSelectionChanged);
    createTableTree();
    viewer.setInput(StatsTreeModel.getInstance());
    // Create the help context id for the viewer's control
    PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.erlide.eunit.core.viewer");
    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) StatsViewLabelProvider(org.erlide.cover.ui.views.helpers.StatsViewLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) TreeViewer(org.eclipse.jface.viewers.TreeViewer) GridData(org.eclipse.swt.layout.GridData) StatsViewContentProvider(org.erlide.cover.ui.views.helpers.StatsViewContentProvider) StatsNameSorter(org.erlide.cover.ui.views.helpers.StatsNameSorter)

Example 3 with DrillDownAdapter

use of org.eclipse.ui.part.DrillDownAdapter in project tmdm-studio-se by Talend.

the class XpathSelectDialog method provideViwerContent.

// changeDomTree(
protected void provideViwerContent(XSDSchema xsdSchema, String filter) {
    drillDownAdapter = new DrillDownAdapter(domViewer);
    domViewer.setLabelProvider(new XSDTreeLabelProvider(selectionFilter));
    XPathTreeContentProvider provider = new XPathTreeContentProvider(this.site, xsdSchema, parent, filter);
    // filter the entity with the filter text but not the concept name.
    // provider.setConceptName(this.conceptName);
    domViewer.setContentProvider(provider);
    domViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent e) {
            StructuredSelection sel = (StructuredSelection) e.getSelection();
            xpath = getXpath(sel);
            xpathText.setText(xpath);
            boolean enable = false;
            if (selectionFilter == null) {
                enable = xpath.length() > 0;
            } else {
                enable = xpath.length() > 0 && (selectionFilter.check(sel.getFirstElement()) == FilterResult.ENABLE);
            }
            getButton(IDialogConstants.OK_ID).setEnabled(enable);
        }
    });
    domViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    domViewer.setSorter(new ViewerSorter() {

        @Override
        public int category(Object element) {
            // SimpleTypeDefinition
            if (element instanceof XSDFacet) {
                return 100;
            }
            // unique keys after element declarations and before other keys
            if (element instanceof XSDIdentityConstraintDefinition) {
                XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) element;
                if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
                    return 300;
                } else if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.KEY_LITERAL)) {
                    return 301;
                } else {
                    return 302;
                }
            }
            return 200;
        }

        @Override
        public int compare(Viewer theViewer, Object e1, Object e2) {
            int cat1 = category(e1);
            int cat2 = category(e2);
            return cat1 - cat2;
        }
    });
    domViewer.setInput(site);
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) XSDTreeLabelProvider(com.amalto.workbench.providers.XSDTreeLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) XPathTreeContentProvider(com.amalto.workbench.providers.XPathTreeContentProvider) XSDFacet(org.eclipse.xsd.XSDFacet) GridData(org.eclipse.swt.layout.GridData) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject)

Example 4 with DrillDownAdapter

use of org.eclipse.ui.part.DrillDownAdapter in project tmdm-studio-se by Talend.

the class DataModelMainPage method createSchemaTreeComp.

private void createSchemaTreeComp(Composite parent) {
    Composite schemaSash = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    schemaSash.setLayout(layout);
    schemaSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    schemaSash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Composite compInfo = new Composite(schemaSash, SWT.NONE);
    layout = new GridLayout();
    layout.verticalSpacing = 0;
    compInfo.setLayout(layout);
    compInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    compInfo.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Composite compSchemaTree = new Composite(schemaSash, SWT.NONE);
    GridLayout glCompSchemaTree = new GridLayout();
    glCompSchemaTree.verticalSpacing = 0;
    glCompSchemaTree.marginWidth = 0;
    glCompSchemaTree.marginHeight = 0;
    glCompSchemaTree.horizontalSpacing = 0;
    compSchemaTree.setLayout(glCompSchemaTree);
    compSchemaTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    compSchemaTree.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Label title = new Label(compInfo, SWT.VERTICAL);
    title.setText(Messages.DataModelEntities);
    title.setFont(FontUtils.getBoldFont(title.getFont()));
    Color blue = new Color(compInfo.getDisplay(), 0, 0, 255);
    title.setForeground(blue);
    title.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    ToolBar toolBarSchemaTree = createToolbarOnComposite(compSchemaTree);
    viewer = new TreeViewer(compSchemaTree, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    addToolItems2SchemaTreeToolBar(toolBarSchemaTree);
    toolBarSchemaTree.pack();
    drillDownAdapter = new DrillDownAdapter(viewer);
    schemaTreeContentProvider = new SchemaTreeContentProvider(this.getSite(), xsdSchema);
    viewer.setContentProvider(schemaTreeContentProvider);
    viewer.setFilters(new ViewerFilter[] { new SchemaRoleAccessFilter(null), new SchemaNameFilter(), new SchemaUniqueElementFilter() });
    viewer.getTree().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            isSchemaSelected = true;
        }
    });
    viewer.setLabelProvider(new XSDTreeLabelProvider());
    viewer.setSorter(schemaTreeSorter);
    // getViewSite());
    viewer.setInput(this.getSite());
    viewer.getTree().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (isReadOnly()) {
                return;
            }
            IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());
            // delete
            if ((e.stateMask == 0) && (e.keyCode == SWT.DEL)) {
                if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) {
                    deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
                    deleteConceptWrapAction.run();
                } else {
                    MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.SelectDeletableTry);
                }
            }
        }
    });
    viewer.setComparer(new ElementComparer());
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) XSDTreeLabelProvider(com.amalto.workbench.providers.XSDTreeLabelProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IElementComparer(org.eclipse.jface.viewers.IElementComparer) Color(org.eclipse.swt.graphics.Color) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) SchemaNameFilter(com.amalto.workbench.providers.datamodel.SchemaNameFilter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SchemaTreeContentProvider(com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) SchemaRoleAccessFilter(com.amalto.workbench.providers.datamodel.SchemaRoleAccessFilter) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SchemaUniqueElementFilter(com.amalto.workbench.providers.datamodel.SchemaUniqueElementFilter)

Example 5 with DrillDownAdapter

use of org.eclipse.ui.part.DrillDownAdapter in project webtools.servertools by eclipse.

the class ServerCacheView method createPartControl.

/**
 * This is a callback that will allow us
 * to create the viewer and initialize it.
 */
public void createPartControl(Composite parent) {
    viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    drillDownAdapter = new DrillDownAdapter(viewer);
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setSorter(new NameSorter());
    viewer.setInput(getViewSite());
    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Aggregations

DrillDownAdapter (org.eclipse.ui.part.DrillDownAdapter)8 TreeViewer (org.eclipse.jface.viewers.TreeViewer)6 GridData (org.eclipse.swt.layout.GridData)5 XSDTreeLabelProvider (com.amalto.workbench.providers.XSDTreeLabelProvider)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 TreeObject (com.amalto.workbench.models.TreeObject)1 XPathTreeContentProvider (com.amalto.workbench.providers.XPathTreeContentProvider)1 SchemaNameFilter (com.amalto.workbench.providers.datamodel.SchemaNameFilter)1 SchemaRoleAccessFilter (com.amalto.workbench.providers.datamodel.SchemaRoleAccessFilter)1 SchemaTreeContentProvider (com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider)1 SchemaUniqueElementFilter (com.amalto.workbench.providers.datamodel.SchemaUniqueElementFilter)1 DescAnnotationComposite (com.amalto.workbench.widgets.DescAnnotationComposite)1 IElementComparer (org.eclipse.jface.viewers.IElementComparer)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1