Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Copying a folder from any location to Workspace (CDT)(Copying a folder from any location to Workspace (CDT))
Copying a folder from any location to Workspace (CDT) [message #1770267] Wed, 09 August 2017 13:56 Go to next message
Faisal Tariq is currently offline Faisal TariqFriend
Messages: 33
Registered: August 2017
Member
Hello,

I am new to Eclipse CDT and the project template. Is there a process in the CDT template that would allow me to copy a folder (which has sub-folders), from a location declared in the environment variable (lets say the folder is at c:/temp_1) to my eclipse workspace (I am using Windows Operating system). Please note the Source can be anywhere.

Can you please provide a template XML Snippet.

Thanks
Re: Copying a folder from any location to Workspace (CDT) [message #1770427 is a reply to message #1770267] Fri, 11 August 2017 08:45 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
Hi Faisal,

Not as such. Are you extending CDT, or a CDT user.

For extending CDT you want to create your own process runner that can run as part of the templating mechanism. Please join us at cdt-dev mailing list as there is some exciting work going on with a new template engine that may even be more suitable.

If you are a CDT user, then AFAIK there is no available option (without writing Java code and becoming a CDT extender) to do what you want.

Jonah
Re: Copying a folder from any location to Workspace (CDT) [message #1770453 is a reply to message #1770427] Fri, 11 August 2017 16:13 Go to previous messageGo to next message
Faisal Tariq is currently offline Faisal TariqFriend
Messages: 33
Registered: August 2017
Member
Hello Jonah,

Thank you for your response. I am trying to add a list of microcontrollers to the File menu in eclipse File->NewProject->etc->micro (which I can do using the Template.xml). However, the next step is that once the Micro is selected then the necessary files at a particular location will get copied into the Eclipse Workspace, which I am struggling with.

I don't mind writing Java Code for this. But at this point I am lost as to how to accomplish this. I was hoping that I would be able to write some java code in Activator.java to do a copy folder/files. I was able to see with a simple Plug-in that when the plug-in was used the Activator "start" was accessed. I can see myself putting the file transfer code in there. However, with the template.xml I do not know how to tie these two together. Any suggestions on this.

I would love to join the cdt-dev mailing list and listen in to all that is going on.

Thanks

Faisal

[Updated on: Fri, 11 August 2017 16:17]

Report message to a moderator

Re: Copying a folder from any location to Workspace (CDT) [message #1770549 is a reply to message #1770453] Mon, 14 August 2017 09:19 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
Hi Faisal,

I trust my answer in https://www.eclipse.org/forums/index.php?t=msg&th=1088192&goto=1770547&#msg_1770547 is sufficient, if not please let me know.

Quote:
I would love to join the cdt-dev mailing list and listen in to all that is going on.

You are free to join, here is the link to self-subscribe yourself. https://dev.eclipse.org/mailman/listinfo/cdt-dev

Jonah
Re: Copying a folder from any location to Workspace (CDT) [message #1770599 is a reply to message #1770549] Mon, 14 August 2017 19:57 Go to previous messageGo to next message
Faisal Tariq is currently offline Faisal TariqFriend
Messages: 33
Registered: August 2017
Member
Thanks Jonah. Your help is appreciated.

Faisal
Re: Copying a folder from any location to Workspace (CDT) [message #1770607 is a reply to message #1770599] Mon, 14 August 2017 23:38 Go to previous messageGo to next message
Faisal Tariq is currently offline Faisal TariqFriend
Messages: 33
Registered: August 2017
Member
Hi Jonah,

Based on your feedback and searching the internet, I am trying to run a simple processRunner, to make sure that I have the structure down to trigger the Java code. But I don't seem to be triggering the java code, instead I am getting an error: "unknown process: com.mam.projectProcess.NewProject"

I made the modifications to an already working project with a template.


-----------------------------------------------------------------------

My java code looks like below (I copied it from another eclipse post )


package com.mam.projectProcess;

import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;

public class NewProject extends ProcessRunner {

public void process(TemplateCore template , ProcessArgument[] args,
String processId, IProgressMonitor monitor) throws ProcessFailureException
{
System.out.println("saveVariables 111 ");
saveVariables(args[0].getSimpleValue(), args[1].getSimpleValue() );

}

protected void saveVariables(String var1 , String var2 )
{
System.out.println("saveVariables : " + var1 + "::" + var2 );
}
}

------------------------------------------------------------------------

This is what my plugin.xml looks like.

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.cdt.core.templates">
<template
id="com.mam.projectTemplates.template"
location="template/template.xml"

projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
</extension>

<extension
point="org.eclipse.cdt.core.templateProcessTypes">
<processType
name= "NewProject"
processRunner="com.mam.projectProcess.NewProject">
<simple name= "projectName"/>
<simple name= "path"/>
<simple name= "uid2"/>
</processType>
</extension>

</plugin>

---------------------------------------------------------------------------

My template is big, so I am just showing you the lines I have added.


<process type="com.mam.projectProcess.NewProject">
<simple name="name" value="$(projectName)"/>
<simple name="targetType" value="$(targetType)"/>
</process>

---------------------------------------------------------------------------

Please let me know if you need more information.

Thanks

Faisal
Re: Copying a folder from any location to Workspace (CDT) [message #1770613 is a reply to message #1770607] Tue, 15 August 2017 07:26 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
What is the name of the plug-in? Is it com.mam.projectProcess? If not, the process in your template IIRC should be the "plug-in name.process name", so if your plug-in name is com.example and the process is NewProject then in the template.xml you should have "com.example.NewProject".

HTH,
Jonah
Re: Copying a folder from any location to Workspace (CDT) [message #1770658 is a reply to message #1770613] Tue, 15 August 2017 18:57 Go to previous message
Faisal Tariq is currently offline Faisal TariqFriend
Messages: 33
Registered: August 2017
Member
Thank you again Jonah. That worked! But I had other bugs in the code that needed fixing, so people beware before using what I posted above.

I can now trigger the template to send me to the newProject Java. I put a breakpoint to see if my code is entering the Java code. (For somereason the system.out.println() did not print in the console). but I do not care about printing right now, however if you have suggestions, I am all ears.

Thanks once again.

Faisal

[Updated on: Tue, 15 August 2017 19:18]

Report message to a moderator

Previous Topic:Qt integration into Eclipse CDT Neon 2
Next Topic:printf() is not appearing.
Goto Forum:
  


Current Time: Thu Mar 28 18:31:08 GMT 2024

Powered by FUDForum. Page generated in 0.02317 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top