1 /*******************************************************************************
2 * Copyright (c) 2000, 2010 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.refactoring.reorg;
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.core.resources.IResource;
18 import org.eclipse.ltk.core.refactoring.Change;
19 import org.eclipse.ltk.core.refactoring.ChangeDescriptor;
20 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
21 import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
22 import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
23 import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
24 import org.eclipse.ltk.core.refactoring.participants.ReorgExecutionLog;
25 import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
27 import org.eclipse.jdt.core.IJavaElement;
28 import org.eclipse.jdt.core.JavaModelException;
30 import org.eclipse.jdt.internal.corext.refactoring.JavaRefactoringArguments;
31 import org.eclipse.jdt.internal.corext.refactoring.tagging.IQualifiedNameUpdating;
32 import org.eclipse.jdt.internal.corext.refactoring.tagging.IReferenceUpdating;
34 import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper;
37 public interface IReorgPolicy extends IReorgDestinationValidator {
40 * @return the unique id of this policy
42 public String getPolicyId();
45 * @return the source resources to reorg
47 public IResource[] getResources();
50 * @return the source java elements to reorg
52 public IJavaElement[] getJavaElements();
55 * @return true if this policy can handle the source elements
56 * @throws JavaModelException in unexpected cases
58 public boolean canEnable() throws JavaModelException;
61 * @return the save mode required for this reorg policy
63 * @see RefactoringSaveHelper
65 public int getSaveMode();
68 * Can destination be a target for the given source elements?
70 * @param destination the destination to verify
71 * @return OK status if valid destination
72 * @throws JavaModelException in unexpected cases
74 public RefactoringStatus verifyDestination(IReorgDestination destination) throws JavaModelException;
77 * @param destination the destination for this reorg
79 public void setDestination(IReorgDestination destination);
82 * @return the destination of this reorg or null if not a resource
84 public IResource getResourceDestination();
87 * @return the destination of this reorg or null if not a java element
89 public IJavaElement getJavaElementDestination();
92 * @return a descriptor describing a reorg from source to target
94 public ChangeDescriptor getDescriptor();
98 * Initializes the reorg policy with arguments from a script.
102 * @return an object describing the status of the initialization. If the
103 * status has severity <code>FATAL_ERROR</code>, the refactoring
104 * will not be executed.
106 public RefactoringStatus initialize(JavaRefactoringArguments arguments);
108 public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context, IReorgQueries queries) throws CoreException;
110 public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) throws CoreException;
112 public static interface ICopyPolicy extends IReorgPolicy{
113 public Change createChange(IProgressMonitor monitor, INewNameQueries queries) throws JavaModelException;
114 public ReorgExecutionLog getReorgExecutionLog();
117 public static interface IMovePolicy extends IReferenceUpdating, IQualifiedNameUpdating, IReorgPolicy{
118 public Change createChange(IProgressMonitor monitor) throws JavaModelException;
119 public Change postCreateChange(Change[] participantChanges, IProgressMonitor monitor) throws CoreException;
120 public ICreateTargetQuery getCreateTargetQuery(ICreateTargetQueries createQueries);
121 public boolean isTextualMove();
122 public CreateTargetExecutionLog getCreateTargetExecutionLog();
123 public void setDestinationCheck(boolean check);
124 public boolean hasAllInputSet();
126 * Checks if <b>Java</b> references to the selected element(s) can be updated if moved to
127 * the selected destination. Even if <code>false</code>, participants could still update
128 * non-Java references.
130 * @return <code>true</code> iff <b>Java</b> references to the moved element can be updated
133 public boolean canUpdateJavaReferences();
134 public boolean canUpdateQualifiedNames();