Example usage for com.intellij.openapi.ui Messages showWarningDialog

List of usage examples for com.intellij.openapi.ui Messages showWarningDialog

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages showWarningDialog.

Prototype

public static void showWarningDialog(@NotNull Component component, String message,
            @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title) 

Source Link

Usage

From source file:com.microsoft.alm.plugin.idea.tfvc.ui.settings.ProjectConfigurableForm.java

License:Open Source License

public ProjectConfigurableForm(final Project project) {
    myProject = project;/*from  w  w w .  java2s . c om*/

    // TODO: set these visible once we start using them
    myResetPasswordsButton.setVisible(false);
    myUseIdeaHttpProxyCheckBox.setVisible(false);
    myTFSCheckBox.setVisible(false);
    myStatefulCheckBox.setVisible(false);
    myReportNotInstalledPoliciesCheckBox.setVisible(false);
    myResetPasswordsButton.setVisible(false);
    serverLabel.setVisible(false);
    passwordLabel.setVisible(false);
    checkinPolicyLabel.setVisible(false);
    noteLabel.setVisible(false);

    pathLabel.setText(TfPluginBundle.message(TfPluginBundle.KEY_TFVC_SETTINGS_DESCRIPTION));
    tfExeField.addBrowseFolderListener(TfPluginBundle.message(TfPluginBundle.KEY_TFVC_SETTINGS_TITLE),
            TfPluginBundle.message(TfPluginBundle.KEY_TFVC_SETTINGS_DESCRIPTION), project,
            FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());

    testExeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            PluginServiceProvider.getInstance().getPropertyService().setProperty(PropertyService.PROP_TF_HOME,
                    getCurrentExecutablePath());
            try {
                TfTool.checkVersion();
                Messages.showInfoMessage(myContentPane,
                        TfPluginBundle.message(TfPluginBundle.KEY_TFVC_SETTINGS_FOUND_EXE),
                        TfPluginBundle.message(TfPluginBundle.KEY_TFVC_TF_VERSION_WARNING_TITLE));
            } catch (ToolVersionException e) {
                Messages.showWarningDialog(myContentPane,
                        LocalizationServiceImpl.getInstance().getExceptionMessage(e),
                        TfPluginBundle.message(TfPluginBundle.KEY_TFVC_TF_VERSION_WARNING_TITLE));
            } catch (ToolException e) {
                Messages.showErrorDialog(myContentPane,
                        LocalizationServiceImpl.getInstance().getExceptionMessage(e),
                        TfPluginBundle.message(TfPluginBundle.KEY_TFVC_TF_VERSION_WARNING_TITLE));
            }

        }
    });

    // load settings
    load();

    // TODO: comment back in when ready to use
    //    myManageButton.addActionListener(new ActionListener() {
    //      public void actionPerformed(final ActionEvent e) {
    //        ManageWorkspacesDialog d = new ManageWorkspacesDialog(myProject);
    //        d.show();
    //      }
    //    });
    //
    //    myUseIdeaHttpProxyCheckBox.setSelected(TFSConfigurationManager.getInstance().useIdeaHttpProxy());
    //
    //    myResetPasswordsButton.addActionListener(new ActionListener() {
    //      public void actionPerformed(final ActionEvent e) {
    //        final String title = "Reset Stored Passwords";
    //        if (Messages.showYesNoDialog(myProject, "Do you want to reset all stored passwords?", title, Messages.getQuestionIcon()) == Messages.YES) {
    //          TFSConfigurationManager.getInstance().resetStoredPasswords();
    //          Messages.showInfoMessage(myProject, "Passwords reset successfully.", title);
    //        }
    //      }
    //    });
    //
    //        ActionListener l = new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                updateNonInstalledCheckbox();
    //            }
    //        };
    //        myStatefulCheckBox.addActionListener(l);
    //        myTFSCheckBox.addActionListener(l);
}

