本文整理匯總了Java中org.eclipse.osgi.util.NLS類的典型用法代碼示例。如果您正苦於以下問題:Java NLS類的具體用法?Java NLS怎麽用?Java NLS使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NLS類屬於org.eclipse.osgi.util包,在下文中一共展示了NLS類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validateDestinationGroup
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Answer a boolean indicating whether the receivers destination specification widgets currently all contain valid
* values.
*/
private boolean validateDestinationGroup() {
String destinationValue = getTargetDirectory();
if (destinationValue.length() == 0) {
setMessage(destinationEmptyMessage());
return false;
}
String conflictingContainer = getConflictingContainerNameFor(destinationValue);
if (conflictingContainer == null) {
// // no error message, but warning may exists
// String threatenedContainer = getOverlappingProjectName(destinationValue);
// if (threatenedContainer == null)
setMessage(null);
// else
// setMessage(NLS.bind(NFARExportMessages.FileExport_damageWarning, threatenedContainer), WARNING);
} else {
setErrorMessage(NLS.bind(N4ExportMessages.FileExport_conflictingContainer, conflictingContainer));
giveFocusToDestination();
return false;
}
return true;
}
示例2: flagMissingRequiredOption
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Locates the page that this option is presented in and flags that the
* option is required and is currently not set. The flagging is done by
* setting the page incomplete and setting the error message that uses
* option's message label.
*
* @param option
* the option that is required and currently not set
*/
protected void flagMissingRequiredOption(TemplateOption option) {
WizardPage page = null;
for (int i = 0; i < pages.size(); i++) {
TemplatePage tpage = pages.get(i);
ArrayList<TemplateOption> list = tpage.options;
if (list.contains(option)) {
page = tpage.page;
break;
}
}
if (page != null) {
page.setPageComplete(false);
String message = NLS.bind(PDEUIMessages.OptionTemplateSection_mustBeSet, option.getMessageLabel());
page.setErrorMessage(message);
}
}
示例3: getDisplayStringWithStatus
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Get the display string based on the current status and the name of the
* job.
* @param showProgress a boolean to indicate if we should
* show progress or not.
*
* @return String
*/
private String getDisplayStringWithStatus(boolean showProgress) {
if (isCanceled()) {
return NLS.bind(ProgressMessages.JobInfo_Cancelled, (new Object[] { getJob().getName() }));
}
if (isBlocked()) {
return NLS.bind(ProgressMessages.JobInfo_Blocked, (new Object[] { getJob().getName(),
blockedStatus.getMessage() }));
}
if (getJob().getState() == Job.RUNNING) {
TaskInfo info = getTaskInfo();
if (info == null) {
return getJob().getName();
}
return info.getDisplayString(showProgress);
}
if (getJob().getState() == Job.SLEEPING) {
return NLS.bind(ProgressMessages.JobInfo_Sleeping, (new Object[] { getJob().getName() }));
}
return NLS.bind(ProgressMessages.JobInfo_Waiting, (new Object[] { getJob().getName() }));
}
示例4: fixIllegalDefaultSeverity
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Fixes an illegally set default severity. The default severity must be within given severity range.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.DEFAULT_SEVERITY_NOT_IN_RANGE)
public void fixIllegalDefaultSeverity(final Issue issue, final IssueResolutionAcceptor acceptor) {
if (issue.getData() != null) {
for (final String severityProposal : issue.getData()) {
final String label = NLS.bind(Messages.CheckQuickfixProvider_DEFAULT_SEVERITY_FIX_LABEL, severityProposal);
final String descn = NLS.bind(Messages.CheckQuickfixProvider_DEFAULT_SEVERITY_FIX_DESCN, severityProposal);
acceptor.accept(issue, label, descn, NO_IMAGE, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.replace(issue.getOffset(), issue.getLength(), severityProposal);
}
});
}
}
}
示例5: validatePage
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
@Override
protected IStatus validatePage(Event event) {
grammarInfoWidget.refresh(null);
String path = grammarFileText.getText();
if (path.length() == 0) {
return new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID,
TMUIMessages.SelectGrammarWizardPage_file_error_required);
}
File f = new File(path);
Registry registry = new Registry();
try {
IGrammar grammar = registry.loadGrammarFromPathSync(f.getName(), new FileInputStream(f));
if (grammar == null || grammar.getScopeName() == null) {
return new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID,
TMUIMessages.SelectGrammarWizardPage_file_error_invalid);
}
grammarInfoWidget.refresh(grammar);
} catch (Exception e) {
return new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID,
NLS.bind(TMUIMessages.SelectGrammarWizardPage_file_error_load, e.getMessage()), e);
}
return null;
}
示例6: getText
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
@Override
public String getText() {
final ICounter branches = line.getBranchCounter();
switch (branches.getStatus()) {
case ICounter.NOT_COVERED:
return NLS.bind(UIMessages.AnnotationTextAllBranchesMissed_message,
Integer.valueOf(branches.getMissedCount()));
case ICounter.FULLY_COVERED:
return NLS.bind(UIMessages.AnnotationTextAllBranchesCovered_message,
Integer.valueOf(branches.getTotalCount()));
case ICounter.PARTLY_COVERED:
return NLS.bind(UIMessages.AnnotationTextSomeBranchesMissed_message,
Integer.valueOf(branches.getMissedCount()),
Integer.valueOf(branches.getTotalCount()));
default:
return null;
}
}
示例7: fixSeverityToMaxSeverity
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Fix severity by setting it to a legal value as is defined by severity range of referenced check. Legal
* severities are passed as issue data (org.eclipse.xtext.validation.Issue#getData()).
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.SEVERITY_NOT_ALLOWED)
public void fixSeverityToMaxSeverity(final Issue issue, final IssueResolutionAcceptor acceptor) {
if (issue.getData() != null) {
for (final String severityProposal : issue.getData()) {
final String label = NLS.bind(Messages.CheckCfgQuickfixProvider_CORRECT_SEVERITY_LABEL, severityProposal);
final String descn = NLS.bind(Messages.CheckCfgQuickfixProvider_CORRECT_SEVERITY_DESCN, severityProposal);
acceptor.accept(issue, label, descn, NO_IMAGE, new IModification() {
public void apply(final IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.replace(issue.getOffset(), issue.getLength(), severityProposal);
}
});
}
}
}
示例8: checkConfigurationEqualsDefault
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Checks whether a configured check's configuration equals the default. Emits an info if this is the case.
*
* @param configuredCheck
* the configured check
*/
@Check
public void checkConfigurationEqualsDefault(final ConfiguredCheck configuredCheck) {
final com.avaloq.tools.ddk.check.check.Check check = configuredCheck.getCheck();
if (!isParameterConfigured(configuredCheck) || check == null || check.eIsProxy()) {
return; // only interesting if check configured and resolvable
}
Iterable<FormalParameter> formalParameters = check.getFormalParameters();
for (final ConfiguredParameter configParam : configuredCheck.getParameterConfigurations()) {
try {
FormalParameter param = Iterables.find(formalParameters, new Predicate<FormalParameter>() {
@Override
public boolean apply(final FormalParameter input) {
return input == configParam.getParameter();
}
});
if (parameterValuesEqual(configParam.getNewValue(), param.getRight())) {
info(NLS.bind(Messages.CheckCfgJavaValidator_CONFIGURED_PARAM_EQUALS_DEFAULT, param.getName()), configParam, CheckcfgPackage.Literals.CONFIGURED_PARAMETER__NEW_VALUE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.CONFIGURED_PARAM_EQUALS_DEFAULT);
}
} catch (NoSuchElementException e) {
LOGGER.debug("Could not find referenced formal parameter");
}
}
}
示例9: createTempDirectory
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Creates the temp directory.
*
* @param name
* the name of the directory, must not be {@code null}
* @return the file, never {@code null}
* @throws DeployException
* Signals that an I/O exception has occurred.
*/
private static File createTempDirectory(final String name) throws DeployException {
final File temp;
try {
temp = File.createTempFile(name, null);
} catch (IOException e) {
LOGGER.error(e.getMessage());
throw new DeployException(e);
}
if (!(temp.delete())) {
LOGGER.error(NLS.bind(Messages.DeployJob_CouldNotCreateTemporaryDirectoryForJar, temp.getAbsolutePath()));
throw new DeployException();
}
if (!(temp.mkdir())) {
LOGGER.error(NLS.bind(Messages.DeployJob_CouldNotCreateTemporaryDirectoryForJar, temp.getAbsolutePath()));
throw new DeployException();
}
return temp;
}
示例10: validateNgProjectName
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/** Validates the name of the Angular-CLI Project. */
private IStatus validateNgProjectName(String name) {
IStatus status = Status.OK_STATUS;
for (int i = 0, cnt = unsupportedProjectNames.length; i < cnt; i++) {
if (unsupportedProjectNames[i].equals(name)) {
status = new Status(IStatus.WARNING, AngularCLIPlugin.PLUGIN_ID,
NLS.bind(AngularCLIMessages.NewAngularProjectWizard_unsupportedProjectNames, name));
break;
}
}
if (status.isOK()) {
String[] parts = name.split("-");
for (int i = 0, cnt = parts.length; i < cnt; i++) {
if (!parts[i].matches(projectNameRegexp)) {
status = new Status(IStatus.WARNING, AngularCLIPlugin.PLUGIN_ID,
NLS.bind(AngularCLIMessages.NewAngularProjectWizard_invalidProjectName, name));
break;
}
}
}
return status;
}
示例11: checkExtensions
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Verifies that all referenced extensions can be found.
*
* @param model
* scope model to check
*/
@Check
public void checkExtensions(final ScopeModel model) {
ResourceManager resourceManager = null;
if (Platform.isRunning()) {
IXtendXpandProject project = Activator.getExtXptModelManager().findProject(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.eResource().getURI().toPlatformString(true))).getProject());
if (project != null) {
resourceManager = new XpandPluginExecutionContext(project).getResourceManager();
}
} else {
resourceManager = new ResourceManagerDefaultImpl();
}
if (resourceManager == null) {
return;
}
for (Extension ext : model.getExtensions()) {
final Resource res = resourceManager.loadResource(ext.getExtension(), XtendFile.FILE_EXTENSION);
if (res == null) {
error(NLS.bind(Messages.extensionNotFound, ext.getExtension()), ext, ScopePackage.Literals.EXTENSION__EXTENSION, null);
}
}
}
示例12: apply
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/** {@inheritDoc} */
@Override
public void apply(final IModificationContext context) throws BadLocationException {
final IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(final XtextResource state) throws Exception { // NOPMD
final EObject target = EcoreUtil2.getContainerOfType(state.getEObject(issue.getUriToProblem().fragment()), type);
if (type.isInstance(target)) {
int offset = NodeModelUtils.findActualNodeFor(target).getOffset();
int lineOfOffset = xtextDocument.getLineOfOffset(offset);
int lineOffset = xtextDocument.getLineOffset(lineOfOffset);
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < (offset - lineOffset); i++) {
buffer.append(' ');
}
xtextDocument.replace(offset, 0, NLS.bind(autodocumentation, buffer.toString()));
}
}
});
}
示例13: checkDataTypeOrEnumRule
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Verify that only rule self directives are used for terminal, enum and data type rules.
*
* @param model
* the GrammarRule
*/
@Check
public void checkDataTypeOrEnumRule(final GrammarRule model) {
if (model.getTargetRule() instanceof TerminalRule || model.getTargetRule() instanceof EnumRule
|| (model.getTargetRule() instanceof ParserRule && GrammarUtil.isDatatypeRule((ParserRule) model.getTargetRule()))) {
Iterator<EObject> grammarElementAccessors = collectGrammarElementAccessors(model);
boolean selfAccessOnly = Iterators.all(grammarElementAccessors, new Predicate<EObject>() {
@Override
public boolean apply(final EObject input) {
return input instanceof GrammarElementReference && ((GrammarElementReference) input).getSelf() != null;
}
});
if (!selfAccessOnly) {
error(NLS.bind("For data type, enum or terminal rule {0} only ''rule'' directive may be used", model.getTargetRule().getName()), FormatPackage.Literals.GRAMMAR_RULE__DIRECTIVES, ILLEGAL_DIRECTIVE_CODE);
}
}
}
示例14: checkExtensions
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Verifies that all referenced extensions can be found.
*
* @param model
* export model to check
*/
@Check
public void checkExtensions(final ExportModel model) {
ResourceManager resourceManager = null;
if (Platform.isRunning()) {
IXtendXpandProject project = Activator.getExtXptModelManager().findProject(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.eResource().getURI().toPlatformString(true))).getProject());
if (project != null) {
resourceManager = new XpandPluginExecutionContext(project).getResourceManager();
}
} else {
resourceManager = new ResourceManagerDefaultImpl();
}
if (resourceManager == null) {
return;
}
for (Extension ext : model.getExtensions()) {
final Resource res = resourceManager.loadResource(ext.getExtension(), XtendFile.FILE_EXTENSION);
if (res == null) {
error(NLS.bind("Extension ''{0}'' not found", ext.getExtension()), ext, ExportPackage.Literals.EXTENSION__EXTENSION, null);
}
}
}
示例15: checkCheckNamesAreUnique
import org.eclipse.osgi.util.NLS; //導入依賴的package包/類
/**
* Checks that Check names are unique. A Check name may only occur once in a Check Catalog.
*
* @param catalog
* the check catalog
*/
@Check
public void checkCheckNamesAreUnique(final CheckCatalog catalog) {
Function<com.avaloq.tools.ddk.check.check.Check, QualifiedName> function = new Function<com.avaloq.tools.ddk.check.check.Check, QualifiedName>() {
@Override
public QualifiedName apply(final com.avaloq.tools.ddk.check.check.Check from) {
return QualifiedName.create(from.getName()); // no need to create a fully qualified name with check catalog here, it is only used for
// comparing check instances
}
};
UniquenessJavaValidationHelper<com.avaloq.tools.ddk.check.check.Check> helper = //
new UniquenessJavaValidationHelper<com.avaloq.tools.ddk.check.check.Check>(function, getMessageAcceptor()) {
@Override
public String getMessage(final com.avaloq.tools.ddk.check.check.Check duplicate) {
return NLS.bind("Duplicate Check name: {0}", duplicate.getName()); //$NON-NLS-1$
}
};
final Iterable<com.avaloq.tools.ddk.check.check.Check> allChecksWithName = Iterables.filter(catalog.getAllChecks(), new Predicate<com.avaloq.tools.ddk.check.check.Check>() {
@Override
public boolean apply(final com.avaloq.tools.ddk.check.check.Check input) {
return input.getName() != null;
}
});
helper.errorOnDuplicates(allChecksWithName, locationInFileProvider::getIdentifierFeature, IssueCodes.DUPLICATE_CHECK);
}