Exemplo n.º 1
0
 /**
  * Creates the Other... menu item
  *
  * @param menu the menu to add the item to
  */
 private void createOtherMenuItem(final Menu menu) {
   final IFileRevision fileResource = getFileRevision();
   if (fileResource == null) {
     return;
   }
   new MenuItem(menu, SWT.SEPARATOR);
   final MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
   menuItem.setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_Other);
   Listener listener =
       new Listener() {
         public void handleEvent(Event event) {
           switch (event.type) {
             case SWT.Selection:
               EditorSelectionDialog dialog = new EditorSelectionDialog(menu.getShell());
               dialog.setMessage(
                   NLS.bind(
                       TeamUIMessages.LocalHistoryPage_OpenWithMenu_OtherDialogDescription,
                       fileResource.getName()));
               if (dialog.open() == Window.OK) {
                 IEditorDescriptor editor = dialog.getSelectedEditor();
                 if (editor != null) {
                   openEditor(editor, editor.isOpenExternal());
                 }
               }
               break;
           }
         }
       };
   menuItem.addListener(SWT.Selection, listener);
 }
Exemplo n.º 2
0
 /**
  * Creates the menu item for the editor descriptor.
  *
  * @param menu the menu to add the item to
  * @param descriptor the editor descriptor, or null for the system editor
  * @param preferredEditor the descriptor of the preferred editor, or <code>null</code>
  */
 private MenuItem createMenuItem(
     Menu menu, final IEditorDescriptor descriptor, final IEditorDescriptor preferredEditor) {
   // XXX: Would be better to use bold here, but SWT does not support it.
   final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
   boolean isPreferred =
       preferredEditor != null && descriptor.getId().equals(preferredEditor.getId());
   menuItem.setSelection(isPreferred);
   menuItem.setText(descriptor.getLabel());
   Image image = getImage(descriptor);
   if (image != null) {
     menuItem.setImage(image);
   }
   Listener listener =
       new Listener() {
         public void handleEvent(Event event) {
           switch (event.type) {
             case SWT.Selection:
               if (menuItem.getSelection()) {
                 openEditor(descriptor, false);
               }
               break;
           }
         }
       };
   menuItem.addListener(SWT.Selection, listener);
   return menuItem;
 }
Exemplo n.º 3
0
  public void createDefaultMenuItem(Menu menu, final IFileRevision revision) {
    final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
    menuItem.setSelection(Utils.getDefaultEditor(revision) == null);
    menuItem.setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_DefaultEditorDescription);

    Listener listener =
        new Listener() {
          public void handleEvent(Event event) {
            switch (event.type) {
              case SWT.Selection:
                if (menuItem.getSelection()) {
                  openEditor(Utils.getDefaultEditor(revision), false);
                }
                break;
            }
          }
        };

    menuItem.addListener(SWT.Selection, listener);
  }