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

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

Introduction

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

Prototype

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

Source Link

Document

Use this method only if you do not know project or component

Usage

From source file:com.google.idea.blaze.base.lang.AdditionalLanguagesHelper.java

License:Open Source License

private void enableLanguageSupport(Project project, LanguageClass language) {
    ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
        ListSection<LanguageClass> existingSection = builder.getLast(AdditionalLanguagesSection.KEY);
        builder.replace(existingSection,
                ListSection.update(AdditionalLanguagesSection.KEY, existingSection).add(language));
        return true;
    });//from   w  ww.j  a  va  2s . c  o  m
    if (edit == null) {
        Messages.showErrorDialog(
                "Could not modify project view. Check for errors in your project view and try again", "Error");
        return;
    }
    edit.apply();

    suppressNotifications(language);

    BlazeSyncManager.getInstance(project)
            .requestProjectSync(new BlazeSyncParams.Builder("Sync", BlazeSyncParams.SyncMode.INCREMENTAL)
                    .addProjectViewTargets(true)
                    .addWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet()).build());
}

From source file:com.google.idea.blaze.base.wizard2.ImportFromWorkspaceProjectViewOption.java

License:Open Source License

private void chooseWorkspacePath() {
    FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false)
            .withShowHiddenFiles(true) // Show root project view file
            .withHideIgnored(false).withTitle("Select Project View File")
            .withDescription("Select a project view file to import.")
            .withFileFilter(virtualFile -> ProjectViewStorageManager
                    .isProjectViewFile(new File(virtualFile.getPath())));
    FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, null, null);

    WorkspacePathResolver workspacePathResolver = builder.getWorkspaceOption().getWorkspacePathResolver();
    File fileBrowserRoot = builder.getWorkspaceOption().getFileBrowserRoot();
    File startingLocation = fileBrowserRoot;
    String projectViewPath = getProjectViewPath();
    if (!projectViewPath.isEmpty()) {
        // If the user has typed part of the path then clicked the '...', try to start from the
        // partial state
        projectViewPath = StringUtil.trimEnd(projectViewPath, '/');
        if (WorkspacePath.validate(projectViewPath)) {
            File fileLocation = workspacePathResolver.resolveToFile(new WorkspacePath(projectViewPath));
            if (fileLocation.exists() && FileUtil.isAncestor(fileBrowserRoot, fileLocation, true)) {
                startingLocation = fileLocation;
            }//from ww  w.  ja  va 2  s  .  co m
        }
    }
    VirtualFile toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(startingLocation.getPath());
    VirtualFile[] files = chooser.choose(null, toSelect);
    if (files.length == 0) {
        return;
    }
    VirtualFile file = files[0];

    if (!FileUtil.isAncestor(fileBrowserRoot.getPath(), file.getPath(), true)) {
        Messages.showErrorDialog(String.format(
                "You must choose a project view file under %s. "
                        + "To use an external project view, please use the 'Copy external' option.",
                fileBrowserRoot.getPath()), "Cannot Use Project View File");
        return;
    }

    String newWorkspacePath = FileUtil.getRelativePath(fileBrowserRoot, new File(file.getPath()));
    projectViewPathField.setText(newWorkspacePath);
}

From source file:com.google.idea.blaze.clwb.wizard2.BlazeCProjectCreator.java

License:Open Source License

@Nullable
public Project createFromWizard() {
    try {//  w  w  w. ja v a  2s. co  m
        return doCreate();
    } catch (final IOException e) {
        UIUtil.invokeLaterIfNeeded(
                () -> Messages.showErrorDialog(e.getMessage(), "Project Initialization Failed"));
        return null;
    }
}

From source file:com.google.idea.blaze.clwb.wizard2.BlazeNewProjectWizard.java

License:Open Source License

private void handleCommitException(CommitStepException e) {
    String message = e.getMessage();
    if (message != null) {
        Messages.showErrorDialog(getCurrentStepComponent(), message);
    }/*from  w w w  . j  a v  a  2s . c om*/
}

From source file:com.google.idea.blaze.java.libraries.AddLibraryTargetDirectoryToProjectViewAction.java

License:Open Source License

