Java Code Examples for com.intellij.openapi.ui.Messages

The following examples show how to use com.intellij.openapi.ui.Messages. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: consulo   Source File: PushController.java    License: Apache License 2.0 6 votes vote down vote up
public boolean ensureForcePushIsNeeded() {
  Collection<MyRepoModel<?, ?, ?>> selectedNodes = getSelectedRepoNode();
  MyRepoModel<?, ?, ?> selectedModel = ContainerUtil.getFirstItem(selectedNodes);
  if (selectedModel == null) return false;
  final PushSupport activePushSupport = selectedModel.getSupport();
  final PushTarget commonTarget = getCommonTarget(selectedNodes);
  if (commonTarget != null && activePushSupport.isSilentForcePushAllowed(commonTarget)) return true;
  return Messages.showOkCancelDialog(myProject, XmlStringUtil.wrapInHtml(DvcsBundle.message("push.force.confirmation.text",
                                                                                            commonTarget != null
                                                                                            ? " to <b>" +
                                                                                              commonTarget.getPresentation() + "</b>"
                                                                                            : "")),
                                     "Force Push", "&Force Push",
                                     CommonBundle.getCancelButtonText(),
                                     Messages.getWarningIcon(),
                                     commonTarget != null ? new MyDoNotAskOptionForPush(activePushSupport, commonTarget) : null) == OK;
}
 
Example 2
private VirtualFile getLocationFromModel(@Nullable Project projectToClose, boolean saveLocation) {
  final File location = new File(FileUtil.toSystemDependentName(myModel.projectLocation().get()));
  if (!location.exists() && !location.mkdirs()) {
    String message = ActionsBundle.message("action.NewDirectoryProject.cannot.create.dir", location.getAbsolutePath());
    Messages.showErrorDialog(projectToClose, message, ActionsBundle.message("action.NewDirectoryProject.title"));
    return null;
  }
  final File baseFile = new File(location, myModel.projectName().get());
  //noinspection ResultOfMethodCallIgnored
  baseFile.mkdirs();
  final VirtualFile baseDir = ApplicationManager.getApplication().runWriteAction(
    (Computable<VirtualFile>)() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(baseFile));
  if (baseDir == null) {
    FlutterUtils.warn(LOG, "Couldn't find '" + location + "' in VFS");
    return null;
  }
  if (saveLocation) {
    RecentProjectsManager.getInstance().setLastProjectCreationLocation(location.getPath());
  }
  return baseDir;
}
 
Example 3
Source Project: r2m-plugin-android   Source File: AsyncHelper.java    License: Apache License 2.0 6 votes vote down vote up
private void showOverrideConfirmationDialog(final List<String> list) {
    this.result = false;
    StringBuilder sb = new StringBuilder("\n");
    for (String e : list) {
        sb.append(e).append("\n");
    }
    int option = Messages.showOkCancelDialog(
            R2MMessages.getMessage("CONFIRM_OVERRIDE_FILES", sb.toString()),
            R2MMessages.getMessage("CONFIRM_OVERRIDE_FILES_TITLE"),
            R2MMessages.getMessage("CONFIRM_OVERRIDE_FILES_BUTTON_TEXT"),
            Messages.CANCEL_BUTTON,
            Messages.getWarningIcon());
    if (option == 0) {
        onActionSuccess(GenerateActions.START_FILE_OPERATIONS);
    } else {
        this.result = true;
        onActionSuccess(GenerateActions.FILE_OPERATION_SUCCESS);
    }
}
 
Example 4
Source Project: consulo   Source File: SchemesToImportPopup.java    License: Apache License 2.0 6 votes vote down vote up
public void show(Collection<T> schemes) {
  if (schemes.isEmpty()) {
    Messages.showMessageDialog("There are no available schemes to import", "Import", Messages.getWarningIcon());
    return;
  }

  final JList list = new JBList(new CollectionListModel<T>(schemes));
  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  list.setCellRenderer(new SchemesToImportListCellRenderer());

  Runnable selectAction = new Runnable() {
    @Override
    public void run() {
      onSchemeSelected((T)list.getSelectedValue());
    }
  };

  showList(list, selectAction);
}
 
