Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Torregrosa Paez2015-08-05 08:30:01 -0400
committerPablo Torregrosa Paez2015-08-07 08:45:49 -0400
commita9df2024f5f407b764972faf520b764cefb2c424 (patch)
tree74d4cb509945ef0019ba9718f42967c70a2dd347
parent53a474aee39d4bf9fb5614167f3059e560c47b86 (diff)
downloadorg.eclipse.tcf-a9df2024f5f407b764972faf520b764cefb2c424.tar.gz
org.eclipse.tcf-a9df2024f5f407b764972faf520b764cefb2c424.tar.xz
org.eclipse.tcf-a9df2024f5f407b764972faf520b764cefb2c424.zip
Target Explorer: Keep customized toolbar within the screen bounds.
Change-Id: Ie5ab9cf42158882127119a1d3dc5faf841538acc Signed-off-by: Pablo Torregrosa Paez <pablo.torregrosa@windriver.com>
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java30
1 files changed, 14 insertions, 16 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java
index 9c6809176..0fe762e3e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java
@@ -34,8 +34,6 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener;
@@ -46,6 +44,7 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
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.Button;
@@ -117,7 +116,6 @@ implements IWorkbenchContribution, IEventListener, IPeerModelListener, IProperty
private boolean clickRunning = false;
private final RGB lightYellowRgb = new RGB(255, 250, 150); // Warning background color
- /* default */ Color lightYellowColor = null;
private enum PanelStyle {DEFAULT,WARNING} // Color styles
/* default */ Color warningBackgroundColor = null;
@@ -161,17 +159,6 @@ implements IWorkbenchContribution, IEventListener, IPeerModelListener, IProperty
layout.marginHeight = 1; layout.marginWidth = 1;
panel.setLayout(layout);
- // Create the warning background color
- lightYellowColor = new Color(PlatformUI.getWorkbench().getDisplay(), lightYellowRgb);
- // Add a dispose listener to the panel to also dispose the color resource
- panel.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- lightYellowColor.dispose();
- lightYellowColor = null;
- }
- });
-
initThemeColors();
labelPanel = new Composite(panel, SWT.BORDER);
@@ -655,7 +642,7 @@ implements IWorkbenchContribution, IEventListener, IPeerModelListener, IProperty
/**
* Calculates the position where the tooltip should be, considering
- * the current cursos position.
+ * the current cursor position.
* @param e
* @return
*/
@@ -664,6 +651,15 @@ implements IWorkbenchContribution, IEventListener, IPeerModelListener, IProperty
if (e.widget instanceof Control) {
p = ((Control) e.widget).toDisplay(e.x, e.y);
+ Point shellSize = customTooltipShell.getSize();
+ Rectangle screenBounds = ((Control) e.widget).getDisplay().getBounds();
+ // Keeps the tooltip inside the screen bounds
+ if (p.x + shellSize.x > screenBounds.width) {
+ p.x -= (p.x + shellSize.x - screenBounds.width);
+ if (p.x < 0) {
+ p.x = 0;
+ }
+ }
p.y += CURSOR_HEIGHT;
}
@@ -721,7 +717,9 @@ implements IWorkbenchContribution, IEventListener, IPeerModelListener, IProperty
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
- customTooltipShell.setVisible(false);
+ if (customTooltipShell!=null) {
+ customTooltipShell.setVisible(false);
+ }
}
});
}

Back to the top