Author: snjeza
Date: 2011-10-27 14:33:37 -0400 (Thu, 27 Oct 2011)
New Revision: 36052
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/FeedsToolTip.java
Log:
JBIDE-10042 Tooltip for feeds in central shows up even though central does not have focus
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/FeedsToolTip.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/FeedsToolTip.java 2011-10-27
17:18:43 UTC (rev 36051)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/FeedsToolTip.java 2011-10-27
18:33:37 UTC (rev 36052)
@@ -18,6 +18,7 @@
import org.eclipse.swt.browser.WindowEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.graphics.Font;
@@ -32,6 +33,7 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.FormText;
/**
@@ -42,60 +44,7 @@
public class FeedsToolTip extends ToolTip {
private String toolText;
- private static Shell CURRENT_TOOLTIP;
- private Label hintLabel;
- private FormText formText;
- private int x;
- private int y;
- private boolean focused = false;
-// private Listener deactivateListener = new Listener() {
-//
-// @Override
-// public void handleEvent(Event event) {
-// if (focused) {
-// if (CURRENT_TOOLTIP != null) {
-// CURRENT_TOOLTIP.dispose();
-// CURRENT_TOOLTIP = null;
-// }
-// activate();
-// hide();
-// focused = false;
-// }
-// }
-// };
-
- private MouseMoveListener mouseMoveListener = new MouseMoveListener() {
- public void mouseMove(MouseEvent e) {
- x = e.x;
- y = e.y;
- }
- };
- private Listener keyListener = new Listener() {
-
- @Override
- public void handleEvent(Event e) {
- if (e == null)
- return;
- if (e.keyCode == SWT.ESC) {
- if (CURRENT_TOOLTIP != null) {
- CURRENT_TOOLTIP.dispose();
- CURRENT_TOOLTIP = null;
- }
- activate();
- focused = false;
- }
- if (e.keyCode == SWT.F2) {
- if (CURRENT_TOOLTIP == null) {
- deactivate();
- hide();
- }
- focused = true;
- createFocusedTooltip(FeedsToolTip.this.formText);
- }
- }
- };
-
public FeedsToolTip(FormText formText, String toolText) {
super(formText);
this.toolText = "<html>" +
@@ -110,67 +59,24 @@
toolText +
"</body>" +
"</html>";
- this.formText = formText;
- setShift(new Point(0, 15));
+ setShift(new Point(0, 0));
setPopupDelay(400);
- setHideOnMouseDown(true);
+ setHideOnMouseDown(false);
}
- public void createFocusedTooltip(final Control control) {
- final Shell stickyTooltip = new Shell(control.getShell(), SWT.ON_TOP | SWT.TOOL
- | SWT.NO_FOCUS);
- stickyTooltip.setLayout(new GridLayout());
- //stickyTooltip.setBackground(stickyTooltip.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- control.getDisplay().asyncExec(new Runnable() {
- public void run() {
- Event event = new Event();
- event.x = x;
- event.y = y;
- event.widget = control;
-
- createToolTipContentArea(event, stickyTooltip);
- stickyTooltip.pack();
-
- stickyTooltip.setLocation(stickyTooltip.getDisplay().getCursorLocation());
- hintLabel.setText("Press 'ESC' to Hide.");
- stickyTooltip.setVisible(true);
- }
- });
- CURRENT_TOOLTIP = stickyTooltip;
- }
-
@Override
- protected Composite createToolTipContentArea(Event event, Composite parent) {
- if (!focused) {
- formText.setFocus();
- }
-// if (formText.getShell() != null) {
-// formText.getShell().addListener(SWT.Deactivate, deactivateListener);
-// }
- formText.addMouseMoveListener(mouseMoveListener);
- formText.addListener(SWT.KeyDown, keyListener);
-
- parent.addDisposeListener(new DisposeListener() {
-
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (formText != null && !formText.isDisposed()) {
- formText.removeMouseMoveListener(mouseMoveListener);
- formText.removeListener(SWT.KeyDown, keyListener);
-// if (formText.getShell() != null && !formText.getShell().isDisposed()) {
-// formText.getShell().removeListener(SWT.Deactivate, deactivateListener);
-// }
- }
- }
- });
-
+ protected Composite createToolTipContentArea(Event event, Composite parent) {
parent.setLayout(new GridLayout());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
parent.setLayoutData(gd);
- Browser browser = new Browser(parent, SWT.NONE);
+ Browser browser;
+ try {
+ browser = new Browser(parent, SWT.NONE);
+ } catch (Exception e1) {
+ browser = new Browser(parent, SWT.WEBKIT);
+ }
browser.setJavascriptEnabled(false);
browser.addOpenWindowListener(new OpenWindowListener() {
public void open(WindowEvent event) {
@@ -183,29 +89,6 @@
browser.setLayoutData(gd);
browser.setText(toolText);
- hintLabel = new Label(parent, SWT.NONE);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- hintLabel.setLayoutData(gd);
- hintLabel.setAlignment(SWT.RIGHT);
- hintLabel.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- hintLabel.setText("Press 'F2' for Focus.");
- hintLabel.setForeground(parent.getDisplay().getSystemColor(
- SWT.COLOR_DARK_GRAY));
-
- final Font font;
- Display display = parent.getDisplay();
- FontData[] fd = parent.getFont().getFontData();
- int size2 = fd.length;
- for (int i = 0; i < size2; i++)
- fd[i].setHeight(7);
- font = new Font(display, fd);
- parent.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- font.dispose();
- }
- });
- hintLabel.setFont(font);
return parent;
}
Show replies by date