Eclipse Plugin Development: Adding items to a working set with the path of the item? - eclipse

Hello,
I'm an eclipse plugin development newbie looking for pointers to get me started on a particular project.
I am trying to build an eclipse plugin that will automatically construct a working set from a text file that simply consists of a list of file path names. The files/items need not share any parent directories. The rough idea is represented in the following diagram:
I am not asking for the solution to this task. That's the over-arching goal. To achieve that goal, I want to conquer some smaller goals first.
With that in mind, here's the smaller goal I'm currently trying to tackle:
In Eclipse, how can I prompt the user for a single file's path, and then add that file to an existing working set?
I'm not sure where to start. Should I work directly off of the existing org.eclipse.ui.workingSets extension point? Or should I use a collection of other extension points? How do I convert strings into something that can be added to a working set? Do I write code that directly modifies the workingsets.xml file?
Even with a much simpler goal, I still feel quite overwhelmed with the vastness of eclipse extension options. There are probably many ways to go about implementing something like this, but I just need one to get started.
Thanks a bunch!

To manipulate working sets you use the working set manager interface IWorkingSetManager. Get this with:
IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
From this you can get a particular working by name with:
IWorkingSet workingSet = manager.getWorkingSet("name");
The contents of a working set is an array of IAdaptable objects:
IAdaptable [] contents = workingSet.getElements();
You add to the contents by adding to this array and setting the contents:
IAdaptable [] newContents
.... get new array with old contents + new contents
workingSet.setElements(newContents);
A lot of Eclipse objects implement IAdaptable, for a file in the workspace you would use IFile. You can use dialogs such as ResourceSelectionDialog to select resources from the workspace.

Related

Generate starter code based on new file VSCode

Is there a way to configure some code based on a file extension when created in VS Code? I'm currently working with psioniq file header which has been pretty helpful in generating good header files, but I'm looking to take this a step farther.
When I create a new file, based on a specific file extension, I would like it to generate some starting code that I can configure. For example, I work with Verilog a lot. It would be really cool if Code could generate based on the file name.
Create new file
Code generates some code (like below) or something else that could be configured based on the filetype:
module <filename> (
input ,
output ,
);
endmodule
Anyone have any extensions they know about or resources they can point me to to implement this?
This would be a pretty easy extension to write but an alternative is snippets.
You can create keywords, based on the extensions, that when you type it it'll create all that code for you.
https://code.visualstudio.com/docs/editor/userdefinedsnippets

VSCode - auto_prepend_file for code suggestions

I have been using VS code instead of eclipse for the last few weeks and find it much quicker, easier to use. However there is one thing I can’t seem to figure out.
My php app calls a prepend file which initiates a class called GlobalClass:
$gc = new GlobalClass();
When I type $gc-> in eclipse I get all the functions prompted. This doesn’t work within VS Code.
If I add use GlobalClass or add the $gc = new GlobalClass(); to the top of the file then it works. Is there any way to declare this within VS Code or to point the editor to the code within the prepend file?

Remove custom code workflow programmatically

