Package net.sf.cvschangelog.actions

Source Code of net.sf.cvschangelog.actions.ChangeLogAction

/*
* Created on May 15, 2005 by Michael Spiegel
*
*/
package net.sf.cvschangelog.actions;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IAction;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.ui.actions.CVSAction;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;

/**
* @author Michael Spiegel
*
*/
public class ChangeLogAction extends CVSAction {
   
    /* (non-Javadoc)
     * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
     */
    protected void execute(IAction action) throws InvocationTargetException,
            InterruptedException {
        IWorkbenchPage perspective = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IWorkbenchPart workbenchPart = perspective.findView("net.sf.cvschangelog.view.ChangeLogView");       
        if (workbenchPart == null) {
            workbenchPart = perspective.getActivePart();
        }
        if (!selection.isEmpty()) {
            Object adapter = CVSAction.getAdapter(selection.getFirstElement(), IResource.class);
            if (adapter instanceof IResource) {
                IResource resource = (IResource) adapter;
                Job job = new ChangeLogJob("CVS ChangeLog",resource.getProject(),workbenchPart);
                job.schedule();
            }
        }
  }

    /* (non-Javadoc)
     * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
     */
    protected boolean isEnabled() throws TeamException {
    if (this.selection.isEmpty()) {
      return false;
    }
    Object element = this.selection.getFirstElement();
    IResource resource = (IResource) getAdapter(element, IResource.class);
    if (resource == null) {
      return false;
    }
    // only enable for resources in a project shared with CVS
    if (RepositoryProvider.getProvider(resource.getProject(),
        CVSProviderPlugin.getTypeId()) == null) {
      return false;
    }
    return true;
    }

}
TOP

Related Classes of net.sf.cvschangelog.actions.ChangeLogAction

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.