Package ru.runa.jbpm.ui.actions

Source Code of ru.runa.jbpm.ui.actions.DeleteAction

package ru.runa.jbpm.ui.actions;

import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.jbpm.ui.util.WorkspaceOperations;

public class DeleteAction extends BaseActionDelegate {

    @SuppressWarnings("unchecked")
  public void run(IAction action) {
        IStructuredSelection selection = getStructuredSelection();
        if (selection != null) {
            WorkspaceOperations.deleteResources(selection.toList());
        }
    }

    @Override
    public void selectionChanged(IAction action, ISelection selection) {
        boolean actionEnabled = false;
        if (selection instanceof IStructuredSelection) {
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            if (!structuredSelection.isEmpty() && structuredSelection.getFirstElement() instanceof IResource) {
                actionEnabled = true;
            }
        }
        action.setEnabled(actionEnabled);
    }
}
TOP

Related Classes of ru.runa.jbpm.ui.actions.DeleteAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.