Search in sources :

Example 1 with IOpenListener

use of org.eclipse.jface.viewers.IOpenListener in project tdi-studio-se by Talend.

the class AbstractFilteredTree method addListeners.

/**
     * Adds the listeners.
     */
private void addListeners() {
    TreeViewer viewer = getViewer();
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            openAction.selectionChanged(event);
            copyAction.selectionChanged(event);
        }
    });
    viewer.addSelectionChangedListener(showCallersCalleesAction);
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            openAction.run();
        }
    });
    Activator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}
Also used : IOpenListener(org.eclipse.jface.viewers.IOpenListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 2 with IOpenListener

use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.

the class TestSuiteLabelProvider method createSection.

private void createSection(Section section, FormToolkit toolkit) {
    section.setText(Messages.TestSuitesPart_section_junit_tests);
    Composite composite = toolkit.createComposite(section);
    section.setClient(composite);
    // Section toolbar buttons
    ToolBar toolbar = new ToolBar(section, SWT.FLAT);
    section.setTextClient(toolbar);
    final ToolItem addItem = new ToolItem(toolbar, SWT.PUSH);
    addItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    addItem.setToolTipText(Messages.TestSuitesPart_add);
    final ToolItem removeItem = new ToolItem(toolbar, SWT.PUSH);
    removeItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    removeItem.setDisabledImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED));
    removeItem.setToolTipText(Messages.TestSuitesPart_remove);
    removeItem.setEnabled(false);
    Table table = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewer = new TableViewer(table);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new TestSuiteLabelProvider());
    toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
    final ToolItem btnMoveUp = new ToolItem(toolbar, SWT.PUSH);
    btnMoveUp.setText("Up");
    btnMoveUp.setImage(imgUp);
    btnMoveUp.setEnabled(false);
    final ToolItem btnMoveDown = new ToolItem(toolbar, SWT.PUSH);
    btnMoveDown.setText("Down");
    btnMoveDown.setImage(imgDown);
    btnMoveDown.setEnabled(false);
    // LISTENERS
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            boolean enabled = selection != null && !selection.isEmpty();
            removeItem.setEnabled(enabled);
            btnMoveUp.setEnabled(enabled);
            btnMoveDown.setEnabled(enabled);
            getManagedForm().fireSelectionChanged(TestSuitesPart.this, selection);
        }
    });
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            String name = (String) ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (name != null)
                doOpenSource(name);
        }
    });
    viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { ResourceTransfer.getInstance() }, new TestSuiteListDropAdapter());
    addItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAdd();
        }
    });
    removeItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doRemove();
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == SWT.DEL) {
                doRemove();
            } else if (e.character == '+') {
                doAdd();
            }
        }
    });
    btnMoveUp.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doMoveUp();
        }
    });
    btnMoveDown.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doMoveDown();
        }
    });
    // Layout
    GridLayout layout;
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    composite.setLayout(layout);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    // gd.widthHint = 75;
    gd.heightHint = 75;
    table.setLayoutData(gd);
    toolbar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridLayout(org.eclipse.swt.layout.GridLayout) ToolBar(org.eclipse.swt.widgets.ToolBar) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) ToolItem(org.eclipse.swt.widgets.ToolItem) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 3 with IOpenListener

use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.

the class LocalRepositorySelectionPage method createControl.

