AddMessageEventWizard.java :  » Library » bonita » org » bonitasoft » studio » properties » sections » message » wizards » Java Open Source

Java Open Source » Library » bonita 
bonita » org » bonitasoft » studio » properties » sections » message » wizards » AddMessageEventWizard.java
/**
 * Copyright (C) 2009 BonitaSoft S.A.
 * BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2.0 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
package org.bonitasoft.studio.properties.sections.message.wizards;

import java.util.Collections;

import org.bonitasoft.studio.model.process.ThrowMessageEvent;
import org.bonitasoft.studio.properties.sections.message.commands.AddEventObjectCommand;
import org.bonitasoft.studio.properties.sections.message.commands.DeleteEventObjectCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.views.properties.tabbed.ISection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

/**
 * @author Romain Bioteau
 *
 */
public class AddMessageEventWizard extends Wizard implements IWizard {

  
  private TransactionalEditingDomain editingDomain;
  private AddMessageEventWizardPage page;
  private ThrowMessageEvent element;
  private ISection callingSection;
  private TabbedPropertySheetPage propertyPage;
  
  
  public AddMessageEventWizard(ThrowMessageEvent element , TransactionalEditingDomain editingDomain,ISection callingSection,TabbedPropertySheetPage page){
    this.editingDomain = editingDomain ;
    this.element = element ;
    this.callingSection = callingSection ;
    this.propertyPage = page ;
  }
  
  @Override
  public void addPages() {
    page = new AddMessageEventWizardPage(element, null,propertyPage);
    addPage(page);
  }
  
  /* (non-Javadoc)
   * @see org.eclipse.jface.wizard.Wizard#performFinish()
   */
  @Override
  public boolean performFinish() {
    editingDomain.getCommandStack().execute(new AddEventObjectCommand(
        element, 
        page.getEventObject(),
        page.getEventName(),
        page.getEventLabel(),
        page.getEventDesc(),
        page.getThrowEvent(),
        page.getTTL(),
        page.getTargetEventName(),
        page.getTargetProcessName()));
    callingSection.refresh();
    return true;
  }

  @Override
  public boolean performCancel() {
    editingDomain.getCommandStack().execute(new DeleteEventObjectCommand(element, Collections.singletonList(page.getEventObject())));
    return super.performCancel();
  }
  
}
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.