List of usage examples for com.intellij.openapi.ui Messages getErrorIcon
@NotNull public static Icon getErrorIcon()
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 moved in the VFS and handles the moves if the user * chooses to do so// w w w .java 2 s.com * @return <code>true</code> if the user elected to move files, <code>false</code> if the user cancelled the * move * @throws CmsConnectionException if the connection to OpenCms failed */ private boolean moveFiles() throws CmsConnectionException { StringBuilder msg = new StringBuilder( "Do you want to move the following files/folders in the OpenCms VFS as well?"); for (VfsFileMoveInfo vfsFileToBeMoved : vfsFilesToBeMoved) { msg.append("\n").append(vfsFileToBeMoved.oldVfsPath); } int dlgStatus = Messages.showOkCancelDialog(msg.toString(), "Move Files/Folders?", Messages.getQuestionIcon()); if (dlgStatus == 0) { console.clear(); plugin.showConsole(); for (VfsFileMoveInfo moveInfo : vfsFilesToBeMoved) { try { console.info("MOVE: " + moveInfo.oldVfsPath + " to " + moveInfo.newParentPath); Folder oldParent = (Folder) getVfsAdapter().getVfsObject(moveInfo.oldParentPath); Folder newParent = (Folder) getVfsAdapter().getVfsObject(moveInfo.newParentPath); if (newParent == null) { newParent = getVfsAdapter().createFolder(moveInfo.newParentPath); } FileableCmisObject resource = (FileableCmisObject) getVfsAdapter() .getVfsObject(moveInfo.oldVfsPath); resource.move(oldParent, newParent); // handle export points handleExportPointsForMovedResources(moveInfo.oldVfsPath, moveInfo.newVfsPath, moveInfo.newIdeaVFile.getPath()); // handle meta data files handleMetaDataForMovedResources(moveInfo.oldOcmsModule, moveInfo.newOcmsModule, moveInfo.oldVfsPath, moveInfo.newVfsPath, moveInfo.newIdeaVFile.isDirectory()); } catch (CmsPermissionDeniedException 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.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// ww w .j a v a2 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.listeners.OpenCmsModuleFileChangeListener.java
License:Open Source License
/** * Starts an OpenCms direct publish session for resources that were affected by the deletes/moves/renames *//* w ww . ja v a 2 s . c o m*/ private void publishAffectedVfsResources() { ArrayList<String> affectedResourcePaths = new ArrayList<String>(getNumAffected()); for (VfsFileDeleteInfo deletedInfo : vfsFilesToBeDeleted) { affectedResourcePaths.add(deletedInfo.vfsPath); } for (VfsFileMoveInfo moveInfo : vfsFilesToBeMoved) { affectedResourcePaths.add(moveInfo.newVfsPath); } for (VfsFileRenameInfo renameInfo : vfsFilesToBeRenamed) { affectedResourcePaths.add(renameInfo.newVfsPath); } if (affectedResourcePaths.size() > 0) { try { plugin.getPluginConnector().publishResources(affectedResourcePaths, false); console.info("PUBLISH: A direct publish session was started successfully"); } catch (OpenCmsConnectorException e) { console.error(e.getMessage()); } catch (IOException e) { LOG.warn("There was an exception while publishing resources after a file change event", e); Messages.showDialog("There was an Error during publish.\nIs OpenCms running?\n\n" + e.getMessage(), "OpenCms Publish Error", new String[] { "Ok" }, 0, Messages.getErrorIcon()); } } }
From source file:com.mediaworx.intellij.opencmsplugin.OpenCmsPlugin.java
License:Open Source License
public boolean checkWebappRootConfiguration(boolean showDialog) { boolean configOK = true; OpenCmsPluginConfigurationData config = getPluginConfiguration(); if (config != null && config.isOpenCmsPluginEnabled()) { File file = new File(config.getWebappRoot()); // show an error message if the webapp root folder was not found if (!file.exists()) { configOK = false;/*from ww w. j av a 2 s . c om*/ if (showDialog) { Messages.showDialog( "The Webapp Root was not found.\nPlease check the OpenCms Webapp Root in the OpenCms Plugin settings.", "OpenCms Plugin - Configuration Error", new String[] { "Ok" }, 0, Messages.getErrorIcon()); } } else { // check if the OpenCms configuration path exists file = new File(config.getWebappRoot() + OpenCmsConfiguration.CONFIGPATH); if (!file.exists()) { configOK = false; if (showDialog) { Messages.showDialog( "The OpenCms configuration was not found.\nPlease check the OpenCms Webapp Root in the OpenCms Plugin settings.", "Error", new String[] { "Ok" }, 0, Messages.getErrorIcon()); } } } } return configOK; }
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}/*w w w . j ava 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.mediaworx.intellij.opencmsplugin.sync.SyncJob.java
License:Open Source License
private void pullModuleResourcePathAncestorMetaInfos() { List<OpenCmsModuleResource> resourcePathParents = new ArrayList<OpenCmsModuleResource>(); for (OpenCmsModule ocmsModule : syncList.getOcmsModules()) { Set<String> handledParents = new HashSet<String>(); for (String resourcePath : ocmsModule.getModuleResources()) { addParentFolderToResourcePaths(resourcePath, ocmsModule, resourcePathParents, handledParents); }/* ww w . j av a2s. com*/ } if (resourcePathParents.size() > 0) { try { Map<String, String> resourceInfos = plugin.getPluginConnector() .getModuleResourceInfos(resourcePathParents); for (OpenCmsModuleResource resourceParent : resourcePathParents) { SyncFolder syncFolder = new SyncFolder(resourceParent.getOpenCmsModule(), resourceParent.getResourcePath(), null, null, SyncAction.PULL, false); doMetaInfoHandling(console, resourceInfos, syncFolder); } } catch (OpenCmsConnectorException e) { console.error(e.getMessage()); } catch (IOException e) { Messages.showDialog( "There was an error pulling the meta information for module resource ancestor folders from OpenCms.\nIs the connector module installed?", "Error", new String[] { "Ok" }, 0, Messages.getErrorIcon()); LOG.warn("There was an Exception pulling the meta information for module resource ancestor folders", e); } } }
From source file:com.mediaworx.intellij.opencmsplugin.sync.SyncJob.java
License:Open Source License
private void pullModuleManifests() { // collect the module names in a List List<String> moduleNames = new ArrayList<String>(syncList.getOcmsModules().size()); for (OpenCmsModule ocmsModule : syncList.getOcmsModules()) { moduleNames.add(ocmsModule.getModuleName()); }// w w w . jav a2 s .c om if (moduleNames.size() > 0) { try { // pull the module manifests Map<String, String> manifestInfos = plugin.getPluginConnector().getModuleManifests(moduleNames); for (OpenCmsModule ocmsModule : syncList.getOcmsModules()) { if (manifestInfos.containsKey(ocmsModule.getModuleName())) { // put the manifest to a file String manifestPath = ocmsModule.getManifestRoot() + "/manifest_stub.xml"; String manifest = manifestInfos.get(ocmsModule.getModuleName()); if (ocmsModule.isSetSpecificModuleVersionEnabled() && StringUtils.isNotEmpty(ocmsModule.getModuleVersion())) { manifest = manifest.replaceFirst("<version>[^<]*</version>", "<version>" + Matcher.quoteReplacement(ocmsModule.getModuleVersion()) + " </version>"); } manifest = PluginTools.ensureUnixNewline(manifest) + "\n"; FileUtils.writeStringToFile(new File(manifestPath), manifest, Charset.forName("UTF-8")); console.info("PULL: " + manifestPath + " pulled from OpenCms"); } else { LOG.warn("No manifest found for module " + ocmsModule.getModuleName()); } } } catch (OpenCmsConnectorException e) { console.error(e.getMessage()); } catch (IOException e) { Messages.showDialog( "There was an error pulling the module manifest files from OpenCms.\nIs the connector module installed?", "Error", new String[] { "Ok" }, 0, Messages.getErrorIcon()); LOG.warn("There was an Exception pulling the module manifests", e); } } }
From source file:com.mediaworx.intellij.opencmsplugin.sync.VfsAdapter.java
License:Open Source License
/** * retrieves (pulls) the VFS resource at the given path * @param path path of the resource to be pulled * @return the VFS resource//from w w w. ja v a2 s . c om * @throws CmsPermissionDeniedException */ public CmisObject getVfsObject(String path) throws CmsPermissionDeniedException { if (!connected) { LOG.warn("not connected"); return null; } path = PluginTools.ensureUnixPath(path); try { return session.getObjectByPath(path); } catch (CmisObjectNotFoundException e) { return null; } catch (CmisPermissionDeniedException e) { LOG.warn("Permission denied, can't access " + path, e); throw new CmsPermissionDeniedException("Permission denied, can't access " + path, e); } catch (CmisConnectionException e) { Messages.showDialog("Error connecting to the VFS" + e.getMessage() + "\nIs OpenCms running?", "Error", new String[] { "Ok" }, 0, Messages.getErrorIcon()); LOG.warn("Error connecting to the VFS", e); connected = false; return null; } }
From source file:com.samebug.clients.idea.components.project.TutorialProjectComponent.java
License:Apache License
@Override public void apiStatusChange(@Nullable String apiStatus) { if (!apiStatusNotificationShowed && apiStatus != null) { apiStatusNotificationShowed = true; if (apiStatus.startsWith("DEPRECATED")) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override/*ww w.j a v a 2 s . co m*/ public void run() { ToolWindowManager.getInstance(myProject).notifyByBalloon("Samebug", MessageType.WARNING, SamebugBundle.message("samebug.tutorial.apiStatus.deprecated"), Messages.getWarningIcon(), null); } }); } else if (apiStatus.startsWith("CLOSED")) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { ToolWindowManager.getInstance(myProject).notifyByBalloon("Samebug", MessageType.ERROR, SamebugBundle.message("samebug.tutorial.apiStatus.closed"), Messages.getErrorIcon(), null); } }); } } }
From source file:com.srmvision.tools.wicketdebug.idea.ApplicationComponent.WicketDebugEntryPoint.java
License:Apache License
void runWebServer() { final int port = PluginProperties.getPort(); try {/*from w w w. j a v a 2 s. c o m*/ InetSocketAddress addr = new InetSocketAddress(port); server = HttpServer.create(addr, 0); server.createContext("/", new IDEAHttpHandler()); server.setExecutor(Executors.newCachedThreadPool()); server.start(); } catch (IOException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { Messages.showMessageDialog( "Wicket Open In IDEA : unable to start webserver on port " + port + ", please check plugin configuration.", "Plugin Error", Messages.getErrorIcon()); } }); } }