コード例 #1
0
ファイル: PaintExample.java プロジェクト: mbigigns/SWTGuitar
 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;
 }
コード例 #2
0
ファイル: PaintExample.java プロジェクト: mbigigns/SWTGuitar
 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);
     }
   }
 }