示例#1
0
 /**
  * Possibly shows a notification or an error dialog depending on {@code success} and {@code
  * isUndo}.
  *
  * @param issue the TurboIssue acted on
  * @param action the Action that acted on the issue
  * @param success whether the action was successful
  * @param isUndo whether action is an undo
  * @return {@code success}
  */
 private boolean handleActionResult(
     TurboIssue issue, Action<TurboIssue> action, Boolean success, boolean isUndo) {
   if (!success) {
     String errorMessage = "Please check if you have write permissions to " + issue.getRepoId();
     showErrorDialog(issue, action, errorMessage);
     return success;
   }
   if (!isUndo) {
     showNotification(issue.getId(), issue.getTitle(), action.getDescription());
     return success;
   }
   return success;
 }
示例#2
0
  private void setupListView() {
    setVgrow(listView, Priority.ALWAYS);
    setupKeyboardShortcuts();

    listView.setOnItemSelected(
        i -> {
          TurboIssue issue = listView.getItems().get(i);
          ui.triggerEvent(
              new IssueSelectedEvent(
                  issue.getRepoId(), issue.getId(), panelIndex, issue.isPullRequest()));

          // Save the stored comment count as its own comment count.
          // The refreshItems(false) call that follows will remove the highlighted effect of the
          // comment bubble.
          // (if it was there before)
          issueCommentCounts.put(issue.getId(), issue.getCommentCount());
          issueNonSelfCommentCounts.put(
              issue.getId(), issue.getMetadata().getNonSelfCommentCount());
          // We assume we already have metadata, so we pass true to avoid refreshItems from trying
          // to get
          // metadata after clicking.
          refreshItems(true);
        });
  }
示例#3
0
  private void setupKeyboardShortcuts() {
    filterTextField.addEventHandler(
        KeyEvent.KEY_RELEASED,
        event -> {
          if (KeyboardShortcuts.BOX_TO_LIST.match(event)) {
            event.consume();
            listView.selectFirstItem();
          }
          if (event.getCode() == KeyboardShortcuts.DOUBLE_PRESS) {
            event.consume();
          }
          if (KeyPress.isDoublePress(KeyboardShortcuts.DOUBLE_PRESS, event.getCode())) {
            event.consume();
            listView.selectFirstItem();
          }
          if (KeyboardShortcuts.MAXIMIZE_WINDOW.match(event)) {
            ui.maximizeWindow();
          }
          if (KeyboardShortcuts.MINIMIZE_WINDOW.match(event)) {
            ui.minimizeWindow();
          }
          if (KeyboardShortcuts.DEFAULT_SIZE_WINDOW.match(event)) {
            ui.setDefaultWidth();
          }
          if (KeyboardShortcuts.SWITCH_DEFAULT_REPO.match(event)) {
            ui.switchDefaultRepo();
          }
        });

    addEventHandler(
        KeyEvent.KEY_RELEASED,
        event -> {
          if (event.getCode() == KeyboardShortcuts.markAsRead) {
            Optional<TurboIssue> item = listView.getSelectedItem();
            if (!item.isPresent()) {
              return;
            }
            TurboIssue issue = item.get();
            LocalDateTime now = LocalDateTime.now();
            ui.prefs.setMarkedReadAt(issue.getRepoId(), issue.getId(), now);
            issue.setMarkedReadAt(Optional.of(now));
            issue.setIsCurrentlyRead(true);
            parentPanelControl.refresh();
            listView.selectNextItem();
          }
          if (event.getCode() == KeyboardShortcuts.markAsUnread) {
            Optional<TurboIssue> item = listView.getSelectedItem();
            if (!item.isPresent()) {
              return;
            }
            TurboIssue issue = item.get();
            ui.prefs.clearMarkedReadAt(issue.getRepoId(), issue.getId());
            issue.setMarkedReadAt(Optional.empty());
            issue.setIsCurrentlyRead(false);
            parentPanelControl.refresh();
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_DOCS) {
            ui.getBrowserComponent().showDocs();
          }
          if (KeyboardShortcuts.LIST_TO_BOX.match(event)) {
            setFocusToFilterBox();
          }
          if (event.getCode() == KeyboardShortcuts.DOUBLE_PRESS
              && KeyPress.isDoublePress(KeyboardShortcuts.DOUBLE_PRESS, event.getCode())) {

            setFocusToFilterBox();
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_ISSUES) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showIssues();
            }
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_PULL_REQUESTS) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showPullRequests();
            }
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_HELP) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showDocs();
            }
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_KEYBOARD_SHORTCUTS) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showKeyboardShortcuts();
            }
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_CONTRIBUTORS) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showContributors();
              event.consume();
            }
          }
          if (event.getCode() == KeyboardShortcuts.scrollToTop) {
            ui.getBrowserComponent().scrollToTop();
          }
          if (event.getCode() == KeyboardShortcuts.scrollToBottom) {
            if (!KeyboardShortcuts.MINIMIZE_WINDOW.match(event)) {
              ui.getBrowserComponent().scrollToBottom();
            }
          }
          if (event.getCode() == KeyboardShortcuts.scrollUp
              || event.getCode() == KeyboardShortcuts.scrollDown) {
            ui.getBrowserComponent().scrollPage(event.getCode() == KeyboardShortcuts.scrollDown);
          }
          if (event.getCode() == KeyboardShortcuts.GOTO_MODIFIER) {
            KeyPress.setLastKeyPressedCodeAndTime(event.getCode());
          }
          if (event.getCode() == KeyboardShortcuts.NEW_COMMENT
              && ui.getBrowserComponent().isCurrentUrlIssue()) {
            ui.getBrowserComponent().jumpToComment();
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_LABELS) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().newLabel();
            } else {
              ui.triggerEvent(new ShowLabelPickerEvent(getSelectedIssue()));
            }
          }
          if (event.getCode() == KeyboardShortcuts.MANAGE_ASSIGNEES
              && ui.getBrowserComponent().isCurrentUrlIssue()) {
            ui.getBrowserComponent().manageAssignees(event.getCode().toString());
          }
          if (event.getCode() == KeyboardShortcuts.SHOW_MILESTONES) {
            if (KeyPress.isValidKeyCombination(KeyboardShortcuts.GOTO_MODIFIER, event.getCode())) {
              ui.getBrowserComponent().showMilestones();
            } else if (ui.getBrowserComponent().isCurrentUrlIssue()) {
              ui.getBrowserComponent().manageMilestones(event.getCode().toString());
            }
          }
          if (KeyboardShortcuts.MAXIMIZE_WINDOW.match(event)) {
            ui.maximizeWindow();
          }
          if (KeyboardShortcuts.MINIMIZE_WINDOW.match(event)) {
            ui.minimizeWindow();
          }
          if (KeyboardShortcuts.DEFAULT_SIZE_WINDOW.match(event)) {
            ui.setDefaultWidth();
          }
          if (KeyboardShortcuts.SWITCH_DEFAULT_REPO.match(event)) {
            ui.switchDefaultRepo();
          }
        });
  }