Java Code Examples for org.eclipse.core.runtime.Assert#isLegal()
The following examples show how to use
org.eclipse.core.runtime.Assert#isLegal() .
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: TextViewerDeleteLineAction.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * Returns the default resource bundle prefix for the given arguments. * * @param type the line deletion type, must be one of <code>WHOLE_LINE</code>, * <code>TO_BEGINNING</code> or <code>TO_END</code> * @param copyToClipboard if <code>true</code>, the contents of the deleted line are copied to * the clipboard * @return the prefix for the property keys into <code>bundle</code> * @since 3.5 */ private static String getPrefix(int type, boolean copyToClipboard) { switch (type) { case WHOLE: return copyToClipboard ? "Editor.CutLine." : "Editor.DeleteLine."; //$NON-NLS-1$ //$NON-NLS-2$ case TO_BEGINNING: return copyToClipboard ? "Editor.CutLineToBeginning." : "Editor.DeleteLineToBeginning."; //$NON-NLS-1$ //$NON-NLS-2$ case TO_END: return copyToClipboard ? "Editor.CutLineToEnd." : "Editor.DeleteLineToEnd."; //$NON-NLS-1$ //$NON-NLS-2$ default: Assert.isLegal(false); return ""; //$NON-NLS-1$ } }
Example 2
Source File: ReorgDestinationFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public Destination(Object destination, int location) { Assert.isNotNull(destination); Assert.isLegal(location == LOCATION_AFTER || location == LOCATION_BEFORE || location == LOCATION_ON); fDestination= destination; fLocation= location; }
Example 3
Source File: CompositeSearchResult.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public CompositeSearchResult(CompositeSearchQuery compositeSearchQuery) { super(compositeSearchQuery); this.query = compositeSearchQuery; Assert.isLegal(!query.getChildren().isEmpty()); childListener = new ISearchResultListener() { int removeAll = 0; @Override public void searchResultChanged(SearchResultEvent e) { if(!(e instanceof RemoveAllEvent) || removeAll++%query.getChildren().size() == 0) fireChange(e); } }; for(ISearchQuery child: query.getChildren()) child.getSearchResult().addListener(childListener); }
Example 4
Source File: DirtyStateEditorSupport.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void unloadAffectedResourcesAndReparseDocument(final IXtextDocument document, final Collection<Resource> affectedResources, boolean reparseRequired) { if ((affectedResources == null || affectedResources.isEmpty()) && !reparseRequired) { return; } Assert.isLegal(document instanceof XtextDocument); final XtextDocument xtextDocument = (XtextDocument) document; xtextDocument.internalModify(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource resource) throws Exception { if (resource == null || resource.getResourceSet() == null) { return; } ResourceSet resourceSet = resource.getResourceSet(); if (affectedResources != null) { for (Resource affectedResource : affectedResources) { affectedResource.unload(); resourceSet.getResources().remove(affectedResource); } } if (currentClient instanceof IDirtyStateEditorSupportClientExtension) ((IDirtyStateEditorSupportClientExtension) currentClient).forceReconcile(); else resource.reparse(document.get()); if (resourceSet instanceof XtextResourceSet) { ((XtextResourceSet) resourceSet).markOutdated(); } } }); }
Example 5
Source File: TagCloudViewer.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * Sets the content provider of this viewer, which must be an * {@link IStructuredContentProvider}. */ @Override public void setContentProvider(IContentProvider contentProvider) { Assert.isLegal(contentProvider instanceof IStructuredContentProvider); super.setContentProvider(contentProvider); }
Example 6
Source File: CopyrightUpdaterCleanUp.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void setOptions(final CleanUpOptions options) { Assert.isLegal(options != null); Assert.isTrue(this.options == null); this.options = options; }
Example 7
Source File: TagCloud.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * Creates a new Tag cloud on the given parent. When using this constructor, * please read the following carefully: <br> * Parameter <code>accuracy</code> defines the size of the raster used when * placing strings, and must be a value greater than <code>0</code>. An * accuracy of <code>1</code> will theoretically give best results, as the * drawable area is analyzed most detailed, but this will also be very slow. * <br> * Parameter <code>maxSize</code> defines the maximum size of the drawable * area and <strong>must</strong> be a power of <code>accuracy</code>, * such that <code>accuracy^n=maxSize</code> holds. <br> * To add scroll bars to the cloud, use {@link SWT#HORIZONTAL} and * {@link SWT#VERTICAL}. * * @param accuracy * @param maxSize * @param parent * @param style */ public TagCloud(Composite parent, int style, int accuracy, int maxSize) { super(parent, style); Assert.isLegal(accuracy > 0, "Parameter accuracy must be greater than 0, but was " + accuracy); Assert.isLegal(maxSize > 0, "Parameter maxSize must be greater than 0, but was " + maxSize); int tmp = maxSize; while (tmp > accuracy) { tmp /= 2; } Assert.isLegal(tmp == accuracy, "Parameter maxSize must be a power of accuracy"); this.accuracy = accuracy; this.maxSize = maxSize; cloudArea = new Rectangle(0, 0, maxSize, maxSize); highlightColor = new Color(getDisplay(), Display.getDefault().getSystemColor(SWT.COLOR_RED).getRGB()); gc = new GC(this); layouter = new DefaultLayouter(accuracy, accuracy); setBackground(new Color(getDisplay(), Display.getDefault().getSystemColor(SWT.COLOR_WHITE).getRGB())); initListeners(); textLayerImage = new Image(getDisplay(), 100, 100); zoomFit(); addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { internalDispose(); } }); }
Example 8
Source File: PopupDialog.java From SWET with MIT License | 5 votes |
/** * Returns an RGB that lies between the given foreground and background * colors using the given mixing factor. A <code>factor</code> of 1.0 will produce a * color equal to <code>fg</code>, while a <code>factor</code> of 0.0 will produce one * equal to <code>bg</code>. * @param bg the background color * @param fg the foreground color * @param factor the mixing factor, must be in [0, 1] * * @return the interpolated color */ private static RGB blend(RGB bg, RGB fg, float factor) { // copy of org.eclipse.jface.internal.text.revisions.Colors#blend(..) Assert.isLegal(bg != null); Assert.isLegal(fg != null); Assert.isLegal(factor >= 0f && factor <= 1f); float complement = 1f - factor; return new RGB((int) (complement * bg.red + factor * fg.red), (int) (complement * bg.green + factor * fg.green), (int) (complement * bg.blue + factor * fg.blue)); }
Example 9
Source File: TagBasedTLCOutputIncrementalParser.java From tlaplus with MIT License | 5 votes |
public LargeTextStoreDocument(long size) { if (size != SIZE_UNKNOWN) { Assert.isLegal(size >= 0, "Negative file size"); if (size > Integer.MAX_VALUE) { size = Integer.MAX_VALUE - 1; } setTextStore(new GapTextStore((int) size, (int) size + 1, 0.1f)); } }
Example 10
Source File: ModulaSpellingProblem.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * Initialize with the given spell event. * * @param spellEvent the spell event * @param document the document */ public ModulaSpellingProblem(ISpellEvent spellEvent, IDocument document) { Assert.isLegal(document != null); Assert.isLegal(spellEvent != null); fSpellEvent= spellEvent; fDocument= document; }
Example 11
Source File: AbapGitWizardPull.java From ADT_Frontend with MIT License | 5 votes |
@Override public void setContainer(IWizardContainer wizardContainer) { super.setContainer(wizardContainer); if (this.pageChangeListener == null && wizardContainer != null) { Assert.isLegal(wizardContainer instanceof WizardDialog, "Wizard container must be of type WizardDialog"); //$NON-NLS-1$ this.pageChangeListener = new PageChangeListener(); ((WizardDialog) wizardContainer).addPageChangingListener(this.pageChangeListener); } }
Example 12
Source File: TagCloud.java From gef with Eclipse Public License 2.0 | 4 votes |
@Override public void addMouseListener(MouseListener listener) { checkWidget(); Assert.isLegal(listener != null); mouseListeners.add(listener); }
Example 13
Source File: TagCloud.java From gef with Eclipse Public License 2.0 | 4 votes |
@Override public void addMouseMoveListener(MouseMoveListener listener) { checkWidget(); Assert.isLegal(listener != null); mouseMoveListeners.add(listener); }
Example 14
Source File: TagCloud.java From gef with Eclipse Public License 2.0 | 4 votes |
public void addSelectionListener(SelectionListener listener) { checkWidget(); Assert.isLegal(listener != null); selectionListeners.add(listener); }
Example 15
Source File: JdtRenameRefactoringParticipantProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public boolean initialize(IRenameElementContext renameElementContext) { Assert.isLegal(renameElementContext instanceof JvmModelJdtRenameParticipantContext); return super.initialize(renameElementContext); }
Example 16
Source File: TagCloud.java From gef with Eclipse Public License 2.0 | 4 votes |
@Override public void addMouseWheelListener(MouseWheelListener listener) { checkWidget(); Assert.isLegal(listener != null); mouseWheelListeners.add(listener); }
Example 17
Source File: TextViewerJoinLinesAction.java From xtext-eclipse with Eclipse Public License 2.0 | 3 votes |
/** * Creates a line joining action. * * @param bundle the resource bundle for UI strings * @param prefix the prefix for the property keys into <code>bundle</code> * @param viewer the viewer * @param joint the string to put between the lines */ public TextViewerJoinLinesAction(ResourceBundle bundle, String prefix, ITextViewer viewer, String joint) { super(bundle, prefix, viewer); Assert.isLegal(joint != null); fJoint= joint; update(); }
Example 18
Source File: FlexAdapter.java From xds-ide with Eclipse Public License 1.0 | 2 votes |
/** * Checks that the given range is valid. * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=69292 * * @param offset the offset of the document range to scan * @param length the length of the document range to scan * @param documentLength the document's length */ private void checkRange(int offset, int length, int documentLength) { Assert.isLegal(offset > -1); Assert.isLegal(length > -1); Assert.isLegal(offset + length <= documentLength); }
Example 19
Source File: DefaultFoldingStructureProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 2 votes |
/** * Registers the listener with the viewer. * * @param viewer * the viewer to register a listener with */ public ProjectionChangeListener(ProjectionViewer viewer) { Assert.isLegal(viewer != null); projectionViewer = viewer; projectionViewer.addProjectionListener(this); }
Example 20
Source File: TagCloud.java From gef with Eclipse Public License 2.0 | 2 votes |
/** * Enable boosting for the first <code>boost</code> elements. By default, no * elements are boosted. * * @param boost */ public void setBoost(int boost) { checkWidget(); Assert.isLegal(boost >= 0, "Boost cannot be negative"); this.boost = boost; }