Java Code Examples for com.intellij.openapi.ui.Messages#showWarningDialog()

The following examples show how to use com.intellij.openapi.ui.Messages#showWarningDialog() . 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 check out the related API usage on the sidebar.
Example 1
Source File: GitVCSBuilder.java    From reviewboard-plugin-for-idea with MIT License 6 votes vote down vote up
private String generateDiff(Project project, VirtualFile root, VirtualFile[] vFiles) {
    try {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
            public void run() {
                FileDocumentManager.getInstance().saveAllDocuments();
            }
        });
        GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.DIFF);
        handler.addParameters("HEAD");
        handler.setSilent(true);
        handler.setStdoutSuppressed(true);
        handler.addRelativeFiles(Arrays.asList(vFiles));
        System.out.println(handler.printableCommandLine());
        return handler.run();
    } catch (Exception e) {
        Messages.showWarningDialog("Svn is still in refresh. Please try again later.", "Alter");
    }
    return null;
}
 
Example 2
Source File: RunTestFileAction.java    From MavenHelper with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
	MavenProject mavenProject = MavenActionUtil.getMavenProject(e.getDataContext());
	if (mavenProject != null) {

		PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext());
		if (psiFile instanceof PsiClassOwner) {
			List<String> goals = getGoals(e, (PsiClassOwner) psiFile,
					MavenActionUtil.getMavenProject(e.getDataContext()));

			final DataContext context = e.getDataContext();
			MavenRunnerParameters params = new MavenRunnerParameters(true, mavenProject.getDirectory(), null, goals,
					MavenActionUtil.getProjectsManager(context).getExplicitProfiles());
			run(context, params);
		} else {
			Messages.showWarningDialog(e.getProject(), "Cannot run for current file", "Maven Test File");
		}
	}
}
 
Example 3
Source File: ChangeSignatureDialogBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void doAction() {
  if (myParametersTable != null) {
    TableUtil.stopEditing(myParametersTable);
  }
  String message = validateAndCommitData();
  if (message != null) {
    if (message != EXIT_SILENTLY) {
      CommonRefactoringUtil.showErrorMessage(getTitle(), message, getHelpId(), myProject);
    }
    return;
  }
  if (myMethodsToPropagateParameters != null && !mayPropagateParameters()) {
    Messages.showWarningDialog(myProject, RefactoringBundle.message("changeSignature.parameters.wont.propagate"),
                               ChangeSignatureHandler.REFACTORING_NAME);
    myMethodsToPropagateParameters = null;
  }

  invokeRefactoring(createRefactoringProcessor());
}
 
Example 4
Source File: AddControllerForm.java    From r2m-plugin-android with Apache License 2.0 6 votes vote down vote up
private void showMissingDependencies() {
    String errorMessage = "The R2M Android SDK cannot be found.\n" +
            "Add these lines to app's build.gradle and re-sync your project:\n\n\n" + "" +
            "// Adding R2M dependencies and public repo\n" +
            "// Go to https://github.com/magnetsystems/r2m-plugin-android for more info\n" +
            "dependencies {\n" +
            "    compile(\"com.magnet:r2m-sdk-android:1.1.0@aar\") {\n" +
            "        transitive = true\n" +
            "    }\n" +
            "}\n" +
            "repositories {\n" +
            "    maven {\n" +
            "        url \"http://repo.magnet.com:8081/artifactory/public/\"\n" +
            "    }\n" +
            "}\n";
    Messages.showWarningDialog(
            errorMessage,
            "Warning");
    // So user can also copy-paste it from the event log
    Logger.error(this.getClass(), errorMessage);

}
 
Example 5
Source File: CreatePullRequestController.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
private boolean sanityCheckOnModel() {
    // if we have no target branches
    if (this.createModel.getRemoteBranchDropdownModel().getSize() == 0) {

        final String warningText
                = TfPluginBundle.message(TfPluginBundle.KEY_CREATE_PR_NO_VALID_TARGET_WARNING_MESSAGE);
        final String warningTitle
                = TfPluginBundle.message(TfPluginBundle.KEY_CREATE_PR_SANITY_CHECK_FAILED_WARNING_TITLE);

        Messages.showWarningDialog(warningText, warningTitle);

        return false;
    }

    return true;
}
 