From source file:com.talkingdata.orm.tool.ORMGenerateAction.java

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    ORMConfig config = ORMConfig.getInstance(project);

    // 1. validate input parameter
    if (!validateConfig(project, config)) {
        return;/* w  w  w.j  a  v a2s.c o m*/
    }

    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl(
            String.format("jdbc:mysql://%s:%s/%s", config.getIp(), config.getPort(), config.getDatabase()));
    dataSource.setUsername(config.getUser());
    dataSource.setPassword(config.getPassword());

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    // 2. validate database is connected
    try {
        jdbcTemplate.execute("SELECT 1");
    } catch (Exception exception) {
        Messages.showWarningDialog(project, "The database is not connected.", "Warning");
        return;
    }

    File resourceDirectory = new File(project.getBasePath(), "/src/main/resources/mybatis");
    if (!resourceDirectory.exists()) {
        resourceDirectory.mkdirs();
    }

    File packageDirectory = new File(project.getBasePath(),
            "/src/main/java/" + config.getPackageName().replaceAll("\\.", "/"));
    if (!packageDirectory.exists()) {
        packageDirectory.mkdirs();
    }

    Properties p = new Properties();
    p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
            "org.apache.velocity.runtime.log.Log4JLogChute");
    Velocity.init(p);

    // 3. query all table
    SqlParser sqlParser = new SqlParser();

    try {
        for (ClassDefinition cls : sqlParser.getTables(jdbcTemplate, config.getDatabase(),
                config.getPackageName())) {
            Map<String, Object> map = new HashMap<>(1);
            map.put("cls", cls);

            File domainDirectory = new File(packageDirectory, "domain");
            if (!domainDirectory.exists()) {
                domainDirectory.mkdirs();
            }
            File clsFile = new File(domainDirectory, cls.getClassName() + ".java");
            if (!clsFile.exists()) {
                clsFile.createNewFile();
            }
            writeFile("com/talkingdata/orm/tool/vm/class.vm", map, new FileWriter(clsFile));

            File daoDirectory = new File(packageDirectory, "dao");
            if (!daoDirectory.exists()) {
                daoDirectory.mkdirs();
            }
            File daoFile = new File(daoDirectory, cls.getClassName() + "Dao.java");
            if (!daoFile.exists()) {
                daoFile.createNewFile();
            }
            writeFile("com/talkingdata/orm/tool/vm/dao.vm", map, new FileWriter(daoFile));

            File mapperFile = new File(resourceDirectory, cls.getClassInstanceName() + ".xml");
            if (!mapperFile.exists()) {
                mapperFile.createNewFile();
            }
            writeFile("com/talkingdata/orm/tool/vm/mapper.vm", map, new FileWriter(mapperFile));
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

}

From source file:com.talkingdata.orm.tool.ORMGenerateAction.java

private boolean validateConfig(Project project, ORMConfig config) {
    // 1. validate input parameter
    if (StringUtils.isBlank(config.getIp())) {
        Messages.showWarningDialog(project, "The database's ip is null.", "Warning");
        return false;
    }//from w ww.  java 2s .  c o  m

    if (StringUtils.isBlank(config.getPort())) {
        Messages.showWarningDialog(project, "The database's port is null.", "Warning");
        return false;
    }

    try {
        Integer.parseInt(config.getPort());
    } catch (NumberFormatException e) {
        Messages.showWarningDialog(project, "The database's port is not number.", "Warning");
        return false;
    }

    if (StringUtils.isBlank(config.getDatabase())) {
        Messages.showWarningDialog(project, "The database's name is null.", "Warning");
        return false;
    }

    if (StringUtils.isBlank(config.getUser())) {
        Messages.showWarningDialog(project, "The database's user is null.", "Warning");
        return false;
    }

    if (StringUtils.isBlank(config.getPassword())) {
        Messages.showWarningDialog(project, "The database's password is null.", "Warning");
        return false;
    }

    if (StringUtils.isBlank(config.getPackageName())) {
        Messages.showWarningDialog(project, "The package's name is null.", "Warning");
        return false;
    }
    return true;
}

From source file:com.urswolfer.intellij.plugin.gerrit.rest.GerritUtil.java

License:Apache License

@SuppressWarnings("UnresolvedPropertyKey")
public boolean testGitExecutable(final Project project) {
    final GitVcsApplicationSettings settings = GitVcsApplicationSettings.getInstance();
    final String executable = settings.getPathToGit();
    final GitVersion version;
    try {//  www.j a  v a  2 s .  c o  m
        version = GitVersion.identifyVersion(executable);
    } catch (Exception e) {
        Messages.showErrorDialog(project, e.getMessage(), GitBundle.getString("find.git.error.title"));
        return false;
    }

    if (!version.isSupported()) {
        Messages.showWarningDialog(project,
                GitBundle.message("find.git.unsupported.message", version.toString(), GitVersion.MIN),
                GitBundle.getString("find.git.success.title"));
        return false;
    }
    return true;
}

From source file:de.fu_berlin.inf.dpp.intellij.ui.util.SafeDialogUtils.java

License:Open Source License

public static void showWarning(final String message, final String title) {
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        @Override/*w  ww  .  j  a  v a2s  .c o m*/
        public void run() {
            Messages.showWarningDialog(saros.getProject(), message, title);
        }
    });
}

From source file:org.coding.git.util.CodingNetNotifications.java

License:Apache License

public static void showWarningDialog(@Nullable Project project, @NotNull String title,
        @NotNull String message) {
    LOG.info(title + "; " + message);
    Messages.showWarningDialog(project, message, title);
}

From source file:org.coding.git.util.CodingNetNotifications.java

License:Apache License

public static void showWarningDialog(@NotNull Component component, @NotNull String title,
        @NotNull String message) {
    LOG.info(title + "; " + message);
    Messages.showWarningDialog(component, message, title);
}

