use of org.eclipse.jface.viewers.TreeSelection in project translationstudio8 by heartsome.
the class GridTreeViewer method remove.
/**
* Removes the element at the specified index of the parent. The selection is updated if required.
*
* @param parentOrTreePath the parent element, the input element, or a tree path to the parent element
* @param index child index
* @since 3.3
*/
public void remove(final Object parentOrTreePath, final int index) {
if (checkBusy())
return;
final List oldSelection = new LinkedList(Arrays.asList(((TreeSelection) getSelection()).getPaths()));
preservingSelection(new Runnable() {
public void run() {
TreePath removedPath = null;
if (internalIsInputOrEmptyPath(parentOrTreePath)) {
Tree tree = (Tree) getControl();
if (index < tree.getItemCount()) {
TreeItem item = tree.getItem(index);
if (item.getData() != null) {
removedPath = getTreePathFromItem(item);
disassociate(item);
}
item.dispose();
}
} else {
Widget[] parentItems = internalFindItems(parentOrTreePath);
for (int i = 0; i < parentItems.length; i++) {
TreeItem parentItem = (TreeItem) parentItems[i];
if (parentItem.isDisposed())
continue;
if (index < parentItem.getItemCount()) {
TreeItem item = parentItem.getItem(index);
if (item.getData() != null) {
removedPath = getTreePathFromItem(item);
disassociate(item);
}
item.dispose();
}
}
}
if (removedPath != null) {
boolean removed = false;
for (Iterator it = oldSelection.iterator(); it.hasNext(); ) {
TreePath path = (TreePath) it.next();
if (path.startsWith(removedPath, getComparer())) {
it.remove();
removed = true;
}
}
if (removed) {
setSelection(new TreeSelection((TreePath[]) oldSelection.toArray(new TreePath[oldSelection.size()]), getComparer()), false);
}
}
}
});
}
use of org.eclipse.jface.viewers.TreeSelection in project tdi-studio-se by Talend.
the class PushToPaletteActionProvider method fillContextMenu.
/**
* Adds a submenu to the given menu with the name "New Component".
*/
@Override
public void fillContextMenu(IMenuManager menu) {
//$NON-NLS-1$
menu.insertBefore("group.edit", copyProjectAction);
// Object obj = ((TreeSelection) this.getContext().getSelection()).getFirstElement();// need to get all
// selected.
Iterator ite = ((TreeSelection) this.getContext().getSelection()).iterator();
selectedFolderList = new ArrayList<IFolder>();
while (ite.hasNext()) {
Object obj = ite.next();
if (obj instanceof IFolder) {
selectedFolderList.add((IFolder) obj);
}
}
}
use of org.eclipse.jface.viewers.TreeSelection in project tdi-studio-se by Talend.
the class FindDialog method getSelectedNode.
/**
* Gets the selected node.
*
* @param viewer The tree viewer
* @return The selected node
*/
private static ITreeNode getSelectedNode(TreeViewer viewer) {
ISelection selection = viewer.getSelection();
if (selection instanceof TreeSelection) {
TreeSelection treeSelection = (TreeSelection) selection;
Object element = treeSelection.getFirstElement();
if (element instanceof ITreeNode) {
return (ITreeNode) element;
}
}
return null;
}
use of org.eclipse.jface.viewers.TreeSelection 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.TreeSelection in project cubrid-manager by CUBRID.
the class MultiDBQueryDNDController method setTreeSelectedItems.
/**
* setTreeSelectedItems
*/
public void setTreeSelectedItems() {
synchronized (this) {
//queryTree.refresh();
TreeViewer treeViewer = perspectiveTreeviewerMap.get(PerspectiveManager.getInstance().getCurrentPerspectiveId());
if (treeViewer == null) {
return;
}
ISelection selection = treeViewer.getSelection();
if (!(selection instanceof TreeSelection)) {
return;
}
TreeSelection ts = (TreeSelection) selection;
Object[] objs = ts.toArray();
for (Object obj : objs) {
// queryTree.setChecked(obj, true);
if (obj instanceof ICubridNode) {
multiDBQueryComposite.getSelectedNodes().add((ICubridNode) obj);
}
}
// multiDBQueryComposite.initialIndex();
//refresh again make the new drag item can be selected
// queryTree.refresh();
multiDBQueryComposite.setInput();
//queryTree.refresh();
}
}
Aggregations