Exemplo n.º 1
0
 private org.eclipse.swt.widgets.ToolItem addToolItem(
     final org.eclipse.swt.widgets.ToolBar toolbar,
     final org.eclipse.swt.examples.paint.Tool tool) {
   final java.lang.String id = tool.group + '.' + tool.name;
   org.eclipse.swt.widgets.ToolItem item =
       new org.eclipse.swt.widgets.ToolItem(toolbar, tool.type);
   item.setText(getResourceString(id + ".label"));
   item.setToolTipText(getResourceString(id + ".tooltip"));
   item.setImage(tool.image);
   item.addSelectionListener(
       new org.eclipse.swt.events.SelectionAdapter() {
         public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
           tool.action.run();
         }
       });
   final int childID = toolbar.indexOf(item);
   toolbar
       .getAccessible()
       .addAccessibleListener(
           new org.eclipse.swt.accessibility.AccessibleAdapter() {
             public void getName(org.eclipse.swt.accessibility.AccessibleEvent e) {
               if (e.childID == childID) {
                 e.result = getResourceString(id + ".description");
               }
             }
           });
   return item;
 }
Exemplo n.º 2
0
 private void createToolBar(org.eclipse.swt.widgets.Composite parent) {
   org.eclipse.swt.widgets.ToolBar toolbar = new org.eclipse.swt.widgets.ToolBar(parent, SWT.NONE);
   java.lang.String group = null;
   for (int i = 0; i < tools.length; i++) {
     org.eclipse.swt.examples.paint.Tool tool = tools[i];
     if (group != null && !tool.group.equals(group)) {
       new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.SEPARATOR);
     }
     group = tool.group;
     org.eclipse.swt.widgets.ToolItem item = addToolItem(toolbar, tool);
     if (i == Default_tool || i == Default_fill || i == Default_linestyle) {
       item.setSelection(true);
     }
   }
 }
Exemplo n.º 3
0
 public void createPartControl(org.eclipse.swt.widgets.Composite frame) {
   final org.eclipse.swt.examples.hoverhelp.HoverHelp.ToolTipHandler tooltip =
       new org.eclipse.swt.examples.hoverhelp.HoverHelp.ToolTipHandler(frame.getShell());
   org.eclipse.swt.layout.GridLayout layout = new org.eclipse.swt.layout.GridLayout();
   layout.numColumns = 3;
   frame.setLayout(layout);
   java.lang.String platform = SWT.getPlatform();
   java.lang.String helpKey = "F1";
   if (platform.equals("gtk")) {
     helpKey = "Ctrl+F1";
   }
   if (platform.equals("carbon") || platform.equals("cocoa")) {
     helpKey = "Help";
   }
   org.eclipse.swt.widgets.ToolBar bar = new org.eclipse.swt.widgets.ToolBar(frame, SWT.BORDER);
   for (int i = 0; i < 5; i++) {
     org.eclipse.swt.widgets.ToolItem item = new org.eclipse.swt.widgets.ToolItem(bar, SWT.PUSH);
     item.setText(
         getResourceString("ToolItem.text", new java.lang.Object[] {new java.lang.Integer(i)}));
     item.setData(
         "TIP_TEXT",
         getResourceString("ToolItem.tooltip", new java.lang.Object[] {item.getText(), helpKey}));
     item.setData(
         "TIP_HELPTEXTHANDLER",
         new org.eclipse.swt.examples.hoverhelp.HoverHelp.ToolTipHelpTextHandler() {
           public java.lang.String getHelpText(org.eclipse.swt.widgets.Widget widget) {
             org.eclipse.swt.widgets.Item item = (org.eclipse.swt.widgets.Item) widget;
             return getResourceString("ToolItem.help", new java.lang.Object[] {item.getText()});
           }
         });
   }
   org.eclipse.swt.layout.GridData gridData = new org.eclipse.swt.layout.GridData();
   gridData.horizontalSpan = 3;
   bar.setLayoutData(gridData);
   tooltip.activateHoverHelp(bar);
   org.eclipse.swt.widgets.Table table = new org.eclipse.swt.widgets.Table(frame, SWT.BORDER);
   for (int i = 0; i < 4; i++) {
     org.eclipse.swt.widgets.TableItem item =
         new org.eclipse.swt.widgets.TableItem(table, SWT.PUSH);
     item.setText(getResourceString("Item", new java.lang.Object[] {new java.lang.Integer(i)}));
     item.setData("TIP_IMAGE", images[hhiInformation]);
     item.setText(
         getResourceString("TableItem.text", new java.lang.Object[] {new java.lang.Integer(i)}));
     item.setData(
         "TIP_TEXT",
         getResourceString("TableItem.tooltip", new java.lang.Object[] {item.getText(), helpKey}));
     item.setData(
         "TIP_HELPTEXTHANDLER",
         new org.eclipse.swt.examples.hoverhelp.HoverHelp.ToolTipHelpTextHandler() {
           public java.lang.String getHelpText(org.eclipse.swt.widgets.Widget widget) {
             org.eclipse.swt.widgets.Item item = (org.eclipse.swt.widgets.Item) widget;
             return getResourceString("TableItem.help", new java.lang.Object[] {item.getText()});
           }
         });
   }
   table.setLayoutData(new org.eclipse.swt.layout.GridData(GridData.VERTICAL_ALIGN_FILL));
   tooltip.activateHoverHelp(table);
   org.eclipse.swt.widgets.Tree tree = new org.eclipse.swt.widgets.Tree(frame, SWT.BORDER);
   for (int i = 0; i < 4; i++) {
     org.eclipse.swt.widgets.TreeItem item = new org.eclipse.swt.widgets.TreeItem(tree, SWT.PUSH);
     item.setText(getResourceString("Item", new java.lang.Object[] {new java.lang.Integer(i)}));
     item.setData("TIP_IMAGE", images[hhiWarning]);
     item.setText(
         getResourceString("TreeItem.text", new java.lang.Object[] {new java.lang.Integer(i)}));
     item.setData(
         "TIP_TEXT",
         getResourceString("TreeItem.tooltip", new java.lang.Object[] {item.getText(), helpKey}));
     item.setData(
         "TIP_HELPTEXTHANDLER",
         new org.eclipse.swt.examples.hoverhelp.HoverHelp.ToolTipHelpTextHandler() {
           public java.lang.String getHelpText(org.eclipse.swt.widgets.Widget widget) {
             org.eclipse.swt.widgets.Item item = (org.eclipse.swt.widgets.Item) widget;
             return getResourceString("TreeItem.help", new java.lang.Object[] {item.getText()});
           }
         });
   }
   tree.setLayoutData(new org.eclipse.swt.layout.GridData(GridData.VERTICAL_ALIGN_FILL));
   tooltip.activateHoverHelp(tree);
   org.eclipse.swt.widgets.Button button = new org.eclipse.swt.widgets.Button(frame, SWT.PUSH);
   button.setText(getResourceString("Hello.text"));
   button.setData("TIP_TEXT", getResourceString("Hello.tooltip"));
   tooltip.activateHoverHelp(button);
 }