private void createQuickFixMenu(final StyledText text) {
    quickFixMenu = new Menu(text);
    MenuItem createItem = new MenuItem(quickFixMenu, SWT.PUSH);
    createItem.setText(
        Messages.getString("ColumnMappingDialog.MenuItem.CreateParameter")); // $NON-NLS-1$
    createItem.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent event) {
            createXMLParameter(text);
          }

          public void widgetDefaultSelected(SelectionEvent event) {}
        });

    MenuItem deleteItem = new MenuItem(quickFixMenu, SWT.PUSH);
    deleteItem.setText(
        Messages.getString("ColumnMappingDialog.MenuItem.DeleteParameter")); // $NON-NLS-1$
    deleteItem.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent event) {
            deleteXMLParameter(text);
          }

          public void widgetDefaultSelected(SelectionEvent event) {}
        });

    updateMenuItemStatus(text);
  }
  /**
   * Creates all the items located in the Search submenu and associate all the menu items with their
   * appropriate functions.
   *
   * @param menuBar Menu the <code>Menu</code> that file contain the Search submenu.
   */
  private void createSearchMenu(Menu menuBar) {
    // Search menu.
    MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
    item.setText(resMessages.getString("Search_menu_title"));
    Menu searchMenu = new Menu(shell, SWT.DROP_DOWN);
    item.setMenu(searchMenu);

    // Search -> Find...
    item = new MenuItem(searchMenu, SWT.NULL);
    item.setText(resMessages.getString("Find"));
    item.setAccelerator(SWT.MOD1 + 'F');
    item.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            searchDialog.setMatchCase(false);
            searchDialog.setMatchWord(false);
            searchDialog.setSearchDown(true);
            searchDialog.setSearchString("");
            searchDialog.setSelectedSearchArea(0);
            searchDialog.open();
          }
        });

    // Search -> Find Next
    item = new MenuItem(searchMenu, SWT.NULL);
    item.setText(resMessages.getString("Find_next"));
    item.setAccelerator(SWT.F3);
    item.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            searchDialog.open();
          }
        });
  }
  private Menu createPopup(Composite parent) {
    Menu menu = new Menu(parent.getShell(), SWT.POP_UP);

    spinOn = new MenuItem(menu, SWT.RADIO);
    spinOn.setText("Spin ON");
    spinOn.addSelectionListener(popupSelectionListener);
    spinOff = new MenuItem(menu, SWT.RADIO);
    spinOff.setText("Spin OFF");
    spinOff.addSelectionListener(popupSelectionListener);
    return menu;
  }
  /* (non-Javadoc)
   * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#createDialogAreaContent(org.eclipse.swt.widgets.Composite)
   */
  @SuppressWarnings("unused")
  @Override
  protected void createDialogAreaContent(Composite parent) {
    super.createDialogAreaContent(parent);

    Menu menu = new Menu(getViewer().getTable());

    menuEdit = new MenuItem(menu, SWT.PUSH);
    menuEdit.setText(Messages.ActionHistorySelectionDialog_button_copy);
    menuEdit.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            editPressed();
          }
        });

    menuCopy = new MenuItem(menu, SWT.PUSH);
    menuCopy.setText(Messages.ActionHistorySelectionDialog_button_edit);
    menuCopy.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            copyPressed();
          }
        });

    menuExecute = new MenuItem(menu, SWT.PUSH);
    menuExecute.setText(Messages.ActionHistorySelectionDialog_button_execute);
    menuExecute.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            okPressed();
          }
        });

    new MenuItem(menu, SWT.SEPARATOR);

    menuRemove = new MenuItem(menu, SWT.PUSH);
    menuRemove.setText(Messages.ActionHistorySelectionDialog_button_remove);
    menuRemove.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            removePressed();
          }
        });
    menuRemove.setImage(
        PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));

    getViewer().getTable().setMenu(menu);
  }
 /**
  * Recursive method to create a menu from the contribute items of a manger
  *
  * @param menu actual menu
  * @param items manager contributor items
  */
 private void createMenu(Menu menu, IContributionItem[] items) {
   for (IContributionItem item : items) {
     if (item instanceof MenuManager) {
       MenuManager manager = (MenuManager) item;
       MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
       subMenuItem.setText(manager.getMenuText());
       Menu subMenu = new Menu(Display.getCurrent().getActiveShell(), SWT.DROP_DOWN);
       subMenuItem.setMenu(subMenu);
       createMenu(subMenu, manager.getItems());
     } else if (item instanceof ActionContributionItem) {
       ActionContributionItem actionItem = (ActionContributionItem) item;
       if (actionItem.getAction() instanceof CustomSelectionAction) {
         final CustomSelectionAction action = (CustomSelectionAction) actionItem.getAction();
         MenuItem actionEnrty = new MenuItem(menu, SWT.CHECK);
         action.setSelection(getLastRawSelection());
         actionEnrty.setText(actionItem.getAction().getText());
         actionEnrty.setSelection(action.isChecked());
         actionEnrty.setEnabled(action.canExecute());
         actionEnrty.addSelectionListener(
             new SelectionAdapter() {
               @Override
               public void widgetSelected(SelectionEvent e) {
                 action.run();
               }
             });
       }
     }
   }
 }
