@Override
 protected void configureAction(Action action) {
   action.setText(Messages.HideReturnTypesAction_title);
   action.setToolTipText(Messages.HideReturnTypesAction_tooltip);
   action.setDescription(Messages.HideReturnTypesAction_description);
   action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
   action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
 }
 @Override
 protected void configureAction(Action action) {
   action.setText(Messages.FilterTerminalRulesContribution_title);
   action.setDescription(Messages.FilterTerminalRulesContribution_description);
   action.setToolTipText(Messages.FilterTerminalRulesContribution_tooltip);
   action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
   action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
 }
 public void createActions(CommonViewer tableViewer, ISelectionProvider provider) {
   action =
       new Action() {
         @Override
         public void run() {
           new Job("Fetching Welcome Page URL") {
             public IStatus run(IProgressMonitor monitor) {
               // Get the url in a background thread to not freeze the UI
               String url2 = null;
               try {
                 url2 = getUrl();
               } catch (CoreException ce) {
                 return ce.getStatus();
               }
               final String url = url2;
               if (url != null) {
                 Display.getDefault()
                     .asyncExec(
                         new Runnable() {
                           public void run() {
                             JBTWebLaunchableClient.checkedCreateInternalBrowser(
                                 url,
                                 getServer().getName(),
                                 JBossServerUIPlugin.PLUGIN_ID,
                                 JBossServerUIPlugin.getDefault().getLog());
                           }
                         });
               }
               return Status.OK_STATUS;
             }
           }.schedule();
         }
       };
   action.setText(ServerActionMessages.OpenWithBrowser);
   action.setDescription(ServerActionMessages.OpenWithBrowserDescription);
   action.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_INTERNAL_BROWSER));
 }
Exemplo n.º 4
0
  private void createActions() {
    String text;

    text = "Submit Move";
    done =
        new Action(text, getImageDescriptor("images/done.gif")) {
          public void run() {
            if (game == null) return;
            if (game.getGameState() != GameState.IN_PROGRESS) return;
            checkTiles();
            IPlayer player = game.getCurrentPlayer();
            if (!player.isLocal()) return;
            Move move = createMove();
            if (move != null) {
              // System.out.println(move);

              if (game.getChallengeMode() == ChallengeMode.VOID) {
                session.validateMove(game, move);
              } else {
                game.doMove(move);
              }
              resetInput(true);
              redraw();
            }
          };
        };
    done.setToolTipText(text);
    done.setDescription(text);

    text = "Exchange Tiles";
    change =
        new Action(text, getImageDescriptor("images/exchange.gif")) {
          public void run() {
            if (game == null) return;
            if (game.getGameState() != GameState.IN_PROGRESS) return;
            IPlayer player = game.getCurrentPlayer();
            if (!player.isLocal()) return;
            if (game.getTilePool().size() < tileRack.capacity()) {
              MessageBox msg = new MessageBox(getShell(), SWT.ICON_INFORMATION | SWT.OK);
              msg.setText("Too Few Tiles Remaining");
              msg.setMessage(
                  "You may not exchange tiles now because there are not enough tiles left in the tile pool.");
              msg.open();
              return;
            }

            IInputValidator validator =
                new IInputValidator() {
                  public String isValid(String text) {
                    Tile[] tiles = Convert.toTiles(text);
                    String rack = Convert.toString(getLocalTileRack().getTiles());
                    if (tiles.length == 0) {
                      return "Enter at least one letter to exchange.";
                    }
                    if (tiles.length > rack.length()) {
                      return "Error: You have entered too many characters.";
                    }
                    for (int i = 0; i < tiles.length; i++) {
                      Tile tile = tiles[i];
                      char letter = tile.getLetter();
                      String string = (letter == '?') ? "\\?" : Character.toString(letter);
                      int len = rack.length();
                      rack = rack.replaceFirst(string, "");
                      if (rack.length() == len) {
                        return "Error: One or more of the letters entered are not in your tile rack.";
                      }
                    }
                    return null;
                  }
                };

            InputDialog in =
                new InputDialog(
                    getShell(),
                    "Exchange Tiles",
                    "Enter the tiles you would like to exchange.  Use a question mark, '?',  to indicate a blank tile.",
                    "",
                    validator);
            if (in.open() == InputDialog.OK) {
              String result = in.getValue().toLowerCase();
              if (result != null && result.length() > 0) {
                Tile[] tiles = Convert.toTiles(result);
                game.doExchangeTiles(tiles);
                resetInput(true);
              }
            }
          };
        };
    change.setToolTipText(text);
    change.setDescription(text);

    text = "Pass This Turn";
    pass =
        new Action(text, getImageDescriptor("images/pass.gif")) {
          public void run() {
            if (game == null) return;
            if (game.getGameState() == GameState.ENDED) return;
            IPlayer player = game.getCurrentPlayer();
            if (!player.isLocal()) return;
            MessageBox msg = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.NO | SWT.YES);
            msg.setText("Pass Turn");
            msg.setMessage("Are you sure you want to pass this turn?");
            int result = msg.open();
            if (result == SWT.YES) {
              game.doPassTurn();
            }
          };
        };
    pass.setToolTipText(text);
    pass.setDescription(text);

    text = "Challenge Last Move";
    challenge =
        new Action(text, getImageDescriptor("images/challenge.gif")) {
          public void run() {
            if (game == null) return;
            if (game.getGameState() == GameState.ENDED) return;
            IPlayer player = game.getCurrentPlayer();
            if (!player.isLocal()) return;
            MessageBox msg = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.NO | SWT.YES);
            msg.setText("Challenge");
            msg.setMessage("Are you sure you want to challenge the previous move?");
            int result = msg.open();
            if (result == SWT.YES) {
              game.doChallenge(player);
            }
          };
        };
    challenge.setToolTipText(text);
    challenge.setDescription(text);

    text = "Resign";
    resign =
        new Action(text, getImageDescriptor("images/resign.gif")) {
          public void run() {
            if (game == null) return;
            if (game.getGameState() == GameState.ENDED) return;
            MessageBox msg = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.NO | SWT.YES);
            msg.setText("Resign");
            msg.setMessage("Are you sure you want to resign?");
            int result = msg.open();
            if (result == SWT.YES) {
              session.getConnection().send(new ResignCommand());
            }
          };
        };

    text = "Abort Game";
    abort =
        new Action(text, getImageDescriptor("images/abort.gif")) {
          public void run() {
            if (game == null) return;
            if (game.getGameState() == GameState.ENDED) return;
            MessageBox msg = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.NO | SWT.YES);
            msg.setText("Abort Game");
            msg.setMessage("Are you sure you want to abort this game?");
            int result = msg.open();
            if (result == SWT.YES) {
              session.getConnection().send(new AbortCommand());
            }
          };
        };

    text = "Adjourn Game";
    adjourn =
        new Action(text, getImageDescriptor("images/adjourn.gif")) {
          public void run() {
            if (game == null) return;
            if (game.getGameState() == GameState.ENDED) return;
            MessageBox msg = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.NO | SWT.YES);
            msg.setText("Adjourn Game");
            msg.setMessage("Are you sure you want to adjourn this game?");
            int result = msg.open();
            if (result == SWT.YES) {
              session.getConnection().send(new AdjournCommand());
            }
          };
        };
  }