use of org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer in project eclipse.jdt.ui by eclipse-jdt.
the class ProjectsView method createViewer.
@Override
protected StructuredViewer createViewer(Composite parent) {
ProblemTreeViewer result = new ProblemTreeViewer(parent, SWT.MULTI);
fFilterUpdater = new FilterUpdater(result);
ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
return result;
}
use of org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer in project eclipse.jdt.ui by eclipse-jdt.
the class BreadcrumbItemDropDown method showMenu.
/**
* Opens the drop down menu.
*/
public void showMenu() {
if (JavaPlugin.DEBUG_BREADCRUMB_ITEM_DROP_DOWN)
// $NON-NLS-1$
System.out.println("BreadcrumbItemDropDown.showMenu()");
if (!fEnabled || fMenuIsShown)
return;
fMenuIsShown = true;
fShell = new Shell(fToolBar.getShell(), SWT.RESIZE | SWT.TOOL | SWT.ON_TOP);
if (JavaPlugin.DEBUG_BREADCRUMB_ITEM_DROP_DOWN)
// $NON-NLS-1$
System.out.println(" creating new shell");
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
fShell.setLayout(layout);
Composite composite = new Composite(fShell, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
composite.setLayout(gridLayout);
fDropDownViewer = new ProblemTreeViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
fDropDownViewer.setUseHashlookup(true);
final Tree tree = (Tree) fDropDownViewer.getControl();
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Object input = fParent.getData();
fParent.getViewer().configureDropDownViewer(fDropDownViewer, input);
fDropDownViewer.setInput(input);
setShellBounds(fShell);
fShell.addControlListener(new ControlAdapter() {
/*
* @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent)
*/
@Override
public void controlResized(ControlEvent e) {
if (isResizingProgrammatically)
return;
Point size = fShell.getSize();
getDialogSettings().put(DIALOG_HEIGHT, size.y);
}
});
fDropDownViewer.addOpenListener(event -> {
if (JavaPlugin.DEBUG_BREADCRUMB_ITEM_DROP_DOWN)
// $NON-NLS-1$
System.out.println("BreadcrumbItemDropDown.showMenu()$treeViewer>open");
ISelection selection = event.getSelection();
if (!(selection instanceof IStructuredSelection))
return;
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element == null)
return;
openElement(element);
});
tree.addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent e) {
if (JavaPlugin.DEBUG_BREADCRUMB_ITEM_DROP_DOWN)
// $NON-NLS-1$
System.out.println("BreadcrumbItemDropDown.showMenu()$treeViewer>mouseUp");
if (e.button != 1)
return;
if ((OpenStrategy.getOpenMethod() & OpenStrategy.SINGLE_CLICK) != 0)
return;
Item item = tree.getItem(new Point(e.x, e.y));
if (item == null)
return;
openElement(item.getData());
}
@Override
public void mouseDown(MouseEvent e) {
}
@Override
public void mouseDoubleClick(MouseEvent e) {
}
});
tree.addMouseMoveListener(new MouseMoveListener() {
TreeItem fLastItem = null;
@Override
public void mouseMove(MouseEvent e) {
if (tree.equals(e.getSource())) {
TreeItem o = tree.getItem(new Point(e.x, e.y));
if ((o != null && !o.equals(fLastItem)) || (fLastItem != null && o == null)) {
boolean showHandPointer = false;
if (o != null) {
Object itemData = o.getData();
if (itemData instanceof IJavaElement) {
int elementType = ((IJavaElement) itemData).getElementType();
if (elementType != IJavaElement.JAVA_PROJECT && elementType != IJavaElement.PACKAGE_FRAGMENT && elementType != IJavaElement.PACKAGE_FRAGMENT_ROOT) {
showHandPointer = true;
}
} else if (itemData instanceof IFile) {
showHandPointer = true;
} else if (itemData instanceof IJarEntryResource) {
showHandPointer = ((IJarEntryResource) itemData).isFile();
}
}
tree.setCursor(showHandPointer ? tree.getDisplay().getSystemCursor(SWT.CURSOR_HAND) : null);
}
if (o != null) {
Rectangle clientArea = tree.getClientArea();
TreeItem currentItem = o;
if (!o.equals(fLastItem)) {
fLastItem = o;
tree.setSelection(new TreeItem[] { fLastItem });
} else if (e.y - clientArea.y < tree.getItemHeight() / 4) {
// Scroll up
if (currentItem.getParentItem() == null) {
int index = tree.indexOf(o);
if (index < 1)
return;
fLastItem = tree.getItem(index - 1);
tree.setSelection(new TreeItem[] { fLastItem });
} else {
Point p = tree.toDisplay(e.x, e.y);
Item item = fDropDownViewer.scrollUp(p.x, p.y);
if (item instanceof TreeItem) {
fLastItem = (TreeItem) item;
tree.setSelection(new TreeItem[] { fLastItem });
}
}
} else if (clientArea.y + clientArea.height - e.y < tree.getItemHeight() / 4) {
// Scroll down
if (currentItem.getParentItem() == null) {
int index = tree.indexOf(o);
if (index >= tree.getItemCount() - 1)
return;
fLastItem = tree.getItem(index + 1);
tree.setSelection(new TreeItem[] { fLastItem });
} else {
Point p = tree.toDisplay(e.x, e.y);
Item item = fDropDownViewer.scrollDown(p.x, p.y);
if (item instanceof TreeItem) {
fLastItem = (TreeItem) item;
tree.setSelection(new TreeItem[] { fLastItem });
}
}
}
} else {
fLastItem = null;
}
}
}
});
tree.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ARROW_UP) {
TreeItem[] selection = tree.getSelection();
if (selection.length != 1)
return;
int selectionIndex = tree.indexOf(selection[0]);
if (selectionIndex != 0)
return;
fShell.close();
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
fDropDownViewer.addTreeListener(new ITreeViewerListener() {
@Override
public void treeCollapsed(TreeExpansionEvent event) {
}
@Override
public void treeExpanded(TreeExpansionEvent event) {
tree.setRedraw(false);
fShell.getDisplay().asyncExec(() -> {
if (fShell.isDisposed())
return;
try {
resizeShell(fShell);
} finally {
tree.setRedraw(true);
}
});
}
});
int index = fParent.getViewer().getIndexOfItem(fParent);
if (index < fParent.getViewer().getItemCount() - 1) {
BreadcrumbItem childItem = fParent.getViewer().getItem(index + 1);
Object child = childItem.getData();
fDropDownViewer.setSelection(new StructuredSelection(child), true);
TreeItem[] selection = tree.getSelection();
if (selection.length > 0) {
tree.setTopItem(selection[0]);
}
}
fShell.setVisible(true);
installCloser(fShell);
}
use of org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer in project eclipse.jdt.ui by eclipse-jdt.
the class MembersView method createViewer.
@Override
protected StructuredViewer createViewer(Composite parent) {
ProblemTreeViewer viewer = new ProblemTreeViewer(parent, SWT.MULTI);
fMemberFilterActionGroup = new MemberFilterActionGroup(viewer, JavaUI.ID_MEMBERS_VIEW);
return viewer;
}
Aggregations