static void addDirectoriesToProjectView(Project project, List<Library> libraries) {
    Set<WorkspacePath> workspacePaths = Sets.newHashSet();
    for (Library library : libraries) {
        WorkspacePath workspacePath = getDirectoryToAddForLibrary(project, library);
        if (workspacePath != null) {
            workspacePaths.add(workspacePath);
        }//from  ww w.j  a  v a2  s  .com
    }
    ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
        ListSection<DirectoryEntry> existingSection = builder.getLast(DirectorySection.KEY);
        ListSection.Builder<DirectoryEntry> directoryBuilder = ListSection.update(DirectorySection.KEY,
                existingSection);
        for (WorkspacePath workspacePath : workspacePaths) {
            directoryBuilder.add(new DirectoryEntry(workspacePath, true));
        }
        builder.replace(existingSection, directoryBuilder);
        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).requestProjectSync(
            new BlazeSyncParams.Builder("Adding Library", BlazeSyncParams.SyncMode.INCREMENTAL)
                    .addProjectViewTargets(true)
                    .addWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet()).build());
}

From source file:com.googlecode.cssxfire.CssXFireConnector.java

License:Apache License

public void initComponent() {
    // start web server
    try {// www  . j a  va  2  s. c o m
        webServer = new SimpleWebServer();
        new Thread(webServer).start();
        initialized = true;
    } catch (BindException e) {
        LOG.error("Unable to start web server - address in use: ", e);
        Messages.showErrorDialog(
                "Unable to start SimpleWebServer on localhost:6776 - address is in use.\n\nCSS-X-Fire will be disabled until restart of "
                        + ApplicationNamesInfo.getInstance().getFullProductName(),
                "CSS-X-Fire error");
    } catch (IOException e) {
        LOG.error("Unable to start web server: ", e);
        Messages.showErrorDialog("Unable to start SimpleWebServer on localhost:6776 - " + e.getMessage()
                + "\n\nCSS-X-Fire will be disabled until restart of "
                + ApplicationNamesInfo.getInstance().getFullProductName(), "CSS-X-Fire error");
    }
}

From source file:com.hp.alm.ali.idea.action.attachment.AttachmentDownloadAction.java

License:Apache License

@Override
protected void actionPerformed(AnActionEvent event, Project project, Entity entity) {
    String name = entity.getPropertyValue("name");
    FileSaverDescriptor desc = new FileSaverDescriptor("Download Attachment",
            "Download attachment to the local filesystem.");
    final VirtualFileWrapper file = FileChooserFactory.getInstance().createSaveFileDialog(desc, project)
            .save(lastDir, name.replaceFirst("\\.agmlink$", ""));
    if (file != null) {
        VirtualFile vf = file.getVirtualFile(true);
        if (vf == null) {
            Messages.showErrorDialog("Invalid file specified", "Error");
            return;
        }//from  ww w .ja  v a 2s .  c  o  m
        lastDir = vf.getParent();
        if (!name.endsWith(".agmlink") || file.getFile().getName().endsWith(".agmlink")) {
            // either regular file or we explicitly ask for .agmlink file
            ProgressManager.getInstance()
                    .run(new AttachmentDownloadTask(project, file.getFile(), name,
                            Integer.valueOf(entity.getPropertyValue("file-size")),
                            new EntityRef(entity.getPropertyValue("parent-type"),
                                    Integer.valueOf(entity.getPropertyValue("parent-id"))),
                            null));
        } else {
            // download referenced content instead
            ProgressManager.getInstance()
                    .run(new AttachmentAgmLinkDownloadTask(project, file.getFile(), name,
                            Integer.valueOf(entity.getPropertyValue("file-size")),
                            new EntityRef(entity.getPropertyValue("parent-type"),
                                    Integer.valueOf(entity.getPropertyValue("parent-id"))),
                            null));
        }
    }
}

From source file:com.hp.alm.ali.idea.action.attachment.AttachmentUpdateTask.java

License:Apache License

public void run(ProgressIndicator indicator) {
    if (file != null) {
        IndicatingInputStream fis;//  w ww  . j  a  v a2 s.  c  om
        try {
            fis = new IndicatingInputStream(file, indicator);
        } catch (FileNotFoundException e) {
            UIUtil.invokeLaterIfNeeded(new Runnable() {
                @Override
                public void run() {
                    Messages.showErrorDialog("File not found.", "Failed to upload attachment");
                }
            });
            return;
        }
        try {
            if (!attachmentService.updateAttachmentContent(filename, parent, fis, file.length(), false)) {
                return;
            }
        } catch (CanceledException e) {
            return;
        }
    }
    if (description != null && !indicator.isCanceled()) {
        attachmentService.updateAttachmentProperty(filename, parent, "description", description, false);
    }
    if (name != null) {
        attachmentService.updateAttachmentProperty(filename, parent, "name", name, false);
    }
}

