Java Code Examples for org.eclipse.core.runtime.Assert

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Android_1, under directory /org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/core/.

Source file: AdvertisedService.java

  19 
vote

public AdvertisedService(ServiceReference ref){
  Assert.isNotNull(ref);
  this.serviceReference=ref;
  this.uuid=UUID.randomUUID().toString();
  String services[]=(String[])this.serviceReference.getProperty(Constants.OBJECTCLASS);
  for (  String k : this.serviceReference.getPropertyKeys()) {
    Object value=this.serviceReference.getProperty(k);
    if (value instanceof String && ((String)value).contains("localhost")) {
      this.properties.put(k,((String)value).replace("localhost",Geo.getHost()));
      continue;
    }
    this.properties.put(k,this.serviceReference.getProperty(k));
  }
  IServiceTypeID serviceTypeID=ServiceIDFactory.getDefault().createServiceTypeID(DiscoveryContainer.getSingleton().getConnectNamespace(),services,IServiceTypeID.DEFAULT_PROTO);
  serviceTypeID=new ZooServiceTypeID((DiscoveryNamespace)DiscoveryContainer.getSingleton().getConnectNamespace(),serviceTypeID,this.serviceReference.getProperty(Constants.SERVICE_ID).toString());
  serviceID=new ZooServiceID(DiscoveryContainer.getSingleton().getConnectNamespace(),serviceTypeID,Geo.getLocation());
  super.properties=new ServiceProperties(this.properties);
  this.properties.put(Constants.OBJECTCLASS,arrayToString(services));
  this.properties.put(LOCATION,Geo.getLocation());
  this.properties.put(WEIGHT,getWeight());
  this.properties.put(PRIORITY,getPriority());
  this.properties.put(NODE_PROPERTY_NAME_PROTOCOLS,arrayToString(IServiceTypeID.DEFAULT_PROTO));
  this.properties.put(NODE_PROPERTY_NAME_SCOPE,arrayToString(IServiceTypeID.DEFAULT_SCOPE));
  this.properties.put(NODE_PROPERTY_NAME_NA,IServiceTypeID.DEFAULT_NA);
  publishedServices.put(serviceTypeID.getInternal(),this);
}
 

Example 2

From project Android_1, under directory /org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/core/.

Source file: DiscoverdService.java

  19 
vote

public DiscoverdService(String path,Properties ps){
  Assert.isNotNull(ps);
  this.uuid=path.split(INode._URI_)[0];
  this.props=ps;
  this.location=URI.create((String)this.props.remove(IService.LOCATION));
  super.priority=Integer.parseInt((String)this.props.remove(IService.PRIORITY));
  super.weight=Integer.parseInt((String)this.props.remove(IService.WEIGHT));
  String[] services=(String[])this.props.remove(Constants.OBJECTCLASS);
  if (services == null) {
    services=(String[])this.props.remove(INode.NODE_PROPERTY_SERVICES);
  }
  String na=(String)this.props.remove(INode.NODE_PROPERTY_NAME_NA);
  String[] protocols=(String[])this.props.remove(INode.NODE_PROPERTY_NAME_PROTOCOLS);
  String[] scopes=(String[])this.props.remove(INode.NODE_PROPERTY_NAME_SCOPE);
  super.properties=new ServiceProperties(this.props);
  this.serviceTypeID=ServiceIDFactory.getDefault().createServiceTypeID(DiscoveryContainer.getSingleton().getConnectNamespace(),services,scopes,protocols,na);
  super.serviceID=new ZooServiceID(DiscoveryContainer.getSingleton().getConnectNamespace(),serviceTypeID,this.location);
}
 

Example 3

From project Android_1, under directory /org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/core/.

Source file: DiscoveryNamespace.java

  19 
vote

public ID createInstance(Object[] parameters) throws IDCreateException {
  Assert.isTrue(parameters != null && parameters.length > 0);
  try {
    if (parameters[0] instanceof String) {
      return new ZooTargetID(this,(String[])parameters);
    }
 else     if (parameters.length == 1 && parameters[0] instanceof IServiceTypeID) {
      return new ZooServiceTypeID(this,(IServiceTypeID)parameters[0]);
    }
 else     if (parameters.length == 2 && parameters[0] instanceof IServiceTypeID && parameters[1] instanceof URI) {
      return new ZooServiceID(this,((IServiceTypeID)parameters[0]),((URI)parameters[1]));
    }
  }
 catch (  Exception e) {
    throw new IDCreateException(NLS.bind("{0} createInstance()",getName()),e);
  }
  return null;
}
 

Example 4

From project Android_1, under directory /org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/core/internal/.

Source file: Configurator.java

  19 