Example 5
Source Project: consulo   Source File: ProjectViewDropTarget.java    License: Apache License 2.0 6 votes vote down vote up
private void doDrop(@Nonnull TreePath target, PsiElement[] sources) {
  final PsiElement targetElement = getPsiElement(target);
  if (targetElement == null) return;

  if (DumbService.isDumb(myProject)) {
    Messages.showMessageDialog(myProject, "Copy refactoring is not available while indexing is in progress", "Indexing", null);
    return;
  }

  final PsiDirectory psiDirectory;
  if (targetElement instanceof PsiDirectoryContainer) {
    final PsiDirectoryContainer directoryContainer = (PsiDirectoryContainer)targetElement;
    final PsiDirectory[] psiDirectories = directoryContainer.getDirectories();
    psiDirectory = psiDirectories.length != 0 ? psiDirectories[0] : null;
  }
  else if (targetElement instanceof PsiDirectory) {
    psiDirectory = (PsiDirectory)targetElement;
  }
  else {
    final PsiFile containingFile = targetElement.getContainingFile();
    LOG.assertTrue(containingFile != null, targetElement);
    psiDirectory = containingFile.getContainingDirectory();
  }
  TransactionGuard.getInstance().submitTransactionAndWait(() -> CopyHandler.doCopy(sources, psiDirectory));
}
 
Example 6
Source Project: adc   Source File: ToolWindowFactory.java    License: Apache License 2.0 6 votes vote down vote up
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    JPanel framePanel = createPanel(project);
    disableAll();

    AndroidDebugBridge adb = AndroidSdkUtils.getDebugBridge(project);
    if (adb == null) {
        return;
    }

    if(adb.isConnected()){
        ToolWindowFactory.this.adBridge = adb;
        Logger.getInstance(ToolWindowFactory.class).info("Successfully obtained debug bridge");
        AndroidDebugBridge.addDeviceChangeListener(deviceChangeListener);
        updateDeviceComboBox();
    } else {
        Logger.getInstance(ToolWindowFactory.class).info("Unable to obtain debug bridge");
        String msg = MessageFormat.format(resourceBundle.getString("error.message.adb"), "");
        Messages.showErrorDialog(msg, resourceBundle.getString("error.title.adb"));
    }

    Content content = contentFactory.createContent(framePanel, "", false);
    toolWindow.getContentManager().addContent(content);
}
 
Example 7
@Override
public void actionPerformed(@NotNull final AnActionEvent event) {
  Project project = event.getProject();
  final Editor editor = event.getData(CommonDataKeys.EDITOR);
  if (project == null || editor == null) return;
  Document document = editor.getDocument();
  FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
  VirtualFile virtualFile = fileDocumentManager.getFile(document);
  ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  if (virtualFile != null) {
    Module module = projectFileIndex.getModuleForFile(virtualFile);
    String moduleName;
    moduleName = module != null ? module.getName() : "No module defined for file";

    VirtualFile moduleContentRoot = projectFileIndex.getContentRootForFile(virtualFile);
    boolean isLibraryFile = projectFileIndex.isLibraryClassFile(virtualFile);
    boolean isInLibraryClasses = projectFileIndex.isInLibraryClasses(virtualFile);
    boolean isInLibrarySource = projectFileIndex.isInLibrarySource(virtualFile);
    Messages.showInfoMessage("Module: " + moduleName + "\n" +
                             "Module content root: " + moduleContentRoot + "\n" +
                             "Is library file: " + isLibraryFile + "\n" +
                             "Is in library classes: " + isInLibraryClasses +
                             ", Is in library source: " + isInLibrarySource,
                             "Main File Info for" + virtualFile.getName());
  }
}
 
