com.igormaznitsa.meta.common.utils.GetUtils Java Examples
The following examples show how to use
com.igormaznitsa.meta.common.utils.GetUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GolangGetMojo.java From mvn-golang with Apache License 2.0 | 5 votes |
private boolean processCustomScriptCallForPackage(@Nonnull final String packageName, @Nonnull final File rootCvsFolder, @Nonnull final CustomScript script) { final List<String> command = new ArrayList<>(); command.add(script.path); if (script.options != null) { command.addAll(Arrays.asList(script.options)); } if (getLog().isDebugEnabled()) { getLog().debug("CLI : " + command); getLog().debug("Package name : " + packageName); getLog().debug("Root CVS folder : " + rootCvsFolder); } getLog().warn(String.format("Starting script in VCS folder [%s] : %s", packageName, StringUtils.join(command.toArray(), ' '))); final ProcessExecutor processExecutor = new ProcessExecutor(command.toArray(new String[0])); processExecutor .exitValueAny() .directory(rootCvsFolder) .environment("MVNGO_CVS_BRANCH", GetUtils.ensureNonNull(this.branch, "")) .environment("MVNGO_CVS_TAG", GetUtils.ensureNonNull(this.tag, "")) .environment("MVNGO_CVS_REVISION", GetUtils.ensureNonNull(this.revision, "")) .environment("MVNGO_CVS_PACKAGE", packageName) .redirectError(System.err) .redirectOutput(System.out); boolean result = false; try { final ProcessResult process = processExecutor.executeNoTimeout(); final int exitValue = process.getExitValue(); result = script.ignoreFail || exitValue == 0; } catch (IOException | InterruptedException | InvalidExitValueException ex) { getLog().error("Error in proces custom script", ex); } return result; }
Example #2
Source File: AbstractJBBPTask.java From java-binary-block-parser with Apache License 2.0 | 5 votes |
@Nullable public static String getTextOrFileContent(@Nonnull final JBBPExtension extension, @Nullable final String text, @Nullable final File file) { String result = null; if (text != null) { result = text; } else if (file != null) { try { result = FileUtils.readFileToString(file, GetUtils.ensureNonNull(extension.inEncoding, "UTF-8")); } catch (IOException ex) { throw new GradleException("Can't read file " + file, ex); } } return result; }
Example #3
Source File: MindMap.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
public void valueForPathChanged(@Nonnull @MustNotContainNull final Topic[] path, @Nullable final String newValue) { if (path.length > 0) { final Topic target = path[path.length - 1]; target.setText(GetUtils.ensureNonNull(newValue, "")); fireTopicChanged(target); } }
Example #4
Source File: Topic.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Nonnull public Topic makeChild(@Nullable final String text, @Nullable final Topic afterTheTopic) { this.map.lock(); try { final Topic result = new Topic(this.map, this, GetUtils.ensureNonNull(text, "")); //NOI18N if (afterTheTopic != null && this.children.indexOf(afterTheTopic) >= 0) { result.moveAfter(afterTheTopic); } return result; } finally { this.map.unlock(); } }
Example #5
Source File: MindMapApplicationSettings.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Nonnull @Override public String asString(@Nonnull Class<?> fieldType, @Nonnull Object value) { if (fieldType == Color.class) { return Integer.toString(((Color) value).getRGB()); } else if (fieldType == Font.class) { final Font font = (Font) value; return font.getFamily() + ':' + Integer.toString(font.getStyle()) + ':' + Integer.toString(font.getSize()); } else if (fieldType == RenderQuality.class) { final RenderQuality rq = (RenderQuality) value; return GetUtils.ensureNonNull(rq, RenderQuality.DEFAULT).name(); } else { throw new Error("Unexpected field type" + fieldType); } }
Example #6
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Override @Nullable public File msgOpenFileDialog(@Nullable final Component parentComponent, @Nonnull String id, @Nonnull String title, @Nullable File defaultFolder, boolean filesOnly, @Nonnull @MustNotContainNull FileFilter[] fileFilters, @Nonnull String approveButtonText) { final File folderToUse; if (defaultFolder == null) { folderToUse = cacheOpenFileThroughDialog.find(null, id); } else { folderToUse = defaultFolder; } final JFileChooser fileChooser = new JFileChooser(folderToUse); fileChooser.setDialogType(JFileChooser.OPEN_DIALOG); fileChooser.setDialogTitle(title); fileChooser.setApproveButtonText(approveButtonText); for (final FileFilter f : fileFilters) { fileChooser.addChoosableFileFilter(f); } if (fileFilters.length != 0) { fileChooser.setFileFilter(fileFilters[0]); } fileChooser.setAcceptAllFileFilterUsed(true); fileChooser.setMultiSelectionEnabled(false); File result = null; if (fileChooser.showDialog(GetUtils.ensureNonNull( parentComponent == null ? null : SwingUtilities.windowForComponent(parentComponent), Main.getApplicationFrame()), approveButtonText) == JFileChooser.APPROVE_OPTION) { result = cacheOpenFileThroughDialog.put(id, fileChooser.getSelectedFile()); } return result; }
Example #7
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Override @Nullable public File msgSaveFileDialog(@Nullable final Component parentComponent, @Nonnull final String id, @Nonnull final String title, @Nullable final File defaultFolder, final boolean filesOnly, @Nonnull @MustNotContainNull final FileFilter[] fileFilters, @Nonnull final String approveButtonText) { final File folderToUse; if (defaultFolder == null) { folderToUse = cacheSaveFileThroughDialog.find(null, id); } else { folderToUse = defaultFolder; } final JFileChooser fileChooser = new JFileChooser(folderToUse); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); fileChooser.setDialogTitle(title); fileChooser.setApproveButtonText(approveButtonText); fileChooser.setAcceptAllFileFilterUsed(true); for (final FileFilter f : fileFilters) { fileChooser.addChoosableFileFilter(f); } if (fileFilters.length != 0) { fileChooser.setFileFilter(fileFilters[0]); } fileChooser.setMultiSelectionEnabled(false); File result = null; if (fileChooser.showDialog(GetUtils.ensureNonNull( parentComponent == null ? null : SwingUtilities.windowForComponent(parentComponent), Main.getApplicationFrame()), approveButtonText) == JFileChooser.APPROVE_OPTION ) { result = cacheSaveFileThroughDialog.put(id, fileChooser.getSelectedFile()); } return result; }
Example #8
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Override @Nullable public Boolean msgConfirmYesNoCancel(@Nullable Component parentComponent, @Nonnull final String title, @Nonnull final String question) { final int result = JOptionPane.showConfirmDialog(GetUtils.ensureNonNull(parentComponent, Main.getApplicationFrame()), question, title, JOptionPane.YES_NO_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { return null; } else { return result == JOptionPane.YES_OPTION; } }
Example #9
Source File: PropertiesPreferences.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Override @Nonnull public String toString() { final StringWriter writer = new StringWriter(); try { this.storage.store(writer, GetUtils.ensureNonNull(this.comment, "")); return writer.toString(); } catch (IOException ex) { throw new Error("Unexpected error", ex); } }
Example #10
Source File: GolangToolMojo.java From mvn-golang with Apache License 2.0 | 5 votes |
@Override @Nonnull @MustNotContainNull public String[] getTailArguments() { final List<String> result = new ArrayList<>(); result.add(this.command); result.addAll(Arrays.asList(GetUtils.ensureNonNull(this.args, ArrayUtils.EMPTY_STRING_ARRAY))); return result.toArray(new String[0]); }
Example #11
Source File: AbstractRepo.java From mvn-golang with Apache License 2.0 | 5 votes |
public int execute(@Nullable String customCommand, @Nonnull final Log logger, @Nonnull final File cvsFolder, @Nonnull @MustNotContainNull final String... args) { final List<String> cli = new ArrayList<>(); cli.add(GetUtils.findFirstNonNull(customCommand, this.command)); cli.addAll(Arrays.asList(args)); if (logger.isDebugEnabled()) { logger.debug("Executing repo command : " + cli); } final ByteArrayOutputStream errorStream = new ByteArrayOutputStream(); final ByteArrayOutputStream outStream = new ByteArrayOutputStream(); final ProcessExecutor executor = new ProcessExecutor(cli); int result = -1; try { final ProcessResult processResult = executor.directory(cvsFolder).redirectError(errorStream).redirectOutput(outStream).executeNoTimeout(); result = processResult.getExitValue(); if (logger.isDebugEnabled()) { logger.debug("Exec.out........................................."); logger.debug(new String(errorStream.toByteArray(), Charset.defaultCharset())); logger.debug("................................................."); } if (result != 0) { logger.error(new String(errorStream.toByteArray(), Charset.defaultCharset())); } } catch (IOException | InterruptedException | InvalidExitValueException ex) { if (ex instanceof InterruptedException) { Thread.currentThread().interrupt(); } logger.error("Unexpected error", ex); } return result; }
Example #12
Source File: MavenUtils.java From mvn-golang with Apache License 2.0 | 5 votes |
/** * Make artifact record from a maven artifact * * @param artifact artifact to be converted into string, must not be null * @return string representation of artifact, must not be null * @see #parseArtifactRecord(java.lang.String, * org.apache.maven.artifact.handler.ArtifactHandler) */ @Nonnull public static String makeArtifactRecord(@Nonnull final Artifact artifact) { return artifact.getGroupId() + "::" + artifact.getArtifactId() + "::" + artifact.getVersionRange().toString() + "::" + GetUtils.ensureNonNull(artifact.getScope(), "compile") + "::" + GetUtils.ensureNonNull(artifact.getType(), "zip") + "::" + GetUtils.ensureNonNull(artifact.getClassifier(), ""); }
Example #13
Source File: AbstractGolangMojo.java From mvn-golang with Apache License 2.0 | 5 votes |
@Nonnull @MustNotContainNull public String[] getBuildFlags() { final List<String> result = new ArrayList<>(); for (final String s : ArrayUtils.joinArrays(GetUtils.ensureNonNull(this.buildFlags, ArrayUtils.EMPTY_STRING_ARRAY), getExtraBuildFlags())) { if (!this.buildFlagsToIgnore.contains(s)) { result.add(s); } } result.addAll(this.tempBuildFlags); return result.toArray(new String[0]); }
Example #14
Source File: AbstractGolangMojo.java From mvn-golang with Apache License 2.0 | 5 votes |
@Nonnull private static String extractComputerName() { String result = System.getenv("COMPUTERNAME"); if (result == null) { result = System.getenv("HOSTNAME"); } if (result == null) { try { result = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException ex) { result = null; } } return GetUtils.ensureNonNull(result, "<Unknown computer>"); }
Example #15
Source File: AbstractGolangMojo.java From mvn-golang with Apache License 2.0 | 5 votes |
@Nonnull private String findSdkArchiveFileName(@Nullable final ProxySettings proxySettings, @Nonnull final String sdkBaseName) throws IOException, MojoExecutionException { String result = getSdkArchiveName(); if (isSafeEmpty(result)) { final Document parsed = convertSdkListToDocument(loadGoLangSdkList(proxySettings, URLEncoder.encode(sdkBaseName, "UTF-8"))); result = extractSDKFileName(getSdkSite(), parsed, sdkBaseName, new String[] {"tar.gz", "zip"}); } else { getLog().info("SDK archive name is predefined : " + result); } return GetUtils.ensureNonNullStr(result); }
Example #16
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override public void msgInfo(@Nullable final Component parentComponent, @Nonnull final String text) { JOptionPane.showMessageDialog(GetUtils.ensureNonNull(parentComponent, Main.getApplicationFrame()), text, "Info", JOptionPane.INFORMATION_MESSAGE); }
Example #17
Source File: GolangGetMojo.java From mvn-golang with Apache License 2.0 | 4 votes |
private synchronized boolean processCVS(@Nonnull @MustNotContainNull final List<PackageList.Package> packages, @Nullable final ProxySettings proxySettings, @Nonnull @MustNotContainNull final File[] goPath) { if (!packages.isEmpty()) { for (final File f : goPath) { for (final PackageList.Package p : packages) { File rootCvsFolder = this.makePathToPackageSources(f, p.getPackage()); if (this.getRelativePathToCvsFolder() == null) { rootCvsFolder = this.isDisableCvsAutosearch() ? rootCvsFolder : this.findRootCvsFolderForPackageSources(f, rootCvsFolder); } if (rootCvsFolder == null) { getLog().error("Can't find CVS folder, may be it was not initially loaded from repository: " + p); return false; } if (this.getLog().isDebugEnabled()) { this.getLog().debug(String.format("CVS folder path for %s is %s", p, rootCvsFolder)); } if (!rootCvsFolder.isDirectory()) { this.getLog().error(String.format("Can't find CVS folder for package '%s' at '%s'", p, rootCvsFolder.getAbsolutePath())); return false; } else { final CVSType repo = CVSType.investigateFolder(rootCvsFolder); if (repo == CVSType.UNKNOWN) { this.getLog().error("Can't recognize CVS in the folder : " + rootCvsFolder + " (for package '" + p + "')"); this.getLog().error("May be to define folder directly through <relativePathToCvsFolder>...</relativePathToCvsFolder>!"); return false; } final String[] customcvs = this.getCustomCvsOptions(); if (customcvs != null || p.doesNeedCvsProcessing()) { if (!repo.getProcessor().prepareFolder(this.getLog(), proxySettings, this.getCvsExe(), rootCvsFolder)) { this.getLog().debug("Can't prepare folder : " + rootCvsFolder); return false; } if (customcvs != null && p.doesNeedCvsProcessing()) { this.getLog().warn("CVS branch, tag or revision are ignored for provided custom CVS options!"); } if (customcvs != null) { this.getLog().info("Custom CVS options : " + Arrays.toString(customcvs)); if (!repo.getProcessor().processCVSForCustomOptions(this.getLog(), proxySettings, rootCvsFolder, this.getCvsExe(), customcvs)) { return false; } } else if (p.doesNeedCvsProcessing()) { this.getLog().info(String.format("Switch '%s' to branch = '%s', tag = '%s', revision = '%s'", p, GetUtils.ensureNonNull(p.getBranch(), "_"), GetUtils.ensureNonNull(p.getTag(), "_"), GetUtils.ensureNonNull(p.getRevision(), "_"))); if (!repo.getProcessor().processCVSRequisites(this.getLog(), proxySettings, this.getCvsExe(), rootCvsFolder, p.getBranch(), p.getTag(), p.getRevision())) { return false; } } } } if (this.getCustomScript() != null) { if (!processCustomScriptCallForPackage(p.getPackage(), rootCvsFolder, Assertions.assertNotNull(this.getCustomScript()))) { return false; } } } } } return true; }
Example #18
Source File: GolangTestMojo.java From mvn-golang with Apache License 2.0 | 4 votes |
@Override @Nonnull @MustNotContainNull public String[] getOptionalExtraTailArguments() { return GetUtils.ensureNonNull(this.testFlags, ArrayUtils.EMPTY_STRING_ARRAY); }
Example #19
Source File: AbstractGolangMojo.java From mvn-golang with Apache License 2.0 | 4 votes |
@Nonnull public Map<?, ?> getEnv() { return GetUtils.ensureNonNull(this.env, Collections.EMPTY_MAP); }
Example #20
Source File: MindMapSettingsPanel.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
public MindMapPanelConfig makeConfig() { final MindMapPanelConfig result = new MindMapPanelConfig(this.etalon, false); result.setPaperColor(this.colorButtonBackgroundColor.getValue()); result.setGridColor(this.colorButtonGridColor.getValue()); result.setCollapsatorBackgroundColor(this.colorButtonCollapsatorFill.getValue()); result.setCollapsatorBorderColor(this.colorButtonCollapsatorBorder.getValue()); result.setConnectorColor(this.colorButtonConnectorColor.getValue()); result.setJumpLinkColor(this.colorButtonJumpLink.getValue()); result.setSelectLineColor(this.colorButtonSelectFrameColor.getValue()); result.setRootBackgroundColor(this.colorButtonRootFill.getValue()); result.setRootTextColor(this.colorButtonRootText.getValue()); result.setFirstLevelBackgroundColor(this.colorButton1stLevelFill.getValue()); result.setFirstLevelTextColor(this.colorButton1stLevelText.getValue()); result.setOtherLevelBackgroundColor(this.colorButton2ndLevelFill.getValue()); result.setOtherLevelTextColor(this.colorButton2ndLevelText.getValue()); result.setGridStep(getInt(this.spinnerGridStep)); result.setConnectorWidth(getFloat(this.spinnerConnectorWidth)); result.setCollapsatorSize(getInt(this.spinnerCollapsatorSize)); result.setCollapsatorBorderWidth(getFloat(this.spinnerCollapsatorWidth)); result.setJumpLinkWidth(getFloat(this.spinnerJumpLinkWidth)); result.setSelectLineWidth(getFloat(this.spinnerSelectionFrameWidth)); result.setSelectLineGap(getInt(this.spinnerSelectionFrameGap)); result.setElementBorderWidth(getFloat(this.spinnerBorderWidth)); result.setShowGrid(this.checkBoxShowGrid.isSelected()); result.setDropShadow(this.checkBoxDropShadow.isSelected()); result.setSmartTextPaste(this.checkBoxSmartTextPaste.isSelected()); result.setFirstLevelHorizontalInset(this.slider1stLevelHorzGap.getValue()); result.setFirstLevelVerticalInset(this.slider1stLevelVertGap.getValue()); result.setOtherLevelHorizontalInset(this.slider2ndLevelHorzGap.getValue()); result.setOtherLevelVerticalInset(this.slider2ndLevelVertGap.getValue()); result.setRenderQuality(GetUtils.ensureNonNull((RenderQuality) comboBoxRenderQuality.getSelectedItem(), RenderQuality.DEFAULT)); result.setFont(this.theFont); final int scaleModifier = (this.checkBoxScalingModifierALT.isSelected() ? KeyEvent.ALT_MASK : 0) | (this.checkBoxScalingModifierCTRL.isSelected() ? KeyEvent.CTRL_MASK : 0) | (this.checkBoxScalingModifierSHFT.isSelected() ? KeyEvent.SHIFT_MASK : 0) | (this.checkBoxScalingModifierMETA.isSelected() ? KeyEvent.META_MASK : 0); result.setScaleModifiers(scaleModifier); for (final Map.Entry<String, KeyShortcut> e : this.mapKeyShortCuts.entrySet()) { result.setKeyShortCut(e.getValue()); } return result; }
Example #21
Source File: PreferencesPanel.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Nonnull @ReturnsOriginal private MindMapPanelConfig fillBySettings(@Nonnull final MindMapPanelConfig config, @Nonnull final Preferences preferences) { config.setShowGrid(this.checkBoxShowGrid.isSelected()); config.setDropShadow(this.checkBoxDropShadow.isSelected()); config.setPaperColor(Assertions.assertNotNull(this.colorChooserPaperColor.getValue())); config.setGridColor(Assertions.assertNotNull(this.colorChooserGridColor.getValue())); config.setConnectorColor(Assertions.assertNotNull(this.colorChooserConnectorColor.getValue())); config.setJumpLinkColor(Assertions.assertNotNull(this.colorChooserJumpLink.getValue())); config.setRootBackgroundColor(Assertions.assertNotNull(this.colorChooserRootBackground.getValue())); config.setRootTextColor(Assertions.assertNotNull(this.colorChooserRootText.getValue())); config.setFirstLevelBackgroundColor(Assertions.assertNotNull(this.colorChooser1stBackground.getValue())); config.setFirstLevelTextColor(Assertions.assertNotNull(this.colorChooser1stText.getValue())); config.setOtherLevelBackgroundColor(Assertions.assertNotNull(this.colorChooser2ndBackground.getValue())); config.setOtherLevelTextColor(Assertions.assertNotNull(this.colorChooser2ndText.getValue())); config.setSelectLineColor(Assertions.assertNotNull(this.colorChooserSelectLine.getValue())); config.setCollapsatorBackgroundColor(Assertions.assertNotNull(this.colorChooserCollapsatorBackground.getValue())); config.setCollapsatorBorderColor(Assertions.assertNotNull(this.colorChooserCollapsatorBorder.getValue())); config.setGridStep((Integer) this.spinnerGridStep.getValue()); config.setSelectLineGap((Integer) this.spinnerSelectLineGap.getValue()); config.setCollapsatorSize((Integer) this.spinnerCollapsatorSize.getValue()); config.setConnectorWidth((Float) this.spinnerConnectorWidth.getValue()); config.setJumpLinkWidth((Float) this.spinnerJumpLinkWidth.getValue()); config.setSelectLineWidth((Float) this.spinnerSelectLineWidth.getValue()); config.setCollapsatorBorderWidth((Float) this.spinnerCollapsatorWidth.getValue()); config.setElementBorderWidth((Float) this.spinnerElementBorderWidth.getValue()); config.setSmartTextPaste(this.checkBoxSmartTextPaste.isSelected()); config.setFirstLevelHorizontalInset(this.slider1stLevelHorzGap.getValue()); config.setFirstLevelVerticalInset(this.slider1stLevelVertGap.getValue()); config.setOtherLevelHorizontalInset(this.slider2ndLevelHorzGap.getValue()); config.setOtherLevelVerticalInset(this.slider2ndLevelVertGap.getValue()); config.setFont(this.fontMindMapEditor); config.setRenderQuality(GetUtils.ensureNonNull((RenderQuality) this.comboBoxRenderQuality.getSelectedItem(), Utils.getDefaultRenderQialityForOs())); for (final Map.Entry<String, KeyShortcut> e : this.mapKeyShortCuts.entrySet()) { config.setKeyShortCut(e.getValue()); } config.setScaleModifiers(getScalingModifiers()); config.saveTo(preferences); // Common behaviour options preferences.putBoolean("useInsideBrowser", this.checkboxUseInsideBrowser.isSelected()); //NOI18N preferences.putBoolean("trimTopicText", this.checkboxTrimTopicText.isSelected()); //NOI18N preferences.putBoolean("showHiddenFiles", this.checkBoxShowHiddenFiles.isSelected()); //NOI18N preferences.putBoolean("makeRelativePathToProject", this.checkboxRelativePathsForFilesInTheProject.isSelected()); //NOI18N preferences.putBoolean("unfoldCollapsedTarget", this.checkBoxUnfoldCollapsedTarget.isSelected()); //NOI18N preferences.putBoolean("copyColorInfoToNewChildAllowed", this.checkBoxCopyColorInfoToNewAllowed.isSelected()); //NOI18N preferences.putBoolean(PREFERENCE_KEY_KNOWLEDGEFOLDER_ALLOWED, this.checkBoxKnowledgeFolderAutogenerationAllowed.isSelected()); final String pathToGraphVizDot = textFieldPathToGraphvizDot.getText(); if (pathToGraphVizDot.trim().isEmpty()) { preferences.remove("plantuml.dotpath"); } else { preferences.put("plantuml.dotpath", pathToGraphVizDot); } PreferencesManager.getInstance().setFont(preferences, SpecificKeys.PROPERTY_TEXT_EDITOR_FONT, fontTextEditor); PreferencesManager.getInstance().setFlag(preferences, SpecificKeys.PROPERTY_BACKUP_LAST_EDIT_BEFORE_SAVE, this.checkBoxBackupLastEdit.isSelected()); // Metrics MetricsService.getInstance().setEnabled(this.checkboxMetricsAllowed.isSelected()); return config; }
Example #22
Source File: AbstractGolangMojo.java From mvn-golang with Apache License 2.0 | 4 votes |
@Nonnull private static String extractDomainName() { final String result = System.getenv("USERDOMAIN"); return GetUtils.ensureNonNull(result, ""); }
Example #23
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override public boolean msgConfirmYesNo(@Nullable final Component parentComponent, @Nonnull final String title, @Nonnull final String question) { return JOptionPane.showConfirmDialog(GetUtils.ensureNonNull(parentComponent, Main.getApplicationFrame()), question, title, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; }
Example #24
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override public boolean msgOkCancel(@Nullable Component parentComponent, @Nonnull final String title, @Nonnull final JComponent component) { return JOptionPane.showConfirmDialog(GetUtils.ensureNonNull(parentComponent, Main.getApplicationFrame()), component, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null) == JOptionPane.OK_OPTION; }
Example #25
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override public boolean msgConfirmOkCancel(@Nullable Component parentComponent, @Nonnull final String title, @Nonnull final String question) { return JOptionPane.showConfirmDialog(GetUtils.ensureNonNull(parentComponent, Main.getApplicationFrame()), question, title, JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION; }
Example #26
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override public void msgWarn(@Nullable Component parentComponent, @Nonnull final String text) { JOptionPane.showMessageDialog(GetUtils.ensureNonNull(parentComponent, Main.getApplicationFrame()), text, "Warning!", JOptionPane.WARNING_MESSAGE); }
Example #27
Source File: AbstractGoPackageAwareMojo.java From mvn-golang with Apache License 2.0 | 4 votes |
@Override @Nonnull @MustNotContainNull public String[] getTailArguments() { return GetUtils.ensureNonNull(getPackages(), ArrayUtils.EMPTY_STRING_ARRAY); }
Example #28
Source File: DialogProviderManager.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override public void msgError(@Nullable final Component parentComponent, @Nonnull final String text) { JOptionPane.showMessageDialog(GetUtils.ensureNonNull(parentComponent, Main.getApplicationFrame()), text, "Error!", JOptionPane.ERROR_MESSAGE); }
Example #29
Source File: TreeCellRenderer.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
private void ensureIcons(@Nonnull final JTree tree) { if (PROJECT_CLOSED == null) { PROJECT_CLOSED = new ImageIcon(UiUtils.makeBadgedRightBottom(UiUtils.iconToImage(tree, GetUtils.ensureNonNull(UIManager.getIcon("Tree.closedIcon"), DEFAULT_FOLDER_CLOSED)), PROJECT_BADGE)); //NOI18N PROJECT_CLOSED_RO = new ImageIcon(UiUtils.makeBadgedRightTop(((ImageIcon) PROJECT_CLOSED).getImage(), READONLY_BADGE)); } if (PROJECT_OPENED == null) { PROJECT_OPENED = new ImageIcon(UiUtils.makeBadgedRightBottom(UiUtils.iconToImage(tree, GetUtils.ensureNonNull(UIManager.getIcon("Tree.openIcon"), DEFAULT_FOLDER_OPENED)), PROJECT_BADGE)); //NOI18N PROJECT_OPENED_RO = new ImageIcon(UiUtils.makeBadgedRightTop(((ImageIcon) PROJECT_OPENED).getImage(), READONLY_BADGE)); } if (FOLDER_CLOSED == null) { FOLDER_CLOSED = new ImageIcon(UiUtils.iconToImage(tree, GetUtils.ensureNonNull(UIManager.getIcon("Tree.closedIcon"), DEFAULT_FOLDER_CLOSED))); //NOI18N FOLDER_CLOSED_RO = new ImageIcon(UiUtils.makeBadgedRightTop(((ImageIcon) FOLDER_CLOSED).getImage(), READONLY_BADGE)); } if (FOLDER_OPENED == null) { FOLDER_OPENED = new ImageIcon(UiUtils.iconToImage(tree, GetUtils.ensureNonNull(UIManager.getIcon("Tree.openIcon"), DEFAULT_FOLDER_OPENED))); //NOI18N FOLDER_OPENED_RO = new ImageIcon(UiUtils.makeBadgedRightTop(((ImageIcon) FOLDER_OPENED).getImage(), READONLY_BADGE)); } if (FOLDER_KF_CLOSED == null) { FOLDER_KF_CLOSED = new ImageIcon(UiUtils.makeBadgedRightBottom(UiUtils.iconToImage(tree, GetUtils.ensureNonNull(UIManager.getIcon("Tree.closedIcon"), DEFAULT_FOLDER_CLOSED)), KF_BADGE)); //NOI18N FOLDER_KF_CLOSED_RO = new ImageIcon(UiUtils.makeBadgedRightTop(((ImageIcon) FOLDER_KF_CLOSED).getImage(), READONLY_BADGE)); } if (FOLDER_KF_OPENED == null) { FOLDER_KF_OPENED = new ImageIcon(UiUtils.makeBadgedRightBottom(UiUtils.iconToImage(tree, GetUtils.ensureNonNull(UIManager.getIcon("Tree.openIcon"), DEFAULT_FOLDER_OPENED)), KF_BADGE)); //NOI18N FOLDER_KF_OPENED_RO = new ImageIcon(UiUtils.makeBadgedRightTop(((ImageIcon) FOLDER_KF_OPENED).getImage(), READONLY_BADGE)); } if (LEAF == null) { LEAF = new ImageIcon(UiUtils.iconToImage(tree, GetUtils.ensureNonNull(UIManager.getIcon("Tree.leafIcon"), DEFAULT_FILE))); //NOI18N LEAF_RO = new ImageIcon(UiUtils.makeBadgedRightTop(((ImageIcon) LEAF).getImage(), READONLY_BADGE)); } if (LEAF_MINDMAP == null) { LEAF_MINDMAP = Icons.DOCUMENT.getIcon(); LEAF_MINDMAP_RO = new ImageIcon(UiUtils.makeBadgedRightTop(Icons.DOCUMENT.getIcon().getImage(), READONLY_BADGE)); } if (LEAF_EMPTY == null) { LEAF_EMPTY = new ImageIcon(UiUtils.iconToImage(tree, DEFAULT_FILE)); //NOI18N LEAF_EMPTY_RO = new ImageIcon(UiUtils.makeBadgedRightTop(UiUtils.iconToImage(tree, DEFAULT_FILE), READONLY_BADGE)); } if (LEAF_PLANTUML == null) { LEAF_PLANTUML = new ImageIcon(UiUtils.iconToImage(tree, PLANTUML_FILE)); //NOI18N LEAF_PLANTUML_RO = new ImageIcon(UiUtils.makeBadgedRightTop(UiUtils.iconToImage(tree, PLANTUML_FILE), READONLY_BADGE)); } if (LEAF_KSTPL == null) { LEAF_KSTPL = new ImageIcon(UiUtils.iconToImage(tree, KSTPL_FILE)); //NOI18N LEAF_KSTPL_RO = new ImageIcon(UiUtils.makeBadgedRightTop(UiUtils.iconToImage(tree, KSTPL_FILE), READONLY_BADGE)); } }
Example #30
Source File: MindmupExporter.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
private void writeRoot(@Nonnull final JSONStringer stringer, @Nonnull final MindMapPanelConfig cfg, @Nullable final Topic root) { stringer.object(); stringer.key("formatVersion").value(3L); stringer.key("id").value("root"); stringer.key("ideas").object(); final Map<String, String> linkMap = new HashMap<>(); final Map<String, TopicId> uuidTopicMap = new HashMap<>(); if (root != null) { stringer.key("1").object(); writeTopic(stringer, cfg, new AtomicInteger(1), root, linkMap, uuidTopicMap); stringer.endObject(); stringer.key("title").value(GetUtils.ensureNonNull(root.getText(), "[Root]")); } else { stringer.key("title").value("Empty map"); } stringer.endObject(); if (!linkMap.isEmpty()) { stringer.key("links").array(); for (final Map.Entry<String, String> entry : linkMap.entrySet()) { final TopicId from = uuidTopicMap.get(entry.getKey()); final TopicId to = uuidTopicMap.get(entry.getValue()); if (from != null && to != null) { stringer.object(); stringer.key("ideaIdFrom").value(from.id); stringer.key("ideaIdTo").value(to.id); stringer.key("attr").object(); stringer.key("style").object(); stringer.key("arrow").value("to"); stringer.key("color").value(Utils.color2html(cfg.getJumpLinkColor(), false)); stringer.key("lineStyle").value("dashed"); stringer.endObject(); stringer.endObject(); stringer.endObject(); } } stringer.endArray(); } stringer.endObject(); }