diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/AbstractBreadcrumb.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/AbstractBreadcrumb.java index 93cab84a742..ce1855e7807 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/AbstractBreadcrumb.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/AbstractBreadcrumb.java @@ -19,6 +19,7 @@ import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreePathBreadcrumbViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -30,7 +31,6 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Widget; - /** * Breadcrumb base class. It creates the breadcrumb viewer and manages * its activation. @@ -42,7 +42,7 @@ */ public abstract class AbstractBreadcrumb { - private BreadcrumbViewer fBreadcrumbViewer; + private TreePathBreadcrumbViewer fBreadcrumbViewer; private boolean fHasFocus; @@ -67,7 +67,7 @@ public AbstractBreadcrumb() { * @param parent the parent composite * @return the viewer */ - protected abstract BreadcrumbViewer createViewer(Composite parent); + protected abstract TreePathBreadcrumbViewer createViewer(Composite parent); /** * Open the element in a new editor if possible. @@ -196,11 +196,7 @@ public Control createContent(Composite parent) { return; } - BreadcrumbItem item= (BreadcrumbItem) fBreadcrumbViewer.doFindItem(element); - if (item == null) { - return; - } - item.openDropDownMenu(); + fBreadcrumbViewer.openDropDownMenu(element); }); fBreadcrumbViewer.addOpenListener(event -> doOpen(event.getSelection())); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java deleted file mode 100644 index 54c960517a5..00000000000 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Pawel Piech (Wind River) - adapted breadcrumb for use in Debug view (Bug 252677) - *******************************************************************************/ -package org.eclipse.debug.internal.ui.viewers.breadcrumb; - -import org.eclipse.jface.viewers.TreePath; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Shell; - - -/** - * An item in a breadcrumb viewer. - *
- * The item shows a label and an image. It also has the ability to expand, that is to open a drop - * down menu. - *
- *- * The drop down allows to select any child of the items input element. The item shows the label and - * icon of its data element, if any. - *
- * - * @since 3.5 - */ -class BreadcrumbItem extends Item { - - private TreePath fPath; - - private final BreadcrumbViewer fParent; - private final Composite fContainer; - - private final BreadcrumbItemDropDown fExpandBlock; - private final BreadcrumbItemDetails fDetailsBlock; - - private boolean fIsLast; - - /** - * A new breadcrumb item which is shown inside the given viewer. - * - * @param viewer the items viewer - * @param parent the container containing the item - */ - public BreadcrumbItem(BreadcrumbViewer viewer, Composite parent) { - super(parent, SWT.NONE); - - fParent= viewer; - - fContainer= new Composite(parent, SWT.NONE); - fContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - GridLayout layout= new GridLayout(2, false); - layout.marginBottom= 1; - layout.marginHeight= 0; - layout.marginWidth= 0; - layout.horizontalSpacing= 0; - fContainer.setLayout(layout); - - fExpandBlock= new BreadcrumbItemDropDown(this, fContainer); - fDetailsBlock= new BreadcrumbItemDetails(this, fContainer); - fContainer.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemComposite"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Returns this items viewer. - * - * @return the viewer showing this item - */ - public BreadcrumbViewer getViewer() { - return fParent; - } - - /* - * @see org.eclipse.swt.widgets.Widget#dispose() - */ - @Override - public void dispose() { - fContainer.dispose(); - super.dispose(); - } - - public TreePath getPath() { - return fPath; - } - - public void setPath(TreePath path) { - fPath = path; - } - - /** - * Should this item show a text label. - * - * @param enabled true if it should - */ - void setShowText(boolean enabled) { - fDetailsBlock.setTextVisible(enabled); - } - - /** - * Does this item show a text label? - * - * @return true if it does. - */ - boolean isShowText() { - return fDetailsBlock.isTextVisible(); - } - - /** - * Returns the width of this item. - * - * @return the width of this item - */ - int getWidth() { - return fDetailsBlock.getWidth() + fExpandBlock.getWidth() + 2; - } - - /** - * Sets whether this item has to be marked as - * selected or not. - * - * @param selected true if marked as selected - */ - void setSelected(boolean selected) { - fDetailsBlock.setSelected(selected); - } - - /** - * Sets whether this item has the keyboard focus. - * - * @param statetrue if it has focus, false otherwise
- */
- void setFocus(boolean state) {
- fDetailsBlock.setFocus(state);
- }
-
- /**
- * Returns whether this item has the keyboard focus.
- *
- * @return true if this item has the keyboard focus
- */
- boolean hasFocus() {
- return fDetailsBlock.hasFocus();
- }
-
- /**
- * Set whether this is the last item in the breadcrumb item chain or not.
- *
- * @param isLast true if this is the last item, false otherwise
- */
- void setIsLastItem(boolean isLast) {
- fIsLast= isLast;
-
- GridData data= (GridData) fContainer.getLayoutData();
- data.grabExcessHorizontalSpace= isLast;
- }
-
- /**
- * Expand this item, shows the drop down menu.
- */
- void openDropDownMenu() {
- fExpandBlock.showMenu();
- }
-
- /**
- * @return true if this item is expanded
- */
- boolean isMenuShown() {
- return fExpandBlock.isMenuShown();
- }
-
- /**
- * Returns the drop down shell.
- *
- * @return the shell of the drop down if shown, null otherwise
- */
- Shell getDropDownShell() {
- return fExpandBlock.getDropDownShell();
- }
-
- /**
- * Returns the bounds of this item.
- *
- * @return the bounds of this item
- */
- public Rectangle getBounds() {
- return fContainer.getBounds();
- }
-
- /**
- * Set the tool tip of the item to the given text.
- *
- * @param text the tool tip for the item
- */
- public void setToolTip(String text) {
- fDetailsBlock.setToolTip(text);
- }
-
- /*
- * @see org.eclipse.swt.widgets.Item#setText(java.lang.String)
- */
- @Override
- public void setText(String string) {
- super.setText(string);
- fDetailsBlock.setText(string);
-
- //more or less space might be required for the label
- if (fIsLast) {
- fContainer.layout(true, true);
- }
- }
-
- /*
- * @see org.eclipse.swt.widgets.Item#setImage(org.eclipse.swt.graphics.Image)
- */
- @Override
- public void setImage(Image image) {
- super.setImage(image);
- fDetailsBlock.setImage(image);
- }
-}
diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDetails.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDetails.java
deleted file mode 100644
index 14effd1e5fc..00000000000
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDetails.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Pawel Piech (Wind River) - adapted breadcrumb for use in Debug view (Bug 252677)
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.viewers.breadcrumb;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * The label and icon part of the breadcrumb item.
- *
- * @since 3.5
- */
-class BreadcrumbItemDetails {
-
- private final Label fElementImage;
- private final Label fElementText;
- private final Composite fDetailComposite;
- private final BreadcrumbItem fParent;
- private final Composite fTextComposite;
- private final Composite fImageComposite;
-
- private boolean fTextVisible;
- private boolean fSelected;
- private boolean fHasFocus;
-
-
- public BreadcrumbItemDetails(BreadcrumbItem parent, Composite parentContainer) {
- fParent= parent;
- fTextVisible= true;
-
- fDetailComposite= new Composite(parentContainer, SWT.NONE);
- fDetailComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
- GridLayout layout= new GridLayout(2, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.horizontalSpacing= 0;
- fDetailComposite.setLayout(layout);
- addElementListener(fDetailComposite);
-
- fImageComposite= new Composite(fDetailComposite, SWT.NONE);
- fImageComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
- layout= new GridLayout(1, false);
- layout.marginHeight= 1;
- layout.marginWidth= 2;
- fImageComposite.setLayout(layout);
- fImageComposite.addPaintListener(e -> {
- if (fHasFocus && !isTextVisible()) {
- e.gc.drawFocus(e.x, e.y, e.width, e.height);
- }
- });
- installFocusComposite(fImageComposite);
- addElementListener(fImageComposite);
-
- fElementImage= new Label(fImageComposite, SWT.NONE);
- GridData layoutData= new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
- fElementImage.setLayoutData(layoutData);
- addElementListener(fElementImage);
-
- fTextComposite= new Composite(fDetailComposite, SWT.NONE);
- fTextComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
- layout= new GridLayout(1, false);
- layout.marginHeight= 2;
- layout.marginWidth= 2;
- fTextComposite.setLayout(layout);
- addElementListener(fTextComposite);
- fTextComposite.addPaintListener(e -> {
- if (fHasFocus && isTextVisible()) {
- e.gc.drawFocus(e.x, e.y, e.width, e.height);
- }
- });
- installFocusComposite(fTextComposite);
- addElementListener(fTextComposite);
-
- fElementText= new Label(fTextComposite, SWT.NONE);
-
- layoutData= new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
- fElementText.setLayoutData(layoutData);
- addElementListener(fElementText);
-
- fTextComposite.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result= fElementText.getText();
- }
- });
- fImageComposite.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result= fElementText.getText();
- }
- });
-
- fDetailComposite.setTabList(new Control[] { fTextComposite });
-
- fDetailComposite.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailComposite"); //$NON-NLS-1$ //$NON-NLS-2$
- fTextComposite.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailTextComposite"); //$NON-NLS-1$ //$NON-NLS-2$
- fImageComposite.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailImageComposite"); //$NON-NLS-1$ //$NON-NLS-2$
- fElementImage.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailImageLabel"); //$NON-NLS-1$ //$NON-NLS-2$
- fElementText.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDetailTextLabel"); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- /**
- * Returns whether this element has the keyboard focus.
- *
- * @return true if this element has the keyboard focus.
- */
- public boolean hasFocus() {
- return fHasFocus;
- }
-
- /**
- * Sets the tool tip to the given text.
- *
- * @param text the tool tip
- */
- public void setToolTip(String text) {
- if (isTextVisible()) {
- fElementText.getParent().setToolTipText(text);
- fElementText.setToolTipText(text);
-
- fElementImage.setToolTipText(text);
- } else {
- fElementText.getParent().setToolTipText(null);
- fElementText.setToolTipText(null);
-
- fElementImage.setToolTipText(text);
- }
- }
-
- /**
- * Sets the image to the given image.
- *
- * @param image the image to use
- */
- public void setImage(Image image) {
- if (image != fElementImage.getImage()) {
- fElementImage.setImage(image);
- }
- }
-
- /**
- * Sets the text to the given text.
- *
- * @param text the text to use
- */
- public void setText(String text) {
- if (text == null) {
- text= ""; //$NON-NLS-1$
- }
- if (!text.equals(fElementText.getText())) {
- fElementText.setText(text);
- }
- }
-
- /**
- * Returns the width of this element.
- *
- * @return current width of this element
- */
- public int getWidth() {
- int result= 2;
-
- if (fElementImage.getImage() != null) {
- result+= fElementImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- }
-
- if (fTextVisible && fElementText.getText().length() > 0) {
- result+= fElementText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- }
-
- return result;
- }
-
- public void setTextVisible(boolean enabled) {
- if (fTextVisible == enabled) {
- return;
- }
-
- fTextVisible= enabled;
-
- GridData data= (GridData) fTextComposite.getLayoutData();
- data.exclude= !enabled;
- fTextComposite.setVisible(enabled);
-
- if (fTextVisible) {
- fDetailComposite.setTabList(new Control[] { fTextComposite });
- } else {
- fDetailComposite.setTabList(new Control[] { fImageComposite });
- }
-
- if (fHasFocus) {
- if (isTextVisible()) {
- fTextComposite.setFocus();
- } else {
- fImageComposite.setFocus();
- }
- }
- }
-
- /**
- * Tells whether this item shows a text or only an image.
- *
- * @return true if it shows a text and an image, false if it only shows the image
- */
- public boolean isTextVisible() {
- return fTextVisible;
- }
-
- public void setSelected(boolean selected) {
- if (selected == fSelected) {
- return;
- }
-
- fSelected= selected;
-
- }
-
- public void setFocus(boolean enabled) {
- if (enabled == fHasFocus) {
- return;
- }
-
- fHasFocus= enabled;
- if (fHasFocus) {
- if (isTextVisible()) {
- fTextComposite.setFocus();
- } else {
- fImageComposite.setFocus();
- }
- }
- }
-
- /**
- * Install focus and key listeners to the given composite.
- *
- * @param composite the composite which may get focus
- */
- private void installFocusComposite(Composite composite) {
- composite.addTraverseListener(e -> {
- if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
- int index= fParent.getViewer().getIndexOfItem(fParent);
- if (e.detail == SWT.TRAVERSE_TAB_NEXT) {
- index++;
- } else {
- index--;
- }
-
- if (index > 0 && index < fParent.getViewer().getItemCount()) {
- fParent.getViewer().selectItem(fParent.getViewer().getItem(index));
- }
-
- e.doit= true;
- }
- });
- composite.addKeyListener(new KeyListener() {
- @Override
- public void keyPressed(KeyEvent e) {
- BreadcrumbViewer viewer= fParent.getViewer();
-
- switch (e.keyCode) {
- case SWT.ARROW_LEFT:
- if (fSelected) {
- viewer.doTraverse(false);
- e.doit= false;
- } else {
- viewer.selectItem(fParent);
- }
- break;
- case SWT.ARROW_RIGHT:
- if (fSelected) {
- viewer.doTraverse(true);
- e.doit= false;
- } else {
- viewer.selectItem(fParent);
- }
- break;
- case SWT.ARROW_DOWN:
- case SWT.ARROW_UP:
- case SWT.KEYPAD_ADD:
- if (!fSelected) {
- viewer.selectItem(fParent);
- }
- openDropDown();
- e.doit= false;
- break;
- case SWT.CR:
- if (!fSelected) {
- viewer.selectItem(fParent);
- }
- viewer.fireOpen();
- break;
- default:
- if (e.character == ' ') {
- if (!fSelected) {
- viewer.selectItem(fParent);
- }
- openDropDown();
- e.doit= false;
- }
- break;
- }
- }
-
- private void openDropDown() {
- Shell shell = fParent.getDropDownShell();
- if (shell == null) {
- fParent.openDropDownMenu();
- shell = fParent.getDropDownShell();
- }
- shell.setFocus();
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
- });
-
- composite.addFocusListener(new FocusListener() {
- @Override
- public void focusGained(FocusEvent e) {
- if (!fHasFocus) {
- fHasFocus= true;
- }
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- if (fHasFocus) {
- fHasFocus= false;
- }
- }
- });
- }
-
- /**
- * Add mouse listeners to the given control.
- *
- * @param control the control to which may be clicked
- */
- private void addElementListener(Control control) {
- control.addMouseListener(new MouseListener() {
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- BreadcrumbViewer viewer= fParent.getViewer();
- Shell shell= fParent.getDropDownShell();
- viewer.selectItem(fParent);
- if (shell == null && e.button == 1 && e.stateMask == 0) {
- fParent.getViewer().fireDoubleClick();
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
- });
- control.addMenuDetectListener(e -> {
- BreadcrumbViewer viewer= fParent.getViewer();
- viewer.selectItem(fParent);
- fParent.getViewer().fireMenuDetect(e);
- });
- }
-}
diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java
deleted file mode 100644
index 55a6901854e..00000000000
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java
+++ /dev/null
@@ -1,610 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2025 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Pawel Piech (Wind River) - adapted breadcrumb for use in Debug view (Bug 252677)
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.viewers.breadcrumb;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.util.Util;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageDataProvider;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.PlatformUI;
-import org.osgi.framework.FrameworkUtil;
-
-
-/**
- * The part of the breadcrumb item with the drop down menu.
- *
- * @since 3.5
- */
-class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite {
-
- private static final boolean IS_MAC_WORKAROUND= "carbon".equals(SWT.getPlatform()); //$NON-NLS-1$
-
- /**
- * An arrow image descriptor. The images color is related to the list
- * fore- and background color. This makes the arrow visible even in high contrast
- * mode. If ltr is true the arrow points to the right, otherwise it
- * points to the left.
- */
- private final class AccessibleArrowImage extends CompositeImageDescriptor {
-
- private final static int ARROW_SIZE= 5;
-
- private final boolean fLTR;
-
- public AccessibleArrowImage(boolean ltr) {
- fLTR= ltr;
- }
-
- /*
- * @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int)
- */
- @Override
- protected void drawCompositeImage(int width, int height) {
- Display display= fParentComposite.getDisplay();
- ImageDataProvider imageProvider = zoom -> {
- Image image = new Image(display, ARROW_SIZE, ARROW_SIZE * 2);
-
- GC gc = new GC(image, fLTR ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT);
- gc.setAntialias(SWT.ON);
-
- Color triangleColor = createColor(SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 0.2, display);
- gc.setBackground(triangleColor);
- gc.fillPolygon(new int[] {
- 0, 0, ARROW_SIZE, ARROW_SIZE, 0, ARROW_SIZE * 2 });
- gc.dispose();
-
- ImageData imageData = image.getImageData(zoom);
- image.dispose();
- int zoomedArrowSize = ARROW_SIZE * zoom / 100;
- for (int y1 = 0; y1 < zoomedArrowSize; y1++) {
- // set opaque pixels for top half of the breadcrumb arrow
- for (int x1 = 0; x1 <= y1; x1++) {
- imageData.setAlpha(fLTR ? x1 : zoomedArrowSize - x1 - 1, y1, 255);
- }
- // set transparent pixels for top half of the breadcrumbe arrow
- for (int x1 = y1 + 1; x1 < zoomedArrowSize; x1++) {
- imageData.setAlpha(fLTR ? x1 : zoomedArrowSize - x1 - 1, y1, 0);
- }
- }
- for (int y2 = 0; y2 < zoomedArrowSize; y2++) {
- // set opaque pixels for bottom half of the breadcrumb arrow
- for (int x2 = 0; x2 <= y2; x2++) {
- imageData.setAlpha(fLTR ? x2 : zoomedArrowSize - x2 - 1, zoomedArrowSize * 2 - y2 - 1, 255);
- }
- // set transparent pixels for bottom half of the breadcrumbe arrow
- for (int x2 = y2 + 1; x2 < zoomedArrowSize; x2++) {
- imageData.setAlpha(fLTR ? x2 : zoomedArrowSize - x2 - 1, zoomedArrowSize * 2 - y2 - 1, 0);
- }
- }
- return imageData;
- };
- drawImage(imageProvider, (width / 2) - (ARROW_SIZE / 2), (height / 2) - ARROW_SIZE);
-
- }
-
- /*
- * @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize()
- */
- @Override
- protected Point getSize() {
- return new Point(10, 16);
- }
-
- private Color createColor(int color1, int color2, double weight, Display display) {
- RGB rgb1= display.getSystemColor(color1).getRGB();
- RGB rgb2= display.getSystemColor(color2).getRGB();
-
- return new Color(rgb1.blend(rgb2, weight));
- }
- }
-
- // Workaround for bug 258196: set the minimum size to 500 because on Linux
- // the size is not adjusted correctly in a virtual tree.
- private static final int DROP_DOWN_MIN_WIDTH= 500;
- private static final int DROP_DOWN_MAX_WIDTH= 501;
-
- private static final int DROP_DOWN_DEFAULT_MIN_HEIGHT= 100;
- private static final int DROP_DOWN_DEFAULT_MAX_HEIGHT= 500;
-
- private static final String DIALOG_SETTINGS= "BreadcrumbItemDropDown"; //$NON-NLS-1$
- private static final String DIALOG_HEIGHT= "height"; //$NON-NLS-1$
- private static final String DIALOG_WIDTH= "width"; //$NON-NLS-1$
-
- private final BreadcrumbItem fParent;
- private final Composite fParentComposite;
- private final ToolBar fToolBar;
-
- private boolean fMenuIsShown;
- private boolean fEnabled;
- private Shell fShell;
- private boolean fIsResizingProgrammatically;
- private int fCurrentWidth = -1;
- private int fCurrentHeight = -1;
-
-
- public BreadcrumbItemDropDown(BreadcrumbItem parent, Composite composite) {
- fParent= parent;
- fParentComposite= composite;
- fMenuIsShown= false;
- fEnabled= true;
-
- fToolBar= new ToolBar(composite, SWT.FLAT);
- fToolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
- fToolBar.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result= BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip;
- }
- });
- ToolBarManager manager= new ToolBarManager(fToolBar);
-
- final Action showDropDownMenuAction= new Action(null, SWT.NONE) {
- @Override
- public void run() {
- Shell shell= fParent.getDropDownShell();
- if (shell != null) {
- return;
- }
-
- shell= fParent.getViewer().getDropDownShell();
- if (shell != null && !shell.isDisposed()) {
- shell.close();
- }
-
- showMenu();
-
- fShell.setFocus();
- }
- };
-
- showDropDownMenuAction.setImageDescriptor(new AccessibleArrowImage(isLeft()));
- showDropDownMenuAction.setToolTipText(BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip);
- manager.add(showDropDownMenuAction);
-
- manager.update(true);
- if (IS_MAC_WORKAROUND) {
- manager.getControl().addMouseListener(new MouseAdapter() {
- // see also BreadcrumbItemDetails#addElementListener(Control)
- @Override
- public void mouseDown(MouseEvent e) {
- showDropDownMenuAction.run();
- }
- });
- }
- fToolBar.setData("org.eclipse.e4.ui.css.id", "DebugBreadcrumbItemDropDownToolBar"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Return the width of this element.
- *
- * @return the width of this element
- */
- public int getWidth() {
- return fToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- }
-
- /**
- * Set whether the drop down menu is available.
- *
- * @param enabled true if available
- */
- public void setEnabled(boolean enabled) {
- fEnabled= enabled;
-
- fToolBar.setVisible(enabled);
- }
-
- /**
- * Tells whether the menu is shown.
- *
- * @return true if the menu is open
- */
- public boolean isMenuShown() {
- return fMenuIsShown;
- }
-
- /**
- * Returns the shell used for the drop down menu if it is shown.
- *
- * @return the drop down shell or null
- */
- public Shell getDropDownShell() {
- if (!isMenuShown()) {
- return null;
- }
-
- return fShell;
- }
-
- /**
- * Opens the drop down menu.
- */
- public void showMenu() {
- if (DebugUIPlugin.DEBUG_BREADCRUMB) {
- DebugUIPlugin.trace("BreadcrumbItemDropDown.showMenu()"); //$NON-NLS-1$
- }
-
- if (!fEnabled || fMenuIsShown) {
- return;
- }
-
- fMenuIsShown= true;
-
- fShell= new Shell(fToolBar.getShell(), SWT.RESIZE | SWT.TOOL | SWT.ON_TOP);
- if (DebugUIPlugin.DEBUG_BREADCRUMB) {
- DebugUIPlugin.trace(" creating new shell"); //$NON-NLS-1$
- }
-
- fShell.addControlListener(new ControlAdapter() {
- /*
- * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent)
- */
- @Override
- public void controlResized(ControlEvent e) {
- if (fIsResizingProgrammatically) {
- return;
- }
-
- Point size= fShell.getSize();
- fCurrentWidth = size.x;
- fCurrentHeight = size.y;
- getDialogSettings().put(DIALOG_WIDTH, size.x);
- getDialogSettings().put(DIALOG_HEIGHT, size.y);
- }
- });
-
- 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);
-
- TreePath path= fParent.getPath();
-
- Control control = fParent.getViewer().createDropDown(composite, this, path);
-
- control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- setShellBounds(fShell);
- fShell.setVisible(true);
- installCloser(fShell);
- }
-
- /**
- * The closer closes the given shell when the focus is lost.
- *
- * @param shell the shell to install the closer to
- */
- private void installCloser(final Shell shell) {
- final Listener focusListener= event -> {
- Widget focusElement= event.widget;
- boolean isFocusBreadcrumbTreeFocusWidget= focusElement == shell || focusElement instanceof Control && ((Control)focusElement).getShell() == shell;
- boolean isFocusWidgetParentShell= focusElement instanceof Control && ((Control)focusElement).getShell().getParent() == shell;
-
- switch (event.type) {
- case SWT.FocusIn:
- if (DebugUIPlugin.DEBUG_BREADCRUMB) {
- DebugUIPlugin.trace("focusIn - is breadcrumb tree: " + isFocusBreadcrumbTreeFocusWidget); //$NON-NLS-1$
- }
-
- if (!isFocusBreadcrumbTreeFocusWidget && !isFocusWidgetParentShell) {
- if (DebugUIPlugin.DEBUG_BREADCRUMB) {
- DebugUIPlugin.trace("==> closing shell since focus in other widget"); //$NON-NLS-1$
- }
- shell.close();
- }
- break;
-
- case SWT.FocusOut:
- if (DebugUIPlugin.DEBUG_BREADCRUMB) {
- DebugUIPlugin.trace("focusOut - is breadcrumb tree: " + isFocusBreadcrumbTreeFocusWidget); //$NON-NLS-1$
- }
- if (event.display.getActiveShell() == null) {
- if (DebugUIPlugin.DEBUG_BREADCRUMB) {
- DebugUIPlugin.trace("==> closing shell since event.display.getActiveShell() != shell"); //$NON-NLS-1$
- }
- shell.close();
- }
- break;
-
- default:
- Assert.isTrue(false);
- }
- };
-
- final Display display= shell.getDisplay();
- display.addFilter(SWT.FocusIn, focusListener);
- display.addFilter(SWT.FocusOut, focusListener);
-
- final ControlListener controlListener= new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- if (!shell.isDisposed()) {
- shell.close();
- }
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- if (!shell.isDisposed()) {
- shell.close();
- }
- }
- };
- fToolBar.getShell().addControlListener(controlListener);
-
- shell.addDisposeListener(e -> {
- if (DebugUIPlugin.DEBUG_BREADCRUMB) {
- DebugUIPlugin.trace("==> shell disposed"); //$NON-NLS-1$
- }
-
- display.removeFilter(SWT.FocusIn, focusListener);
- display.removeFilter(SWT.FocusOut, focusListener);
-
- if (!fToolBar.isDisposed()) {
- fToolBar.getShell().removeControlListener(controlListener);
- }
- });
- shell.addShellListener(new ShellListener() {
- @Override
- public void shellActivated(ShellEvent e) {
- }
-
- @Override
- public void shellClosed(ShellEvent e) {
- if (DebugUIPlugin.DEBUG_BREADCRUMB) {
- DebugUIPlugin.trace("==> shellClosed"); //$NON-NLS-1$
- }
- if (!fMenuIsShown) {
- return;
- }
-
- fMenuIsShown= false;
- }
-
- @Override
- public void shellDeactivated(ShellEvent e) {
- }
-
- @Override
- public void shellDeiconified(ShellEvent e) {
- }
-
- @Override
- public void shellIconified(ShellEvent e) {
- }
- });
- }
-
- private IDialogSettings getDialogSettings() {
- IDialogSettings javaSettings = PlatformUI
- .getDialogSettingsProvider(FrameworkUtil.getBundle(BreadcrumbItemDropDown.class)).getDialogSettings();
- IDialogSettings settings= javaSettings.getSection(DIALOG_SETTINGS);
- if (settings == null) {
- settings= javaSettings.addNewSection(DIALOG_SETTINGS);
- }
- return settings;
- }
-
- private int getMaxWidth() {
- try {
- return getDialogSettings().getInt(DIALOG_WIDTH);
- } catch (NumberFormatException e) {
- return DROP_DOWN_MAX_WIDTH;
- }
- }
-
- private int getMaxHeight() {
- try {
- return getDialogSettings().getInt(DIALOG_HEIGHT);
- } catch (NumberFormatException e) {
- return DROP_DOWN_DEFAULT_MAX_HEIGHT;
- }
- }
-
- /**
- * Calculates a useful size for the given shell.
- *
- * @param shell the shell to calculate the size for.
- */
- private void setShellBounds(Shell shell) {
-
- Rectangle rect= fParentComposite.getBounds();
- Rectangle toolbarBounds= fToolBar.getBounds();
-
- Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
- int height= Math.max(Math.min(size.y, getMaxHeight()), DROP_DOWN_DEFAULT_MIN_HEIGHT);
- int width= Math.max(getMaxWidth(), DROP_DOWN_MIN_WIDTH);
-
- int imageBoundsX= 0;
- if (fParent.getImage() != null) {
- imageBoundsX= fParent.getImage().getImageData().width;
- }
-
- Rectangle trim= fShell.computeTrim(0, 0, width, height);
- int x= toolbarBounds.x + toolbarBounds.width + 2 + trim.x - imageBoundsX;
- if (!isLeft()) {
- x+= width;
- }
-
- int y = rect.y;
- if (isTop()) {
- y+= rect.height;
- } else {
- y-= height;
- }
-
- Point pt= new Point(x, y);
- pt= fParentComposite.toDisplay(pt);
-
- Rectangle monitor = Util.getClosestMonitor(shell.getDisplay(), pt).getClientArea();
- int overlap= (pt.x + width) - (monitor.x + monitor.width);
- if (overlap > 0) {
- pt.x-= overlap;
- }
- if (pt.x < monitor.x) {
- pt.x= monitor.x;
- }
-
- shell.setLocation(pt);
- fIsResizingProgrammatically= true;
- try {
- shell.setSize(width, height);
- fCurrentWidth = width;
- fCurrentHeight = height;
- } finally {
- fIsResizingProgrammatically= false;
- }
- }
-
- /**
- * Set the size of the given shell such that more content can be shown. The shell size does not
- * exceed a user-configurable maximum.
- *
- * @param shell the shell to resize
- */
- private void resizeShell(final Shell shell) {
- int maxHeight= getMaxHeight();
- int maxWidth = getMaxWidth();
-
- if (fCurrentHeight >= maxHeight && fCurrentWidth >= maxWidth) {
- return;
- }
-
- Point preferedSize= shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
-
- int newWidth;
- if (fCurrentWidth >= DROP_DOWN_MAX_WIDTH) {
- newWidth= fCurrentWidth;
- } else {
- // Workaround for bug 319612: Do not resize width below the
- // DROP_DOWN_MIN_WIDTH. This can happen because the Shell.getSize()
- // is incorrectly small on Linux.
- newWidth= Math.min(Math.max(Math.max(preferedSize.x, fCurrentWidth), DROP_DOWN_MIN_WIDTH), maxWidth);
- }
- int newHeight;
- if (fCurrentHeight >= maxHeight) {
- newHeight= fCurrentHeight;
- } else {
- newHeight= Math.min(Math.max(preferedSize.y, fCurrentHeight), maxHeight);
- }
-
- if (newHeight != fCurrentHeight || newWidth != fCurrentWidth) {
- shell.setRedraw(false);
- try {
- fIsResizingProgrammatically= true;
- shell.setSize(newWidth, newHeight);
- fCurrentWidth = newWidth;
- fCurrentHeight = newHeight;
-
- Point location = shell.getLocation();
- Point newLocation = location;
- if (!isLeft()) {
- newLocation = new Point(newLocation.x - (newWidth - fCurrentWidth), newLocation.y);
- }
- if (!isTop()) {
- newLocation = new Point(newLocation.x, newLocation.y - (newHeight - fCurrentHeight));
- }
- if (!location.equals(newLocation)) {
- shell.setLocation(newLocation.x, newLocation.y);
- }
- } finally {
- fIsResizingProgrammatically= false;
- shell.setRedraw(true);
- }
- }
- }
-
- /**
- * Tells whether this the breadcrumb is in LTR mode or RTL mode. Or whether the breadcrumb
- * is on the right-side status coolbar, which has the same effect on layout.
- *
- * @return true if the breadcrumb in left-to-right mode, false
- * otherwise
- */
- private boolean isLeft() {
- return (fParentComposite.getStyle() & SWT.RIGHT_TO_LEFT) == 0 &&
- (fParent.getViewer().getStyle() & SWT.RIGHT) == 0;
- }
-
- /**
- * Tells whether this the breadcrumb is in LTR mode or RTL mode. Or whether the breadcrumb
- * is on the right-side status coolbar, which has the same effect on layout.
- *
- * @return true if the breadcrumb in left-to-right mode, false
- * otherwise
- */
- private boolean isTop() {
- return (fParent.getViewer().getStyle() & SWT.BOTTOM) == 0;
- }
-
- @Override
- public void close() {
- if (fShell != null && !fShell.isDisposed()) {
- fShell.close();
- }
- }
-
- @Override
- public void notifySelection(ISelection selection) {
- fParent.getViewer().fireMenuSelection(selection);
- }
-
- @Override
- public void updateSize() {
- if (fShell != null && !fShell.isDisposed()) {
- resizeShell(fShell);
- }
- }
-}
-
diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbMessages.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbMessages.java
deleted file mode 100644
index 5040f399cb4..00000000000
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbMessages.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Pawel Piech (Wind River) - adapted breadcrumb for use in Debug view (Bug 252677)
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.viewers.breadcrumb;
-
-import org.eclipse.osgi.util.NLS;
-
-
-/**
- * Helper class to get NLSed messages.
- *
- * @since 3.5
- */
-public class BreadcrumbMessages extends NLS {
-
- private static final String BUNDLE_NAME= BreadcrumbMessages.class.getName();
-
- public static String BreadcrumbItemDropDown_showDropDownMenu_action_toolTip;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, BreadcrumbMessages.class);
- }
-
- private BreadcrumbMessages() {
- }
-}
diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbMessages.properties b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbMessages.properties
deleted file mode 100644
index c2e61cf1e1b..00000000000
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbMessages.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2008, 2009 IBM Corporation and others.
-#
-# This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License 2.0
-# which accompanies this distribution, and is available at
-# https://www.eclipse.org/legal/epl-2.0/
-#
-# SPDX-License-Identifier: EPL-2.0
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# Pawel Piech (Wind River) - adapted breadcrumb for use in Debug view (Bug 252677)
-###############################################################################
-
-BreadcrumbItemDropDown_showDropDownMenu_action_toolTip=Show Children
diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java
deleted file mode 100644
index da024b76f6c..00000000000
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java
+++ /dev/null
@@ -1,778 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2018 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Pawel Piech (Wind River) - adapted breadcrumb for use in Debug view (Bug 252677)
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.viewers.breadcrumb;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ITreePathContentProvider;
-import org.eclipse.jface.viewers.ITreePathLabelProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.ViewerLabel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.MenuDetectEvent;
-import org.eclipse.swt.events.MenuDetectListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * A breadcrumb viewer shows a the parent chain of its input element in a list. Each breadcrumb item
- * of that list can be expanded and a sibling of the element presented by the breadcrumb item can be
- * selected.
- *
- * Content providers for breadcrumb viewers must implement the ITreePathContentProvider
- * interface.
- *
- * Label providers for breadcrumb viewers must implement the ITreePathLabelProvider interface.
- *
BreadcrumbViewer.
- * - * Style is one of: - *
null
- * if no drop down is shown at the moment.
- *
- * @return the drop downs shell or null
- */
- public Shell getDropDownShell() {
- for (BreadcrumbItem item : fBreadcrumbItems) {
- if (item.isMenuShown()) {
- return item.getDropDownShell();
- }
- }
-
- return null;
- }
-
- /**
- * Add the given listener to the set of listeners which will be informed
- * when a context menu is requested for a breadcrumb item.
- *
- * @param listener the listener to add
- */
- public void addMenuDetectListener(MenuDetectListener listener) {
- fMenuListeners.add(listener);
- }
-
- /**
- * Remove the given listener from the set of menu detect listeners.
- * Does nothing if the listener is not element of the set.
- *
- * @param listener the listener to remove
- */
- public void removeMenuDetectListener(MenuDetectListener listener) {
- fMenuListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.jface.viewers.StructuredViewer#assertContentProviderType(org.eclipse.jface.viewers.IContentProvider)
- */
- @Override
- protected void assertContentProviderType(IContentProvider provider) {
- super.assertContentProviderType(provider);
- Assert.isTrue(provider instanceof ITreePathContentProvider);
- }
-
- /*
- * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object, java.lang.Object)
- */
- @Override
- protected void inputChanged(final Object input, Object oldInput) {
- if (fContainer.isDisposed()) {
- return;
- }
-
- disableRedraw();
- try {
- preservingSelection(() -> buildItemChain(input));
- } finally {
- enableRedraw();
- }
- }
-
- /*
- * @see org.eclipse.jface.viewers.StructuredViewer#doFindInputItem(java.lang.Object)
- */
- @Override
- protected Widget doFindInputItem(Object element) {
- if (element == null) {
- return null;
- }
-
- if (element == getInput() || element.equals(getInput())) {
- return doFindItem(element);
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.StructuredViewer#doFindItem(java.lang.Object)
- */
- @Override
- protected Widget doFindItem(Object element) {
- if (element == null) {
- return null;
- }
-
- for (BreadcrumbItem item : fBreadcrumbItems) {
- if (item.getData() == element || element.equals(item.getData())) {
- return item;
- }
- }
-
- return null;
- }
-
- /*
- * @see org.eclipse.jface.viewers.StructuredViewer#doUpdateItem(org.eclipse.swt.widgets.Widget, java.lang.Object, boolean)
- */
- @Override
- protected void doUpdateItem(Widget widget, Object element, boolean fullMap) {
- myDoUpdateItem(widget, element, fullMap);
- }
-
- private boolean myDoUpdateItem(Widget widget, Object element, boolean fullMap) {
- if (widget instanceof final BreadcrumbItem item) {
- // remember element we are showing
- if (fullMap) {
- associate(element, item);
- } else {
- Object data= item.getData();
- if (data != null) {
- unmapElement(data, item);
- }
- item.setData(element);
- mapElement(element, item);
- }
-
- refreshItem(item);
- }
- return false;
- }
-
- /**
- * This implementation of getSelection() returns an instance of
- * ITreeSelection.
- * @return the current selection
- */
- @Override
- public ISelection getSelection() {
- Control control = getControl();
- if (control == null || control.isDisposed()) {
- return TreeSelection.EMPTY;
- }
- if (fSelectedItem != null) {
- TreePath path = getTreePathFromItem(fSelectedItem);
- if (path != null) {
- return new TreeSelection(new TreePath[] { path });
- }
- }
- return TreeSelection.EMPTY;
- }
-
- protected TreePath getTreePathFromItem(BreadcrumbItem item) {
- List