Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/UserInterfaceManager.java

Issue 9834028: Initial implementation of "Rename Local Variable" refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: LInked/inline mode for rename Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/UserInterfaceManager.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/UserInterfaceManager.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/UserInterfaceManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..8fbae400b6db4eb4fff655b4df2c63782c4c20b2
--- /dev/null
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/UserInterfaceManager.java
@@ -0,0 +1,59 @@
+package com.google.dart.tools.ui.internal.refactoring;
+
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class UserInterfaceManager {
+
+ private static class Tuple {
+ private Class<? extends UserInterfaceStarter> starter;
+ private Class<? extends RefactoringWizard> wizard;
+
+ public Tuple(Class<? extends UserInterfaceStarter> s, Class<? extends RefactoringWizard> w) {
+ starter = s;
+ wizard = w;
+ }
+ }
+
+ private Map<Class<? extends RefactoringProcessor>, Tuple> fMap = new HashMap<Class<? extends RefactoringProcessor>, Tuple>();
+
+ public UserInterfaceStarter getStarter(Refactoring refactoring) {
+ RefactoringProcessor processor = (RefactoringProcessor) refactoring.getAdapter(RefactoringProcessor.class);
+ if (processor == null) {
+ return null;
+ }
+ Tuple tuple = fMap.get(processor.getClass());
+ if (tuple == null) {
+ return null;
+ }
+ try {
+ UserInterfaceStarter starter = tuple.starter.newInstance();
+ Class<? extends RefactoringWizard> wizardClass = tuple.wizard;
+ Constructor<? extends RefactoringWizard> constructor = wizardClass.getConstructor(new Class[] {Refactoring.class});
+ RefactoringWizard wizard = constructor.newInstance(new Object[] {refactoring});
+ starter.initialize(wizard);
+ return starter;
+ } catch (NoSuchMethodException e) {
+ return null;
+ } catch (IllegalAccessException e) {
+ return null;
+ } catch (InstantiationException e) {
+ return null;
+ } catch (IllegalArgumentException e) {
+ return null;
+ } catch (InvocationTargetException e) {
+ return null;
+ }
+ }
+
+ protected void put(Class<? extends RefactoringProcessor> processor,
+ Class<? extends UserInterfaceStarter> starter, Class<? extends RefactoringWizard> wizard) {
+ fMap.put(processor, new Tuple(starter, wizard));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698