Example 8
Source Project: SlackStorm   Source File: SlackPost.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void pushMessage(String message, String details) throws IOException {
    String input = "payload=" + URLEncoder.encode(channel.getPayloadMessage(details, message), "UTF-8");

    try {
        URL url = new URL(channel.getUrl());
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setDoInput(true);
        conn.setDoOutput(true);

        DataOutputStream wr = new DataOutputStream (conn.getOutputStream ());
        wr.writeBytes (input);
        wr.flush ();
        wr.close ();

        if (conn.getResponseCode() == 200 && readInputStreamToString(conn).equals("ok")) {
            Messages.showMessageDialog(project, "Message Sent.", "Information", SlackStorage.getSlackIcon());
        }
        else {
            Messages.showMessageDialog(project, "Message not sent, check your configuration.", "Error", Messages.getErrorIcon());
        }

    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}
 
Example 9
Source Project: consulo   Source File: BaseToolsPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void removeSelected() {
  CheckedTreeNode node = getSelectedToolNode();
  if (node != null) {
    int result = Messages.showYesNoDialog(this, ToolsBundle.message("tools.delete.confirmation"), CommonBundle.getWarningTitle(), Messages.getWarningIcon());
    if (result != 0) {
      return;
    }
    myIsModified = true;
    if (node.getUserObject() instanceof Tool) {
      Tool tool = (Tool)node.getUserObject();
      CheckedTreeNode parentNode = (CheckedTreeNode)node.getParent();
      ((ToolsGroup)parentNode.getUserObject()).removeElement(tool);
      removeNodeFromParent(node);
      if (parentNode.getChildCount() == 0) {
        removeNodeFromParent(parentNode);
      }
    }
    else if (node.getUserObject() instanceof ToolsGroup) {
      removeNodeFromParent(node);
    }
    update();
    IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(myTree);
  }
}
 
Example 10
Source Project: EasyCode   Source File: HttpUtils.java    License: MIT License 6 votes vote down vote up
/**
 * post json请求
 *
 * @param uri   地址
 * @param param 参数
 * @return 请求返回结果
 */
public static String postJson(String uri, Map<String, Object> param) {
    HttpPost httpPost = new HttpPost(HOST_URL + uri);
    httpPost.setHeader(HttpHeaders.USER_AGENT, USER_AGENT);
    httpPost.setHeader(HttpHeaders.CONTENT_TYPE, CONTENT_TYPE);
    httpPost.setConfig(getDefaultConfig());
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        if (!CollectionUtil.isEmpty(param)) {
            httpPost.setEntity(new StringEntity(objectMapper.writeValueAsString(param), "utf-8"));
        }
        return handlerRequest(httpPost);
    } catch (JsonProcessingException e) {
        Messages.showWarningDialog("JSON解析出错!", MsgValue.TITLE_INFO);
        ExceptionUtil.rethrow(e);
    }
    return null;
}
 
Example 11
Source Project: azure-devops-intellij   Source File: IdeaHelper.java    License: MIT License 6 votes vote down vote up
/**
 * Verifies if TF is configured, show notification and warning message if not
 *
 * @param project Idea project
 * @return true if TF is configured, false if TF is not correctly configured
 */
public static boolean isTFConfigured(@NotNull final Project project) {
    String tfLocation = TfTool.getLocation();
    if (StringUtils.isEmpty(tfLocation)) {
        tfLocation = TfTool.tryDetectTf();
        if (!StringUtils.isEmpty(tfLocation)) {
            PluginServiceProvider.getInstance().getPropertyService().setProperty(PropertyService.PROP_TF_HOME, tfLocation);
            return true;
        }
        //TF is not configured, show warning message
        int result = Messages.showDialog(project,
                TfPluginBundle.message(TfPluginBundle.KEY_TFVC_NOT_CONFIGURED),
                TfPluginBundle.message(TfPluginBundle.KEY_TFVC),
                new String[] {
                        TfPluginBundle.message(TfPluginBundle.KEY_TFVC_NOT_CONFIGURED_DIALOG_OPEN_SETTINGS),
                        TfPluginBundle.message(TfPluginBundle.KEY_TFVC_NOT_CONFIGURED_DIALOG_CANCEL)},
                0, getWarningIcon());
        if (result == 0) {
            ShowSettingsUtil.getInstance().showSettingsDialog(project, TFSVcs.TFVC_NAME);
        }
        return false;
    }

    return true;
}
 