Example 6
Source File: ThriftCompilerConfigurable.java    From intellij-thrift with Apache License 2.0 6 votes vote down vote up
@Override
public void onSuccess() {
  if (thriftCmd != null) {
    if (version != null) {
      Messages.showInfoMessage(
        project,
        ThriftBundle.message("thrift.compiler.check.success", version),
        ThriftBundle.message("thrift.compiler.check.success.title")
      );
    }

    setModified(true);
  }
  else {
    Messages.showWarningDialog(
      project,
      ThriftBundle.message("thrift.compiler.check.not-found"),
      ThriftBundle.message("thrift.compiler.check.not-found.title")
    );
  }
}
 
Example 7
Source File: TeamServicesSettingsModel.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Deletes the passwords/contexts from the table only but not permanently
 */
public void deletePasswords() {
    final ListSelectionModel selectionModel = getTableSelectionModel();
    if (!selectionModel.isSelectionEmpty()) {
        if (Messages.showYesNoDialog(project, TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_DELETE_MSG), TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_DELETE_TITLE), Messages.getQuestionIcon()) == Messages.YES) {
            // only delete contexts from the table at the moment and not for good (when Apply is used that is when we actually delete the contexts in deleteContexts)
            deleteContexts.addAll(tableModel.getSelectedContexts());
            populateContextTable();
        }
    } else {
        Messages.showWarningDialog(project, TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_NO_ROWS_SELECTED), TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_DELETE_TITLE));
    }
}
 
Example 8
Source File: PrePostReviewForm.java    From reviewboard-plugin-for-idea with MIT License 5 votes vote down vote up
@Override
public boolean isOKActionEnabled() {
    peopleTextField.addCurrentTextToHistory();
    groupTextField.addCurrentTextToHistory();
    if (reviewIdTextField.isEnabled()) {
        String reviewId = reviewIdTextField.getText();
        if (reviewId == null || "".equals(reviewId)) {
            Messages.showWarningDialog(project, "Please fill review request id", null);
            reviewIdTextField.grabFocus();
            return false;
        }
    }
    return true;
}
 
Example 9
Source File: GaugeWebBrowserPreview.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected Url getUrl(OpenInBrowserRequest request, VirtualFile virtualFile) throws BrowserException {
    try {
        if (!request.isAppendAccessToken()) return null;
        GaugeSettingsModel settings = getGaugeSettings();
        Spectacle spectacle = new Spectacle(request.getProject(), settings);
        if (spectacle.isInstalled())
            return previewUrl(request, virtualFile, settings);
        spectacle.notifyToInstall();
    } catch (Exception e) {
        Messages.showWarningDialog(String.format("Unable to create html file for %s", virtualFile.getName()), "Error");
    }
    return null;
}
 
Example 10
Source File: TeamServicesSettingsModelTest.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Test
public void testDeletePasswords_NoRowSelected() {
    teamServicesSettingsModel.getTableModel().addServerContexts(new ArrayList<ServerContext>(ImmutableList.of(mockServerContext_GitRepo, mockServerContext_TfvcRepo)));
    teamServicesSettingsModel.deletePasswords();

    assertEquals(0, teamServicesSettingsModel.getDeleteContexts().size());
    assertEquals(2, teamServicesSettingsModel.getTableModel().getRowCount());
    assertEquals(mockServerContext_TfvcRepo, teamServicesSettingsModel.getTableModel().getServerContext(0));
    assertEquals(mockServerContext_GitRepo, teamServicesSettingsModel.getTableModel().getServerContext(1));
    verifyStatic(times(1));
    Messages.showWarningDialog(mockProject, TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_NO_ROWS_SELECTED), TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_DELETE_TITLE));
}
 
Example 11
Source File: IdeaHelper.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Verifies if Git exe is configured, show notification and warning message if not
 *
 * @param project Idea project
 * @return true if Git exe is configured, false if Git exe is not correctly configured
 */
public static boolean isGitExeConfigured(@NotNull final Project project) {
    final GitExecutableValidator validator = GitVcs.getInstance(project).getExecutableValidator();
    if (!validator.checkExecutableAndNotifyIfNeeded()) {
        //Git.exe is not configured, show warning message in addition to notification from Git plugin
        Messages.showWarningDialog(project,
                TfPluginBundle.message(TfPluginBundle.KEY_GIT_NOT_CONFIGURED),
                TfPluginBundle.message(TfPluginBundle.KEY_TF_GIT));
        return false;
    }

    return true;
}
 
