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();
}
}
}
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();
}
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 + ")");
}
}
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();
}
}
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);
}
}
Aggregations