Example 12
Source Project: Intellij-Plugin   Source File: CustomRenameHandler.java    License: Apache License 2.0 6 votes vote down vote up
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
    PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
    if (element == null) element = psiElement;
    psiElement = element;
    String text = element.toString();

    //Finding text from annotation
    if (isMethod(element)) {
        List<String> values = StepUtil.getGaugeStepAnnotationValues((PsiMethod) element);
        if (values.size() == 0) {
            return;
        } else if (values.size() == 1)
            text = values.get(0);
        else if (values.size() > 1) {
            Messages.showWarningDialog("Refactoring for steps having aliases are not supported", "Warning");
            return;
        }
    } else if (isStep(element)) {
        text = ((SpecStepImpl) element).getStepValue().getStepAnnotationText();
    } else if (isConcept(element)) {
        text = removeIdentifiers(((ConceptStepImpl) element).getStepValue().getStepAnnotationText());
    }
    final RefactoringDialog form = new RefactoringDialog(this.editor.getProject(), file, this.editor, text);
    form.show();
}
 
Example 13
Source Project: consulo   Source File: ReopenProjectAction.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  //Force move focus to IdeFrame
  IdeEventQueue.getInstance().getPopupManager().closeAllPopups();

  final int modifiers = e.getModifiers();
  final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK) || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK) || e.getPlace() == ActionPlaces.WELCOME_SCREEN;

  Project project = e.getData(CommonDataKeys.PROJECT);
  if (!new File(myProjectPath).exists()) {
    if (Messages.showDialog(project, "The path " +
                                     FileUtil.toSystemDependentName(myProjectPath) +
                                     " does not exist.\n" +
                                     "If it is on a removable or network drive, please make sure that the drive is connected.", "Reopen Project", new String[]{"OK", "&Remove From List"}, 0,
                            Messages.getErrorIcon()) == 1) {
      myIsRemoved = true;
      RecentProjectsManager.getInstance().removePath(myProjectPath);
    }
    return;
  }

  ProjectUtil.openAsync(myProjectPath, project, forceOpenInNewFrame, UIAccess.current());
}
 
Example 14
Source Project: needsmoredojo   Source File: DojoSettingsConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e)
{
    autoDetectDojoSources.setEnabled(false);
    VirtualFile directory = SourcesLocator.getDojoSourcesDirectory(project, false);

    if(directory == null)
    {
        Messages.showInfoMessage("Could not find any dojo sources via auto-detection", "Auto-detect Dojo Sources");
        autoDetectDojoSources.setEnabled(true);
        return;
    }

    dojoSourcesText.setText(directory.getCanonicalPath());
    dojoSourceString = directory.getCanonicalPath();
    autoDetectDojoSources.setEnabled(true);

    updateModifiedState();
}
 
Example 15
Source Project: consulo   Source File: PasswordPromptComponent.java    License: Apache License 2.0 6 votes vote down vote up
public PasswordPromptComponent(PasswordSafeSettings.ProviderType type,
                               String message,
                               boolean showUserName,
                               String passwordPrompt,
                               String rememberPrompt) {
  myIconLabel.setText("");
  myIconLabel.setIcon(Messages.getWarningIcon());
  myMessageLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
  myMessageLabel.setText(message);
  setTargetProviderType(type);
  setUserInputVisible(showUserName);
  if (passwordPrompt != null) myPasswordLabel.setText(passwordPrompt);
  if (rememberPrompt != null) {
    myRememberCheckBox.setText(rememberPrompt);
    DialogUtil.registerMnemonic(myRememberCheckBox);
  }
}
 
Example 16
Source Project: intellij-pants-plugin   Source File: FastpassUpdater.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  if (fastpassBinaryExists()) {
    systemVersion(FASTPASS_PATH)
      .ifPresent(systemVersion -> extractFastpassData(project)
        .ifPresent(data -> {
          if (!data.version.equals(systemVersion)) {
            String message = "Do you want to update fastpass to version: " + systemVersion + "?";
            int answer = Messages.showYesNoDialog(project, message, DIALOG_TITLE, null);
            if (answer == Messages.YES) {
              updateFastpassVersion(project, data);
            }
          }
          else {
            Messages.showInfoMessage(project, "Fastpass is already up to date", DIALOG_TITLE);
          }
        }));
  }
}
 
