Java Code Examples for com.intellij.openapi.util.text.StringUtil#isEmpty()
The following examples show how to use
com.intellij.openapi.util.text.StringUtil#isEmpty() .
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: OptionTagBinding.java From consulo with Apache License 2.0 | 6 votes |
public OptionTagBinding(@Nonnull MutableAccessor accessor, @Nullable OptionTag optionTag) { super(accessor, optionTag == null ? null : optionTag.value(), optionTag == null ? null : optionTag.converter()); if (optionTag == null) { myTagName = Constants.OPTION; myNameAttribute = Constants.NAME; myValueAttribute = Constants.VALUE; } else { myNameAttribute = optionTag.nameAttribute(); myValueAttribute = optionTag.valueAttribute(); String tagName = optionTag.tag(); if (StringUtil.isEmpty(myNameAttribute) && Constants.OPTION.equals(tagName)) { tagName = myAccessor.getName(); } myTagName = tagName; } }
Example 2
Source File: CSharpChangeSignatureDialog.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Override @RequiredUIAccess protected JComponent getRowPresentation(ParameterTableModelItemBase<CSharpParameterInfo> item, boolean selected, final boolean focused) { final String typeText = item.typeCodeFragment.getText(); CSharpModifier modifier = item.parameter.getModifier(); String text = ""; if(modifier != null) { text = modifier.getPresentableText() + " "; } final String separator = StringUtil.repeatSymbol(' ', getTypesMaxLength() - typeText.length() + 1); text += typeText + separator + item.parameter.getName(); final String defaultValue = item.defaultValueCodeFragment.getText(); String tail = ""; if(StringUtil.isNotEmpty(defaultValue)) { tail += " argument value = " + defaultValue; } if(!StringUtil.isEmpty(tail)) { text += " //" + tail; } return JBListTable.createEditorTextFieldPresentation(getProject(), getFileType(), " " + text, selected, focused); }
Example 3
Source File: OrderPanel.java From consulo with Apache License 2.0 | 6 votes |
public void setCheckboxColumnName(final String name) { final int width; if (StringUtil.isEmpty(name)) { CHECKBOX_COLUMN_NAME = ""; width = new JCheckBox().getPreferredSize().width; } else { CHECKBOX_COLUMN_NAME = name; final FontMetrics fontMetrics = myEntryTable.getFontMetrics(myEntryTable.getFont()); width = fontMetrics.stringWidth(" " + name + " ") + 4; } final TableColumn checkboxColumn = myEntryTable.getColumnModel().getColumn(getCheckboxColumn()); checkboxColumn.setWidth(width); checkboxColumn.setPreferredWidth(width); checkboxColumn.setMaxWidth(width); checkboxColumn.setMinWidth(width); }
Example 4
Source File: ListPopupImpl.java From consulo with Apache License 2.0 | 5 votes |
private void valuesSelected(final Object[] values) { if (shouldUseStatistics()) { final String filter = getSpeedSearch().getFilter(); if (!StringUtil.isEmpty(filter)) { for (Object value : values) { final String text = getListStep().getTextFor(value); StatisticsManager.getInstance().incUseCount(new StatisticsInfo("#list_popup:" + getListStep().getTitle() + "#" + filter, text)); } } } }
Example 5
Source File: FileStructurePopup.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static String getSpeedSearchText(Object object) { String text = String.valueOf(object); Object value = StructureViewComponent.unwrapWrapper(object); if (text != null) { if (value instanceof PsiTreeElementBase && ((PsiTreeElementBase)value).isSearchInLocationString()) { String locationString = ((PsiTreeElementBase)value).getLocationString(); if (!StringUtil.isEmpty(locationString)) { String locationPrefix = null; String locationSuffix = null; if (value instanceof LocationPresentation) { locationPrefix = ((LocationPresentation)value).getLocationPrefix(); locationSuffix = ((LocationPresentation)value).getLocationSuffix(); } return text + StringUtil.notNullize(locationPrefix, LocationPresentation.DEFAULT_LOCATION_PREFIX) + locationString + StringUtil.notNullize(locationSuffix, LocationPresentation.DEFAULT_LOCATION_SUFFIX); } } return text; } // NB!: this point is achievable if the following method returns null // see com.intellij.ide.util.treeView.NodeDescriptor.toString if (value instanceof TreeElement) { return ReadAction.compute(() -> ((TreeElement)value).getPresentation().getPresentableText()); } return null; }
Example 6
Source File: SimpleColoredComponent.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private TextLayout createTextLayout(String text, Font basefont, FontRenderContext fontRenderContext) { if (StringUtil.isEmpty(text)) return null; AttributedString string = new AttributedString(text); int start = 0; int end = text.length(); AttributedCharacterIterator it = string.getIterator(new AttributedCharacterIterator.Attribute[0], start, end); Font currentFont = basefont; int currentIndex = start; for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) { Font font = basefont; if (!font.canDisplay(c)) { for (SuitableFontProvider provider : SuitableFontProvider.EP_NAME.getExtensions()) { font = provider.getFontAbleToDisplay(c, basefont.getSize(), basefont.getStyle(), basefont.getFamily()); if (font != null) break; } } int i = it.getIndex(); if (!Comparing.equal(currentFont, font)) { if (i > currentIndex) { string.addAttribute(TextAttribute.FONT, currentFont, currentIndex, i); } currentFont = font; currentIndex = i; } } if (currentIndex < end) { string.addAttribute(TextAttribute.FONT, currentFont, currentIndex, end); } return new TextLayout(string.getIterator(), fontRenderContext); }
Example 7
Source File: ProjectLevelVcsManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
void writeDirectoryMappings(@Nonnull Element element) { if (myProject.isDefault()) { element.setAttribute(ATTRIBUTE_DEFAULT_PROJECT, Boolean.TRUE.toString()); } for (VcsDirectoryMapping mapping : getDirectoryMappings()) { VcsRootSettings rootSettings = mapping.getRootSettings(); if (rootSettings == null && StringUtil.isEmpty(mapping.getDirectory()) && StringUtil.isEmpty(mapping.getVcs())) { continue; } Element child = new Element(ELEMENT_MAPPING); child.setAttribute(ATTRIBUTE_DIRECTORY, mapping.getDirectory()); child.setAttribute(ATTRIBUTE_VCS, mapping.getVcs()); if (rootSettings != null) { Element rootSettingsElement = new Element(ELEMENT_ROOT_SETTINGS); rootSettingsElement.setAttribute(ATTRIBUTE_CLASS, rootSettings.getClass().getName()); try { rootSettings.writeExternal(rootSettingsElement); child.addContent(rootSettingsElement); } catch (WriteExternalException e) { // don't add element } } element.addContent(child); } }
Example 8
Source File: UnityDebugProcess.java From consulo-unity3d with Apache License 2.0 | 5 votes |
private void print(String text, String stacktrace, ConsoleView view, ConsoleViewContentType contentType) { view.print(text + "\n", contentType); if(contentType == ConsoleViewContentType.ERROR_OUTPUT && !StringUtil.isEmpty(stacktrace)) { StringBuilder builder = new StringBuilder(); String[] strings = StringUtil.splitByLines(stacktrace); for(String line : strings) { builder.append(" at ").append(line).append("\n"); } view.print(builder.toString(), contentType); } }
Example 9
Source File: RunAnythingManager.java From consulo with Apache License 2.0 | 5 votes |
private void predefineSelectedText(@Nullable String searchText) { if (StringUtil.isEmpty(searchText)) { searchText = mySelectedText; } if (StringUtil.isNotEmpty(searchText)) { myRunAnythingUI.getSearchField().setValue(searchText); myRunAnythingUI.getSearchField().selectAll(); } }
Example 10
Source File: BaseRNConsoleNPMAction.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected String getMetroPortParams() { String port = RNPathUtil.getRNMetroPortFromConfig(project); if(!StringUtil.isEmpty(port)) { port = " --port " + port; } else { port = ""; } return port; }
Example 11
Source File: PackagesNotificationPanel.java From vue-for-idea with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void showResult(String packageName, @Nullable String errorDescription) { if (StringUtil.isEmpty(errorDescription)) { showSuccess("Package successfully installed."); } else { String title = "Install packages failed"; final String firstLine = title + ": Error occurred when installing package " + packageName + ". "; showError(firstLine + "<a href=\"xxx\">Details...</a>", title, firstLine + errorDescription); } }
Example 12
Source File: CSharpMethodStubElementType.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override @RequiredReadAction public void indexStub(@Nonnull CSharpMethodDeclStub stub, @Nonnull IndexSink indexSink) { String name = getName(stub); if(!StringUtil.isEmpty(name)) { indexSink.occurrence(CSharpIndexKeys.METHOD_INDEX, name); if(!stub.isNested()) { if(BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.DELEGATE_MASK)) { String parentQName = stub.getParentQName(); DotNetNamespaceStubUtil.indexStub(indexSink, CSharpIndexKeys.MEMBER_BY_NAMESPACE_QNAME_INDEX, CSharpIndexKeys.MEMBER_BY_ALL_NAMESPACE_QNAME_INDEX, parentQName, name); } } if(BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.EXTENSION_MASK)) { indexSink.occurrence(CSharpIndexKeys.EXTENSION_METHOD_BY_NAME_INDEX, name); } if(BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.DELEGATE_MASK)) { indexSink.occurrence(CSharpIndexKeys.DELEGATE_METHOD_BY_NAME_INDEX, name); } } }
Example 13
Source File: ModuleExtensionProviderEP.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override protected Image compute() { if (StringUtil.isEmpty(icon)) { return AllIcons.Toolbar.Unknown; } Image temp = IconLoader.findIcon(icon, getLoaderForClass()); return temp == null ? AllIcons.Toolbar.Unknown : temp; }
Example 14
Source File: EditorNotificationPanel.java From consulo with Apache License 2.0 | 5 votes |
@Nls @Nonnull @Override public String getText() { String text = myLabel.getText(); return StringUtil.isEmpty(text) ? EditorBundle.message("editor.notification.default.action.name") : StringUtil.shortenTextWithEllipsis(text, 50, 0); }
Example 15
Source File: AbstractExternalModuleImportProvider.java From consulo with Apache License 2.0 | 4 votes |
/** * Asks current builder to ensure that target external project is defined. * * @param context current wizard context * @throws WizardStepValidationException if gradle project is not defined and can't be constructed */ @SuppressWarnings("unchecked") public void ensureProjectIsDefined(@Nonnull ExternalModuleImportContext<C> context) throws WizardStepValidationException { final String externalSystemName = myExternalSystemId.getReadableName(); File projectFile = getProjectFile(); if (projectFile == null) { throw new WizardStepValidationException(ExternalSystemBundle.message("error.project.undefined")); } projectFile = getExternalProjectConfigToUse(projectFile); final Ref<WizardStepValidationException> error = new Ref<>(); final ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() { @Override public void onSuccess(@Nullable DataNode<ProjectData> externalProject) { myExternalProjectNode = externalProject; } @Override public void onFailure(@Nonnull String errorMessage, @Nullable String errorDetails) { if (!StringUtil.isEmpty(errorDetails)) { LOG.warn(errorDetails); } error.set(new WizardStepValidationException(ExternalSystemBundle.message("error.resolve.with.reason", errorMessage))); } }; final Project project = getContextOrDefaultProject(context); final File finalProjectFile = projectFile; final String externalProjectPath = FileUtil.toCanonicalPath(finalProjectFile.getAbsolutePath()); final Ref<WizardStepValidationException> exRef = new Ref<>(); executeAndRestoreDefaultProjectSettings(project, new Runnable() { @Override public void run() { try { ExternalSystemUtil.refreshProject(project, myExternalSystemId, externalProjectPath, callback, true, ProgressExecutionMode.MODAL_SYNC); } catch (IllegalArgumentException e) { exRef.set(new WizardStepValidationException(ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName))); } } }); WizardStepValidationException ex = exRef.get(); if (ex != null) { throw ex; } if (myExternalProjectNode == null) { WizardStepValidationException exception = error.get(); if (exception != null) { throw exception; } } else { applyProjectSettings(context); } }
Example 16
Source File: FileStructurePopup.java From consulo with Apache License 2.0 | 4 votes |
@Nullable private String getSearchPrefix() { if (ApplicationManager.getApplication().isUnitTestMode()) return myTestSearchFilter; return mySpeedSearch != null && !StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix()) ? mySpeedSearch.getEnteredPrefix() : null; }
Example 17
Source File: FileUtil.java From consulo with Apache License 2.0 | 4 votes |
public static int pathHashCode(@Nullable String path) { return StringUtil.isEmpty(path) ? 0 : PATH_HASHING_STRATEGY.computeHashCode(toCanonicalPath(path)); }
Example 18
Source File: BuildUtils.java From CppTools with Apache License 2.0 | 4 votes |
public static List<String> appendAllOptions(List<String> runCommand, String additionalCommandLineParameters) { if (StringUtil.isEmpty(additionalCommandLineParameters)) return runCommand; StringTokenizer tokenizer = new StringTokenizer(additionalCommandLineParameters, " "); while(tokenizer.hasMoreElements()) runCommand = appendOptions(runCommand, tokenizer.nextToken()); return runCommand; }
Example 19
Source File: AsposeMavenModuleWizardStep.java From Aspose.OCR-for-Java with MIT License | 4 votes |
private static void setTestIfEmpty(@NotNull JTextField artifactIdField, @Nullable String text) { if (StringUtil.isEmpty(artifactIdField.getText())) { artifactIdField.setText(StringUtil.notNullize(text)); } }
Example 20
Source File: ActionManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
private static String obtainActionId(SimpleXmlElement element, String className) { String id = element.getAttributeValue(ID_ATTR_NAME); return StringUtil.isEmpty(id) ? StringUtil.getShortName(className) : id; }