Example usage for org.eclipse.jface.util Assert isNotNull

List of usage examples for org.eclipse.jface.util Assert isNotNull

Introduction

In this page you can find the example usage for org.eclipse.jface.util Assert isNotNull.

Prototype

public static void isNotNull(Object object, String message) 

Source Link

Document

Asserts that the given object is not null.

Usage

From source file:com.architexa.org.eclipse.gef.editparts.AbstractEditPart.java

License:Open Source License

/**
 * @see EditPart#installEditPolicy(Object, EditPolicy)
 *///  ww  w.j  ava2s. c  o  m
public void installEditPolicy(Object key, EditPolicy editPolicy) {
    Assert.isNotNull(key, "Edit Policies must be installed with keys");//$NON-NLS-1$
    if (policies == null) {
        policies = new Object[2];
        policies[0] = key;
        policies[1] = editPolicy;
    } else {
        int index = 0;
        while (index < policies.length && !key.equals(policies[index]))
            index += 2;
        if (index < policies.length) {
            index++;
            EditPolicy old = (EditPolicy) policies[index];
            if (old != null && isActive())
                old.deactivate();
            policies[index] = editPolicy;
        } else {
            Object newPolicies[] = new Object[policies.length + 2];
            System.arraycopy(policies, 0, newPolicies, 0, policies.length);
            policies = newPolicies;
            policies[index] = key;
            policies[index + 1] = editPolicy;
        }
    }

    if (editPolicy != null) {
        editPolicy.setHost(this);
        if (isActive())
            editPolicy.activate();
    }
}

From source file:com.architexa.org.eclipse.gef.ui.actions.ActionRegistry.java

License:Open Source License

/**
 * Register an action with this registry.  The action must have an ID.
 * @param action the action being registered.
 *//*from   w  w w. j  a va 2  s .  co  m*/
public void registerAction(IAction action) {
    Assert.isNotNull(action.getId(), "action must have an ID in " + //$NON-NLS-1$
            getClass().getName() + " :registerAction(IAction)");//$NON-NLS-1$
    registerAction(action.getId(), action);
}

From source file:com.jasperassistant.designer.viewer.ReportViewer.java

License:Open Source License

/**
 * @see com.jasperassistant.designer.viewer.IReportViewer#setDocument(net.sf.jasperreports.engine.JasperPrint)
 *//*from  w w  w .  jav a  2  s .c  o m*/
public void setDocument(JasperPrint document) {
    Assert.isNotNull(document, Messages.getString("ReportViewer.documentNotNull")); //$NON-NLS-1$
    Assert.isNotNull(document.getPages(), Messages.getString("ReportViewer.documentNotEmpty")); //$NON-NLS-1$
    Assert.isTrue(!document.getPages().isEmpty(), Messages.getString("ReportViewer.documentNotEmpty")); //$NON-NLS-1$

    this.document = document;
    this.reason = null;
    this.pageIndex = Math.min(Math.max(0, pageIndex), getPageCount() - 1);
    setZoomInternal(computeZoom());
    fireViewerModelChanged();
}

From source file:com.mentor.nucleus.bp.ui.text.editor.SyntaxHighlightingPreferences.java

License:Open Source License

public SyntaxHighlightingPreferences(ISharedTextColors aSharedColors) {

    Assert.isNotNull(aSharedColors, "Argument of type ISharedTextColors cannot be null");

    sharedColors = aSharedColors;
}

From source file:crosswalk.diagram.custom.CompartmentChildCreateCommand.java

License:Apache License

@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
        throws ExecutionException {

    View view = ViewService.getInstance().createView(viewDescriptor.getViewKind(),
            viewDescriptor.getElementAdapter(), containerView, viewDescriptor.getSemanticHint(), index,
            viewDescriptor.isPersisted(), viewDescriptor.getPreferencesHint());
    Assert.isNotNull(view, "failed to create a view"); //$NON-NLS-1$
    viewDescriptor.setView(view);/*w  w  w  . j  a va2 s.  c om*/

    if (index > -1) {
        EList nodes = (EList) getContainerView().getElement().eGet(view.getElement().eContainingFeature());
        Object o = nodes.remove(nodes.size() - 1);
        nodes.add(index, o);
    }

    return CommandResult.newOKCommandResult(viewDescriptor);
}

From source file:descent.internal.corext.refactoring.RefactoringElementFilterDescriptor.java

License:Open Source License

private RefactoringElementFilterDescriptor(IConfigurationElement element) {
    fElement = element;/*from   w  ww .j av  a2 s. co  m*/
    Assert.isNotNull(getFilterClass(),
            "An extension for extension-point descent.ui.internal_refactoringElementFilter does not specify a valid class"); //$NON-NLS-1$
    Assert.isNotNull(getId(),
            "An extension for extension-point descent.ui.internal_refactoringElementFilter does not provide a valid ID"); //$NON-NLS-1$
    fFilterOKToUse = true;
}

