how modify the already installed content-assist? - eclipse

First of, how can I see what plugin manages the CTRL + SPACE content-assist? And how can I modify it in other to add my own stuff. Any help/idea is gladly welcome.
Thanks.

I think you're looking for "Templates". Assuming you're using Java, this is in the Windows -> Preferences menu, then Java->Editor->Templates. For example, the screenshot below shows the CTRL-SPACE content assist when you type "sysout".

If i would have this task, I would go to preferences. Look for content assist settings. Write down some specific text you see in dialog box. Then go to plugins folder, and start to search inside archives. When match is present, open the plugin.xml of that plugin, and you will see the extension points of the plugin. Based on its name, I am pretty sure you will find the appropiate one. Then you can either google it, or look for plugins extending the extension point. Using JDGui or fetching source code of the extension example plugin will help you in disassembling. Eclipse usually not well documented as for extension points, so i do it this way.

Related

qgis preferences in a python plugin

I'm developing a qgis python plugin. This plugin changes the default UI windows displayed (which I've already managed to do) and creates a few new tabs and such. Recently, it was requested that I modify some of the options within qgis. These are what they want me to modify:
Under Settings -> Options -> CRS ... modify the preference to Always start new projects with this CRS. They want me to change that to a specific CRS. They also want me to change several settings under the general tab and the map tools tab.
I have no idea where these preferences live in the API and/or how I can change them. I don't think I need specifics, but if you could give me a general idea of where to look, it would be much appreciated. Thanks!
I figured out the answer here. This mailing list entry: http://lists.osgeo.org/pipermail/qgis-developer/2012-October/022627.html and this http://qt-project.org/doc/qt-5.0/qtcore/qsettings.html were helpful. I ended up going into the windows registry to figure out the names of the options (since that's where they're set when you use store QSettings natively in Windows. It was under HKEY_USERS/myid/Software/QuantumGIS. In there, I just experimented by turning things on and off to figure out what needed to be changed in the plugin. I did that like this.
settings = QSettings(QSettings.NativeFormat, QSettings.UserScope, 'QuantumGIS', 'QGis')
settings.setValue('/Projections/projectDefaultCrs', 'EPSG:2278')
Hope this helps someone else.

sublime text - eclipse App Explorer equivalent

Hi I wondering if there is the equivalent to an App Explorer in Sublime Text 2.
When using eclipse, I use the App Explorer panel to search by file name.
I have a file naming convention that helps me find files by there functionality within the system.
So say I want to list all files relating to the registration process. I search for "regis" via the App Explorer and get a nice list of the relevant files. This filtered list is available all the time until I search again.
I can use Sublime Text's cmd+p but prefer the above as I can see the folder hierarchy etc.
In essence it is merely a file name filter on the folder list.
Are there any plugins that may give me something similar.
Any help much appreciated.
No, as far as I can tell nothing like this has been implemented in Sublime Text 2. I would suggest opening an issue at Sublime's UserEcho forum.
In the meantime:
Typing "regis" into Sublime's 'GoTo Anything' panel will bring up the files you're looking for, and show you their paths (I realize this doesn't help you with visualizing the hierarchy, but that's as close as it gets).
I use a package called SyncedSideBar - this will at least show you a visual representation of the folder hierarchy in the sidebar, for the open file, if it's added to the project.
The GoTo Folder package by freewizard may do something similar to what you're looking for, but I had trouble getting it to work. Maybe you'll have more success.
Good luck!

Eclipse content assist (for PHP or anything) not using active working set

