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

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

Introduction

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

Prototype

@NotNull
    public static Icon getQuestionIcon() 

Source Link

Usage

From source file:com.google.gct.idea.appengine.deploy.AppEngineUpdateDialog.java

License:Apache License

@Override
protected void doOKAction() {
    if (getOKAction().isEnabled()) {
        Module selectedModule = myModuleComboBox.getSelectedModule();
        String sdk = "";
        String war = "";
        AppEngineGradleFacet facet = AppEngineGradleFacet.getAppEngineFacetByModule(selectedModule);
        if (facet != null) {
            AppEngineConfigurationProperties model = facet.getConfiguration().getState();
            if (model != null) {
                sdk = model.APPENGINE_SDKROOT;
                war = model.WAR_DIR;/*  www.  j  a  va  2s .  c  o m*/
            }
        }

        String client_secret = null;
        String client_id = null;
        String refresh_token = null;

        CredentialedUser selectedUser = myElysiumProjectId.getSelectedUser();
        if (selectedUser == null) {
            selectedUser = GoogleLogin.getInstance().getActiveUser();
            // Ask the user if he wants to continue using the active user credentials.
            if (selectedUser != null) {
                if (Messages.showYesNoDialog(this.getPeer().getOwner(),
                        "The Project ID you entered could not be found.  Do you want to deploy anyway using "
                                + GoogleLogin.getInstance().getActiveUser().getEmail() + " for credentials?",
                        "Deploy", Messages.getQuestionIcon()) != Messages.YES) {
                    return;
                }
            } else {
                // This should not happen as its validated.
                Messages.showErrorDialog(this.getPeer().getOwner(), "You need to be logged in to deploy.",
                        "Login");
                return;
            }
        }

        if (selectedUser != null) {
            client_secret = selectedUser.getGoogleLoginState().fetchOAuth2ClientSecret();
            client_id = selectedUser.getGoogleLoginState().fetchOAuth2ClientId();
            refresh_token = selectedUser.getGoogleLoginState().fetchOAuth2RefreshToken();
        }

        if (Strings.isNullOrEmpty(client_secret) || Strings.isNullOrEmpty(client_id)
                || Strings.isNullOrEmpty(refresh_token)) {
            // The login is somehow invalid, bail -- this shouldn't happen.
            LOG.error("StartUploading while logged in, but it doesn't have full credentials.");
            if (Strings.isNullOrEmpty(client_secret)) {
                LOG.error("(null) client_secret");
            }
            if (Strings.isNullOrEmpty(client_id)) {
                LOG.error("(null) client_id");
            }
            if (Strings.isNullOrEmpty(refresh_token)) {
                LOG.error("(null) refresh_token");
            }
            Messages.showErrorDialog(this.getPeer().getOwner(),
                    "The project ID is not a valid Google Console Developer Project.", "Login");
            return;
        }

        // These should not fail as they are a part of the dialog validation.
        if (Strings.isNullOrEmpty(sdk) || Strings.isNullOrEmpty(war)
                || Strings.isNullOrEmpty(myElysiumProjectId.getText()) || selectedModule == null) {
            Messages.showErrorDialog(this.getPeer().getOwner(),
                    "Could not deploy due to missing information (sdk/war/projectid).", "Deploy");
            LOG.error("StartUploading was called with bad module/sdk/war");
            return;
        }

        close(OK_EXIT_CODE); // We close before kicking off the update so it doesn't interfere with the output window coming to focus.

        // Kick off the upload.  detailed status will be shown in an output window.
        new AppEngineUpdater(myProject, selectedModule, sdk, war, myElysiumProjectId.getText(),
                myVersion.getText(), client_secret, client_id, refresh_token).startUploading();
    }
}

From source file:com.google.gct.idea.debugger.ui.CloudDebugHistoricalSnapshots.java

License:Apache License