vote

public void configure(ServiceReference reference){
  Assert.isNotNull(reference);
  Set<String> legalKeys=getProperties().keySet();
  for (  String key : reference.getPropertyKeys()) {
    if (legalKeys.contains(key) || key.startsWith("zoodiscovery"))     getProperties().put(key,reference.getProperty(key));
  }
  init();
}
 

Example 5

From project Android_1, under directory /org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/core/internal/.

Source file: Configurator.java

  19 
vote

public static boolean isValid(String flavorInput){
  Assert.isNotNull(flavorInput);
  boolean valid=flavorInput.contains("=");
  String f=flavorInput.split("=")[0];
  valid&=f.equals(ZOODISCOVERY_FLAVOR_CENTRALIZED) || f.equals(ZOODISCOVERY_FLAVOR_REPLICATED) || f.equals(ZOODISCOVERY_FLAVOR_STANDALONE);
  return valid;
}
 

Example 6

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/editors/.

Source file: NonRuleBasedDamagerRepairer.java

  19 
vote

/** 
 * Constructor for NonRuleBasedDamagerRepairer.
 */
public NonRuleBasedDamagerRepairer(ITokenScanner scanner,TextAttribute defaultTextAttribute){
  Assert.isNotNull(defaultTextAttribute);
  Assert.isNotNull(scanner);
  this.scanner=scanner;
  fDefaultTextAttribute=defaultTextAttribute;
}
 

Example 7

From project Bio-PEPA, under directory /uk.ac.ed.inf.common/src/uk/ac/ed/inf/common/launching/.

Source file: BaseRunner.java

  19 
vote

/** 
 * Configures a runner with this launcher id
 * @param launcherId
 * @param optionMap
 * @throws CoreException
 */
public BaseRunner(String launcherId,Map<String,String> optionMap) throws CoreException {
  Assert.isNotNull(optionMap);
  Assert.isNotNull(launcherId);
  this.fOptionMap=optionMap;
  this.fLauncherId=launcherId;
  ILaunchManager manager=DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType type=manager.getLaunchConfigurationType(fLauncherId);
  Assert.isNotNull(type);
  fCopy=type.newInstance(null,fLauncherId + " configuration");
  for (  Map.Entry<String,String> entry : fOptionMap.entrySet()) {
    fCopy.setAttribute(entry.getKey(),entry.getValue());
  }
  fResultFolder=LaunchingUtils.getOutputFolder(fCopy);
  if (fResultFolder == null) {
    throw new CoreException(StatusFactory.newCannotObtainResultFolder(null,null));
  }
}
 

Example 8

From project Bio-PEPA, under directory /uk.ac.ed.inf.common/src/uk/ac/ed/inf/common/launching/.

Source file: RuntimeMonitorWithLock.java

  19 
vote

public synchronized int waitFor() throws DebugException {
  while (!isTerminated())   try {
synchronized (fLock) {
      fLock.wait();
    }
  }
 catch (  InterruptedException e) {
  }
  Assert.isTrue(isTerminated());
  return this.getExitValue();
}
 

Example 9

From project Bio-PEPA, under directory /uk.ac.ed.inf.common.ui.plotting/src/uk/ac/ed/inf/common/ui/plotting/dialogs/.

Source file: ChartDialog.java

  19 
vote

public ChartDialog(Shell parentShell,IChart chart,Point initialSize){
  super(parentShell);
  Assert.isTrue(chart instanceof CommonChart);
  setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
  this.chart=chart;
  this.initialSize=initialSize;
}
 

Example 10

From project bioclipse.opentox, under directory /plugins/net.bioclipse.opentox.ds/src/net/bioclipse/opentox/ds/prefs/.

Source file: ModelsListEditor.java

  19 
vote

/** 
 * Moves the currently selected item up or down.
 * @param up <code>true</code> if the item should move up,and <code>false</code> if it should move down
 */
private void swap(boolean up){
  setPresentsDefaultValue(false);
  int index=list.getSelectionIndex();
  int target=up ? index - 1 : index + 1;
  if (index >= 0) {
    String[] selection=list.getSelection();
    Assert.isTrue(selection.length == 1);
    list.remove(index);
    list.add(selection[0],target);
    list.setSelection(target);
  }
  selectionChanged();
}
 

Example 11

From project bpelunit, under directory /tycho/net.bpelunit.toolsupport/editors/wizards/fields/.

Source file: SelectionButtonDialogFieldGroup.java

  19 
vote

/** 
 * Creates a group with border (label in border). Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE For border styles see <code>Group</code>
 */