For a variety of reasons too convoluted to explain here, I find myself in a position where I need to be able to remove custom code workflows, while leaving the solution there.
I essentially have the same code as the plugin registration tool
Namely
service.Delete("plugintype", new Guid(info));
where info is the workflow id [running on a foreach loop but that's beside the point]
However, while the tool removes the workflows without any issues, my code complains about dependencies.
EM:
Additional information: The PluginType(a0b2dcf7-cf2a-111e-7da9-003021880a42) component cannot be deleted because it is referenced by 1 other components. For a list of referenced components, use the RetrieveDependenciesForDeleteRequest.
which I duly did
RetrieveDependenciesForDeleteRequest req = new RetrieveDependenciesForDeleteRequest();
req.ComponentType = 90; //plugintype
req.ObjectId = new Guid(info);
RetrieveDependenciesForDeleteResponse resp = (RetrieveDependenciesForDeleteResponse)OrgService.Execute(req);
This retrieves an optionvalueset, but there is little I can do with it as I cannot remove it from the solution as the solution is managed.
The only difference I can see is the way the OrganizationServiceProxy gets instantiated. The plugin registration tool includes a way to refresh the securitytoken, but as far as I can tell it's not doing much (I've stepped through the code, but it's possible I missed something)
Are you sure that it is an OptionSetValue that is the dependency? It's much easier to use GUI to determine what the dependencies are. Fire up your solution in CRM 2011, click 'plug-in assemblies', select the relevant assembly then go through each custom workflow/plugin item and click 'Show Dependences'.
In my case I had another workflow (created within CRM) that was referencing a custom workflow preventing removal of the assembly.
You won't be able to remove components from a Managed solution... Are you the author of the solution originally?
As an aside, does your workflow fire on change of the OptionSet that is showing as a dependency?

Can't find 'Build.xml' after export Antenna files

I have made a J2ME program. This program will be used in 3 specific countries and has to support 7 different screen resolutions.
At the moment I have created 7 different builds for each resolution type and 3 variants in each for each of the 3 countries.
I am using LWUIT as my UI framework. I have configured MTJ with the following.
antenna-bin-1.2.1-beta.jar
WTK2.5.2_01
proguard4.8
on Eclipse 3.7.2
In the package explorer i right click on my project directory
select 'Export' (I couldn't find 'Export Antenna Build Files' under the 'Mobile Tools for Java' option)
I wait for it to do its thing.
I open the project folder and search for Build.xml. But can't find anything .
I find a folder called 'mtj-build' that contains another folder(custom-tasks) and two files mtj-build.properties and mtj-build.xml .
I want to able to write a build file that would be able to do the following
put in the correct resources according to the resolution its building
put in the correct theme according to the resolution its building
set the relevant attributes in the Application Descriptor file for each country
repeat this process automatically for each resolution and each country and place the respective .Jad and .Jar files in a particular folder structure as shown.
MainFolder:
{
Country1:{
Res1,
Res2,
Res3,
....},
Country2:{
Res1,
Res2,
Res3,
....},
Country3:{
Res1,
Res2,
Res3,
....},
....etc}
}
As I understand to do this I would need to set up a Build.xml. But then I can't find Build.xml after selecting the Export Antenna Build Files option.
How do I achieve this goal? Is it even possible to do this? Please do help . Thanks in Advance
===================UPDATE TO THIS POST #1======================
Follow the links mentioned by Eugen Martynov below.
on a side note: The reason I wasn't getting the option to Export Antenna Build files on the right click of the project was because they were referring to a customized version of the Eclipse IDE called Pulsar Eclipse.[ http://www.eclipse.org/pulsar/ ]
The Antenna build xml file generated by it is far more optimized than the one you get out of the standard Eclipse. I dunno why that is. But thats my Observation.
===================UPDATE TO THIS POST #2======================
Thanks for your suggestion Eugen. I will be writing a few sub Ant Build files to simplify my problem. I still have to figure out how to break this down.
Thanks for the link Telmo Pimentel Mota. In my current build I have 'wtkbuild' and 'wtkpackage'. And the build is working great. I just now have to figure out how to call or execute one build file from another following Eguen's suggestion.
I wouldn't give you complete answer but I give you way to find out it yourself.
Here about ant and building process. Here is building j2me with antenna. There are also should be examples of build.xml files in antenna sample folder. Here is alternate example about ant and building j2me without using antenna.
In your case you have to use different res folders and set different manifest options based on two additional properties country and resolution. You could pass properties outside build.xml by using properties file or by command line:
ant -f <path to build.xml> -D<property name>=<property value>

How to add an extra plist property using CMake?

I'm trying to add the item
<key>UIStatusBarHidden</key><true/>
to my plist that's auto-generated by CMake. For certain keys, it appears there are pre-defined ways to add an item; for example:
set(MACOSX_BUNDLE_ICON_FILE ${ICON})
But I can't find a way to add an arbitrary property.
I tried using the MACOSX_BUNDLE_INFO_PLIST target property as follows: I'd like the resulting plist to be identical to the old one, except with the new property I want, so I just copied the auto-generated plist and set that as my template. But the plist uses some Xcode variables, which also look like ${foo}, and CMake grumbles about this:
Syntax error in cmake code when
parsing string
<string>com.bedaire.${PRODUCT_NAME:identifier}</string>
syntax error, unexpected cal_SYMBOL,
expecting } (47)
Policy CMP0010 is not set: Bad
variable reference syntax is an error.
Run "cmake --help-policy CMP0010"
for policy details. Use the
cmake_policy command to set the
policy and suppress this warning. This
warning is for project developers.
Use -Wno-dev to suppress it.
In any case, I'm not even sure that this is the right thing to do. I can't find a good example or any good documentation about this. Ideally, I'd just let CMake generate everything as before, and just add a single extra line. What can I do?
Have you looked into copying the relevant *.plist.in file in /opt/local/share/cmake-2.8/Modules (such as MacOSXBundleInfo.plist.in), editing it to put <key>UIStatusBarHidden</key><true/> (or #VAR_TO_REPLACE_BY_CMAKE#), and adding the directory of the edited version in the CMAKE_MODULE_PATH?
If you have CMake installed as an app bundle, then the location of that file is /Applications/CMake.app/Contents/share/cmake-N.N/Modules
You can add your values using # and pass #ONLY to configure_file.
Unfortunately there is no simple way to add custom line to generated file.