示例#6
0
  /** @see ContributionItem#fill(Menu, int) */
  @Override
  public void fill(final Menu menu, int index) {
    RecentProjectsService rfs =
        (RecentProjectsService) PlatformUI.getWorkbench().getService(RecentProjectsService.class);
    RecentProjectsService.Entry[] entries = rfs.getRecentFiles();
    if (entries == null || entries.length == 0) {
      return;
    }

    // add separator
    new MenuItem(menu, SWT.SEPARATOR, index);

    int i = entries.length;
    for (RecentProjectsService.Entry entry : entries) {
      String file = entry.getFile();
      MenuItem mi = new MenuItem(menu, SWT.PUSH, index);
      String filename = FilenameUtils.getName(file);
      String shortened = shorten(file, MAX_LENGTH, filename.length());
      String nr = String.valueOf(i);
      if (i <= 9) {
        // add mnemonic for the first 9 items
        nr = "&" + nr; // $NON-NLS-1$
      }
      mi.setText(nr + "  " + shortened); // $NON-NLS-1$
      mi.setData(file);
      mi.addSelectionListener(new MenuItemSelectionListener(new File(file)));
      --i;
    }
  }
示例#7
0
 @Override
 public Menu getMenu(Control parent) {
   if (menu != null) {
     menu.dispose();
   }
   Menu newMenu = new Menu(parent);
   List<String> preferenceConfigurations =
       PrologRuntimeUIPlugin.getDefault().getPreferenceConfigurations();
   String defaultConfiguration =
       PrologRuntimeUIPlugin.getDefault()
           .getPreferenceStore()
           .getString(PrologRuntimeUI.PREF_CONFIGURATION);
   for (String preferenceConfiguration : preferenceConfigurations) {
     MenuItem item = new MenuItem(newMenu, SWT.NONE);
     item.setText(preferenceConfiguration.replaceAll("&", "&&"));
     if (preferenceConfiguration.equals(defaultConfiguration)) {
       item.setImage(ImageRepository.getImage(ImageRepository.NEW_PROCESS));
     }
     final String configuration = preferenceConfiguration;
     item.addSelectionListener(
         new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
             askForNameAndCreateProcess(configuration);
           }
         });
   }
   menu = newMenu;
   return menu;
 }
 private void addResetItem(final Menu menu) {
   final MenuItem resetMenuItem = new MenuItem(menu, SWT.Activate);
   resetMenuItem.setText(WorkbenchMessages.PerspectiveBar_reset);
   final IWorkbenchWindow workbenchWindow = window.getContext().get(IWorkbenchWindow.class);
   workbenchWindow
       .getWorkbench()
       .getHelpSystem()
       .setHelp(resetMenuItem, IWorkbenchHelpContextIds.RESET_PERSPECTIVE_ACTION);
   resetMenuItem.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent event) {
           if (psTB.isDisposed()) return;
           IHandlerService handlerService =
               (IHandlerService) workbenchWindow.getService(IHandlerService.class);
           IStatus status = Status.OK_STATUS;
           try {
             handlerService.executeCommand(
                 IWorkbenchCommandConstants.WINDOW_RESET_PERSPECTIVE, null);
           } catch (ExecutionException e) {
             status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e);
           } catch (NotDefinedException e) {
             status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e);
           } catch (NotEnabledException e) {
             status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e.getMessage(), e);
           } catch (NotHandledException e) {
           }
           if (!status.isOK())
             StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
         }
       });
 }
  // only used at the constructor
  private void addMenuOptions() {
    final MenuItem addElementMenuItem = new MenuItem(this, SWT.NONE);
    addElementMenuItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            TreeItem[] selected = tree.getSelection();
            TreeItem item;
            if (selected.length > 0) {
              TreeItem parent = selected[0].getParentItem();
              System.out.println("Insert Before - " + selected[0].getText());

              if (parent == null) {
                int index = tree.indexOf(selected[0]);
                item = setml.createNode(tree, index + 1);

              } else {
                int index = parent.indexOf(selected[0]);
                item = setml.createNode_state(parent, index + 1);
              }

            } else {
              System.out.println("Insert Before - nothing selected. Insert at beggining");
              item = setml.createNode(tree, 0);
            }
            item.setText("abv");
          }
        });
    addElementMenuItem.setText("Add New");
  }
