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.mediaworx.intellij.opencmsplugin.listeners.OpenCmsModuleFileChangeListener.java

License:Open Source License

/**
 * Presents a dialog asking the user if files are to be renamed in the VFS and handles the renames if the user
 * chooses to do so/*from  w w w  .ja  v a  2 s  .c om*/
 * @return  <code>true</code> if the user elected to rename files, <code>false</code> if the user cancelled the
 *          rename
 * @throws CmsConnectionException if the connection to OpenCms failed
 */
private boolean renameFiles() throws CmsConnectionException {
    StringBuilder msg = new StringBuilder(
            "Do you want to rename the following files/folders in the OpenCms VFS as well?");
    for (VfsFileRenameInfo vfsFileToBeRenamed : vfsFilesToBeRenamed) {
        msg.append("\n").append(vfsFileToBeRenamed.oldVfsPath).append(" -> ")
                .append(vfsFileToBeRenamed.newName);
    }

    int dlgStatus = Messages.showOkCancelDialog(msg.toString(), "Move Files/Folders?",
            Messages.getQuestionIcon());

    if (dlgStatus == 0) {
        console.clear();
        plugin.showConsole();
        for (VfsFileRenameInfo renameInfo : vfsFilesToBeRenamed) {
            console.info("RENAME: " + renameInfo.oldVfsPath + " to " + renameInfo.newName);
            try {
                CmisObject file = getVfsAdapter().getVfsObject(renameInfo.oldVfsPath);
                if (file == null) {
                    LOG.warn("Error renaming " + renameInfo.oldVfsPath
                            + ": the resource could not be loaded through CMIS");
                    continue;
                }
                HashMap<String, Object> properties = new HashMap<String, Object>();
                properties.put(PropertyIds.NAME, renameInfo.newName);
                file.updateProperties(properties);

                // handle export points
                handleExportPointsForMovedResources(renameInfo.oldVfsPath, renameInfo.newVfsPath,
                        renameInfo.newIdeaVFile.getPath());

                // handle meta data files
                handleMetaDataForMovedResources(renameInfo.ocmsModule, renameInfo.ocmsModule,
                        renameInfo.oldVfsPath, renameInfo.newVfsPath, renameInfo.newIdeaVFile.isDirectory());
            } catch (CmsPermissionDeniedException e) {
                LOG.warn("Exception moving files - permission denied", e);
                Messages.showDialog("Error moving files/folders. " + e.getMessage(), "Error",
                        new String[] { "Ok" }, 0, Messages.getErrorIcon());
            }
        }
        return true;
    }
    return false;
}

From source file:com.mediaworx.intellij.opencmsplugin.sync.OpenCmsSyncer.java

License:Open Source License

/**
 * Analyzes the given file list using the {@link SyncFileAnalyzer} and triggers the sync to/from OpenCms using
 * the {@link SyncJob}//from ww w  .  j a v  a  2  s.  c o m
 * @param syncFiles list of local files (and folders) that are used as starting point for the sync
 */
public void syncFiles(List<File> syncFiles) {

    SyncFileAnalyzer analyzer;

    try {
        analyzer = new SyncFileAnalyzer(plugin, syncFiles, pullMetaDataOnly);
    } catch (CmsConnectionException e) {
        Messages.showDialog(e.getMessage(), "Error", new String[] { "Ok" }, 0, Messages.getErrorIcon());
        return;
    }

    ProgressManager.getInstance().runProcessWithProgressSynchronously(analyzer,
            "Analyzing local and VFS syncFiles and folders ...", true, plugin.getProject());

    if (!analyzer.isExecuteSync()) {
        return;
    }

    int numSyncEntities = analyzer.getSyncList().size();

    boolean proceed = numSyncEntities > 0;
    LOG.info("proceed? " + proceed);

    StringBuilder message = new StringBuilder();
    if (analyzer.hasWarnings()) {
        message.append("Infos/Warnings during file analysis:\n").append(analyzer.getWarnings().append("\n"));
    }
    if (proceed) {
        SyncJob syncJob = new SyncJob(plugin, analyzer.getSyncList());
        if (showConfirmDialog && !pullMetaDataOnly
                && ((numSyncEntities == 1 && message.length() > 0) || numSyncEntities > 1)) {
            assembleConfirmMessage(message, syncJob.getSyncList());
            int dlgStatus = Messages.showOkCancelDialog(plugin.getProject(), message.toString(),
                    "Start OpenCms VFS Sync?", Messages.getQuestionIcon());
            proceed = dlgStatus == 0;
        }
        if (proceed) {
            plugin.showConsole();
            new Thread(syncJob).start();
        }
    } else {
        message.append("Nothing to sync");
        Messages.showMessageDialog(message.toString(), "OpenCms VFS Sync", Messages.getInformationIcon());
    }
}