Example 17
SelectConfigDialog() {
  super(null, false, false);
  setTitle("Run Configuration");
  myPanel = new JPanel();
  myTextPane = new JTextPane();
  Messages.installHyperlinkSupport(myTextPane);
  String selectConfig = "<html><body>" +
                        "<p>The run configuration for the Flutter module must be selected." +
                        "<p>Please change the run configuration to the one created when the<br>" +
                        "module was created. See <a href=\"" +
                        FlutterConstants.URL_RUN_AND_DEBUG +
                        "\">the Flutter documentation</a> for more information.</body></html>";
  myTextPane.setText(selectConfig);
  myPanel.add(myTextPane);
  init();
  //noinspection ConstantConditions
  getButton(getCancelAction()).setVisible(false);
}
 
Example 18
Source Project: r2m-plugin-android   Source File: ExampleChooserHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static String showExamplesDialog() {

        EXAMPLES_DIALOG_UP = true;
        try {
            List<String> examples = getManifest().getExamplesList();
            String response = Messages.showEditableChooseDialog(
                    R2MMessages.getMessage("CHOOSE_EXAMPLE_LABEL"),
                    R2MMessages.getMessage("CHOOSE_EXAMPLE_TITLE"),
                    Messages.getQuestionIcon(),
                    examples.toArray(new String[examples.size()]),
                    R2MMessages.getMessage("CHOOSE_EXAMPLE_DEFAULT_VALUE"),
                    null);
            return response == null ? null : response.split(ExamplesManifest.DESCRIPTION_SEPARATOR_KEY)[0];
        } finally {
            EXAMPLES_DIALOG_UP = false;
        }
    }
 
Example 19
Source Project: intellij   Source File: AlwaysPresentGoSyncPlugin.java    License: Apache License 2.0 6 votes vote down vote up
private static void fixLanguageSupport(Project project) {
  ProjectViewEdit edit =
      ProjectViewEdit.editLocalProjectView(
          project,
          builder -> {
            removeGoWorkspaceType(builder);
            addToAdditionalLanguages(builder);
            return true;
          });
  if (edit == null) {
    Messages.showErrorDialog(
        "Could not modify project view. Check for errors in your project view and try again",
        "Error");
    return;
  }
  edit.apply();

  BlazeSyncManager.getInstance(project)
      .incrementalProjectSync(/* reason= */ "enabled-go-support");
}
 
Example 20
Source Project: consulo   Source File: SdkListConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(final AnActionEvent e) {
  final Object o = getSelectedObject();
  if (o instanceof SdkImpl) {
    final SdkImpl selected = (SdkImpl)o;
    String defaultNewName = SdkConfigurationUtil.createUniqueSdkName(selected.getName(), mySdksModel.getSdks());
    final String newName = Messages.showInputDialog("Enter bundle name:", "Copy Bundle", null, defaultNewName, new NonEmptyInputValidator() {
      @Override
      public boolean checkInput(String inputString) {
        return super.checkInput(inputString) && mySdksModel.findSdk(inputString) == null;
      }
    });
    if (newName == null) return;

    SdkImpl sdk = selected.clone();
    sdk.setName(newName);
    sdk.setPredefined(false);

    mySdksModel.doAdd(sdk, sdk1 -> addSdkNode(sdk1, true));
  }
}
 
Example 21
Source Project: consulo   Source File: RemoteServerConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public JComponent createOptionsPanel() {
  mySettingsPanel.add(BorderLayout.CENTER, ConfigurableUIMigrationUtil.createComponent(myConfigurable));
  myTestConnectionButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      try {
        myConfigurable.apply();
      }
      catch (ConfigurationException exc) {
        Messages.showErrorDialog(myMainPanel, "Cannot test connection: " + exc.getMessage(), exc.getTitle());
        return;
      }
      testConnection();
    }
  });
  myMainPanel.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
  return myMainPanel;
}
 