From source file:org.intellij.plugins.intelliLang.InjectionsSettingsUI.java

License:Apache License

private void doImportAction(final DataContext dataContext) {
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, false) {
        @Override//from  w w  w .j  a  v  a  2 s  .  co  m
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory()
                    || "xml".equals(file.getExtension()) || file.getFileType() instanceof ArchiveFileType);
        }

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            return "xml".equalsIgnoreCase(file.getExtension());
        }
    };
    descriptor
            .setDescription("Please select the configuration file (usually named IntelliLang.xml) to import.");
    descriptor.setTitle("Import Configuration");

    descriptor.putUserData(LangDataKeys.MODULE_CONTEXT, LangDataKeys.MODULE.getData(dataContext));

    final SplitterProportionsData splitterData = new SplitterProportionsDataImpl();
    splitterData.externalizeFromDimensionService("IntelliLang.ImportSettingsKey.SplitterProportions");

    final VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
    if (file == null) {
        return;
    }
    try {
        final Configuration cfg = Configuration.load(file.getInputStream());
        if (cfg == null) {
            Messages.showWarningDialog(myProject,
                    "The selected file does not contain any importable configuration.", "Nothing to Import");
            return;
        }
        final CfgInfo info = getDefaultCfgInfo();
        final Map<String, Set<InjInfo>> currentMap = ContainerUtil.classify(info.injectionInfos.iterator(),
                new Convertor<InjInfo, String>() {
                    @Override
                    public String convert(final InjInfo o) {
                        return o.injection.getSupportId();
                    }
                });
        final List<BaseInjection> originalInjections = new ArrayList<BaseInjection>();
        final List<BaseInjection> newInjections = new ArrayList<BaseInjection>();
        //// remove duplicates
        //for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
        //  final Set<BaseInjection> currentInjections = currentMap.get(supportId);
        //  if (currentInjections == null) continue;
        //  for (BaseInjection injection : currentInjections) {
        //    Configuration.importInjections(newInjections, Collections.singleton(injection), originalInjections, newInjections);
        //  }
        //}
        //myInjections.clear();
        //myInjections.addAll(newInjections);

        for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
            ArrayList<InjInfo> list = new ArrayList<InjInfo>(
                    ObjectUtils.notNull(currentMap.get(supportId), Collections.<InjInfo>emptyList()));
            final List<BaseInjection> currentInjections = getInjectionList(list);
            final List<BaseInjection> importingInjections = cfg.getInjections(supportId);
            if (currentInjections == null) {
                newInjections.addAll(importingInjections);
            } else {
                Configuration.importInjections(currentInjections, importingInjections, originalInjections,
                        newInjections);
            }
        }
        info.replace(originalInjections, newInjections);
        myInjectionsTable.getListTableModel().setItems(getInjInfoList(myInfos));
        final int n = newInjections.size();
        if (n > 1) {
            Messages.showInfoMessage(myProject, n + " entries have been successfully imported",
                    "Import Successful");
        } else if (n == 1) {
            Messages.showInfoMessage(myProject, "One entry has been successfully imported",
                    "Import Successful");
        } else {
            Messages.showInfoMessage(myProject, "No new entries have been imported", "Import");
        }
    } catch (Exception ex) {
        Configuration.LOG.error(ex);

        final String msg = ex.getLocalizedMessage();
        Messages.showErrorDialog(myProject, msg != null && msg.length() > 0 ? msg : ex.toString(),
                "Import Failed");
    }
}

From source file:org.jetbrains.android.exportSignedPackage.ExportSignedPackageWizard.java

License:Apache License

private void createAndAlignApk(final String apkPath) {
    AndroidPlatform platform = getFacet().getConfiguration().getAndroidPlatform();
    assert platform != null;
    String sdkPath = platform.getSdkData().getLocation();
    String zipAlignPath = sdkPath + File.separatorChar + AndroidCommonUtils.toolPath(SdkConstants.FN_ZIPALIGN);
    File zipalign = new File(zipAlignPath);
    final boolean runZipAlign = zipalign.isFile();
    File destFile = null;/* w w  w .j  av a  2  s  .c  o  m*/
    try {
        destFile = runZipAlign ? FileUtil.createTempFile("android", ".apk") : new File(apkPath);
        createApk(destFile);
    } catch (Exception e) {
        showErrorInDispatchThread(e.getMessage());
    }
    if (destFile == null)
        return;

    if (runZipAlign) {
        File realDestFile = new File(apkPath);
        final String message = AndroidCommonUtils.executeZipAlign(zipAlignPath, destFile, realDestFile);
        if (message != null) {
            showErrorInDispatchThread(message);
            return;
        }
    }
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            String title = AndroidBundle.message("android.export.package.wizard.title");
            final Project project = getProject();
            final File apkFile = new File(apkPath);

            final VirtualFile vApkFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(apkFile);
            if (vApkFile != null) {
                vApkFile.refresh(true, false);
            }

            if (!runZipAlign) {
                Messages.showWarningDialog(project,
                        AndroidCommonBundle.message("android.artifact.building.cannot.find.zip.align.error"),
                        title);
            }

            if (ShowFilePathAction.isSupported()) {
                if (Messages.showOkCancelDialog(project,
                        AndroidBundle.message("android.export.package.success.message", apkFile.getName()),
                        title, RevealFileAction.getActionName(), IdeBundle.message("action.close"),
                        Messages.getInformationIcon()) == Messages.OK) {
                    ShowFilePathAction.openFile(apkFile);
                }
            } else {
                Messages.showInfoMessage(project,
                        AndroidBundle.message("android.export.package.success.message", apkFile), title);
            }
        }
    }, ModalityState.NON_MODAL);
}

