Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2013-01-12 00:54:08 -0500
committerDoug Schaefer2013-01-12 00:57:49 -0500
commit09357c4df6205e576e46ae8194d82e6f7dad7653 (patch)
treeafd7aca91b6970b42758d847d558c4364911e2ec /core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes
parent5cb3203f4a6c8627a90649a7dcd8075651a17bbc (diff)
downloadorg.eclipse.cdt-09357c4df6205e576e46ae8194d82e6f7dad7653.tar.gz
org.eclipse.cdt-09357c4df6205e576e46ae8194d82e6f7dad7653.tar.xz
org.eclipse.cdt-09357c4df6205e576e46ae8194d82e6f7dad7653.zip
Added support for Qt. Extended AddFiles template to change start/end
patterns.
Diffstat (limited to 'core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes')
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java38
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties6
2 files changed, 36 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java
index e6674033e7..1f4fa400df 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * Copyright (c) 2007, 2013 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
+ * Doug Schaefer (QNX) - Added overridable start and end patterns
*******************************************************************************/
package org.eclipse.cdt.core.templateengine.process.processes;
@@ -29,7 +30,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-
/**
* Adds Files to the Project
*/
@@ -40,9 +40,30 @@ public class AddFiles extends ProcessRunner {
*/
@Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
- String projectName = args[0].getSimpleValue();
- IProject projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- ProcessArgument[][] files = args[1].getComplexArrayValue();
+ IProject projectHandle = null;
+ ProcessArgument[][] files = null;
+ String startPattern = null;
+ String endPattern = null;
+
+ for (ProcessArgument arg : args) {
+ String argName = arg.getName();
+ if (argName.equals("projectName")) { //$NON-NLS-1$
+ projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(arg.getSimpleValue());
+ } else if (argName.equals("files")) { //$NON-NLS-1$
+ files = arg.getComplexArrayValue();
+ } else if (argName.equals("startPattern")) { //$NON-NLS-1$
+ startPattern = arg.getSimpleValue();
+ } else if (argName.equals("endPattern")) { //$NON-NLS-1$
+ endPattern = arg.getSimpleValue();
+ }
+ }
+
+ if (projectHandle == null)
+ throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddFiles.8"))); //$NON-NLS-1$
+
+ if (files == null)
+ throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddFiles.9"))); //$NON-NLS-1$
+
for(int i=0; i<files.length; i++) {
ProcessArgument[] file = files[i];
String fileSourcePath = file[0].getSimpleValue();
@@ -67,7 +88,12 @@ public class AddFiles extends ProcessRunner {
} catch (IOException e) {
throw new ProcessFailureException(Messages.getString("AddFiles.3") + fileSourcePath); //$NON-NLS-1$
}
- fileContents = ProcessHelper.getValueAfterExpandingMacros(fileContents, ProcessHelper.getReplaceKeys(fileContents), template.getValueStore());
+ if (startPattern != null && endPattern != null)
+ fileContents = ProcessHelper.getValueAfterExpandingMacros(fileContents, ProcessHelper.getReplaceKeys(fileContents, startPattern, endPattern), template.getValueStore(),
+ startPattern, endPattern);
+ else
+ fileContents = ProcessHelper.getValueAfterExpandingMacros(fileContents, ProcessHelper.getReplaceKeys(fileContents), template.getValueStore());
+
contents = new ByteArrayInputStream(fileContents.getBytes());
} else {
try {
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties
index d8d5f2d2cd..d100e9797d 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties
@@ -9,13 +9,15 @@
# Bala Torati (Symbian) - Initial API and implementation
###############################################################################
-AddFiles.1=Add File failure: template source not found:
+AddFiles.1=Add Files failure: template source not found:
AddFiles.2=Add Files failure: template source not found:
AddFiles.3=Add Files failure: cannot read template source:
-AddFiles.4=Add File failure: cannot read template source:
+AddFiles.4=Add Files failure: cannot read template source:
AddFiles.5=Add Files failure: File already exists.
AddFiles.6=Add Files failure:
AddFiles.7=Add Files failure:
+AddFiles.8=Add Files failure: projectName not specified
+AddFiles.9=Add Files failure: No files
AddFile.0=Add File failure: template source not found:
AddFile.1=Add File failure: template source not found:
AddFile.2=Add File failure: cannot read template source:

Back to the top