Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-10-20 03:39:30 -0400
committerEike Stepper2013-10-20 03:39:30 -0400
commitde0a142df274752941a9b4988fbf2c7098b39773 (patch)
tree7001b3068ea32e3cc982b1f0497ae6f1f63ec2fb
parentacab41df1fd9e79078100285f1c0a42cbadb85eb (diff)
downloadcdo-de0a142df274752941a9b4988fbf2c7098b39773.tar.gz
cdo-de0a142df274752941a9b4988fbf2c7098b39773.tar.xz
cdo-de0a142df274752941a9b4988fbf2c7098b39773.zip
More logging in SetupTaskPerformer
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java200
1 files changed, 108 insertions, 92 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java
index 7b2d619d6e..f7c2cc026f 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java
@@ -30,11 +30,13 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.edit.EMFEditPlugin;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import java.io.File;
@@ -57,6 +59,13 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
private static final String RELENG_URL = System.getProperty("releng.url",
"http://download.eclipse.org/modeling/emf/cdo/updates/integration").replace('\\', '/');
+ private static final ComposedAdapterFactory ADAPTER_FACTORY = new ComposedAdapterFactory(
+ EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry());
+
+ private static final Pattern STRING_EXPANSION_PATTERN = Pattern.compile("\\$\\{([^${}|]+)(\\|([^}]+))?}");
+
+ private static final Map<String, StringFilter> STRING_FILTER_REGISTRY = new HashMap<String, StringFilter>();
+
private static final long serialVersionUID = 1L;
private static ProgressLog progress;
@@ -74,7 +83,6 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
public SetupTaskPerformer(File branchDir)
{
trigger = Trigger.BOOTSTRAP;
-
this.branchDir = branchDir;
initialize();
@@ -90,34 +98,6 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
initialize();
}
- private void initialize()
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
-
- URI uri = URI.createFileURI(branchDir.toString() + "/setup.xmi");
- Resource resource = resourceSet.getResource(uri, true);
-
- setup = (Setup)resource.getContents().get(0);
-
- Branch branch = setup.getBranch();
- String branchName = branch.getName();
-
- Project project = branch.getProject();
- String projectName = project.getName();
-
- put("setup.git.prefix", setup.getPreferences().getGitPrefix());
- put("setup.install.dir", getInstallDir());
- put("setup.project.dir", getProjectDir());
- put("setup.branch.dir", getBranchDir());
- put("setup.eclipse.dir", getEclipseDir());
- put("setup.tp.dir", getTargetPlatformDir());
- put("setup.ws.dir", getWorkspaceDir());
- put("setup.project.name", projectName);
- put("setup.branch.name", branchName);
- put("releng.url", RELENG_URL);
- }
-
public void dispose()
{
setup = null;
@@ -176,67 +156,11 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
restartNeeded = true;
}
- private static final Pattern PATTERN = Pattern.compile("\\$\\{([^${}|]+)(\\|([^}]+))?}");
-
- protected String lookup(String key)
- {
- Object object = get(key);
- if (object != null)
- {
- return object.toString();
- }
-
- return System.getProperty(key, key);
- }
-
- interface StringFilter
- {
- public String filter(String value);
- }
-
- private static final Map<String, StringFilter> FILTERS = new HashMap<String, StringFilter>();
-
- static
- {
- FILTERS.put("uri", new StringFilter()
- {
- public String filter(String value)
- {
- return URI.createFileURI(value).toString();
- }
- });
- FILTERS.put("upper", new StringFilter()
- {
- public String filter(String value)
- {
- return value.toUpperCase();
- }
- });
- FILTERS.put("lower", new StringFilter()
- {
- public String filter(String value)
- {
- return value.toLowerCase();
- }
- });
- }
-
- protected String filter(String value, String filterName)
- {
- StringFilter filter = FILTERS.get(filterName);
- if (filter != null)
- {
- return filter.filter(value);
- }
-
- return value;
- }
-
public String expandString(String string)
{
StringBuilder result = new StringBuilder();
int previous = 0;
- for (Matcher matcher = PATTERN.matcher(string); matcher.find();)
+ for (Matcher matcher = STRING_EXPANSION_PATTERN.matcher(string); matcher.find();)
{
result.append(string.substring(previous, matcher.start()));
String key = matcher.group(1);
@@ -249,9 +173,11 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
value = filter(value, filterName);
}
}
+
result.append(value);
previous = matcher.end();
}
+
result.append(string.substring(previous));
return result.toString();
}
@@ -337,10 +263,59 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
setup = copySetup(setupTasks, substitutions);
reorder(setupTasks);
-
perform(setupTasks);
}
+ protected String lookup(String key)
+ {
+ Object object = get(key);
+ if (object != null)
+ {
+ return object.toString();
+ }
+
+ return System.getProperty(key, key);
+ }
+
+ protected String filter(String value, String filterName)
+ {
+ StringFilter filter = STRING_FILTER_REGISTRY.get(filterName);
+ if (filter != null)
+ {
+ return filter.filter(value);
+ }
+
+ return value;
+ }
+
+ private void initialize()
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
+
+ URI uri = URI.createFileURI(branchDir.toString() + "/setup.xmi");
+ Resource resource = resourceSet.getResource(uri, true);
+
+ setup = (Setup)resource.getContents().get(0);
+
+ Branch branch = setup.getBranch();
+ String branchName = branch.getName();
+
+ Project project = branch.getProject();
+ String projectName = project.getName();
+
+ put("setup.git.prefix", setup.getPreferences().getGitPrefix());
+ put("setup.install.dir", getInstallDir());
+ put("setup.project.dir", getProjectDir());
+ put("setup.branch.dir", getBranchDir());
+ put("setup.eclipse.dir", getEclipseDir());
+ put("setup.tp.dir", getTargetPlatformDir());
+ put("setup.ws.dir", getWorkspaceDir());
+ put("setup.project.name", projectName);
+ put("setup.branch.name", branchName);
+ put("releng.url", RELENG_URL);
+ }
+
private void reorder(EList<SetupTask> setupTasks)
{
for (int i = 0, size = setupTasks.size(), count = 0; i < size; ++i)
@@ -351,9 +326,8 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
throw new IllegalArgumentException("Circular requirements " + setupTask);
}
- EList<SetupTask> requirements = setupTask.getRequirements();
boolean changed = false;
- for (SetupTask requirement : requirements)
+ for (SetupTask requirement : setupTask.getRequirements())
{
int index = setupTasks.indexOf(requirement);
if (index > i)
@@ -386,8 +360,8 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
if (Activator.SETUP_IDE && trigger != Trigger.MANUAL)
{
File logFile = new File(getInstallDir(), "setup.log");
- IWorkbenchWindow window = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
- final Shell shell = window.getShell();
+ Shell shell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell();
+
ProgressLogDialog.run(shell, logFile, "Setting up IDE", new ProgressLogRunnable()
{
public boolean run(ProgressLog log) throws Exception
@@ -410,6 +384,7 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
for (SetupTask neededTask : neededTasks)
{
+ log("Performing setup task " + getLabel(neededTask));
neededTask.perform(this);
neededTask.dispose();
}
@@ -512,6 +487,12 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
return result;
}
+ private static String getLabel(Object object)
+ {
+ IItemLabelProvider labelProvider = (IItemLabelProvider)ADAPTER_FACTORY.adapt(object, IItemLabelProvider.class);
+ return labelProvider.getText(object);
+ }
+
public static ProgressLog getProgress()
{
return progress;
@@ -521,4 +502,39 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
{
SetupTaskPerformer.progress = progress;
}
+
+ static
+ {
+ STRING_FILTER_REGISTRY.put("uri", new StringFilter()
+ {
+ public String filter(String value)
+ {
+ return URI.createFileURI(value).toString();
+ }
+ });
+
+ STRING_FILTER_REGISTRY.put("upper", new StringFilter()
+ {
+ public String filter(String value)
+ {
+ return value.toUpperCase();
+ }
+ });
+
+ STRING_FILTER_REGISTRY.put("lower", new StringFilter()
+ {
+ public String filter(String value)
+ {
+ return value.toLowerCase();
+ }
+ });
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public interface StringFilter
+ {
+ public String filter(String value);
+ }
}

Back to the top