Example 22
Source Project: consulo   Source File: FilterDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void doOKAction() {
  String errorMessage = null;
  if (noText(myNameField.getText())) {
    errorMessage = ToolsBundle.message("tools.filters.add.name.required.error");
  } else if (noText(myRegexpField.getText())) {
    errorMessage = ToolsBundle.message("tools.filters.add.regex.required.error");
  }

  if (errorMessage != null) {
    Messages.showMessageDialog(getContentPane(), errorMessage, CommonBundle.getErrorTitle(), Messages.getErrorIcon());
    return;
  }

  try {
    checkRegexp(myRegexpField.getText());
  } catch (InvalidExpressionException e) {
    Messages.showMessageDialog(getContentPane(), e.getMessage(), ToolsBundle.message("tools.filters.add.regex.invalid.title"), Messages.getErrorIcon());
    return;
  }
  super.doOKAction();
}
 
Example 23
Source Project: NutzCodeInsight   Source File: AbstractNavigationHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public final void navigate(MouseEvent mouseEvent, PsiElement psiElement) {
    if (canNavigate(psiElement)) {
        final Project project = psiElement.getProject();
        final List<VirtualFile> fileList = findTemplteFileList(psiElement);
        if (fileList.size() == 1) {
            FileEditorManager.getInstance(project).openFile(fileList.get(0), true);
        } else if (fileList.size() > 1) {
            final List<VirtualFile> infos = new ArrayList<>(fileList);
            List<PsiElement> elements = new ArrayList<>();
            PsiManager psiManager = PsiManager.getInstance(psiElement.getProject());
            infos.forEach(virtualFile -> elements.add(psiManager.findFile(virtualFile).getNavigationElement()));
            NavigationUtil.getPsiElementPopup(elements.toArray(new PsiElement[0]), title).show(new RelativePoint(mouseEvent));
        } else {
            if (fileList == null || fileList.size() <= 0) {
                Messages.showErrorDialog("没有找到这个资源文件,请检查!", "错误提示");
            }
        }
    }

}
 
Example 24
Source Project: azure-devops-intellij   Source File: AnnotateActionTest.java    License: MIT License 6 votes vote down vote up
@Test
public void testExecute_Success() {
    ArgumentCaptor<URI> argCapture = ArgumentCaptor.forClass(URI.class);
    when(mockTeamProjectReference.getName()).thenReturn("TeamName");
    when(mockItemInfo.getServerItem()).thenReturn("$/path/to/file.txt");
    when(mockServerContext.getTeamProjectReference()).thenReturn(mockTeamProjectReference);
    when(mockActionContext.getServerContext()).thenReturn(mockServerContext);
    when(mockActionContext.getItem()).thenReturn(mockItemInfo);
    annotateAction.execute(mockActionContext);

    verifyStatic(times(0));
    Messages.showErrorDialog(any(Project.class), anyString(), anyString());
    verifyStatic(times(1));
    BrowserUtil.browse(argCapture.capture());
    assertEquals(serverURI.toString() +
                    "TeamName/_versionControl/?path=%24%2Fpath%2Fto%2Ffile.txt&_a=contents&annotate=true&hideComments=true",
            argCapture.getValue().toString());
}
 
Example 25
Source Project: intellij-haxe   Source File: HaxeDebugRunner.java    License: Apache License 2.0 6 votes vote down vote up
private static void showInfoMessage(final Project project, final String message, final String title) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (false /* TODO: Get display behavior from the plugin configuration. */) {
            // Put up a modal dialog.  Folks don't like this much, so this should not be the default.
            Messages.showInfoMessage(project, message, title);
          } else {
            // Show the error on the status bar.
            StatusBarUtil.setStatusBarInfo(project, message);
            // XXX: Should we log this, too??
          }
          // Add the output to the "Problems" pane.
          ProblemsView.SERVICE.getInstance(project).addMessage(MessageCategory.INFORMATION, new String[]{message},
                                                               null, null, null,
                                                               null, UUID.randomUUID());
        }
    });
}
 