public SelectionButtonDialogFieldGroup(int buttonsStyle,String[] buttonNames,int nColumns,int borderStyle){
  super();
  Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
  fButtonNames=buttonNames;
  fButtonsStyle=buttonsStyle;
  int nButtons=buttonNames.length;
  fButtonsSelected=new boolean[nButtons];
  fButtonsEnabled=new boolean[nButtons];
  for (int i=0; i < nButtons; i++) {
    fButtonsSelected[i]=false;
    fButtonsEnabled[i]=true;
  }
  if (buttonsStyle == SWT.RADIO) {
    fButtonsSelected[0]=true;
  }
  fGroupBorderStyle=borderStyle;
  fGroupNumberOfColumns=(nColumns <= 0) ? nButtons : nColumns;
}
 

Example 12

From project bpelunit, under directory /tycho/net.bpelunit.toolsupport/editors/wizards/fields/.

Source file: TableLayoutComposite.java

  19 
vote

private Point computeTableSize(Table table){
  Point result=table.computeSize(SWT.DEFAULT,SWT.DEFAULT);
  int width=0;
  int size=columns.size();
  for (int i=0; i < size; ++i) {
    ColumnLayoutData layoutData=columns.get(i);
    if (layoutData instanceof ColumnPixelData) {
      ColumnPixelData col=(ColumnPixelData)layoutData;
      width+=col.width;
      if (col.addTrim) {
        width+=COLUMN_TRIM;
      }
    }
 else     if (layoutData instanceof ColumnWeightData) {
      ColumnWeightData col=(ColumnWeightData)layoutData;
      width+=col.minimumWidth;
    }
 else {
      Assert.isTrue(false,"Unknown column layout data");
    }
  }
  if (width > result.x)   result.x=width;
  return result;
}
 

Example 13

From project bpelunit, under directory /tycho/net.bpelunit.toolsupport/src/net/bpelunit/toolsupport/editors/wizards/fields/.

Source file: SelectionButtonDialogFieldGroup.java

  19 
vote

/** 
 * Creates a group with border (label in border). Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE For border styles see <code>Group</code>
 */
public SelectionButtonDialogFieldGroup(int buttonsStyle,String[] buttonNames,int nColumns,int borderStyle){
  super();
  Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
  fButtonNames=buttonNames;
  fButtonsStyle=buttonsStyle;
  int nButtons=buttonNames.length;
  fButtonsSelected=new boolean[nButtons];
  fButtonsEnabled=new boolean[nButtons];
  for (int i=0; i < nButtons; i++) {
    fButtonsSelected[i]=false;
    fButtonsEnabled[i]=true;
  }
  if (buttonsStyle == SWT.RADIO) {
    fButtonsSelected[0]=true;
  }
  fGroupBorderStyle=borderStyle;
  fGroupNumberOfColumns=(nColumns <= 0) ? nButtons : nColumns;
}
 

Example 14

From project bpelunit, under directory /tycho/net.bpelunit.toolsupport/src/net/bpelunit/toolsupport/editors/wizards/fields/.

Source file: TableLayoutComposite.java

  19 
vote

private Point computeTableSize(Table table){
  Point result=table.computeSize(SWT.DEFAULT,SWT.DEFAULT);
  int width=0;
  int size=columns.size();
  for (int i=0; i < size; ++i) {
    ColumnLayoutData layoutData=columns.get(i);
    if (layoutData instanceof ColumnPixelData) {
      ColumnPixelData col=(ColumnPixelData)layoutData;
      width+=col.width;
      if (col.addTrim) {
        width+=COLUMN_TRIM;
      }
    }
 else     if (layoutData instanceof ColumnWeightData) {
      ColumnWeightData col=(ColumnWeightData)layoutData;
      width+=col.minimumWidth;
    }
 else {
      Assert.isTrue(false,"Unknown column layout data");
    }
  }
  if (width > result.x)   result.x=width;
  return result;
}
 

Example 15

From project bundlemaker, under directory /integrationtest/org.bundlemaker.itest.spring/src/org/bundlemaker/itest/spring/experimental/.

Source file: PatternBasedTypeSelector.java

  19 
vote

/** 
 * <p> Creates a new instance of type  {@link PatternBasedTypeSelector}. </p>
 * @param sourceModuleIdentifier
 * @param typeIncludes
 * @param typeExcludes
 * @param moduleIdentifier
 */
public PatternBasedTypeSelector(ModuleIdentifier sourceModuleIdentifier,String[] typeIncludes,String[] typeExcludes,ModuleIdentifier selectedModuleIdentifier){
  Assert.isNotNull(selectedModuleIdentifier);
  _sourceModuleIdentifier=new HashSet<IModuleIdentifier>();
  if (sourceModuleIdentifier != null) {
    _sourceModuleIdentifier.add(sourceModuleIdentifier);
  }
  _includes=typeIncludes != null ? typeIncludes : new String[]{};
  _excludes=typeExcludes != null ? typeExcludes : new String[]{};
  _selectedModuleIdentifier=selectedModuleIdentifier;
}
 

