Ejemplo 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;
 }