KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > core > refactoring > RefactoringCore


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ltk.core.refactoring;
12
13 import org.eclipse.core.runtime.IAdaptable;
14
15 import org.eclipse.ltk.core.refactoring.history.IRefactoringHistoryService;
16
17 import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
18 import org.eclipse.ltk.internal.core.refactoring.history.RefactoringContributionManager;
19 import org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistoryService;
20
21 /**
22  * Central access point to access resources managed by the refactoring
23  * core plug-in.
24  * <p>
25  * Note: this class is not intended to be extended by clients.
26  * </p>
27  *
28  * @since 3.0
29  */

30 public class RefactoringCore {
31
32     /**
33      * The id of the Refactoring plug-in (value <code>"org.eclipse.ltk.core.refactoring"</code>).
34      *
35      * @since 3.2
36      */

37     public static final String JavaDoc ID_PLUGIN= "org.eclipse.ltk.core.refactoring"; //$NON-NLS-1$
38

39     private static IValidationCheckResultQueryFactory fQueryFactory= new DefaultQueryFactory();
40
41     private static class NullQuery implements IValidationCheckResultQuery {
42         public boolean proceed(RefactoringStatus status) {
43             return true;
44         }
45         public void stopped(RefactoringStatus status) {
46             // do nothing
47
}
48     }
49     
50     private static class DefaultQueryFactory implements IValidationCheckResultQueryFactory {
51         public IValidationCheckResultQuery create(IAdaptable context) {
52             return new NullQuery();
53         }
54     }
55     
56     private RefactoringCore() {
57         // no instance
58
}
59
60     /**
61      * Returns the singleton undo manager for the refactoring undo stack.
62      *
63      * @return the refactoring undo manager.
64      */

65     public static IUndoManager getUndoManager() {
66         return RefactoringCorePlugin.getUndoManager();
67     }
68
69     /**
70      * Returns the singleton refactoring history service.
71      *
72      * @return the refactoring history service
73      *
74      * @since 3.2
75      */

76     public static IRefactoringHistoryService getHistoryService() {
77         return RefactoringHistoryService.getInstance();
78     }
79
80     /**
81      * Returns the refactoring contribution with the specified unique id.
82      *
83      * @param id
84      * the unique id of the contribution
85      * @return the refactoring contribution, or <code>null</code> if in
86      * contribution is registered with for this id
87      *
88      * @since 3.2
89      */

90     public static RefactoringContribution getRefactoringContribution(String JavaDoc id) {
91         return RefactoringContributionManager.getInstance().getRefactoringContribution(id);
92     }
93
94     /**
95      * When condition checking is performed for a refactoring then the
96      * condition check is interpreted as failed if the refactoring status
97      * severity return from the condition checking operation is equal
98      * or greater than the value returned by this method.
99      *
100      * @return the condition checking failed severity
101      */

102     public static int getConditionCheckingFailedSeverity() {
103         return RefactoringStatus.WARNING;
104     }
105     
106     /**
107      * Returns the query factory.
108      *
109      * @return the query factory
110      *
111      * @since 3.1
112      */

113     public static IValidationCheckResultQueryFactory getQueryFactory() {
114         return fQueryFactory;
115     }
116     
117     /**
118      * An internal method to set the query factory.
119      * <p>
120      * This method is NOT official API. It is a special method for the refactoring UI
121      * plug-in to set a dialog based query factory.
122      * </p>
123      * @param factory the factory to set or <code>null</code>
124      *
125      * @since 3.1
126      */

127     public static void internalSetQueryFactory(IValidationCheckResultQueryFactory factory) {
128         if (factory == null) {
129             fQueryFactory= new DefaultQueryFactory();
130         } else {
131             fQueryFactory= factory;
132         }
133     }
134 }
135
Popular Tags