Example 16

From project bundlemaker, under directory /integrationtest/org.bundlemaker.itest.spring/src/org/bundlemaker/itest/spring/experimental/.

Source file: PatternBasedTypeSelector.java

  19 
vote

/** 
 * {@inheritDoc}
 */
public IType selectType(IResourceModule referencingModule,String fullyQualifiedName,Set<IType> types){
  Assert.isTrue(referencingModule.hasModularizedSystem());
  if (!_sourceModuleIdentifier.isEmpty() && !_sourceModuleIdentifier.contains(referencingModule.getModuleIdentifier())) {
    return null;
  }
  boolean included=false;
  for (  String include : _includes) {
    if (fullyQualifiedName.matches(PatternUtils.convertAntStylePattern(include))) {
      included=true;
    }
  }
  if (!included) {
    return null;
  }
  for (  String exclude : _excludes) {
    if (fullyQualifiedName.matches(PatternUtils.convertAntStylePattern(exclude))) {
      return null;
    }
  }
  for (  IType iType : types) {
    if (iType.getModule(referencingModule.getModularizedSystem()).getModuleIdentifier().equals(_selectedModuleIdentifier)) {
      return iType;
    }
  }
  return null;
}
 

Example 17

From project bundlemaker, under directory /main/org.bundlemaker.core/src/org/bundlemaker/analysis/model/impl/.

Source file: Dependency.java

  19 
vote

/** 
 * <p> Creates a new instance of type  {@link Dependency}. </p>
 * @param from
 * @param to
 * @param isLeafDependency
 */
public Dependency(IBundleMakerArtifact from,IBundleMakerArtifact to,boolean isLeafDependency){
  Assert.isNotNull(from);
  Assert.isNotNull(to);
  _from=from;
  _to=to;
  _isLeafDependency=isLeafDependency;
}
 

Example 18

From project bundlemaker, under directory /main/org.bundlemaker.core/src/org/bundlemaker/core/analysis/.

Source file: ArtifactHelper.java

  19 
vote

/** 
 * <p> </p>
 * @param < T >
 * @param artifact
 * @param regexp
 * @param clazz
 * @return
 */
@SuppressWarnings("unchecked") public static <T extends IBundleMakerArtifact>T getChildByPath(IBundleMakerArtifact artifact,final IPath path,final Class<T> clazz){
  if (artifact == null) {
    return null;
  }
  Assert.isNotNull(clazz);
  if (path.segmentCount() > 1) {
    return getChildByPath(artifact.getChild(path.segments()[0]),path.removeFirstSegments(1),clazz);
  }
 else {
    IBundleMakerArtifact result=artifact.getChild(path.segments()[0]);
    if (result != null && !(clazz.isAssignableFrom(result.getClass()))) {
      throw new RuntimeException();
    }
    return (T)result;
  }
}
 

Example 19

From project bundlemaker, under directory /main/org.bundlemaker.core/src/org/bundlemaker/core/analysis/.

Source file: ArtifactHelper.java

  19 
vote

/** 
 * {@inheritDoc}
 */
public static <T extends IBundleMakerArtifact>List<T> findChildren(IBundleMakerArtifact artifact,final Class<T> clazz){
  Assert.isNotNull(clazz);
  final List<T> result=new LinkedList<T>();
  IArtifactTreeVisitor visitor=new IArtifactTreeVisitor(){
    @Override public boolean visit(    IPackageArtifact artifact){
      check(clazz,result,artifact);
      return true;
    }
    @Override public boolean visit(    ITypeArtifact artifact){
      check(clazz,result,artifact);
      return true;
    }
    @Override public boolean visit(    IResourceArtifact artifact){
      check(clazz,result,artifact);
      return true;
    }
    @Override public boolean visit(    IModuleArtifact artifact){
      check(clazz,result,artifact);
      return true;
    }
    @Override public boolean visit(    IGroupArtifact artifact){
      check(clazz,result,artifact);
      return true;
    }
    @Override public boolean visit(    IRootArtifact artifact){
      check(clazz,result,artifact);
      return true;
    }
    private <T>void check(    final Class<T> clazz,    final List<T> result,    IBundleMakerArtifact artifact){
      if (!clazz.isAssignableFrom(artifact.getClass())) {
        return;
      }
      result.add((T)artifact);
    }
  }
;
  artifact.accept(visitor);
  return result;
}