示例#10
0
  private Menu createOptionsMenu(Shell shell) {
    final Menu menu = new Menu(shell, SWT.POP_UP);
    final MenuItem displayImagesItem = new MenuItem(menu, SWT.CHECK);
    displayImagesItem.setText("Display Images");
    displayImagesItem.setSelection(displayImages);

    final MenuItem imagesAsHexItem = new MenuItem(menu, SWT.CHECK);
    imagesAsHexItem.setText("Display Images with Hex Viewer");

    final MenuItem decodeItem = new MenuItem(menu, SWT.CHECK);
    decodeItem.setText("Remove URL encoding");

    displayImagesItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean value = displayImagesItem.getSelection();
            imagesAsHexItem.setEnabled(value);
            setDisplayImageState(value);
            displayImages = value;
          }
        });

    imagesAsHexItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean value = imagesAsHexItem.getSelection();
            setDisplayImagesAsHexState(value);
            displayImagesAsHex = value;
          }
        });

    decodeItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean value = decodeItem.getSelection();
            setUrlDecodeState(value);
            urlDecodeState = value;
          }
        });
    return menu;
  }
示例#11
0
  @Override
  public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(3, false));
    new Label(parent, SWT.NONE);

    Label lblNewLabel = new Label(parent, SWT.NONE);
    GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblNewLabel.widthHint = 301;
    lblNewLabel.setLayoutData(gd_lblNewLabel);
    lblNewLabel.setText("Seach Books");
    new Label(parent, SWT.NONE);
    new Label(parent, SWT.NONE);

    findByTitle = new Text(parent, SWT.BORDER);
    GridData gd_text = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
    gd_text.widthHint = 335;
    findByTitle.setLayoutData(gd_text);
    findByTitle.setLayoutData(
        new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));

    prefix = findByTitle.getText();

    createViewer(parent, prefix);

    {
      Button btnAddBook = new Button(parent, SWT.LEFT);
      btnAddBook.addSelectionListener(actionAddBook(parent));
      btnAddBook.setText("Add Book");
    }
    new Label(parent, SWT.LEFT);
    {
      Button btnRemoveBook = new Button(parent, SWT.NONE);
      btnRemoveBook.addSelectionListener(actionDelate());
      btnRemoveBook.setText("Delete book");
    }
    new Label(parent, SWT.NONE);

    Menu menu = new Menu(parent);
    parent.setMenu(menu);

    MenuItem mntmAddBook = new MenuItem(menu, SWT.NONE);
    mntmAddBook.setText("Add Book");
    mntmAddBook.addSelectionListener(actionAddBook(parent));

    filter = new BookTitleFilter(findByTitle.getText());
    tableBooks.addFilter(filter);
    findByTitle.addKeyListener(
        new KeyAdapter() {
          public void keyReleased(KeyEvent ke) {
            prefix = findByTitle.getText();
            filter.setPrefix(prefix);
            tableBooks.refresh();
          }
        });
  }