public CloudDebugHistoricalSnapshots(@NotNull CloudDebugProcessHandler processHandler) {
    super(new BorderLayout());

    myTable = new JBTable() {
        //  Returning the Class of each column will allow different
        //  renderers to be used based on Class
        @Override// w w  w . j  a  v  a2 s . co m
        public Class getColumnClass(int column) {
            if (column == 0) {
                return Icon.class;
            }
            Object value = getValueAt(0, column);
            return value != null ? getValueAt(0, column).getClass() : String.class;
        }

        // We override prepareRenderer to supply a tooltip in the case of an error.
        @NotNull
        @Override
        public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (c instanceof JComponent) {
                JComponent jc = (JComponent) c;
                Breakpoint breakpoint = CloudDebugHistoricalSnapshots.this.getModel().getBreakpoints().get(row);
                jc.setToolTipText(BreakpointUtil.getUserErrorMessage(breakpoint.getStatus()));
            }
            return c;
        }
    };

    myTable.setModel(new MyModel(null));

    myTable.setTableHeader(null);
    myTable.setShowGrid(false);
    myTable.setRowMargin(0);
    myTable.getColumnModel().setColumnMargin(0);
    myTable.getColumnModel().getColumn(1).setCellRenderer(new SnapshotTimeCellRenderer());
    myTable.getColumnModel().getColumn(2).setCellRenderer(new DefaultRenderer());
    myTable.getColumnModel().getColumn(3).setCellRenderer(new DefaultRenderer());
    myTable.getColumnModel().getColumn(4).setCellRenderer(new MoreCellRenderer());
    myTable.resetDefaultFocusTraversalKeys();
    myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    myTable.setPreferredScrollableViewportSize(new Dimension(WINDOW_WIDTH_PX, WINDOW_HEIGHT_PX));
    myTable.setAutoCreateColumnsFromModel(false);
    myTable.getEmptyText().setText(GctBundle.getString("clouddebug.nosnapshots"));

    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableUpDownActions()
            .disableAddAction();

    decorator.setToolbarPosition(ActionToolbarPosition.TOP);
    decorator.setRemoveAction(new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            fireDeleteBreakpoints(getSelectedBreakpoints());
        }
    });

    decorator.addExtraAction(new AnActionButton(GctBundle.getString("clouddebug.delete.all"),
            GoogleCloudToolsIcons.CLOUD_DEBUG_DELETE_ALL_BREAKPOINTS) {
        @Override
        public void actionPerformed(AnActionEvent e) {
            if (Messages.showDialog(GctBundle.getString("clouddebug.remove.all"),
                    GctBundle.getString("clouddebug.delete.snapshots"),
                    new String[] { GctBundle.getString("clouddebug.buttondelete"),
                            GctBundle.getString("clouddebug.cancelbutton") },
                    1, Messages.getQuestionIcon()) == 0) {
                MyModel model = (MyModel) myTable.getModel();
                fireDeleteBreakpoints(model.getBreakpoints());
            }
        }
    });

    decorator.addExtraAction(new AnActionButton(GctBundle.getString("clouddebug.reactivatesnapshotlocation"),
            GoogleCloudToolsIcons.CLOUD_DEBUG_REACTIVATE_BREAKPOINT) {
        @Override
        public void actionPerformed(AnActionEvent e) {
            myProcess.getBreakpointHandler().cloneToNewBreakpoints(getSelectedBreakpoints());
        }
    });

    this.add(decorator.createPanel());
    myProcess = processHandler.getProcess();
    onBreakpointsChanged();

    myProcess.getXDebugSession().addSessionListener(this);
    myProcess.addListener(this);

    // This is the  click handler that does one of three things:
    // 1. Single click on a final snapshot will load the debugger with that snapshot
    // 2. Single click on a pending snapshot will show the line of code
    // 3. Single click on "More" will show the breakpoint config dialog.
    myTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent me) {
            JTable table = (JTable) me.getSource();
            Point p = me.getPoint();
            Breakpoint breakpoint = getBreakPoint(p);
            int col = table.columnAtPoint(p);
            if (breakpoint != null && col == 4 && supportsMoreConfig(breakpoint)) {
                BreakpointsDialogFactory.getInstance(myProcess.getXDebugSession().getProject())
                        .showDialog(myProcess.getBreakpointHandler().getXBreakpoint(breakpoint));
            } else if (me.getClickCount() == 1 && breakpoint != null && myTable.getSelectedRows().length == 1) {
                myProcess.navigateToSnapshot(breakpoint.getId());
            }
        }
    });

    // we use a motion listener to create a hand cursor over a link within a table.
    myTable.addMouseMotionListener(new MouseMotionListener() {
        @Override
        public void mouseDragged(MouseEvent me) {
        }

        @Override
        public void mouseMoved(MouseEvent me) {
            JTable table = (JTable) me.getSource();
            Point p = me.getPoint();
            int column = table.columnAtPoint(p);
            Breakpoint breakpoint = getBreakPoint(p);
            if (column == 4 && breakpoint != null && supportsMoreConfig(breakpoint)) {
                if (myTable.getCursor() != HAND_CURSOR) {
                    myTable.setCursor(HAND_CURSOR);
                }
                return;
            }
            if (myTable.getCursor() != DEFAULT_CURSOR) {
                myTable.setCursor(DEFAULT_CURSOR);
            }
        }
    });
}

