[197541] Tooltip support
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/GeneralToolTip.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/GeneralToolTip.java
index 7583b37..ff863ee 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/GeneralToolTip.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/GeneralToolTip.java
@@ -28,7 +28,6 @@
s += server.getRuntime().getName() + " - ";
s += server.getModules().length + " modules";
text.setText(s);
- text.setCapture(true);
return parent;
}
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java
index d373827..41459ce 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java
@@ -28,6 +28,10 @@
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
@@ -37,6 +41,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.wst.server.core.IServerType;
@@ -45,59 +50,111 @@
import org.eclipse.wst.server.core.internal.Trace;
import org.eclipse.wst.server.ui.IServerToolTip;
+
+
public class ServerToolTip extends ToolTip {
+ protected Hashtable<String,ArrayList> toolTipProviders = new Hashtable<String,ArrayList>();
+ protected static Shell CURRENT_TOOLTIP;
+ private Label hintLabel;
protected Server server;
- protected Hashtable<String,ArrayList> toolTipProviders = new Hashtable<String,ArrayList>();
- protected boolean shouldHide = true;
protected Tree tree;
- protected final static int MARGIN = 5;
-// final ServerToolTip instance;
-// Shell tip;
+ private int x;
+ private int y;
+
public ServerToolTip(final Control control) {
super(control);
if (control instanceof Tree) {
tree =(Tree)control;
- }
-// This is and the rest of the commented code is a hack to see if I can try to stop the hiding of the tooltip when the mouse exits the area
-// instance=this;
-// control.addKeyListener(new KeyListener(){
-//
-// public void keyPressed(KeyEvent e) {
-// System.out.println(e.character);
-// if (e.keyCode == SWT.F3){
-// shouldHide = false;
-// deactivate();
-// }
-// if (e.keyCode == SWT.ESC){
-// show(new Point(0,0));
-// hide();
-// }
-//
-// }
-//
-// public void deactivate(){
-// try{
-// final Method method = ToolTip.class.getDeclaredMethod( "toolTipHookByTypeRecursively", Control.class,boolean.class,int.class); //$NON-NLS-1$
-// method.setAccessible( true );
-// method.invoke( instance, tip, false,SWT.MouseExit );
-// System.out.println("hello");
-// }
-// catch (Exception e){
-// e.printStackTrace();
-// }
-// }
-// public void keyReleased(KeyEvent e) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// });
+ }
+
+ control.addMouseMoveListener(new MouseMoveListener(){
+
+ public void mouseMove(MouseEvent e) {
+ x=e.x;
+ y=e.y;
+ }
+
+ });
+
+ control.addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent e) {
+ if (e.keyCode == SWT.ESC){
+ System.out.println("[ESC]");
+ CURRENT_TOOLTIP.setVisible(false);
+ CURRENT_TOOLTIP.dispose();
+ activate();
+
+ }
+ if (e.keyCode == SWT.F3){
+ System.out.println("[F3]");
+ deactivate();
+ hide();
+ createFocusedTooltip(control);
+ }
+ }
+ public void keyReleased(KeyEvent e){
+ // nothing to do
+ }
+ });
+
+
+
loadExtensions();
}
+
+ protected void createFocusedTooltip(final Control control){
+ final Shell stickyTooltip = new Shell(control.getShell(), SWT.ON_TOP | SWT.TOOL
+ | SWT.NO_FOCUS);
+ stickyTooltip.setLayout(new FillLayout());
+ 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= tree;
+
+ createToolTipContentArea(event,stickyTooltip);
+ stickyTooltip.pack();
+
+ stickyTooltip.setLocation(stickyTooltip.getDisplay().getCursorLocation());
+ hintLabel.setText(Messages.toolTipDisableFocus);
+ stickyTooltip.setVisible(true);
+// Eventually we want to add a listener that checks if
+// the mouseDown event is ocurring outside of the bounds of the tooltip
+// if it is, then hide the tooltip
+// addListener(stickyTooltip);
+ }
+ });
+ CURRENT_TOOLTIP = stickyTooltip;
+
+
+ }
+
+// read the createFocusedTooltip method for information on why this is commented out
+//
+// private void addListener(Control control){
+// control.addMouseListener(new StickyTipMouseListener());
+// if (control instanceof Composite){
+// Control[] childrens = ((Composite)control).getChildren();
+// for (Control child :childrens){
+// addListener(child);
+// }
+// }
+//
+// }
+
+
+ @Override
+ protected Object getToolTipArea(Event event) {
+ Object o = tree.getItem(new Point(event.x,event.y));
+ return o;
+ }
protected Composite createToolTipContentArea(Event event, Composite parent) {
-// tip = parent.getShell();
+
Object o = tree.getItem(new Point(event.x,event.y));
if (o == null) {
hide();
@@ -128,14 +185,14 @@
for (IServerToolTip tipProvider : listOfProviders){
tipProvider.createContent(adoptersComposite,server);
}
- }
+ }
// Add the F3 text
- Label label = new Label(parent,SWT.BORDER);
- label.setAlignment(SWT.RIGHT);
- label.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- label.setText(Messages.toolTipEnableFocus);
- label.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+ hintLabel = new Label(parent,SWT.BORDER);
+ hintLabel.setAlignment(SWT.RIGHT);
+ hintLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ hintLabel.setText(Messages.toolTipEnableFocus);
+ hintLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
final Font font;
Display display = parent.getDisplay();
@@ -149,14 +206,15 @@
font.dispose();
}
});
- label.setFont(font);
+ hintLabel.setFont(font);
parseText(sText.getText(),sText);
-
+
return parent;
}
+
- public void parseText(String htmlText,StyledText sText){
+ protected void parseText(String htmlText,StyledText sText){
TextPresentation presentation = new TextPresentation();
HTML2TextReader reader = new HTML2TextReader(new StringReader(htmlText), presentation);
String text;
@@ -210,10 +268,30 @@
}
}
-// @Override
-// public void hide() {
-// if (shouldHide == true || !sText.isFocusControl()){
-// super.hide();
+// read the createFocusedTooltip method for information on why this is commented out
+//
+// protected class StickyTipMouseListener implements MouseListener{
+//
+// public void mouseDoubleClick(MouseEvent e) {
+// // TODO Auto-generated method stub
+//
// }
-// }
+//
+// public void mouseDown(MouseEvent e) {
+// //System.out.println("mouseDown");
+// if (CURRENT_TOOLTIP.getBounds().contains(new Point(e.x,e.y)) == true){
+// CURRENT_TOOLTIP.setVisible(false);
+// CURRENT_TOOLTIP.dispose();
+// activate();
+// CURRENT_TOOLTIP.removeMouseListener(this);
+// }
+// }
+//
+// public void mouseUp(MouseEvent e) {
+// // TODO Auto-generated method stub
+//
+// }
+//
+// }
+
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java
index 04b4e66..be5024f 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java
@@ -212,8 +212,8 @@
toolTip = new ServerToolTip(treeTable);
toolTip.setShift(new Point(-5, -5));
// time is in miliseconds
- toolTip.setPopupDelay(100);
- toolTip.setHideOnMouseDown(false);
+ toolTip.setPopupDelay(200);
+ toolTip.setHideOnMouseDown(true);
toolTip.activate();
}