Example 12
Source File: SelectPackageTemplatePresenterImpl.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
@Override
public void addFavourite(String path) {
    if(isDuplicateFavourite(path)){
        Messages.showWarningDialog(Localizer.get("warning.FavouriteAlreadyExists"), "WarningDialog");
        return;
    }

    SaveUtil.editor()
            .addFavourite(new Favourite(path, SaveUtil.reader().getListFavourite().size()))
            .save();

    view.updateFavouritesUI();
}
 
Example 13
Source File: FileTemplateHelper.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
public static boolean isCurrentSchemeValid(Project project, FileTemplateSource fileTemplateSource) {
    switch (fileTemplateSource) {
        case PROJECT_ONLY:
        case PROJECT_PRIORITY:
        case DEFAULT_PRIORITY:
            if (FileTemplateHelper.isDefaultScheme(project)) {
                Messages.showWarningDialog(project, Localizer.get("warning.SwitchToProjectScheme"), "Warning Dialog");
                return false;
            }
    }

    return true;
}
 
Example 14
Source File: TemplateEditorConfigurable.java    From code-generator with Apache License 2.0 5 votes vote down vote up
private void createNewTemplate(String templateName) {
    MyGroupNode parent = getParentNode();
    if (Objects.isNull(parent)) {
        Messages.showWarningDialog("Please select a group", "Warning");
        return;
    }
    TemplateGroup group = templateGroupMap.get(parent.getDisplayName());

    Template template = new Template();
    template.setName(templateName);
    template.setContent("");
    addTemplateNode(group, template, parent);
    group.addTemplate(template);
}
 
Example 15
Source File: SelectSavePath.java    From EasyCode with MIT License 5 votes vote down vote up
/**
 * 确认按钮回调事件
 */
private void onOK() {
    List<Template> selectTemplateList = getSelectTemplate();
    // 如果选择的模板是空的
    if (selectTemplateList.isEmpty()) {
        Messages.showWarningDialog("Can't Select Template!", MsgValue.TITLE_INFO);
        return;
    }
    String savePath = pathField.getText();
    if (StringUtils.isEmpty(savePath)) {
        Messages.showWarningDialog("Can't Select Save Path!", MsgValue.TITLE_INFO);
        return;
    }
    // 针对Linux系统路径做处理
    savePath = savePath.replace("\\", "/");
    // 保存路径使用相对路径
    String basePath = project.getBasePath();
    if (!StringUtils.isEmpty(basePath) && savePath.startsWith(basePath)) {
        savePath = savePath.replace(basePath, ".");
    }
    // 保存配置
    TableInfo tableInfo = tableInfoService.getTableInfoAndConfig(cacheDataUtils.getSelectDbTable());
    tableInfo.setSavePath(savePath);
    tableInfo.setSavePackageName(packageField.getText());
    tableInfo.setPreName(preField.getText());
    tableInfo.setTemplateGroupName((String) groupComboBox.getSelectedItem());
    Module module = getSelectModule();
    if (module != null) {
        tableInfo.setSaveModelName(module.getName());
    }
    tableInfoService.save(tableInfo);

    // 生成代码
    codeGenerateService.generateByUnifiedConfig(getSelectTemplate(), unifiedConfig.isSelected(), !titleConfig.isSelected());
    // 关闭窗口
    dispose();
}
 