Example 26
Source Project: consulo   Source File: IncompatibleEncodingDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected JComponent createCenterPanel() {
  JLabel label = new JLabel(XmlStringUtil.wrapInHtml("The encoding you've chosen ('" +
                                                     charset.displayName() +
                                                     "') may change the contents of '" +
                                                     virtualFile.getName() +
                                                     "'.<br>" +
                                                     "Do you want to<br>" +
                                                     "1. <b>Reload</b> the file from disk in the new encoding '" +
                                                     charset.displayName() +
                                                     "' and overwrite editor contents or<br>" +
                                                     "2. <b>Convert</b> the text and overwrite file in the new encoding" +
                                                     "?"));
  label.setIcon(Messages.getQuestionIcon());
  label.setIconTextGap(10);
  return label;
}
 
Example 27
private VirtualFile getLocationFromModel(@Nullable Project projectToClose, boolean saveLocation) {
  final File location = new File(FileUtil.toSystemDependentName(myModel.projectLocation().get()));
  if (!location.exists() && !location.mkdirs()) {
    String message = ActionsBundle.message("action.NewDirectoryProject.cannot.create.dir", location.getAbsolutePath());
    Messages.showErrorDialog(projectToClose, message, ActionsBundle.message("action.NewDirectoryProject.title"));
    return null;
  }
  final File baseFile = new File(location, myModel.projectName().get());
  //noinspection ResultOfMethodCallIgnored
  baseFile.mkdirs();
  final VirtualFile baseDir = ApplicationManager.getApplication().runWriteAction(
    (Computable<VirtualFile>)() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(baseFile));
  if (baseDir == null) {
    FlutterUtils.warn(LOG, "Couldn't find '" + location + "' in VFS");
    return null;
  }
  if (saveLocation) {
    RecentProjectsManager.getInstance().setLastProjectCreationLocation(location.getPath());
  }
  return baseDir;
}
 
Example 28
Source Project: consulo   Source File: JBMacMessages.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int showYesNoDialog(@Nonnull String title,
                           String message,
                           @Nonnull String yesButton,
                           @Nonnull String noButton,
                           @Nullable consulo.ui.Window window) {
  if (window == null) {
    window = getForemostWindow(null);
  }
  SheetMessage sheetMessage = new SheetMessage(window, title, message, UIUtil.getQuestionIcon(),
                                               new String [] {yesButton, noButton}, null, yesButton, noButton);
  return sheetMessage.getResult().equals(yesButton) ? Messages.YES : Messages.NO;
}
 
Example 29
Source Project: crud-intellij-plugin   Source File: CrudActionDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void doNextAction() {
    ModuleWizardStep step = getCurrentStepObject();
    try {
        if (step.validate()) {
            super.doNextAction();
        }
    } catch (ConfigurationException e) {
        Messages.showErrorDialog(step.getComponent(), e.getMessage(), e.getTitle());
    }
}
 
Example 30
Source Project: consulo   Source File: FilterDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void doOKAction() {

  // Validate filter name

  myFilter.setName(myNameField.getText().trim());
  if (myFilter.getName().length() == 0) {
    Messages.showMessageDialog(myTable,
                               IdeBundle.message("error.filter.name.should.be.specified"),
                               CommonBundle.getErrorTitle(),
                               Messages.getErrorIcon());
    return;
  }
  for (int i = 0; i < myFilters.size(); i++) {
    TodoFilter filter = myFilters.get(i);
    if (myFilterIndex != i && myFilter.getName().equals(filter.getName())) {
      Messages.showMessageDialog(myTable,
                                 IdeBundle.message("error.filter.with.the.same.name.already.exists"),
                                 CommonBundle.getErrorTitle(),
                                 Messages.getErrorIcon());
      return;
    }
  }

  // Validate that at least one pettern is selected

  if (myFilter.isEmpty()) {
    Messages.showMessageDialog(myTable,
                               IdeBundle.message("error.filter.should.contain.at.least.one.pattern"),
                               CommonBundle.getErrorTitle(),
                               Messages.getErrorIcon());
    return;
  }

  super.doOKAction();
}