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

Java tutorial

Introduction

Here is the source code for com.metaaps.eoclipse.workflowmanager.NCE.DeleteHandler.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 org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;

import com.metaaps.eoclipse.common.Model;
import com.metaaps.eoclipse.workflowmanager.WorkFlow;
import com.metaaps.eoclipse.workflowmanager.WorkFlowManager;

/**
 * @author leforthomas
 * Handler for the deletion of a workflow in the tree.
 */
public class DeleteHandler extends AbstractHandler {

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        IStructuredSelection currentSelection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
        Object obj = currentSelection.iterator().next();
        if (obj instanceof WorkFlow) {
            WorkFlowManager.getInstance().removeChild(obj);
            WorkFlowManager.getInstance().fireChanged(obj, Model.REMOVED);
        }

        return null;
    }

}