示例#12
0
文件: MainMenu.java 项目: nfvs/Siafu
  /**
   * Create the options menu.
   *
   * @param header the header from which the menu hangs
   */
  private void createOptionsMenu(final MenuItem header) {
    if (optionsMenu != null) {
      optionsMenu.dispose();
    }

    optionsMenu = new Menu(shell, SWT.DROP_DOWN);

    MenuItem viewShowPathItem = new MenuItem(optionsMenu, SWT.CHECK);
    viewShowPathItem.setText("&Show agent's path\tCTRL+P");
    viewShowPathItem.setAccelerator(SWT.CTRL + 'P');
    viewShowPathItem.setSelection(true);
    viewShowPathItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            gui.setPathShown(!gui.isPathShown());
          }
        });

    MenuItem simulateNightItem = new MenuItem(optionsMenu, SWT.CHECK);
    simulateNightItem.setText("Simulate &night");
    simulateNightItem.setSelection(gui.isNightSimulated());
    simulateNightItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            gui.simulateNight(((MenuItem) e.getSource()).getSelection());
          }
        });

    new MenuItem(optionsMenu, SWT.SEPARATOR);

    MenuItem toolsOptionsItem = new MenuItem(optionsMenu, SWT.PUSH);
    toolsOptionsItem.setText("Con&figuration\tCtrl+T");
    toolsOptionsItem.setAccelerator(SWT.CTRL + 'T');
    toolsOptionsItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            new ConfigShell(siafuConfig);
          }
        });

    optionsMenuHeader.setMenu(optionsMenu);
  }
 private void addCloseItem(final Menu menu) {
   MenuItem menuItem = new MenuItem(menu, SWT.NONE);
   menuItem.setText(WorkbenchMessages.WorkbenchWindow_close);
   menuItem.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           MPerspective persp = (MPerspective) menu.getData();
           if (persp != null) closePerspective(persp);
         }
       });
 }
示例#14
0
 public void fill(Menu menu) {
   MenuItem item = new MenuItem(menu, SWT.NONE);
   item.setText(NLS.bind("Compare with Patch Set {0}", base.getPatchSetId()));
   item.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent e) {
           run();
         }
       });
 }
 @Override
 public void popupMenu(TreeViewer tv, Tree tree, Menu menu) {
   MenuItem mi = new MenuItem(menu, SWT.PUSH);
   mi.setText(Messages.AbstractSearchedNode_clear);
   mi.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent event) {
           clear();
         }
       });
 }
示例#16
0
 /**
  * Creates a pop up menu for this handler.
  *
  * @return
  */
 public Menu getMenu() {
   Menu menu = new Menu(tree.getTree());
   MenuItem itemCopy = new MenuItem(menu, SWT.NONE);
   itemCopy.setText(Resources.getMessage("ClipboardHandlerTree.0")); // $NON-NLS-1$
   itemCopy.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent arg0) {
           copy();
         }
       });
   return menu;
 }
 private void setupPopupMenu() {
   final Menu menuPopup = new Menu(this.getShell(), SWT.POP_UP);
   final MenuItem itemDelete = new MenuItem(menuPopup, SWT.PUSH);
   itemDelete.setText("删除联系人...");
   menuPopup.addListener(
       SWT.Show,
       new Listener() {
         @Override
         public void handleEvent(Event event) {
           TreeItem[] treeItems = tree.getSelection();
           List<ContactInfo> infoList = new ArrayList<ContactInfo>();
           if (treeItems != null) {
             for (TreeItem treeItem : treeItems) {
               ContactInfo info = (ContactInfo) treeItem.getData();
               if (info != null) {
                 infoList.add(info);
               }
             }
           }
           if (infoList.size() > 0) {
             itemDelete.setEnabled(true);
           } else {
             itemDelete.setEnabled(false);
           }
         }
       });
   itemDelete.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent e) {
           TreeItem[] treeItems = tree.getSelection();
           List<ContactInfo> infoList = new ArrayList<ContactInfo>();
           if (treeItems != null) {
             for (TreeItem treeItem : treeItems) {
               ContactInfo info = (ContactInfo) treeItem.getData();
               if (info != null) {
                 infoList.add(info);
               }
             }
           }
           if (infoList.size() > 0) {
             MessageBox mb = new MessageBox(getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION);
             mb.setMessage("确定要删除选择的联系人?");
             mb.setText("提示");
             if (mb.open() == SWT.OK) {
               deleteContact(infoList);
             }
           }
         }
       });
   tree.setMenu(menuPopup);
 }
