本文整理汇总了Java中org.eclipse.core.runtime.Assert.isNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.isNotNull方法的具体用法?Java Assert.isNotNull怎么用?Java Assert.isNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.Assert
的用法示例。
在下文中一共展示了Assert.isNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BatchSourceViewerConfiguration
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
* Creates configuration by given adaptable
*
* @param adaptable
* must provide {@link ColorManager} and {@link IFile}
*/
public BatchSourceViewerConfiguration(IAdaptable adaptable) {
IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
this.fPreferenceStore = new ChainedPreferenceStore(
new IPreferenceStore[] { getPreferences().getPreferenceStore(), generalTextStore });
Assert.isNotNull(adaptable, "adaptable may not be null!");
this.annotationHoover = new BatchEditorAnnotationHoover();
this.contentAssistant = new ContentAssistant();
contentAssistProcessor = new BatchEditorSimpleWordContentAssistProcessor();
contentAssistant.enableColoredLabels(true);
contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
for (BatchDocumentIdentifier identifier: BatchDocumentIdentifiers.values()){
contentAssistant.setContentAssistProcessor(contentAssistProcessor, identifier.getId());
}
contentAssistant.addCompletionListener(contentAssistProcessor.getCompletionListener());
this.colorManager = adaptable.getAdapter(ColorManager.class);
Assert.isNotNull(colorManager, " adaptable must support color manager");
this.defaultTextAttribute = new TextAttribute(
colorManager.getColor(getPreferences().getColor(COLOR_NORMAL_TEXT)));
this.adaptable=adaptable;
}
示例2: BashSourceViewerConfiguration
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
* Creates configuration by given adaptable
*
* @param adaptable
* must provide {@link ColorManager} and {@link IFile}
*/
public BashSourceViewerConfiguration(IAdaptable adaptable) {
IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
this.fPreferenceStore = new ChainedPreferenceStore(
new IPreferenceStore[] { getPreferences().getPreferenceStore(), generalTextStore });
Assert.isNotNull(adaptable, "adaptable may not be null!");
this.annotationHoover = new BashEditorAnnotationHoover();
this.contentAssistant = new ContentAssistant();
contentAssistProcessor = new BashEditorSimpleWordContentAssistProcessor();
contentAssistant.enableColoredLabels(true);
contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
for (BashDocumentIdentifier identifier: BashDocumentIdentifiers.values()){
contentAssistant.setContentAssistProcessor(contentAssistProcessor, identifier.getId());
}
contentAssistant.addCompletionListener(contentAssistProcessor.getCompletionListener());
this.colorManager = adaptable.getAdapter(ColorManager.class);
Assert.isNotNull(colorManager, " adaptable must support color manager");
this.defaultTextAttribute = new TextAttribute(
colorManager.getColor(getPreferences().getColor(COLOR_NORMAL_TEXT)));
this.adaptable=adaptable;
}
示例3: HydrographCompletionProposal
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
public HydrographCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition,
Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
Assert.isNotNull(replacementString);
Assert.isTrue(replacementOffset >= 0);
Assert.isTrue(replacementLength >= 0);
Assert.isTrue(cursorPosition >= 0);
fReplacementString = replacementString;
fReplacementOffset = replacementOffset;
fReplacementLength = replacementLength;
fCursorPosition = cursorPosition;
fImage = image;
fDisplayString = displayString;
fContextInformation = contextInformation;
fAdditionalProposalInfo = additionalProposalInfo;
}
示例4: doEditFormula
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
protected Assignment doEditFormula(Assignment formula) // gets called when editing a constant and ...
{
Assert.isNotNull(formula);
// Create the wizard
AssignmentWizard wizard = new AssignmentWizard(getSection().getText(), getSection().getDescription(),
(Assignment) formula, AssignmentWizard.SHOW_OPTION, AssignmentWizardPage.CONSTANT_WIZARD_ID);
// Create the wizard dialog
WizardDialog dialog = new WizardDialog(getTableViewer().getTable().getShell(), wizard);
wizard.setWizardDialog(dialog);
dialog.setHelpAvailable(true);
// Open the wizard dialog
if (Window.OK == dialog.open())
{
return wizard.getFormula();
} else
{
return null; // We get here if the user cancels.
}
}
示例5: apply
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
public static String apply(Document doc, Collection<? extends TextEdit> edits) throws BadLocationException {
Assert.isNotNull(doc);
Assert.isNotNull(edits);
List<TextEdit> sortedEdits = new ArrayList<>(edits);
sortByLastEdit(sortedEdits);
String text = doc.get();
for (int i = sortedEdits.size() - 1; i >= 0; i--) {
TextEdit te = sortedEdits.get(i);
Range r = te.getRange();
if (r != null && r.getStart() != null && r.getEnd() != null) {
int start = getOffset(doc, r.getStart());
int end = getOffset(doc, r.getEnd());
text = text.substring(0, start)
+ te.getNewText()
+ text.substring(end, text.length());
}
}
return text;
}
示例6: expandNode
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
* Attempts to expand all nodes along the path specified by the node array parameter.
* The method is copied from SWTBotTree with an additional check if the node is already expanded.
*
* @param bot
* tree bot, must not be {@code null}
* @param nodes
* node path to expand, must not be {@code null} or empty
* @return the last tree item that was expanded, or {@code null} if no item was found
*/
public static SWTBotTreeItem expandNode(final SWTBotTree bot, final String... nodes) {
Assert.isNotNull(bot, ARGUMENT_BOT);
Assert.isNotNull(nodes, ARGUMENT_NODES);
assertArgumentIsNotEmpty(nodes, ARGUMENT_NODES);
new SWTBot().waitUntil(widgetIsEnabled(bot));
SWTBotTreeItem item = bot.getTreeItem(nodes[0]);
if (!item.isExpanded()) {
item.expand();
}
final List<String> asList = new ArrayList<String>(Arrays.asList(nodes));
asList.remove(0);
if (!asList.isEmpty()) {
item = expandNode(item, asList.toArray(new String[asList.size()]));
}
return item;
}
示例7: createDependency
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
protected void createDependency(Button master, Control slave) {
Assert.isNotNull(slave);
indent(slave);
MasterButtonSlaveSelectionListener listener = new MasterButtonSlaveSelectionListener(master, slave);
master.addSelectionListener(listener);
this.masterSlaveListeners.add(listener);
}
示例8: getSWTImage
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
private Image getSWTImage() {
Shell shell = getShell();
final Display display;
if (shell == null || shell.isDisposed()) {
shell = getParentShell();
}
if (shell == null || shell.isDisposed()) {
display = Display.getCurrent();
// The dialog should be always instantiated in UI thread.
// However it was possible to instantiate it in other threads
// (the code worked in most cases) so the assertion covers
// only the failing scenario. See bug 107082 for details.
Assert.isNotNull(display,
"The dialog should be created in UI thread"); //$NON-NLS-1$
} else {
display = shell.getDisplay();
}
final Image[] image = new Image[1];
display.syncExec(new Runnable() {
public void run() {
image[0] = display.getSystemImage(SWT.ICON_QUESTION);
}
});
return image[0];
}
示例9: disconnect
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
private void disconnect() {
Assert.isNotNull(fCurrentTarget);
ITextViewer viewer = fCurrentTarget.getViewer();
Assert.isNotNull(viewer);
viewer.getDocument().removeDocumentListener(fDocumentListener);
fAssistant.uninstall();
fAssistant.removeProposalListener(fProposalListener);
fCurrentTarget.fWidget = null;
Shell shell = fCurrentTarget.fShell;
fCurrentTarget.fShell = null;
if (shell != null && !shell.isDisposed())
shell.removeShellListener(fCloser);
// this one is asymmetric: we don't install the model in
// connect, but leave it to its callers to ensure they
// have the model installed if they need it
uninstallAnnotationModel(fCurrentTarget);
unregisterAutoEditVetoer(viewer);
// don't remove the verify key listener to let it keep its position
// in the listener queue
if (fCurrentTarget.fKeyListener != null)
fCurrentTarget.fKeyListener.setEnabled(false);
((IPostSelectionProvider) viewer).removePostSelectionChangedListener(fSelectionListener);
redraw();
}
示例10: install
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
@Override
public void install(ITextViewer viewer) {
Assert.isNotNull(viewer);
this.viewer = viewer;
viewer.addTextInputListener(internalListener);
IDocument document = viewer.getDocument();
if (document != null) {
internalListener.inputDocumentChanged(null, document);
}
themeChangeListener = new ThemeChangeListener();
ThemeManager.getInstance().addPreferenceChangeListener(themeChangeListener);
}
示例11: createSection
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
* Creates an expandable section within the parent created previously by calling
* <code>createSectionComposite</code>. Controls can be added directly to the returned
* composite, which has no layout initially.
*
* @param label the display name of the section
* @return a composite within the expandable section
*/
public Composite createSection(String label) {
Assert.isNotNull(fBody);
final ExpandableComposite excomposite = new ExpandableComposite(fBody, SWT.NONE,
ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
if (fFirstChild == null) fFirstChild = excomposite;
excomposite.setText(label);
String last = null;
if (fLastOpenKey != null && fDialogSettingsStore != null)
last = fDialogSettingsStore.getString(fLastOpenKey);
if (fFirstChild == excomposite && !__NONE.equals(last) || label.equals(last)) {
excomposite.setExpanded(true);
if (fFirstChild != excomposite) fFirstChild.setExpanded(false);
} else {
excomposite.setExpanded(false);
}
excomposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
updateSectionStyle(excomposite);
manage(excomposite);
Composite contents = new Composite(excomposite, SWT.NONE);
excomposite.setClient(contents);
return contents;
}
示例12: getValidModel
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
* Gets the valid model.
*
* @param grammar
* the grammar
* @return the valid model
*/
private ValidModel getValidModel(final Grammar grammar) {
if (model != null) {
return model;
}
Resource resource = null;
final String name = GrammarUtil.getName(grammar) + '.' + XTEXT_EXTENSION;
URI uri;
for (final Resource res : grammar.eResource().getResourceSet().getResources()) {
if (res.getURI() != null && name.equals(EmfResourceUtil.getFileName(res.getURI()))) {
resource = res;
break;
}
}
if (getValidURI() == null) {
Assert.isNotNull(resource, NLS.bind(Messages.RESOURCE_NOT_FOUND, name));
uri = resource.getURI().trimFileExtension().appendFileExtension(VALID_EXTENSION);
} else {
uri = URI.createURI(getValidURI());
}
resource = resource.getResourceSet().getResource(uri, true);
final List<Issue> issues = VALIDATOR.validate(resource, LOGGER);
for (final Issue issue : issues) {
if (issue.isSyntaxError() || issue.getSeverity() == Severity.ERROR) {
throw new WorkflowInterruptedException(NLS.bind(Messages.ERROR_FOUND, uri.toString()));
}
}
model = (ValidModel) resource.getContents().get(0);
return model;
}
示例13: GradleHyperlinkDetector
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
public GradleHyperlinkDetector(IAdaptable adaptable) {
Assert.isNotNull(adaptable, "Adaptable may not be null!");
IFile ifile = adaptable.getAdapter(IFile.class);
try {
editorFile = getResourceHelper().toFile(ifile);
} catch (CoreException e) {
/*
* if not working - ignore, so hyper link detection will return null
*/
}
transformer= adaptable.getAdapter(GradleStringTransformer.class);
}
示例14: switchPosition
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
private void switchPosition(LinkedPosition pos, boolean select, boolean showProposals) {
Assert.isNotNull(pos);
if (pos.equals(fFramePosition))
return;
if (fFramePosition != null && fCurrentTarget != null)
fPositionListener.linkingFocusLost(fFramePosition, fCurrentTarget);
// undo
endCompoundChangeIfNeeded();
redraw(); // redraw current position being left - usually not needed
IDocument oldDoc = fFramePosition == null ? null : fFramePosition.getDocument();
IDocument newDoc = pos.getDocument();
switchViewer(oldDoc, newDoc, pos);
fFramePosition = pos;
if (select)
select();
if (fFramePosition == fExitPosition && !fIterator.isCycling())
leave(ILinkedModeListener.NONE);
else {
redraw(); // redraw new position
ensureAnnotationModelInstalled();
}
if (showProposals)
triggerContentAssist();
if (fFramePosition != fExitPosition && fDoContextInfo)
triggerContextInfo();
if (fFramePosition != null && fCurrentTarget != null)
fPositionListener.linkingFocusGained(fFramePosition, fCurrentTarget);
}
示例15: setAction
import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
public void setAction(String id, Action action) {
Assert.isNotNull(id);
if (action == null) {
actions.remove(id);
} else {
actions.put(id, action);
}
}