My requirement is to use a new external compare tool for certain type of file extensions in eclipse RCP product.
For other files eclipse default compare editor should be used.
In order to achieve this , I am using ASPECTJ to hook to eclipse default compare editor method . In my aspect method I am validating the file which is selected, If the file is a particular type I am trying to call my external compare tool or else continue with using eclipse default editor.
I am not able to get two files( that is left and right input file) from the compareEditorInput Object which is a parameter.
Is there any way to get two input files so that i can pass to my external compare tool??
The compare editor itself does not require that the input comes from files, nor does the base CompareEditorInput class.
Subclasses of CompareEditorInput such as ResourceCompareInput do work from files so you may be able to get the input from them. But these are internal classes and not part of the API.
Related
I am creating a plugin for Eclipse, which contains tools for creating a custom type of project. These projects have a custom nature and builder. My builder (implements IncrementalProjectBuilder) takes a single input file, and generates a few (usually between 3 and 5) output files. When I run Clean Project, I need to remove the files the builder has previously generated.
Problem 1: The names of the generated files are not known exactly, but I do know the sort of files I expect to find (e.g. I know the extensions, and partial file names).
Problem 2: The user may add their own files to the project, which should not be affected by my build / clean steps.
My initial attempt was naive: remove every file except from the input file. This works, but has obvious problems.
My second attempt was better: I came up with a list of possible file names that may be generated, see if any of them exist and remove them.
By only knowing partial file names and matching them, I may inadvertently delete a user's file. E.g. I know I will generate a file called *_file.py. If the file I generate is called abc_file.py and the user has added their own xyz_file.py, I want to clean (remove) abc_file.py but leave xyz_file.py untouched.
The program which generates the output files from the input is constantly changing, and I don't want to rely on a concrete list of files that would need constant maintenance.
So, my question comes down to this. What methods exist for identifying the files generated by my custom builder, so I can remove them during a clean?
I've spent a couple of days Googling this one with not much to show for it. I am vaguely aware of a file system watcher in Java (Java7 WatchService?), but I don't know if that's the best solution to this problem.
Any information, advice or ideas appreciated.
One brute force approach would be to compare the project before and after the other program is invoked to get the list of files that were created/generated. Of course, it would be ideal if that program could somehow tell you which files it created. Once you have that list, you could iterate over those files as IFile's as use the setDerived() method to mark them as not being source files. When it comes time to clean the directory, you could use the derived setting to decide which files can be deleted.
I'm creating some editors for a simple project, so far everything is fine, except that at the moment, my editors are bound to an specific file extension, for example, one editor opens xml files, other editor opens .properties files, and that's fine for now, but what I need to do, is to launch the editor just when the opened file contains an specific string. I'm actually trying to launch my editors when the project version is "3.4", so, when the files contains something like this: version="3.4", it should launch my editor, is there a way to do that, or is there a better way to to that?
Notice that the project version is specified in a project facet as well.
You can add a describer element as a child of content-type which defines a class to be called which can check if a file is valid for this content type.
<content-type id="customType"
base-type="org.eclipse.jst.jsf.facesconfig.facesConfigFile"
file-extensions="xml">
<describer class="package.MyDescriber"/>
</content-type>
The class must implement IContentDescriber (or ITextContentDescriber).
The method:
public int describe(InputStream contents, IContentDescription description)
is called to check the contents. Return VALID if it is OK, INVALID if not.
You can also support other properties for the file (such as determining the character encoding) if needed.
More information in the Eclipse help on the extension point.
this is a standalone utility. on launching the utility, it asks the user to input the location of an input.xml file. what i am trying to figure out is if there is a way to - read the input.xml file during runtime and using the data specified within that xml file, build the next user input panel.
the data specified within input.xml will include number and type of input fields, radio buttons with options' values, password field or text field etc.
in case it's possible the actual solution would include multiple such input.xml files to generate corresponding input panels at runtime.
any suggestions on its feasibility?? (the constraint is using izpack as the base/utility)
EDIT: nope, doesnt seem possible. in order to build the dynamic UserInputPanel at runtime, a fresh compile required at runtime which would be like another installer running in parallel. havent been able to find any easier option.
I've created a new project wizard and it creates a blank file. I want the file to contain some sample code. I don't want to put the sample code there via a static String. Should I be looking to add the org.eclipse.ui.editors.templates extension point to my plug-in project or is this not its intended purpose? Based on what I've read, it sounds like it's perhaps only intended for code completion templates?
Well the JavaDoc for the org.eclipse.jface.text.templates package that provides this support says:
Templates are shortcuts for frequently used fragments of text such as
code patterns or complex text entities. They may contain variables
which are only resolved at the time when the template is inserted
within a context. Together with linked mode, inserting a template can
create a on-the-fly edit mask within a text viewer.
Templates are specified as text, variables are defined using the
${variable} notation known from Ant, for example.
So I think they can be used to insert any text.
I am writing a java project in which I am making changes in one of the properties files. I am using eclipse juno for my development, now I want an eclipse shortcut from which I can know that the properites file is being used internally in which different java files.
I know that one way is to press ctrl + h and in file search typing the name of the file and in type selecting the .java extension. My query is that is there any other shortcut to know that where this properties file is called internally in different java files
.
There isn't such a built-in command for getting the references of an entry in a property file. The type hierarchy and the "Control + Click"-thing works because the java sources can be interpreted to get actual calls. For accesses to .property files this is not as easy as there are several ways to access them for example.
That's why there sometimes a pattern is used where the properties are only accessed by exactly one Java class. This class then provides the properties as static fields for example. Doing this the compiler helps you in getting the references.