WorkflowElement.java :  » Workflow-Engines » OpenWFE » org » openwfe » gpe » model » Java Open Source

Java Open Source » Workflow Engines » OpenWFE 
OpenWFE » org » openwfe » gpe » model » WorkflowElement.java
/*
 * Created on 7 mai 2005
 *
 */
package org.openwfe.gpe.model;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

/**
 * @author Christelle
 *
 */
public class WorkflowElement extends Composite{
  
  private String privateName = "";
  public static String name = "Process-Definition";
  private String revision = "";
  private String description = "enter a description for this workflow";
  private String language = "english";
  private boolean one = false;
  
  protected static IPropertyDescriptor[] descriptors;
  
  public static final String PRIVATENAME = "privateName";
  public static final String REVISION = "revision";
  public static final String DESCRIPTION = "description";
  public static final String LANGUAGE = "language";
  
  static {
    descriptors = new IPropertyDescriptor[] {
        new TextPropertyDescriptor(PRIVATENAME,"name"),
        new TextPropertyDescriptor(REVISION,"revision"),
        new TextPropertyDescriptor(DESCRIPTION,"description"),
        new TextPropertyDescriptor(LANGUAGE,"language"),
        };
  }
  
  public String getPrivateName(){
    return privateName;
  }
  public void setPrivateName(String s) {
    privateName = s;
    firePropertyChange(PRIVATENAME, null, s);
  }
  public String getName(){
    return name ;
  }
  
  public void setName(String s) {
    name = s;
  }
  public String getRevision(){
    return revision;
  }
  public void setRevision(String s){
    revision = s;
    firePropertyChange(REVISION, null, s);
  }
  
  /**
   * @return Returns the description.
   */
  public String getDescription() {
    return description;
  }
  /**
   * @param description The description to set.
   */
  public void setDescription(String description) {
    this.description = description;
    firePropertyChange(DESCRIPTION, null, description);
  }
  /**
   * @return Returns the language.
   */
  public String getLanguage() {
    return language;
  }
  /**
   * @param language The language to set.
   */
  public void setLanguage(String language) {
    this.language = language;
    firePropertyChange(LANGUAGE, null, language);
  }
  public IPropertyDescriptor[] getPropertyDescriptors() {
    return descriptors;
  }
  
  public Object getPropertyValue(Object propName) {
    if(PRIVATENAME.equals(propName))
      return getPrivateName();
    if(REVISION.equals(propName))
      return getRevision();
    if(DESCRIPTION.equals(propName))
      return getDescription();
    if(LANGUAGE.equals(propName))
      return getLanguage();
    return super.getPropertyValue(propName);
  }
  
  public void setPropertyValue(Object id, Object value){
    if(id == PRIVATENAME)
      setPrivateName((String)value);
    if(id == REVISION)
      setRevision((String)value);
    if(id == DESCRIPTION)
      setDescription((String)value);
    if(id == LANGUAGE)
      setLanguage((String)value);
  }
  
  public void addChild(FlowElement child){
    addChild(child, -1);
  }
  
  public void addChild(FlowElement child, int index){
    if (!(child instanceof WorkflowElement)){
      if (index >= 0){
        children.add(index,child);
        fireStructureChange(CHILDREN, child);
        one = true;
      }else{
        children.add(child);
        fireStructureChange(CHILDREN, child);
        one = true;
      }
    }else{
      MessageDialog.openInformation(null,"Alert","A workflow has already been defined");
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.