示例#18
0
 org.eclipse.swt.widgets.Menu createFileMenu() {
   org.eclipse.swt.widgets.Menu bar = shell.getMenuBar();
   org.eclipse.swt.widgets.Menu menu = new org.eclipse.swt.widgets.Menu(bar);
   org.eclipse.swt.widgets.MenuItem item;
   item = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
   item.setText(resources.getString("Open_menuitem"));
   item.setAccelerator(SWT.MOD1 + 'O');
   item.addSelectionListener(
       new org.eclipse.swt.events.SelectionAdapter() {
         public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
           openFile();
         }
       });
   item = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
   item.setText(resources.getString("Exit_menuitem"));
   item.addSelectionListener(
       new org.eclipse.swt.events.SelectionAdapter() {
         public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
           menuFileExit();
         }
       });
   return menu;
 }
  private MenuItem createBlankFileMenu(
      Menu parent, final String editorType, final String fileExtension) {
    MenuItem item = new MenuItem(parent, SWT.PUSH);
    item.setText(Messages.NewFileTemplateMenuContributor_LBL_BlankFile);
    item.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            createNewBlankFile(editorType, fileExtension);
          }
        });
    return item;
  }
示例#20
0
  private void createLabels() {

    // Add status labels
    infoItem = new ToolItem(toolbar, SWT.SEPARATOR);
    infoComposite = new Composite(toolbar, SWT.NONE);
    infoItem.setControl(infoComposite);
    infoComposite.setLayout(null);

    labelAttribute = new Label(infoComposite, SWT.SINGLE | SWT.READ_ONLY);
    labelAttribute.setText(Resources.getMessage("MainToolBar.33")); // $NON-NLS-1$
    labelAttribute.pack();
    labelTransformations = new Label(infoComposite, SWT.SINGLE | SWT.READ_ONLY);
    labelTransformations.setText(Resources.getMessage("MainToolBar.33")); // $NON-NLS-1$
    labelTransformations.pack();
    labelSelected = new Label(infoComposite, SWT.SINGLE | SWT.READ_ONLY);
    labelSelected.setText(Resources.getMessage("MainToolBar.31")); // $NON-NLS-1$
    labelSelected.pack();
    labelApplied = new Label(infoComposite, SWT.SINGLE | SWT.READ_ONLY);
    labelApplied.setText(Resources.getMessage("MainToolBar.32")); // $NON-NLS-1$
    labelApplied.pack();

    // Copy info to clip board on right-click
    Menu menu = new Menu(toolbar);
    MenuItem itemCopy = new MenuItem(menu, SWT.NONE);
    itemCopy.setText(Resources.getMessage("MainToolBar.42")); // $NON-NLS-1$
    itemCopy.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            if (tooltip != null) {
              Clipboard clipboard = new Clipboard(toolbar.getDisplay());
              TextTransfer textTransfer = TextTransfer.getInstance();
              clipboard.setContents(new String[] {tooltip}, new Transfer[] {textTransfer});
              clipboard.dispose();
            }
          }
        });
    labelSelected.setMenu(menu);
    labelApplied.setMenu(menu);
    labelTransformations.setMenu(menu);

    // Add listener for layout
    toolbar.addControlListener(
        new ControlAdapter() {
          @Override
          public void controlResized(final ControlEvent arg0) {
            layout();
          }
        });
  }
  /**
   * Create contents of the window.
   *
   * @wbp.parser.entryPoint
   */
  protected void createContents() {
    shell = new Shell();
    shell.setSize(450, 300);
    shell.setText("buy train ticket");
    shell.setLayout(new FormLayout());

    Menu menuBar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menuBar);

    MenuItem actionMenuItem = new MenuItem(menuBar, SWT.CASCADE);
    actionMenuItem.setText("Action");

    Menu actionMenu = new Menu(actionMenuItem);
    actionMenuItem.setMenu(actionMenu);

    MenuItem buyTrainTicketMenuItem = new MenuItem(actionMenu, SWT.NONE);
    buyTrainTicketMenuItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            BuyTrainTicketDialog dialog = new BuyTrainTicketDialog(shell);
            dialog.open();
          }
        });
    buyTrainTicketMenuItem.setText("Buy Train Ticket");

    MenuItem viewMenuItem = new MenuItem(menuBar, SWT.CASCADE);
    viewMenuItem.setText("View");

    Menu viewMenu = new Menu(viewMenuItem);
    viewMenuItem.setMenu(viewMenu);

    MenuItem messagesMenuItem = new MenuItem(viewMenu, SWT.NONE);
    messagesMenuItem.setText("Messages");

    int browserStyle = SWT.NONE;
    if (System.getProperty("os.name").equals("Linux")) {
      browserStyle = SWT.MOZILLA;
    }
    browser = new Browser(shell, browserStyle);
    FormData fd_browser = new FormData();
    fd_browser.bottom = new FormAttachment(0, 247);
    fd_browser.right = new FormAttachment(0, 442);
    fd_browser.top = new FormAttachment(0);
    fd_browser.left = new FormAttachment(0);
    browser.setLayoutData(fd_browser);

    this.shell.setMaximized(true);
  }
 private void createRemoveMenuItem() {
   MenuItem removeItem = new MenuItem(popupMenu, SWT.PUSH);
   removeItem.setText("Delete");
   ImageDescriptor descriptor =
       ImageDescriptor.createFromURL(
           Plugin.getDefault().getBundle().getEntry(getDeleteImagePath()));
   removeItem.setImage(SharedImages.INSTANCE.getImage(descriptor));
   removeItem.setEnabled(hasSelection());
   removeItem.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           removeSelectedObject();
         }
       });
 }