From source file:com.microsoft.intellij.actions.PackageAction.java

License:Open Source License

private boolean checkSdk() {
    String sdkPath = null;//from ww w  .ja va 2s  .co m
    if (AzurePlugin.IS_WINDOWS) {
        try {
            sdkPath = WindowsAzureProjectManager.getLatestAzureSdkDir();
        } catch (IOException e) {
            log(message("error"), e);
        }
        try {
            if (sdkPath == null) {
                int choice = Messages.showOkCancelDialog(message("sdkInsErrMsg"), message("sdkInsErrTtl"),
                        Messages.getQuestionIcon());
                if (choice == Messages.OK) {
                    Desktop.getDesktop().browse(URI.create(message("sdkInsUrl")));
                }
                return false;
            }
        } catch (Exception ex) {
            // only logging the error in log file not showing anything to
            // end user
            log(message("error"), ex);
            return false;
        }
    } else {
        log("Not Windows OS, skipping getSDK");
    }
    return true;
}

From source file:com.microsoft.intellij.forms.WebSiteDeployForm.java

License:Open Source License

void deleteWebApp() {
    if (selectedWebSite != null) {
        String name = selectedWebSite.getName();
        int choice = Messages.showOkCancelDialog(String.format(message("delMsg"), name), message("delTtl"),
                Messages.getQuestionIcon());
        if (choice == Messages.OK) {
            try {
                AzureManagerImpl.getManager().deleteWebSite(selectedWebSite.getSubscriptionId(),
                        selectedWebSite.getWebSpaceName(), name);
                webSiteList.remove(webSiteJList.getSelectedIndex());
                webSiteConfigMap.remove(selectedWebSite);
                AzureSettings.getSafeInstance(AzurePlugin.project).saveWebApps(webSiteConfigMap);
                selectedWebSite = null;/*from   w  w w. j  a v a  2  s  .  c  om*/
                if (webSiteConfigMap.isEmpty()) {
                    setMessages("There are no Azure web apps in the imported subscriptions.");
                } else {
                    setWebApps(webSiteConfigMap);
                }
            } catch (AzureCmdException e) {
                String msg = message("delWebErr") + "\n"
                        + String.format(message("webappExpMsg"), e.getMessage());
                PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e);
            }
        }
    } else {
        PluginUtil.displayErrorDialog(message("errTtl"), "Select a web app container to delete.");
    }
}

From source file:com.microsoft.intellij.ui.AppInsightsMngmtPanel.java

License:Open Source License

private ActionListener removeButtonListener() {
    return new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int curSelIndex = insightsTable.getSelectedRow();
            if (curSelIndex > -1) {
                String keyToRemove = ApplicationInsightsResourceRegistry.getKeyAsPerIndex(curSelIndex);
                String moduleName = MethodUtils.getModuleNameAsPerKey(myProject, keyToRemove);
                if (moduleName != null && !moduleName.isEmpty()) {
                    PluginUtil.displayErrorDialog(message("aiErrTtl"),
                            String.format(message("rsrcUseMsg"), moduleName));
                } else {
                    int choice = Messages.showOkCancelDialog(message("rsrcRmvMsg"), message("aiErrTtl"),
                            Messages.getQuestionIcon());
                    if (choice == Messages.OK) {
                        ApplicationInsightsResourceRegistry.getAppInsightsResrcList().remove(curSelIndex);
                        AzureSettings.getSafeInstance(myProject).saveAppInsights();
                        ((InsightsTableModel) insightsTable.getModel()).setResources(getTableContent());
                        ((InsightsTableModel) insightsTable.getModel()).fireTableDataChanged();
                    }//  w  w  w.  j  a  va 2 s.c o  m
                }
            }
        }
    };
}

From source file:com.microsoft.intellij.ui.ApplicationsTab.java

License:Open Source License