public void createControl(Composite parent) {
    setTitle("Select Local Repository");
    setMessage("Bundle will be imported into the selected repository.");
    Table table = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    final TableViewer viewer = new TableViewer(table);
    viewer.setContentProvider(new RepositoryTreeContentProvider());
    viewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
    viewer.setFilters(new ViewerFilter[] { new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return (element instanceof RepositoryPlugin) && ((RepositoryPlugin) element).canWrite();
        }
    } });
    try {
        Workspace workspace = Central.getWorkspace();
        viewer.setInput(workspace);
        if (selectedRepository != null)
            viewer.setSelection(new StructuredSelection(selectedRepository));
        validate(workspace);
    } catch (Exception e) {
        logger.logError("Error querying local repositories", e);
        setErrorMessage("Error querying local repositories, see log for details.");
    }
    // LISTENERS
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
        }
    });
    viewer.addOpenListener(new IOpenListener() {

        public void open(OpenEvent evt) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
            IWizardPage nextPage = getNextPage();
            if (nextPage != null)
                getContainer().showPage(nextPage);
        }
    });
    setControl(table);
}
Also used : Table(org.eclipse.swt.widgets.Table) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) RepositoryTreeContentProvider(bndtools.model.repo.RepositoryTreeContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryTreeLabelProvider(bndtools.model.repo.RepositoryTreeLabelProvider) IOpenListener(org.eclipse.jface.viewers.IOpenListener) IWizardPage(org.eclipse.jface.wizard.IWizardPage) TableViewer(org.eclipse.jface.viewers.TableViewer) Workspace(aQute.bnd.build.Workspace) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 4 with IOpenListener

use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.

the class MapValuesContentProvider method createAvailableBundlesPanel.

Control createAvailableBundlesPanel(Composite parent) {
    Composite panel = new Composite(parent, SWT.NONE);
    new Label(panel, SWT.NONE).setText("Available Bundles:");
    selectionSearchTxt = new Text(panel, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    selectionSearchTxt.setMessage("filter bundle name");
    final Tree availableTree = new Tree(panel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    availableViewer = new TreeViewer(availableTree);
    availableViewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
    availableViewer.setContentProvider(new RepositoryTreeContentProvider());
    availableViewer.setAutoExpandLevel(2);
    availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
    // Load data
    try {
        refreshBundleList();
    } catch (Exception e) {
        setErrorMessage("Error querying repositories: " + e.getMessage());
        logger.logError("Error querying repository configuration.", e);
    }
    // Listeners
    selectionSearchTxt.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.ARROW_DOWN)
                availableTree.setFocus();
        }
    });
    selectionSearchTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
        }
    });
    availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        // Enable add button when a bundle or bundle version is selected on
        // the left
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) availableViewer.getSelection();
            for (Iterator<?> iter = sel.iterator(); iter.hasNext(); ) {
                Object element = iter.next();
                if (element instanceof RepositoryBundle || element instanceof RepositoryBundleVersion || element instanceof ProjectBundle) {
                    addButton.setEnabled(true);
                    return;
                }
            }
            addButton.setEnabled(false);
        }
    });
    availableViewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            doAdd();
        }
    });
    GridLayout layout;
    GridData gd;
    layout = new GridLayout(1, false);
    panel.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    selectionSearchTxt.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 300;
    gd.widthHint = 250;
    availableTree.setLayoutData(gd);
    return panel;
}
Also used : RepositoryBundle(bndtools.model.repo.RepositoryBundle) RepositoryBundleVersion(bndtools.model.repo.RepositoryBundleVersion) ModifyListener(org.eclipse.swt.events.ModifyListener) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) RepositoryTreeContentProvider(bndtools.model.repo.RepositoryTreeContentProvider) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) ProjectBundle(bndtools.model.repo.ProjectBundle) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Iterator(java.util.Iterator) Tree(org.eclipse.swt.widgets.Tree) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) RepositoryTreeLabelProvider(bndtools.model.repo.RepositoryTreeLabelProvider) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridData(org.eclipse.swt.layout.GridData) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 5 with IOpenListener

use of org.eclipse.jface.viewers.IOpenListener in project tdi-studio-se by Talend.

the class HeapHistogramPage method createContextMenu.

/**
     * Creates the context menu.
     * 
     * @param actionBars The action bars
     */
private void createContextMenu(IActionBars actionBars) {
    final OpenDeclarationAction openAction = OpenDeclarationAction.createOpenDeclarationAction(actionBars);
    final CopyAction copyAction = CopyAction.createCopyAction(actionBars);
    configureColumnsAction = new ConfigureColumnsAction(this);
    heapViewer.addSelectionChangedListener(openAction);
    heapViewer.getControl().addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            heapViewer.removeSelectionChangedListener(copyAction);
        }

        @Override
        public void focusGained(FocusEvent e) {
            heapViewer.addSelectionChangedListener(copyAction);
        }
    });
    heapViewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            openAction.run();
        }
    });
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            manager.add(openAction);
            manager.add(copyAction);
            manager.add(new Separator());
            manager.add(configureColumnsAction);
        }
    });
    Menu menu = menuMgr.createContextMenu(heapViewer.getControl());
    heapViewer.getControl().setMenu(menu);
}
Also used : OpenDeclarationAction(org.talend.designer.runtime.visualization.internal.actions.OpenDeclarationAction) CopyAction(org.talend.designer.runtime.visualization.internal.actions.CopyAction) FocusEvent(org.eclipse.swt.events.FocusEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) IOpenListener(org.eclipse.jface.viewers.IOpenListener) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) ConfigureColumnsAction(org.talend.designer.runtime.visualization.internal.actions.ConfigureColumnsAction) FocusListener(org.eclipse.swt.events.FocusListener) Separator(org.eclipse.jface.action.Separator) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Aggregations

IOpenListener (org.eclipse.jface.viewers.IOpenListener)11 OpenEvent (org.eclipse.jface.viewers.OpenEvent)11 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)9 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)9 GridData (org.eclipse.swt.layout.GridData)8 GridLayout (org.eclipse.swt.layout.GridLayout)8 Composite (org.eclipse.swt.widgets.Composite)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 TableViewer (org.eclipse.jface.viewers.TableViewer)6 Table (org.eclipse.swt.widgets.Table)6 TreeViewer (org.eclipse.jface.viewers.TreeViewer)5 Label (org.eclipse.swt.widgets.Label)5 ISelection (org.eclipse.jface.viewers.ISelection)4 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Iterator (java.util.Iterator)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 Viewer (org.eclipse.jface.viewers.Viewer)3