示例#23
0
  private void createViewer(Composite parent, String prefix) {
    new Label(parent, SWT.NONE);
    new Label(parent, SWT.NONE);
    tableBooks = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    table = tableBooks.getTable();
    GridData gd_table = new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1);
    gd_table.widthHint = 497;
    gd_table.heightHint = 311;
    table.setLayoutData(gd_table);
    createColumns(parent, tableBooks);

    List<BookVO> books = new ArrayList<>();
    try {
      books = findBooksService.sendGet(prefix);
    } catch (Exception e) {
      e.printStackTrace();
    }

    input = new WritableList(books, BookVO.class);
    IBeanValueProperty[] values =
        BeanProperties.values(new String[] {"id", "title", "authors", "libraryName"});
    ViewerSupport.bind(tableBooks, input, values);

    {
      Menu menu = new Menu(table);
      table.setMenu(menu);

      MenuItem mntmDelate = new MenuItem(menu, SWT.NONE);
      mntmDelate.setText("Delate Book");
      mntmDelate.addSelectionListener(actionDelate());

      MenuItem mntmAdd = new MenuItem(menu, SWT.NONE);
      mntmAdd.setText("Add Book");
      mntmAdd.addSelectionListener(actionAddBook(parent));
    }
  }
    @Override
    protected void fillMenu(final Menu menu) {
      final TexUIResources texResources = TexUIResources.INSTANCE;
      final List<TexCommand> commands = fCategory.getCommands();
      for (final TexCommand command : commands) {
        final MenuItem item = new MenuItem(menu, SWT.PUSH);

        final String imageKey = texResources.getCommandImageId(command);
        if (imageKey != null) {
          item.setImage(texResources.getImage(imageKey));
        }
        item.setText(command.getControlWord());
        item.setData(command);

        item.addSelectionListener(this);
      }
    }