From source file:com.google.gct.idea.settings.ImportSettings.java

License:Apache License

/**
 * Parse and update the IDEA settings in the jar at <code>path</code>.
 * Note: This function might require a restart of the application.
 * @param path The location of the jar with the new IDEA settings.
 */// w ww .j  av a2  s  .c om
public static void doImport(String path) {
    final File saveFile = new File(path);
    try {
        if (!saveFile.exists()) {
            Messages.showErrorDialog(IdeBundle.message("error.cannot.find.file", presentableFileName(saveFile)),
                    DIALOG_TITLE);
            return;
        }

        // What is this file used for?
        final ZipEntry magicEntry = new ZipFile(saveFile).getEntry(SETTINGS_JAR_MARKER);
        if (magicEntry == null) {
            Messages.showErrorDialog(
                    "The file " + presentableFileName(saveFile) + " contains no settings to import",
                    DIALOG_TITLE);
            return;
        }

        final ArrayList<ExportableComponent> registeredComponents = new ArrayList<ExportableComponent>(
                Arrays.asList(ApplicationManager.getApplication()
                        .getComponents(ExportableApplicationComponent.class)));
        registeredComponents.addAll(ServiceBean.loadServicesFromBeans(ExportableComponent.EXTENSION_POINT,
                ExportableComponent.class));

        List<ExportableComponent> storedComponents = getComponentsStored(saveFile, registeredComponents);

        Set<String> relativeNamesToExtract = new HashSet<String>();
        for (final ExportableComponent aComponent : storedComponents) {
            final File[] exportFiles = aComponent.getExportFiles();
            for (File exportFile : exportFiles) {
                final File configPath = new File(PathManager.getConfigPath());
                final String rPath = FileUtil.getRelativePath(configPath, exportFile);
                assert rPath != null;
                final String relativePath = FileUtil.toSystemIndependentName(rPath);
                relativeNamesToExtract.add(relativePath);
            }
        }

        relativeNamesToExtract.add(PluginManager.INSTALLED_TXT);

        final File tempFile = new File(PathManager.getPluginTempPath() + "/" + saveFile.getName());
        FileUtil.copy(saveFile, tempFile);
        File outDir = new File(PathManager.getConfigPath());
        final ImportSettingsFilenameFilter filenameFilter = new ImportSettingsFilenameFilter(
                relativeNamesToExtract);
        StartupActionScriptManager.ActionCommand unzip = new StartupActionScriptManager.UnzipCommand(tempFile,
                outDir, filenameFilter);
        StartupActionScriptManager.addActionCommand(unzip);

        // remove temp file
        StartupActionScriptManager.ActionCommand deleteTemp = new StartupActionScriptManager.DeleteCommand(
                tempFile);
        StartupActionScriptManager.addActionCommand(deleteTemp);

        UpdateSettings.getInstance().forceCheckForUpdateAfterRestart();

        String key = ApplicationManager.getApplication().isRestartCapable()
                ? "message.settings.imported.successfully.restart"
                : "message.settings.imported.successfully";
        final int ret = Messages.showOkCancelDialog(
                IdeBundle.message(key, ApplicationNamesInfo.getInstance().getProductName(),
                        ApplicationNamesInfo.getInstance().getFullProductName()),
                IdeBundle.message("title.restart.needed"), Messages.getQuestionIcon());
        if (ret == Messages.OK) {
            ((ApplicationEx) ApplicationManager.getApplication()).restart(true);
        }
    } catch (ZipException e1) {
        Messages.showErrorDialog(
                "Error reading file " + presentableFileName(saveFile) + ".\\nThere was " + e1.getMessage(),
                DIALOG_TITLE);
    } catch (IOException e1) {
        Messages.showErrorDialog(IdeBundle.message("error.reading.settings.file.2",
                presentableFileName(saveFile), e1.getMessage()), DIALOG_TITLE);
    }
}

