/******************************************************************************* * Copyright (c) 2000, 2011 IBM Corporation and others. * 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: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.debug.core.refactoring; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; import org.eclipse.ltk.core.refactoring.participants.MoveParticipant; /** * Participant for IPackageFragment move. */ public class LaunchConfigurationIPackageFragmentMoveParticipant extends MoveParticipant { private IPackageFragment fPackageFragment; private IPackageFragmentRoot fDestination; /* (non-Javadoc) * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) */ @Override protected boolean initialize(Object element) { fPackageFragment= (IPackageFragment)element; Object destination= getArguments().getDestination(); if (destination instanceof IPackageFragmentRoot) { fDestination= (IPackageFragmentRoot) destination; // nothing to do if the project doesn't change if (fDestination.getJavaProject().equals(fPackageFragment.getJavaProject())) { return false; } return true; } return false; } /* (non-Javadoc) * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() */ @Override public String getName() { return RefactoringMessages.LaunchConfigurationParticipant_0; } /* (non-Javadoc) * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) */ @Override public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException { return new RefactoringStatus(); } /* (non-Javadoc) * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) */ @Override public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { return JDTDebugRefactoringUtil.createChangesForPackageMove(fPackageFragment, fDestination); } }