From source file:org.jetbrains.idea.svn.dialogs.CopiesPanel.java

License:Apache License

private void updateList(@NotNull final List<WCInfo> infoList,
        @NotNull final List<WorkingCopyFormat> supportedFormats) {
    myPanel.removeAll();//from   ww w .  j  a  v a 2s .  c o  m
    final Insets nullIndent = new Insets(1, 3, 1, 0);
    final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE, new Insets(2, 2, 0, 0), 0, 0);
    gb.insets.left = 4;
    myPanel.add(myRefreshLabel, gb);
    gb.insets.left = 1;

    final LocalFileSystem lfs = LocalFileSystem.getInstance();
    final Insets topIndent = new Insets(10, 3, 0, 0);
    for (final WCInfo wcInfo : infoList) {
        final Collection<WorkingCopyFormat> upgradeFormats = getUpgradeFormats(wcInfo, supportedFormats);

        final VirtualFile vf = lfs.refreshAndFindFileByIoFile(new File(wcInfo.getPath()));
        final VirtualFile root = (vf == null) ? wcInfo.getVcsRoot() : vf;

        final JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, "");
        editorPane.setEditable(false);
        editorPane.setFocusable(true);
        editorPane.setBackground(UIUtil.getPanelBackground());
        editorPane.setOpaque(false);
        editorPane.addHyperlinkListener(new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    if (CONFIGURE_BRANCHES.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Configure Branches"))
                            return;
                        BranchConfigurationDialog.configureBranches(myProject, root, true);
                    } else if (FIX_DEPTH.equals(e.getDescription())) {
                        final int result = Messages.showOkCancelDialog(myVcs.getProject(),
                                "You are going to checkout into '" + wcInfo.getPath()
                                        + "' with 'infinity' depth.\n"
                                        + "This will update your working copy to HEAD revision as well.",
                                "Set Working Copy Infinity Depth", Messages.getWarningIcon());
                        if (result == Messages.OK) {
                            // update of view will be triggered by roots changed event
                            SvnCheckoutProvider.checkout(myVcs.getProject(), new File(wcInfo.getPath()),
                                    wcInfo.getRootUrl(), SVNRevision.HEAD, SVNDepth.INFINITY, false, null,
                                    wcInfo.getFormat());
                        }
                    } else if (CHANGE_FORMAT.equals(e.getDescription())) {
                        changeFormat(wcInfo, upgradeFormats);
                    } else if (MERGE_FROM.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Merge From"))
                            return;
                        mergeFrom(wcInfo, root, editorPane);
                    } else if (CLEANUP.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Cleanup"))
                            return;
                        new CleanupWorker(new VirtualFile[] { root }, myVcs.getProject(),
                                "action.Subversion.cleanup.progress.title").execute();
                    }
                }
            }

            private boolean checkRoot(VirtualFile root, final String path, final String actionName) {
                if (root == null) {
                    Messages.showWarningDialog(myProject, "Invalid working copy root: " + path,
                            "Can not " + actionName);
                    return false;
                }
                return true;
            }
        });
        editorPane.setBorder(null);
        editorPane.setText(formatWc(wcInfo, upgradeFormats));

        final JPanel copyPanel = new JPanel(new GridBagLayout());

        final GridBagConstraints gb1 = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST,
                GridBagConstraints.NONE, nullIndent, 0, 0);
        gb1.insets.top = 1;
        gb1.gridwidth = 3;

        gb.insets = topIndent;
        gb.fill = GridBagConstraints.HORIZONTAL;
        ++gb.gridy;

        final JPanel contForCopy = new JPanel(new BorderLayout());
        contForCopy.add(copyPanel, BorderLayout.WEST);
        myPanel.add(contForCopy, gb);

        copyPanel.add(editorPane, gb1);
        gb1.insets = nullIndent;
    }

    myPanel.revalidate();
    myPanel.repaint();
}