示例#25
0
文件: MainMenu.java 项目: nfvs/Siafu
  /**
   * Create the help menu.
   *
   * @param header the header from which the menu hangs
   */
  private void createHelpMenu(final MenuItem header) {
    if (helpMenu != null) {
      helpMenu.dispose();
    }
    helpMenu = new Menu(shell, SWT.DROP_DOWN);
    MenuItem helpAboutItem = new MenuItem(helpMenu, SWT.PUSH);
    helpAboutItem.setText("&About");

    helpAboutItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            new AboutShell();
          }
        });

    helpMenuHeader.setMenu(helpMenu);
  }
  /**
   * Creates all the items located in the Sort cascading submenu and associate all the menu items
   * with their appropriate functions.
   *
   * @return Menu The cascading menu with all the sort menu items on it.
   */
  private Menu createSortMenu() {
    Menu submenu = new Menu(shell, SWT.DROP_DOWN);
    MenuItem subitem;
    for (int i = 0; i < columnNames.length; i++) {
      subitem = new MenuItem(submenu, SWT.NULL);
      subitem.setText(columnNames[i]);
      final int column = i;
      subitem.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              sort(column);
            }
          });
    }

    return submenu;
  }
 public static MenuItem createShowHideMenuItem(Menu menu, final Composite composite) {
   final MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
   menuItem.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent e) {
           if (menuItem.getSelection()) {
             show(composite);
           } else {
             hide(composite);
           }
           composite.layout();
           composite.getParent().layout();
         }
       });
   return menuItem;
 }
 private void createAddEsbNotifierMenuItem(Menu menu) {
   MenuItem addEsbNotifierMenuItem = new MenuItem(menu, SWT.PUSH);
   addEsbNotifierMenuItem.setText("New ESB Notifier");
   ImageDescriptor enabledDescriptor =
       ImageDescriptor.createFromURL(
           Plugin.getDefault().getBundle().getEntry("/icons/full/obj16/esb_enabled.gif"));
   addEsbNotifierMenuItem.setImage(SharedImages.INSTANCE.getImage(enabledDescriptor));
   addEsbNotifierMenuItem.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           addNewActionElement(ESB_NOTIFIER_ID);
           if (((MenuItem) e.widget).getParent() != popupMenu) {
             elementToCreate = ESB_NOTIFIER_ID;
             setEsbNotifierInfo(addActionElementToolbarContributionItem.getAction());
           }
         }
       });
 }
示例#29
0
 public MenuItem getAboutMenuItem() {
   if (aboutMenuItem == null) {
     aboutMenuItem = new MenuItem(getHelp(), SWT.PUSH);
     aboutMenuItem.setText("&about");
     Image img = new Image(getMaster().getDisplay(), "images/about.png");
     aboutMenuItem.setImage(img);
     aboutMenuItem.addSelectionListener(
         new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
             getMaster().getMasterCenter().showComposite(getMaster().getMasterCenter().getAbout());
             getMaster().getMasterCenter().layout();
             getMaster().getShell().layout();
           }
         });
   }
   return aboutMenuItem;
 }
示例#30
0
  public void addOperationFilter(final Filter filter) {
    MenuItem[] items = filtersMenu.getItems();
    int pos = 0;
    for (MenuItem item : items) {
      if (item == configureItem) {
        break;
      }
      pos++;
    }
    pos--;
    operationFilters.add(filter);

    final MenuItem item = new MenuItem(filtersMenu, SWT.CHECK, pos);
    item.setText(filter.getName());
    item.setSelection(filter.getEnabled());
    item.setData(filter);
    item.addSelectionListener(this);
  }