From source file:descent.internal.ui.wizards.dialogfields.DialogField.java

License:Open Source License

protected final void assertCompositeNotNull(Composite comp) {
    Assert.isNotNull(comp, "uncreated control requested with composite null"); //$NON-NLS-1$
}

From source file:org.cfeclipse.cfml.editors.contentassist.CFEContentAssist.java

License:Open Source License

/**
 * Gets the proposal ready. Sets up the image, the text to insert into the text,
 * and finally returns the completed proposal.
 * /*from w w w.j ava  2 s. c  om*/
 * @param offset - offset in the document
 * @param type - type of thing we're making a proposal for
 * @param currentlen - length that we'd need to insert if the user selected the proposal
 * @param name - name of the proposal
 * @param display - string to display
 * @param help - the help associated with this proposal
 * @return - the completed, indented, image'd proposal
 * 
 * @see org.eclipse.jface.text.contentassist.ICompletionProposal
 */
public static CompletionProposal finaliseProposal(int offset, short type, int currentlen, String name,
        String display, String help) {
    Assert.isNotNull(name, "CFEContentAssist::finaliseProposal()");
    Assert.isNotNull(display, "CFEContentAssist::finaliseProposal()");
    Assert.isNotNull(help, "CFEContentAssist::finaliseProposal()");
    Assert.isTrue(currentlen <= name.length(), "CFEContentAssist::finaliseProposal()");

    //now remove chars so when they hit enter it wont write the whole
    //word just the part they havent typed
    String replacementString = name.substring(currentlen, name.length());

    //the tag len and icon
    int insertlen = replacementString.length();
    org.eclipse.swt.graphics.Image img = null;

    switch (type) {
    case ATTRTYPE:
        replacementString += "=\"\"";
        insertlen += "\"\"".length(); // Compensate for the addition of =""
        img = CFPluginImages.get(CFPluginImages.ICON_ATTR);
        break;
    case TAGTYPE:
        //Check if we need to add the closer.
        if (name.endsWith(">")) {
            IPreferenceStore store = CFMLPlugin.getDefault().getPreferenceStore();
            if (store.getBoolean(AutoIndentPreferenceConstants.P_AUTOINSERT_CLOSE_TAGS)) {
                if (store.getBoolean(AutoIndentPreferenceConstants.P_AUTOINDENT_ONTAGCLOSE)) {
                    /* TODO figure out how to do this properly. 
                     * Right now the whole auto insertion thing is a mess that needs to be seriously thought out and refactored. 
                     */
                    replacementString += "</" + name.substring(0, name.length() - 1);
                } else {
                    replacementString += "</" + name.substring(0, name.length() - 1);
                }
            }

        }

        //Find out what type it is
        if (name.startsWith("cf")) {
            img = CFPluginImages.get(CFPluginImages.ICON_DEFAULT);
        } else {
            img = CFPluginImages.get(CFPluginImages.ICON_TAG);
        }

        break;
    case VALUETYPE:
        img = CFPluginImages.get(CFPluginImages.ICON_VALUE);
        break;
    case SCOPETYPE:
        img = CFPluginImages.get(CFPluginImages.ICON_VALUE);
        break;
    case PARAMETERTYPE:
        insertlen = name.length();
        img = CFPluginImages.get(CFPluginImages.ICON_PARAM);
        break;
    }
    int replaceLength = 0;
    ISelection selection = CFMLPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow()
            .getSelectionService().getSelection();
    if (selection instanceof TextSelection) {
        replaceLength = ((TextSelection) selection).getLength();
    }
    CompletionProposal prop = new CompletionProposal(replacementString, offset, replaceLength, insertlen, img,
            display, null, help);
    return prop;
}

From source file:org.cfeclipse.cfml.editors.NonRuleBasedDamagerRepairer.java

License:Open Source License

/**
 * Constructor for NonRuleBasedDamagerRepairer.
 *//*ww  w. j a  v  a 2 s . c  om*/
public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) {
    Assert.isNotNull(defaultTextAttribute, "NonRuleBasedDamagerRepairer::NonRuleBasedDamagerRepairer()");

    fDefaultTextAttribute = defaultTextAttribute;
}

From source file:org.cfeclipse.cfml.preferences.StatusInfo.java

License:Open Source License

public void setError(String errorMessage) {
    Assert.isNotNull(errorMessage, "StatusInfo::setError()");
    fStatusMessage = errorMessage;
    fSeverity = 4;
}