The Eclipse content assist for PHP (and I'm assuming for other types as well) isn't using the currently active working set - it's searching ALL files in the project. How do I change it to only use the active working set?
When doing a Ctrl+Shift+R search, it was also looking for all files in the project (not what I wanted), until I clicked the small black triangle in that window and selected the working set I wanted it to use. Now it successfully only shows the files that match my search string in the working set. However, this doesn't change anything in the autocomplete content assist feature (i.e. doing a Ctrl+Space to complete the name of a function or variable). Is there any way to accomplish this?
I'm using Eclipse Indigo release, so it's very recent.
I'm afraid it's not possible the way you put it. Eclipse Working Sets just give you a way to organize your projects.
However you may want to take a look at Mylyn, which is fully integrated with Eclipse platform. Here and here is a nice overview of what you can do with Mylyn. But briefly, what it allows you to do is to create a task and maintain a context associated with it. This way, only the relevant files will be displayed in Project Explorer and autocomplete would suggest you only task-focused options.

Making Eclipse Plugins: How to open class declaration from String e.g. "java.is.Good"

I want to make a tool like this:
"java.is.Good.toString()" I want to search this String and jump to the Good.toString() method body.
how to active this?
I can read sourcecode of eclipse, but know nothing about eclipse plugins development, so please give me some guide just like:
THE KEY METHOD
org.eclipse.jdt.core.search.MethodDeclarationMatch
[I can't find where to turn a String path to a JavaElement for search]
THE KEY SAMPLE
[I can't find the eclipse "navigate->open declaration" sourcecode]
try eclipse plug-in spy tools to find existing function codes and description.
As the jdt, there are many api for users to do such things like find a JavaElement by string name.
However, it's a pity that few people are familiar to this part and all depends on you.
Good luck.
The same functionality (Open Type under Cursor, Open File under Cursor) gives plugin called AnyEdit Tools (update site: http://andrei.gmxhome.de/eclipse/). Look into its sources or just use it.
P.S. Useful hotkeys for plugin development/hacking:
Shift+Alt+F1 - Plugin Selection Spy, shows detailed information about current window/editor/selection (contributing plugin, classes, selection etc.)
Shift+Alt+F3 - Show Contributing Plug-in, shows which plugin has contributed active window

How to Change Netbeans Fonts and Colors Preview Document?

Within the Netbeans 6.5's Tools -> Options -> Fonts & Colors -> Syntax dialog, you have the ability to change the look and feel of the Netbeans text editor. When you select a language, you are presented with a preview of your font/color scheme. However, when I preview Java, there are far more options for syntax changes than are being displayed in that preview window. If I were able to view a more robust piece of code, I'd be able to see the immediate effect of more of the options.
How can I supply a preview document to view my font/color changes?
UPDATE:
After looking into this some more, I've been able to narrow down the problem a bit. From what I can tell, everything in Netbeans is considered a plugin. The GUI editor is a plugin, and even the text editor is a plugin. This means that what ever piece of Netbeans that actually analyzes Java code and does syntax highlights is also a plugin (since Java is just one of many languages Netbeans highlights, it makes sense this is a plugin).
I think fromvega is on the right track with his suggestion. The tutorial for creating a manifest file editing plugin pointed me in the right direction. The tutorial eludes to a file used as a sample document used for font/color previews. It tells you how to create one inside this new plugin project. (Located in "Registering the Options in the NetBeans System Filesystem", part 4. About 4/5 of the way down the page.)
My next line of thought was to look for the Java syntax editing mode plugin and find this file and update it with a richer example file. I looked in the installation directory and came up empty, but I found what looks like the appropriate files within my user settings directory. There is a config directory with a lot of subfolders within my user directory (Windows: C:\Documents and Settings\saterus.netbeans\config).
I've been poking around inside this directory a bit, but have only found the xml files the manifest tutorial talks about. I have been unable to find the extensionless sample file for the Java plugin that I believe should be there.
Since I've hit a brick wall for the moment, I thought I'd toss it back to the SO community and see if you guys might make the last leap and find the solution.
Just for anyone who wants to alter this themselves it is possible on a unix machine to use grep to locate the file i.e.
grep -lr "some part of the current sample code" /path/to/netbeans
I used this method to locate the ruby example filename and from that identified that it is kept in org-netbeans-modules-ruby.jar as a file called RubyExample. By simply altering that file I was able to construct a better sample file for my own use.
Hope this helps someone!
The document which is displayed (for each mime type) is specified in a particular folder in the "system file system" (which is a NetBeans concept which is a virtual file system composed from contributions from individual modules; this is how functionality is dynamically registered in NetBeans).
Modules typically specify their system file system contributions in a file named "layer.xml" in the plugin. The create plugin templates typically offer to create this for you.
For example, here's how the Python example is registered:
<filesystem>
...
<folder name="OptionsDialog">
<folder name="PreviewExamples">
<folder name="text">
<file name="x-python" url="PythonExample.py"/>
</folder>
</folder>
...
Here, PythonExample.py is a sample file in the same directory as the layer file.
Therefore, what you need to do is create a plugin which overrides the existing registration(s) for the mime type(s) you care about and provide alternate sample documents. You may need to hide the existing registration first (see the _hidden
part from http://doc.javanb.com/netbeans-api-javadoc-5-0-0/org-openide-filesystems/org/openide/filesystems/MultiFileSystem.html ).
Hopefully this guides you in the right direction.
However, in thinking about it, we probably ought to make the preview area editable - so people can cut & paste whatever codefragment they care about right in there. This wouldn't be persistent, so whenever you change languages you get the original samples back - but it provides a quick way to see your own code. This shouldn't be just for the Fonts & Colors customization, but for the Formatting preview panels as well.
I've filed an issue against NetBeans for this:
http://www.netbeans.org/issues/show_bug.cgi?id=155964
-- Tor
I think you can only accomplish that with a new plugin, since you need somekind of parsing to define what is what.
Give a look a these tutorials, I haven't read them in details but they seem to show you how to do what you want:
http://platform.netbeans.org/tutorials/nbm-mfsyntax.html
http://www.antonioshome.net/kitchen/netbeans/nbms-coloring.php