Search in sources :

Example 1 with ITreeSelection

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

the class SubscribeAction method setSelection.

/**
     * Sets the selection.
     * 
     * @param selection The selection
     */
private void setSelection(ISelection selection) {
    objectName = null;
    if (selection instanceof ITreeSelection) {
        ITreeSelection new_name = (ITreeSelection) selection;
        Object element = new_name.getFirstElement();
        if (element instanceof MBean) {
            objectName = ((MBean) element).getObjectName();
        }
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection)

Example 2 with ITreeSelection

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

the class AbstractTreeNodeButton method init.

private void init(Composite parent, String tooltip, Image image) {
    button = new Button(parent, SWT.PUSH);
    button.setToolTipText(tooltip);
    button.setImage(image);
    button.setEnabled(false);
    button.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (treeViewer != null && !treeViewer.getTree().isDisposed() && treeViewer.getSelection() instanceof ITreeSelection) {
                handleSelectionEvent((TreeSelection) treeViewer.getSelection());
            }
        }
    });
    treeViewer = form.getTreeViewer();
    addTreeListeners();
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) Button(org.eclipse.swt.widgets.Button) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreeSelection(org.eclipse.jface.viewers.TreeSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event)

Example 3 with ITreeSelection

use of org.eclipse.jface.viewers.ITreeSelection in project linuxtools by eclipse.

the class PerfOpenData method open.

@Override
public void open(IPath file) {
    // get project name of where the file resides.
    String projectName = null;
    IFile location = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file);
    // If unable to get location from workspace, try getting from current file selection
    if (location == null) {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        ISelection selection = page.getSelection();
        if (selection instanceof ITreeSelection) {
            Object element = ((ITreeSelection) selection).getFirstElement();
            if (element instanceof IFile) {
                IFile eFile = (IFile) element;
                IProject project = eFile.getProject();
                projectName = project.getName();
                URI fileURI = ((IFile) element).getLocationURI();
                ILaunchConfiguration config = createDefaultConfiguration(projectName);
                PerfCore.report(config, null, null, fileURI.getPath(), null);
                String timestamp = DateFormat.getInstance().format(new Date(eFile.getLocalTimeStamp()));
                // $NON-NLS-1$ //$NON-NLS-2$
                PerfCore.refreshView(fileURI.toString() + " (" + timestamp + ")");
            }
        }
    } else {
        projectName = location.getProject().getName();
        ILaunchConfiguration config = createDefaultConfiguration(projectName);
        PerfCore.report(config, null, null, file.toOSString(), null);
        String timestamp = DateFormat.getInstance().format(new Date(location.getLocalTimeStamp()));
        // $NON-NLS-1$ //$NON-NLS-2$
        PerfCore.refreshView(file.toOSString() + " (" + timestamp + ")");
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IFile(org.eclipse.core.resources.IFile) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) URI(java.net.URI) IProject(org.eclipse.core.resources.IProject) Date(java.sql.Date)

Example 4 with ITreeSelection

use of org.eclipse.jface.viewers.ITreeSelection in project linuxtools by eclipse.

the class DockerContainersView method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    final ITreeSelection treeSelection = (ITreeSelection) selection;
    if (treeSelection.isEmpty()) {
        setConnection(null);
        return;
    }
    final Object firstSegment = treeSelection.getPaths()[0].getFirstSegment();
    if (firstSegment instanceof IDockerConnection) {
        final IDockerConnection connection = (IDockerConnection) firstSegment;
        setConnection(connection);
        setLabelFilterIds();
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 5 with ITreeSelection

use of org.eclipse.jface.viewers.ITreeSelection in project linuxtools by eclipse.

the class DockerImagesView method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    final ITreeSelection treeSelection = (ITreeSelection) selection;
    if (treeSelection.isEmpty()) {
        setConnection(null);
        return;
    }
    final Object firstSegment = treeSelection.getPaths()[0].getFirstSegment();
    if (firstSegment instanceof IDockerConnection) {
        final IDockerConnection connection = (IDockerConnection) firstSegment;
        setConnection(connection);
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Aggregations

ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)56 TreePath (org.eclipse.jface.viewers.TreePath)17 ISelection (org.eclipse.jface.viewers.ISelection)16 TreeSelection (org.eclipse.jface.viewers.TreeSelection)8 ArrayList (java.util.ArrayList)7 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)7 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)7 IFile (org.eclipse.core.resources.IFile)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)5 IProject (org.eclipse.core.resources.IProject)4 IStatus (org.eclipse.core.runtime.IStatus)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)4 GridData (org.eclipse.swt.layout.GridData)4 Composite (org.eclipse.swt.widgets.Composite)4 TracePattern (org.erlide.tracing.core.mvc.model.TracePattern)4 Test (org.junit.Test)4 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)3 URL (java.net.URL)3 HashSet (java.util.HashSet)3