Disable key bindings in eclipse - java

I have defined my own project nature in eclipse. This project has a specific file. For this file type I want to disable copy paste. I have already removed copy and Paste options from context menu of the file by using eclipse Activity-Pattern binding. But, still the user can do Ctrl+C and Ctrl+V from keyboard to achieve the same. Is there any way I can disable these predefined key bindings in eclipse. I would like to define such a functionality in my plugin.xml. Please help.

Related

Is it possible to override default code formatt of Eclipse

I have java code style formatter of Eclipse (for that matter it can be formatter of the other language also). When I import he format then it is saved in the workspace and that is applicable for that workspace.
I want code format/style imported and saved in the Eclipse setting itself so that this Eclipse used by anyone gets the format whatever workspace they use.
Is it possible to override the default format? Do I have to write my own plugin?
Thanks,
I can suggest the following in the Java perspective, Eclipse version Indigo...
click Window -> Preferences
expand Java -> Code Style
click Formatter
This will get you to the Formatter screen below. Follow the link on the top right
and see if this provides you with what you are requesting.
Configure Project Specific Settings screen
I wanted settings to be present in the eclipse packaging itself so that these settings (code format, template, spacing strategy etc.) are not repeated at every project and workspace level.
I got a way (at least it works on Linux with neon version). Here are the steps
Open eclipse with some workspace location
Apply all the settings like code formatting, template, Editor
preferences and all other preferred settings present in Window ->
Preferences Press OK. it will save the preferences.
Go to File -> Export -> General -> Preferences and press Next
Make sure Export all is checked and then provide the To
Preference File location and then Click Finish
Now open the exported file in you favorite editor
You will observe it is like a properties file with each property prefixed with /instance/ or /configuration/ (these are preference scopes). Remove all these prefixes (after that all the properties will look like org.* or net.* etc.). You will also see some workspace path related properties are present in this file, either remove them or change to appropriate one.
Save this file with some name say my-eclipse-preference.epf and copy
this file to your eclipse location (where eclipse start file is
present, say ECLIPSE_HOME)
Open $ECLIPSE_HOME/configuration/config.ini and add a line with
the property puluginCoustomization=my-eclipse-preference.epf at the end and save config.ini.
Restart the eclipse, you will find your settings are present even if you open with empty/new workspace. If you are starting from terminal then got to
the ECLIPSE_HOME directory first and then start.
If you want to start from the terminal but you want to avoid going
to the directory to start (i.e. starting from any location) then you should store the file my-eclipse-preference.epf at some standard location and have the value of puluginCoustomization with full path in config.ini.
Hope this helps.

Eclipse automatically opening some files in system editor