private ActionListener createRemoveButtonListener() {
    return new ActionListener() {
        @Override//from   w ww .  j a v a 2  s.  c o  m
        public void actionPerformed(ActionEvent e) {
            int curSelIndex = appTable.getSelectedRow();
            if (curSelIndex > -1) {
                if (!newRole) {
                    try {
                        int choice = Messages.showYesNoDialog(message("appRmvMsg"), message("appRmvTtl"),
                                Messages.getQuestionIcon());
                        if (choice == Messages.YES) {
                            String cmpntName = appList.get(curSelIndex).getImpAs();
                            String cmpntPath = String.format("%s%s%s%s%s",
                                    PluginUtil.getModulePath(ModuleManager.getInstance(project)
                                            .findModuleByName(waProjManager.getProjectName())),
                                    File.separator, waRole.getName(), message("approot"), cmpntName);
                            waRole.removeServerApplication(cmpntName);
                            modified = true;
                            if (!fileToDel.contains(cmpntPath)) {
                                fileToDel.add(cmpntPath);
                            }
                            //                                JdkSrvConfig.getTableViewer().refresh();
                            //                                JdkSrvConfigListener.disableRemoveButton();
                        } else {
                            return;
                        }
                    } catch (Exception ex) {
                        PluginUtil.displayErrorDialogAndLog(message("srvErrTtl"), message("rmvSrvAppErrMsg"),
                                ex);
                        return;
                    }
                }
                appList.remove(curSelIndex);
                ((ApplicationsTableModel) appTable.getModel()).fireTableDataChanged();

            }
        }
    };
}

From source file:com.microsoft.intellij.ui.azureroles.AzureRolePanel.java

License:Open Source License

/**
 * Method checks if number of instances are equal to 1
 * and caching is enabled as well as high availability
 * feature is on then ask input from user,
 * whether to turn off high availability feature
 * or he wants to edit instances./*from  w w  w .j a  v a 2s  .  c  om*/
 *
 * @param val
 * @return boolean
 */
private boolean handleHighAvailabilityFeature(boolean val) {
    boolean isBackupSet = false;
    boolean okToProceed = val;
    try {
        /*
         * checks if number of instances are equal to 1
        * and caching is enabled
        */
        if (txtNoOfInstances.getText().trim().equalsIgnoreCase("1")
                && windowsAzureRole.getCacheMemoryPercent() > 0) {
            /*
             * Check high availability feature of any of the cache is on
            */
            Map<String, WindowsAzureNamedCache> mapCache = windowsAzureRole.getNamedCaches();
            for (Iterator<WindowsAzureNamedCache> iterator = mapCache.values().iterator(); iterator
                    .hasNext();) {
                WindowsAzureNamedCache cache = (WindowsAzureNamedCache) iterator.next();
                if (cache.getBackups()) {
                    isBackupSet = true;
                }
            }
            /*
             * High availability feature of any of the cache is on.
             */
            if (isBackupSet) {
                int choice = Messages.showOkCancelDialog(message("highAvailMsg"), message("highAvailTtl"),
                        Messages.getQuestionIcon());
                /*
                * Set High availability feature to No.
                */
                if (choice == Messages.OK) {
                    for (Iterator<WindowsAzureNamedCache> iterator = mapCache.values().iterator(); iterator
                            .hasNext();) {
                        WindowsAzureNamedCache cache = iterator.next();
                        if (cache.getBackups()) {
                            cache.setBackups(false);
                        }
                    }
                    okToProceed = true;
                    waProjManager.save();
                } else {
                    /*
                     * Stay on Role properties page.
                     */
                    okToProceed = false;
                    txtNoOfInstances.requestFocus();
                }
            }
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("cachErrTtl"), message("cachGetErMsg"), e);
        okToProceed = false;
    }
    return okToProceed;
}

From source file:com.microsoft.intellij.ui.azureroles.CachingPanel.java

License:Open Source License

/**
 * Listener method for remove button which
 * deletes the selected cache entry./*from   ww  w. j  a  v a  2s .  c o  m*/
 */
protected void removeBtnListener() {
    try {
        int choice = Messages.showYesNoDialog(message("cachRmvMsg"), message("cachRmvTtl"),
                Messages.getQuestionIcon());
        if (choice == Messages.YES) {
            WindowsAzureNamedCache cachToDel = tblCache.getSelectedObject();
            cachToDel.delete();
            tblCache.getListTableModel().setItems(new ArrayList<WindowsAzureNamedCache>(mapCache.values()));
            setModified(true);
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("cachErrTtl"), message("cachDelErMsg"), e);
    }
}