From source file:com.hp.alm.ali.idea.entity.EntityEditManager.java

License:Apache License

public int askUser() {
    return Messages.showYesNoCancelDialog(project,
            "There are unsaved changes, if you proceed they will be discarded. Proceed?", "HP ALI",
            Messages.getQuestionIcon());
}

From source file:com.igormaznitsa.ideamindmap.editor.MindMapDialogProvider.java

License:Apache License

@Override
public boolean msgConfirmOkCancel(final String title, final String text) {
    return Messages.showOkCancelDialog(this.project, text, title, Messages.getQuestionIcon()) == Messages.OK;
}

From source file:com.igormaznitsa.ideamindmap.editor.MindMapDialogProvider.java

License:Apache License

@Override
public boolean msgConfirmYesNo(final String title, final String text) {
    return Messages.showYesNoDialog(this.project, text, title, Messages.getQuestionIcon()) == Messages.YES;
}

From source file:com.igormaznitsa.ideamindmap.editor.MindMapDialogProvider.java

License:Apache License

@Override
public Boolean msgConfirmYesNoCancel(final String title, final String text) {
    final int result = Messages.showYesNoCancelDialog(this.project, text, title, Messages.getQuestionIcon());
    return result == Messages.CANCEL ? null : result == Messages.YES;
}

From source file:com.imaginea.betterdocs.EditorToggleAction.java

License:Apache License

public EditorToggleAction() {
    super("Move", "Move", Messages.getQuestionIcon());
}

From source file:com.intellij.application.options.codeStyle.ManageCodeStyleSchemesDialog.java

License:Apache License

@Nullable
private String importExternalCodeStyle(String importerName) throws SchemeImportException {
    final SchemeImporter<CodeStyleScheme> importer = SchemeImporterEP.getImporter(importerName,
            CodeStyleScheme.class);
    if (importer != null) {
        FileChooserDialog fileChooser = FileChooserFactory.getInstance()
                .createFileChooser(new FileChooserDescriptor(true, false, false, false, false, false) {
                    @Override/*from  ww  w .  java  2s . co  m*/
                    public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
                        return file.isDirectory() || importer.getSourceExtension().equals(file.getExtension());
                    }

                    @Override
                    public boolean isFileSelectable(VirtualFile file) {
                        return !file.isDirectory() && importer.getSourceExtension().equals(file.getExtension());
                    }
                }, null, myContentPane);
        VirtualFile[] selection = fileChooser.choose(null,
                CodeStyleSchemesUIConfiguration.Util.getRecentImportFile());
        if (selection.length == 1) {
            VirtualFile selectedFile = selection[0];
            selectedFile.refresh(false, false);
            CodeStyleSchemesUIConfiguration.Util.setRecentImportFile(selectedFile);
            try {
                InputStream nameInputStream = selectedFile.getInputStream();
                String[] schemeNames;
                try {
                    schemeNames = importer.readSchemeNames(nameInputStream);
                } finally {
                    nameInputStream.close();
                }
                CodeStyleScheme currScheme = myModel.getSelectedScheme();
                ImportSchemeChooserDialog schemeChooserDialog = new ImportSchemeChooserDialog(myContentPane,
                        schemeNames, !currScheme.isDefault() ? currScheme.getName() : null);
                if (schemeChooserDialog.showAndGet()) {
                    String schemeName = schemeChooserDialog.getSelectedName();
                    String targetName = schemeChooserDialog.getTargetName();
                    CodeStyleScheme targetScheme = null;
                    if (schemeChooserDialog.isUseCurrentScheme()) {
                        targetScheme = myModel.getSelectedScheme();
                    } else {
                        if (targetName == null)
                            targetName = ApplicationBundle.message("code.style.scheme.import.unnamed");
                        for (CodeStyleScheme scheme : myModel.getSchemes()) {
                            if (targetName.equals(scheme.getName())) {
                                targetScheme = scheme;
                                break;
                            }
                        }
                        if (targetScheme == null) {
                            int row = mySchemesTableModel.createNewScheme(getSelectedScheme(), targetName);
                            mySchemesTable.getSelectionModel().setSelectionInterval(row, row);
                            targetScheme = mySchemesTableModel.getSchemeAt(row);
                        } else {
                            int result = Messages.showYesNoDialog(myContentPane,
                                    ApplicationBundle.message("message.code.style.scheme.already.exists",
                                            targetName),
                                    ApplicationBundle.message("title.code.style.settings.import"),
                                    Messages.getQuestionIcon());
                            if (result != Messages.YES) {
                                return null;
                            }
                        }
                    }
                    InputStream dataInputStream = selectedFile.getInputStream();
                    try {
                        importer.importScheme(dataInputStream, schemeName, targetScheme);
                        myModel.fireSchemeChanged(targetScheme);
                    } finally {
                        dataInputStream.close();
                    }
                    return targetScheme.getName();
                }
            } catch (IOException e) {
                throw new SchemeImportException(e);
            }
        }
    }
    return null;
}