Was finding this problem with Eclipse(Kepler) over the last week, so downloaded Eclipse (Luna) and checked out the relevent project into an entirely new workspace.
I'm using *.str files for a particular project (they are standard editor files anyway - short for 'string'). But Eclipse wants to open such files as macVim files:
I have NO file associations set for *.str files:
...althought I do use macVim to open them in the underlying operating system. So I change the system editor to TextEdit and Eclipse happily now wants them to open in TextEdit - but I want to open them in the eclipse editor! (appart from anything else, I've got to develop an editor plugin for *.str files.
How can I convince Eclipse that it can open *.str in it's own editors without having to resort to the system editor?
EDIT - follow the answers - my understanding is this. If Eclipse doens't know what the file is, it will ask the system. If you ask it to open in a particular editor it will overlay that information on that particular file, and to make it happen in general (and change the icon) you need to add a file association.
You can add a a File Associations for '*.str' and set the Associated Editor to 'Text Editor'. Eclipse will use this for files that you have not yet opened.
For files that you have already opened Eclipse will be remembering the editor you last used, so for these right click on the file and use 'Open With > Text Editor'. You should only have to do this once.
Right click on the file, select open with, and there should be three options (Text Editor/System Editor/Default). Selecting text editor should associate it with eclipse (from within eclipse only) in future.

Jar Export Shortcut Key in Eclipse?

I need to know the Jar Exporting Shortcut Key in Eclipse to destination.I don't know if it is possible or not.
I am export jar file now Right click on Project folder and select export then select JAR like this way.But i feel to difficult every day using like this.
So Can you please suggest me any shortcut key for export jar file in eclipse.
At present, there is no predefined keyboard shortcut for exporting Jar.
Solution
Add a custom shortcut in Windows->Preferences->General->Keys by defining a Custom key binding
All the Eclipse commands and their associated shortcut keys are displayed here. You can use the predefined ones or assign/change new shortcuts here.
After assigning the shortcut, it will show the user defined key binding.
For me it shows my custom combination Ctrl + Alt + R as follows:

How to clean the list of previous "command line" in execute maven goal window of intellij ce

IntelliJ CE is great integrating maven execution for modules.
Im using IntelliJ CE 13, and for custom maven executions i'm using the "Execute maven goal" window.
A great feature it has is it remembers all (and i mean all) of the previous executions, which is a great thing to avoid typing over and over the same command.
BUT, if anytime you type a really long command, the window gets resized to fit in the command, so it's a little bit annoying to scroll in order to view the "choose module" button.
Is there any way of "cleaning" that list of previous executions???
To the best of my knowledge, there is not a way via the UI to clear that list. You may want to open a feature request to do such: http://youtrack.jetbrains.com/
That said, there is a hack you can do to clear it (or selective items).
Close your project
Go to the .idea directory within your project
if you are using file based project and not directory based project settings, you can search the .iws file for the following
Backup the workspace.xml file
Open the workspace.xml file
Do a search for <component name="mavenExecuteGoalHistory">
It's path is: /project/component[#name='mavenExecuteGoalHistory']
Delete any or all of the <option> elements within that <component> element
Save the file and reopen your project.
I found another solution to this problem since the I didn't get the suggested answer to work. There is a way to access a context menu where a delete option is available.
By highlighting your project folder and navigating to the top menu "Run"->"Run Maven Goal", you will be directed to the mentioned context menu.
This works on Intellij IDEA 2020.3.1
Context Menu

Where to tweak an Eclipse to change the default settings used when creating a new Workspace?

We use Eclipse with projects in CVS. It has proven to be the simplest to create a new workspace when having to deal with another branch or application, and then use Team -> Import project set to get all the needed projects from CVS.
Unfortunately, I then have to do the following each and every time:
Change text font to Consolas 11 pt
Disable spell checking in text editors
Run everything in the background
plus some more of the same.
I'd like to change the standard values once and for all in the Eclipse distribution files after having unzipped the distribution (Windows). Where are these defaults located inside Eclipse?
EDIT: For now we just have a preference file which must be read in. An extra step, but works...
EDIT 2014: I've ended up creating a workspace with the settings I want, and then creating a new copy everytime I need a new one. Also handles Maven Central information etc. Accepted the oldest answer saying essentially this.
You can export your settings from a workspace and import them into any other (this basically does what VonC's answer says, but with some measure of error checking).
To do so, in the source workspace select File->Export...->General->Preferences, then select Export All and enter a file to export to, then Finish.
You can then import the preferences into any workspace by doing File->Import...->General->Preferences, browse to the preferences file and hitting Finish.
I have created a clean workspace with all settings i want to have. This workspace i have copied into a save folder i will never delete ;)
When i want to create a workspace for a new project, i copy the confugured workspace and thats it.
I have than configured the svn repository path, code format (you also can import preferences in eclipse for this), view configuration and so on.
Try checking:
<workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings
Some .prefs files could be interesting to copy from one workspace to the next.
(like org.eclipse.team.cvs.ui.prefs which contains any non-default value for CVS settings)
I want to fix the defaults inside Eclipse so the workspace is created with the defaults I want every time.
Hard core solution:
Change the .options file within <eclipse-SDK-3.5-win32>\eclipse\plugins\org.eclipse.team.cvs.core_3.3.200.I20090430-0408.jar (that is the name I have for eclipse3.5)
That is the file with the default values, at least for CVS.
Here's what I do:
Start up Eclipse
Without importing or starting any projects, edit the workspace and make all the config changes you want
Open up the workspace in windows explorer and create a copy of the folder.
Then, any time you wish to use it, copy this folder to your new workspace folder location - you may need to create the new workspace folder first (and definitely call it something different.)
This is what I do anyway. Yes, it's very dirty but it does get what I want pretty quickly!
When importing preferences (Rich Seller's approach above), especially those that were created by someone else, make sure you backup your Eclipse environment first. That's easy, since it's portable - just copy it to a temporary location.
I've totally hosed my Eclipse environment importing preferences in the past, and importing my own preferences, which I exported just prior to importing, did not fix my issues.
Fix the defaults inside Eclipse so the workspace is created with the defaults, If you want every time suggestions, then
Go to eclipse extract path -eclipse\configuration\.settings -> Edit -org.eclipse.ui.ide ->
Change value to true: SHOW_WORKSPACE_SELECTION_DIALOG=true
Similarly in this file you can directly change other default settings.
I find a way to do that:
open <eclipse>\plugins\org.eclipse.cpp.package.cpp_1.4.2.201210131-1456\plugin_customization.ini
and add
folding
org.eclipse.cdt.ui/editor_folding_enabled=true
org.eclipse.cdt.ui/editor_folding_preprocessor_enabled=true
then new project will enable folding by default.
So
You need to know where your prefer locate, in my case, folding is under org.eclipse.cdt.ui, you can try on an project then check <workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings to find it
"org.eclipse.cpp.package.cpp_1.4.2.201210131-1456" should be variable depends on what version you use. whatever it's, you should find "plugin_customization.ini "

Categories