com.metaaps.eoclipse.workflowmanager.NCE.SaveHandler.java Source code

Java tutorial

Introduction

Here is the source code for com.metaaps.eoclipse.workflowmanager.NCE.SaveHandler.java

Source

/*******************************************************************************
 * Copyright (c) 2010 METAAPS SRL(U).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     METAAPS SRL(U) - created by Thomas Lefort - initial API and implementation
 ******************************************************************************/
package com.metaaps.eoclipse.workflowmanager.NCE;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.handlers.HandlerUtil;

import com.metaaps.eoclipse.workflowmanager.WorkFlow;

/**
 * @author leforthomas
 * 
 * Handler to save a workflow from the tree.
 * 
 */
public class SaveHandler extends AbstractHandler implements IHandler {

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        IStructuredSelection currentSelection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
        Object obj = currentSelection.iterator().next();
        if (obj instanceof WorkFlow) {
            WorkFlow workflow = (WorkFlow) obj;
            workflow.save(false);
        }

        return null;
    }

}