From source file:com.intellij.application.options.InitialConfigurationDialog.java

License:Apache License

@Override
protected void doOKAction() {
    final Project project = CommonDataKeys.PROJECT
            .getData(DataManager.getInstance().getDataContext(myMainPanel));

    super.doOKAction();

    // set keymap
    ((KeymapManagerImpl) KeymapManager.getInstance())
            .setActiveKeymap((Keymap) myKeymapComboBox.getSelectedItem());
    // set color scheme
    EditorColorsManager.getInstance()/*from  w w w  .  j a  v  a 2 s . c om*/
            .setGlobalScheme((EditorColorsScheme) myColorSchemeComboBox.getSelectedItem());
    // create default todo_pattern for color scheme
    TodoConfiguration.getInstance().resetToDefaultTodoPatterns();

    final boolean createScript = myCreateScriptCheckbox.isSelected();
    final boolean createEntry = myCreateEntryCheckBox.isSelected();
    if (createScript || createEntry) {
        final String pathName = myScriptPathTextField.getText();
        final boolean globalEntry = myGlobalEntryCheckBox.isSelected();
        ProgressManager.getInstance().run(new Task.Backgroundable(project, getTitle()) {
            @Override
            public void run(@NotNull final ProgressIndicator indicator) {
                indicator.setFraction(0.0);
                if (createScript) {
                    indicator.setText("Creating launcher script...");
                    CreateLauncherScriptAction.createLauncherScript(project, pathName);
                    indicator.setFraction(0.5);
                }
                if (createEntry) {
                    CreateDesktopEntryAction.createDesktopEntry(project, indicator, globalEntry);
                }
                indicator.setFraction(1.0);
            }
        });
    }
    UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem();
    LafManagerImpl lafManager = (LafManagerImpl) LafManager.getInstance();
    if (info.getName().contains("Darcula") != (LafManager.getInstance()
            .getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo)) {
        lafManager.setLookAndFeelAfterRestart(info);
        int rc = Messages.showYesNoDialog(project,
                "IDE appearance settings will be applied after restart. Would you like to restart now?",
                "IDE Appearance", Messages.getQuestionIcon());
        if (rc == Messages.YES) {
            ((ApplicationImpl) ApplicationManager.getApplication()).restart(true);
        }
    } else if (!info.equals(lafManager.getCurrentLookAndFeel())) {
        lafManager.setCurrentLookAndFeel(info);
        lafManager.updateUI();
    }
}