Example 16
Source File: PostReviewAction.java    From reviewboard-plugin-for-idea with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getData(PlatformDataKeys.PROJECT);
    final VirtualFile[] vFiles = event.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
    if (vFiles == null || vFiles.length == 0) {
        Messages.showMessageDialog("No file to be review", "Alert", null);
        return;
    }
    final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(vFiles[0]);
    if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, vFiles)) {
        setActionEnable(event, true);
        Messages.showWarningDialog("Some of selected files are not under control of SVN.", "Warning");
        return;
    }

    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);

    for (VirtualFile vf : vFiles) {
        LocalChangeList changeList = changeListManager.getChangeList(vf);
        if (changeList != null) {
            changeMessage = changeList.getName();
            break;
        }
    }

    changeListManager.invokeAfterUpdate(new Runnable() {
        @Override
        public void run() {
            System.out.println("Executing...");
            try {
                VCSBuilder builder = VCSBuilder.Factory.getBuilder(vcs);
                if (builder != null) {
                    execute(project, builder, vFiles);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }, InvokeAfterUpdateMode.SYNCHRONOUS_CANCELLABLE, "Refresh VCS", ModalityState.current());
}
 
Example 17
Source File: HttpUtils.java    From EasyCode with MIT License 5 votes vote down vote up
/**
 * 统一处理请求
 *
 * @param request 请求对象
 * @return 响应字符串
 */
private static String handlerRequest(HttpUriRequest request) {
    try {
        CloseableHttpResponse response = HTTP_CLIENT.execute(request);
        String body = EntityUtils.toString(response.getEntity());
        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
            Messages.showWarningDialog("连接到服务器错误!", MsgValue.TITLE_INFO);
            return null;
        }
        HttpClientUtils.closeQuietly(response);
        // 解析JSON数据
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode jsonNode = objectMapper.readTree(body);
        if (jsonNode.get(STATE_CODE).asInt() == 0) {
            JsonNode data = jsonNode.get("data");
            if (data instanceof TextNode) {
                return data.asText();
            }
            return data.toString();
        }
        // 获取错误消息
        String msg = jsonNode.get("msg").asText();
        Messages.showWarningDialog(msg, MsgValue.TITLE_INFO);
    } catch (IOException e) {
        Messages.showWarningDialog("无法连接到服务器!", MsgValue.TITLE_INFO);
        ExceptionUtil.rethrow(e);
    }
    return null;
}
 
Example 18
Source File: InstalledPluginsManagerMain.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void checkInstalledPluginDependencies(PluginDescriptor pluginDescriptor) {
  final Set<PluginId> notInstalled = new HashSet<>();
  final Set<PluginId> disabledIds = new HashSet<>();
  final PluginId[] dependentPluginIds = pluginDescriptor.getDependentPluginIds();
  final PluginId[] optionalDependentPluginIds = pluginDescriptor.getOptionalDependentPluginIds();
  for (PluginId id : dependentPluginIds) {
    if (ArrayUtil.find(optionalDependentPluginIds, id) > -1) continue;
    final boolean disabled = ((InstalledPluginsTableModel)myPluginsModel).isDisabled(id);
    final boolean enabled = ((InstalledPluginsTableModel)myPluginsModel).isEnabled(id);
    if (!enabled && !disabled) {
      notInstalled.add(id);
    }
    else if (disabled) {
      disabledIds.add(id);
    }
  }
  if (!notInstalled.isEmpty()) {
    Messages.showWarningDialog(
            "Plugin " + pluginDescriptor.getName() + " depends on unknown plugin" + (notInstalled.size() > 1 ? "s " : " ") + StringUtil.join(notInstalled, PluginId::toString, ", "),
            CommonBundle.getWarningTitle());
  }
  if (!disabledIds.isEmpty()) {
    final Set<PluginDescriptor> dependencies = new HashSet<>();
    for (PluginDescriptor ideaPluginDescriptor : myPluginsModel.getAllPlugins()) {
      if (disabledIds.contains(ideaPluginDescriptor.getPluginId())) {
        dependencies.add(ideaPluginDescriptor);
      }
    }
    final String disabledPluginsMessage = "disabled plugin" + (dependencies.size() > 1 ? "s " : " ");
    String message = "Plugin " +
                     pluginDescriptor.getName() +
                     " depends on " +
                     disabledPluginsMessage +
                     StringUtil.join(dependencies, PluginDescriptor::getName, ", ") +
                     ". Enable " +
                     disabledPluginsMessage.trim() +
                     "?";
    if (Messages.showOkCancelDialog(myActionsPanel, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon()) == Messages.OK) {
      ((InstalledPluginsTableModel)myPluginsModel).enableRows(dependencies.toArray(new PluginDescriptor[dependencies.size()]), Boolean.TRUE);
    }
  }
}
 
Example 19
Source File: MindMapDialogProvider.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void msgWarn(@Nullable final Component parentComponent, @Nonnull final String text) {
  Messages.showWarningDialog(this.project, text, "Warning");
}
 
Example 20
Source File: RollbackChangesDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void showNoChangesDialog(Project project) {
  String operationName = UIUtil.removeMnemonic(RollbackUtil.getRollbackOperationName(project));
  Messages.showWarningDialog(project, VcsBundle.message("commit.dialog.no.changes.detected.text"),
                             VcsBundle.message("changes.action.rollback.nothing", operationName));
}