From source file:com.microsoft.intellij.ui.azureroles.CertificatesPanel.java

License:Open Source License

private void removeCertificate() {
    try {//from   w w  w .j  a  v  a2  s.  co  m
        WindowsAzureCertificate delCert = tblCertificates.getSelectedObject();
        if (delCert.isRemoteAccess() && delCert.isSSLCert()) {
            String temp = String.format("%s%s%s", message("sslTtl"), " and ", message("cmhLblRmtAces"));
            PluginUtil.displayErrorDialog(message("certRmTtl"),
                    String.format(message("certComMsg"), temp, temp));
        } else if (delCert.isRemoteAccess()) {
            PluginUtil.displayErrorDialog(message("certRmTtl"),
                    String.format(message("certComMsg"), message("cmhLblRmtAces"), message("cmhLblRmtAces")));
        } else if (delCert.isSSLCert()) {
            PluginUtil.displayErrorDialog(message("certRmTtl"),
                    String.format(message("certComMsg"), message("sslTtl"), message("sslTtl")));
        } else {
            int choice = Messages.showOkCancelDialog(String.format(message("certRmMsg"), delCert.getName()),
                    message("certRmTtl"), Messages.getQuestionIcon());
            if (choice == Messages.OK) {
                delCert.delete();
                certSelected = "";
                setModified(true);
                tblCertificates.getListTableModel().removeRow(tblCertificates.getSelectedRow());
            }
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("certErrTtl"), message("certErrMsg"), e);
    }
}

From source file:com.microsoft.intellij.ui.azureroles.ComponentsPanel.java

License:Open Source License

/**
 * Listener method for remove button which
 * deletes the selected component./* ww w.jav a  2 s .co  m*/
 */
private void removeComponent() {
    WindowsAzureRoleComponent component = tblComponents.getSelectedObject();
    //        IWorkspace workspace = ResourcesPlugin.getWorkspace();
    //        IWorkspaceRoot root = workspace.getRoot();
    //        WindowsAzureRoleComponent component = listComponents.get(selIndex);
    try {
        /* First condition: Checks component is part of a JDK,
         * server configuration
        * Second condition: For not showing error message
        * "Disable Server JDK Configuration"
        * while removing server application
        * when server or JDK  is already disabled.
        */
        if (component.getIsPreconfigured() && (!(component.getType().equals(message("typeSrvApp"))
                && windowsAzureRole.getServerName() == null))) {
            PluginUtil.displayErrorDialog(message("jdkDsblErrTtl"), message("jdkDsblErrMsg"));
        } else {
            int choice = Messages.showYesNoDialog(message("cmpntRmvMsg"), message("cmpntRmvTtl"),
                    Messages.getQuestionIcon());
            if (choice == Messages.YES) {
                String cmpntPath = String.format("%s%s%s%s%s",
                        PluginUtil.getModulePath(ModuleManager.getInstance(project)
                                .findModuleByName(waProjManager.getProjectName())),
                        File.separator, windowsAzureRole.getName(), message("approot"),
                        component.getDeployName());
                File file = new File(cmpntPath);
                // Check import source is equal to approot
                if (component.getImportPath().isEmpty() && file.exists()) {
                    int selected = Messages.showYesNoCancelDialog(message("cmpntSrcRmvMsg"),
                            message("cmpntSrcRmvTtl"), Messages.getQuestionIcon());
                    switch (selected) {
                    case Messages.YES:
                        //yes
                        component.delete();
                        //                                tblViewer.refresh();
                        fileToDel.add(file);
                        break;
                    case Messages.NO:
                        //no
                        component.delete();
                        //                                tblViewer.refresh();
                        break;
                    case Messages.CANCEL:
                        //cancel
                        break;
                    default:
                        break;
                    }
                } else {
                    component.delete();
                    //                        tblViewer.refresh();
                    fileToDel.add(file);
                }
                myModified = true;
            }
        }
        //            if (tblComponents.getItemCount() == 0) {
        //                // table is empty i.e. number of rows = 0
        //                btnRemove.setEnabled(false);
        //                btnEdit.setEnabled(false);
        //            }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("cmpntSetErrTtl"), message("cmpntRmvErrMsg"), e);
    }
}