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

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

Introduction

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

Prototype

public static boolean isLegal(boolean expression) 

Source Link

Document

Asserts that an argument is legal.

Usage

From source file:at.spardat.xma.guidesign.presentation.dialog.formdata.MyFractionNum.java

License:Open Source License

public MyFractionNum(int nominator, int denominator) {
    BigDecimal nom = new BigDecimal(Integer.toString(nominator * 100));
    BigDecimal denom = new BigDecimal(Integer.toString(denominator));
    setFraction(nom.divide(denom, 2, BigDecimal.ROUND_HALF_UP).toString(), ".");
    Assert.isLegal(Integer.parseInt(digitBefComma) <= 100);
}

From source file:net.refractions.udig.style.sld.editor.internal.PageHistoryEntry.java

License:Open Source License

/**
 * Creates a new entry./* www  .  java 2 s  .c o  m*/
 * 
 * @param id the page id
 * @param label the label to display, usually the page label
 * @param argument an argument to pass to the page, may be
 *        <code>null</code>
 */
public PageHistoryEntry(String id, String label, Object argument) {
    Assert.isLegal(id != null);
    Assert.isLegal(label != null);
    this.id = id;
    this.label = label;
    this.argument = argument;
}

From source file:org.eclipse.birt.report.designer.internal.ui.editors.schematic.tools.LibraryElementsToolHandleExtends.java

License:Open Source License

/**
 * Constructor. Creates a new extends for the given element.
 * /*from   ww w  .j  a v a 2 s  .  c o  m*/
 * @param elementHandle
 *            the handle of the element
 */
public LibraryElementsToolHandleExtends(DesignElementHandle elementHandle) {
    super();
    Assert.isLegal(elementHandle.getRoot() instanceof LibraryHandle);
    this.elementHandle = elementHandle;
}

From source file:org.eclipse.birt.report.designer.internal.ui.views.outline.providers.GridProvider.java

License:Open Source License

protected boolean performInsert(Object model, SlotHandle slotHandle, String type, String position,
        Map extendData) throws Exception {
    Assert.isLegal(type.equals(ReportDesignConstants.ROW_ELEMENT));

    GridHandleAdapter adapter = HandleAdapterFactory.getInstance().getGridHandleAdapter(model);

    if (slotHandle.getCount() > 0) {
        int rowNumber = HandleAdapterFactory.getInstance()
                .getRowHandleAdapter(slotHandle.get(slotHandle.getCount() - 1)).getRowNumber();
        adapter.insertRow(1, rowNumber);
    } else {//w w w  . j  av  a  2s  . co  m
        adapter.insertRowInSlotHandle(slotHandle.getSlotID());
    }
    return true;
}

From source file:org.eclipse.birt.report.designer.internal.ui.views.outline.providers.RowProvider.java

License:Open Source License

protected boolean performInsert(Object model, SlotHandle slotHandle, String type, String position,
        Map extendedData) throws Exception {
    Assert.isLegal(ReportDesignConstants.ROW_ELEMENT.equals(type));
    TableHandleAdapter adapter = HandleAdapterFactory.getInstance().getTableHandleAdapter(getRoot(model));
    if (!StringUtil.isEqual(position, InsertAction.CURRENT)) {
        int rowNumber = HandleAdapterFactory.getInstance().getRowHandleAdapter(model).getRowNumber();
        if (StringUtil.isEqual(position, InsertAction.ABOVE)) {
            adapter.insertRow(-1, rowNumber);
        } else if (StringUtil.isEqual(position, InsertAction.BELOW)) {
            adapter.insertRow(1, rowNumber);
        } else {//from  w w  w.  ja  v a2  s.  c  o m
            return false;
        }
    } else {
        adapter.insertRowInSlotHandle(slotHandle.getSlotID());
    }
    return true;

}

From source file:org.rubypeople.rdt.internal.ui.browsing.ProjectAndSourceFolderContentProvider.java

License:Open Source License

public Object[] getChildren(Object element) {
    if (!exists(element))
        return NO_CHILDREN;

    try {//from  www. j  a  va  2 s.  co m
        startReadInDisplayThread();
        if (element instanceof IStructuredSelection) {
            Assert.isLegal(false);
            Object[] result = new Object[0];
            Class clazz = null;
            Iterator iter = ((IStructuredSelection) element).iterator();
            while (iter.hasNext()) {
                Object item = iter.next();
                if (clazz == null)
                    clazz = item.getClass();
                if (clazz == item.getClass())
                    result = concatenate(result, getChildren(item));
                else
                    return NO_CHILDREN;
            }
            return result;
        }
        if (element instanceof IStructuredSelection) {
            Assert.isLegal(false);
            Object[] result = new Object[0];
            Iterator iter = ((IStructuredSelection) element).iterator();
            while (iter.hasNext())
                result = concatenate(result, getChildren(iter.next()));
            return result;
        }
        if (element instanceof IRubyProject)
            return getSourceFolderRoots((IRubyProject) element);
        if (element instanceof ISourceFolderRoot)
            return NO_CHILDREN;

        return super.getChildren(element);

    } catch (RubyModelException e) {
        return NO_CHILDREN;
    } finally {
        finishedReadInDisplayThread();
    }
}