From source file:com.hp.alm.ali.idea.action.attachment.AttachmentUploadTask.java

License:Apache License

public void run(ProgressIndicator indicator) {
    IndicatingInputStream fis;/*from ww  w  . j  ava2 s .  co  m*/
    try {
        fis = new IndicatingInputStream(file, indicator);
    } catch (FileNotFoundException e) {
        UIUtil.invokeLaterIfNeeded(new Runnable() {
            @Override
            public void run() {
                Messages.showErrorDialog("File not found.", "Failed to upload attachment");
            }
        });
        return;
    }
    try {
        String attachmentName = attachmentService.createAttachment(filename, fis, file.length(), parent);
        if (attachmentName == null) {
            return;
        }

        if (description != null && !indicator.isCanceled()) {
            attachmentService.updateAttachmentProperty(attachmentName, parent, "description", description,
                    false);
        }
    } catch (CanceledException e) {
        // user gave up
    }
}

From source file:com.hp.alm.ali.idea.cfg.AliAbstractConfigurable.java

License:Apache License

private void initialize() {
    SearchableOptionsRegistrar.getInstance().addOption("integration", null, HP_ALM_INTEGRATION, getId(),
            getDisplayName());/*  w ww.  j a v a 2 s .co  m*/
    SearchableOptionsRegistrar.getInstance().addOption("alm", null, HP_ALM_INTEGRATION, getId(),
            getDisplayName());
    SearchableOptionsRegistrar.getInstance().addOption("qc", null, HP_ALM_INTEGRATION, getId(),
            getDisplayName());
    SearchableOptionsRegistrar.getInstance().addOption("QC", null, HP_ALM_INTEGRATION, getId(),
            getDisplayName());
    SearchableOptionsRegistrar.getInstance().addOption("agm", null, HP_ALM_INTEGRATION, getId(),
            getDisplayName());
    SearchableOptionsRegistrar.getInstance().addOption("agile", null, HP_ALM_INTEGRATION, getId(),
            getDisplayName());
    SearchableOptionsRegistrar.getInstance().addOption("manager", null, HP_ALM_INTEGRATION, getId(),
            getDisplayName());

    JPanel content = new JPanel(new BorderLayout());
    JLabel label = new JLabel(IconLoader.getIcon("/ali_icon_64x64.png"));
    label.setVerticalAlignment(SwingConstants.TOP);

    JPanel jPanel = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(3, 3, 3, 3);
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 0;
    c.gridheight = 6;
    jPanel.add(label, c);
    c.gridheight = 1;
    c.gridx++;
    c.gridwidth = 3;
    jPanel.add(new JLabel(getCaption()), c);
    c.gridwidth = 1;
    c.gridy++;
    jPanel.add(new JLabel("Location:"), c);
    SearchableOptionsRegistrar.getInstance().addOption("location", null, "Location:", getId(),
            getDisplayName());
    c.gridx++;
    locationField = getLocationField();
    jPanel.add((JTextComponent) locationField, c);
    locationField.getDocument().addDocumentListener(this);
    c.gridx = 2;
    c.gridy++;
    c.gridwidth = 2;
    JLabel exLabel = new JLabel("E.g. http://mycompany.com:8080/qcbin");
    exLabel.setFont(exLabel.getFont().deriveFont(Font.ITALIC, exLabel.getFont().getSize() - 2));
    jPanel.add(exLabel, c);
    c.gridwidth = 1;
    c.gridx = 1;
    c.gridy++;
    jPanel.add(new JLabel("Username:"), c);
    SearchableOptionsRegistrar.getInstance().addOption("username", null, "Username:", getId(),
            getDisplayName());
    c.gridx++;
    usernameField = getUsernameField();
    jPanel.add((JTextComponent) usernameField, c);
    usernameField.getDocument().addDocumentListener(this);
    c.gridx = 1;
    c.gridy++;
    jPanel.add(new JLabel("Password:"), c);
    SearchableOptionsRegistrar.getInstance().addOption("password", null, "Password:", getId(),
            getDisplayName());
    c.gridx++;
    passwdField = getPasswordField();
    jPanel.add((JTextComponent) passwdField, c);
    passwdField.getDocument().addDocumentListener(this);
    c.gridx = 1;
    c.gridy++;
    jPanel.add(new JLabel("Domain:"), c);
    SearchableOptionsRegistrar.getInstance().addOption("domain", null, "Domain:", getId(), getDisplayName());
    c.gridx++;
    domainField = getDomainField();
    jPanel.add((JTextComponent) domainField, c);
    domainField.getDocument().addDocumentListener(this);
    c.gridx = 1;
    c.gridy++;
    jPanel.add(new JLabel("Project:"), c);
    SearchableOptionsRegistrar.getInstance().addOption("project", null, "Project:", getId(), getDisplayName());
    c.gridx++;
    projectField = getProjectField();
    jPanel.add((JTextComponent) projectField, c);
    projectField.getDocument().addDocumentListener(this);
    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 2;
    storePasswd = new JCheckBox("Remember password");
    jPanel.add(storePasswd, c);
    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    testButton.setDisabledIcon(IconLoader.getIcon("/process/disabledRun.png"));
    testButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            ProgressManager.getInstance().run(new Task.Modal(null, "Checking connection", false) {
                public void run(ProgressIndicator indicator) {
                    try {
                        indicator.setIndeterminate(true);
                        ServerType type = AliConfigurable.getServerType(locationField.getText().trim(),
                                domainField.getText().trim(), projectField.getText().trim(),
                                usernameField.getText().trim(), passwdField.getText());
                        switch (type) {
                        case ALM11:
                        case ALI:
                        case ALI2:
                        case ALM11_5:
                        case ALI11_5:
                        case ALM12:
                        case ALI12:
                        case AGM:
                            setTestText("Connection successful (" + type.toString() + ")");
                            break;
                        }
                    } catch (Exception e) {
                        setTestText(e.getMessage());
                    }
                }
            });
        }
    });
    jPanel.add(testButton, c);
    c.gridx++;
    c.gridwidth = 2;
    jPanel.add(testLabel, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    jPanel.add(new JLabel(IconLoader.getIcon("/horizon.png")), c);

    JTextPane desc = HTMLAreaField.createTextPane(
            "<html>When connecting to HP Agile Manager you can either fill in the above form<br>"
                    + "manually or upload the tenant descriptor to auto-configure the values.<br>"
                    + "You can obtain the tenant descriptor from the ALI Summary tab in the<br>"
                    + "HP Agile Manager configuration</html>");
    desc.setOpaque(false);
    c.gridwidth = 3;
    c.gridx++;
    jPanel.add(desc, c);

    c.gridy++;
    c.fill = GridBagConstraints.NONE;
    final JButton browse = new JButton("Browse");
    browse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor desc = new FileChooserDescriptor(true, false, false, false, false, false);
            final VirtualFile[] file = FileChooserFactory.getInstance().createFileChooser(desc, null, browse)
                    .choose((VirtualFile) null, null);
            if (file.length == 0) {
                return;
            }

            try {
                SAXBuilder builder = new SAXBuilder();
                InputStream fis = file[0].getInputStream();
                Document document = builder.build(fis);
                Element rootNode = document.getRootElement();
                locationField.setValue(rootNode.getChild("location").getText());
                domainField.setValue(rootNode.getChild("domain").getText());
                projectField.setValue(rootNode.getChild("project").getText());
                fis.close();
            } catch (Exception ex) {
                Messages.showErrorDialog("Tenant descriptor is not valid.", "Error");
            }
        }
    });
    jPanel.add(browse, c);

    addAdditionalSettings(jPanel, c);

    c.gridwidth = 1;
    c.gridx = 3;
    c.gridy++;
    c.weightx = 1.0;
    c.weighty = 1.0;
    jPanel.add(new JPanel(), c);

    content.add(jPanel, BorderLayout.CENTER);
    Component southern = getSouthernComponent();
    if (southern != null) {
        content.add(southern, BorderLayout.SOUTH);
    }

    configurationPanel = content;
}