KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > refactoring > ConfigUndoneChange


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.refactoring;
5
6 import org.eclipse.core.resources.IProject;
7 import org.eclipse.core.runtime.IProgressMonitor;
8 import org.eclipse.core.runtime.OperationCanceledException;
9 import org.eclipse.ltk.core.refactoring.Change;
10 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
11
12 import org.terracotta.dso.TcPlugin;
13 import com.terracottatech.config.TcConfigDocument.TcConfig;
14
15 public class ConfigUndoneChange extends Change {
16   private TcConfig fConfig;
17   private IProject fProject;
18     
19   public ConfigUndoneChange(IProject project, TcConfig config) {
20     super();
21     fProject = project;
22     fConfig = config;
23   }
24   
25   public Object JavaDoc getModifiedElement() {
26     return null;
27   }
28   
29   public String JavaDoc getName() {
30     return "TCConfigUndoneUpdate";
31   }
32   
33   public void initializeValidationData(IProgressMonitor pm) {/**/}
34   
35   public RefactoringStatus isValid(IProgressMonitor pm)
36     throws OperationCanceledException
37   {
38     return new RefactoringStatus();
39   }
40   
41   public Change perform(IProgressMonitor pm) {
42     TcPlugin plugin = TcPlugin.getDefault();
43     TcConfig config = (TcConfig)plugin.getConfiguration(fProject).copy();
44     
45     try {
46       plugin.setConfigurationFromString(fProject, fConfig.xmlText(plugin.getXmlOptions()));
47     } catch(Exception JavaDoc e) {
48       e.printStackTrace();
49     }
50     
51     // create the undo change
52
return new ConfigUndoneChange(fProject, config);
53   }
54 }
55
Popular Tags