Eclipse Luna no syntax coloring - java

Well I have a problem with one of my classes in Eclipse. In there I define an inner Enum type.
In the picture you can see one of the enum-Constants:https: //www.dropbox.com/s/z9shh52au35mkzy/Pict1.JPG
Now I wanted to add some code to the "setup()" method. Sadly the syntax coloring for the new code doens't show up and even if I create a syntax error inside, it doesn't recognize it. (it works at other places)
https://www.dropbox.com/s/0t6que0pg1hr1tw/Pict2.JPG (can't put pictures in the question yet, I hope you don't mind if I put links there)
Finally, when I save the file and reopen it, the error behaviour is the same, but my pour code looks like this: https://www.dropbox.com/s/9lqzchv4xrnpau6/Pict3.JPG
As you can see, even in the other enum constants, there is just color at keywords and things outside of methods. (If I remove the added code and reopen, it works as if nothing hab happened)
So my question is, how can I fix this?
Thanks in advance.

Related

JComboBox: arrow-button should be shown at any time

If a JComboBox is not selected, the arrow-button on the right is not shown. This leads to the fact that a combo-box cannot be distinguished from a normal textfield.
The question is now: how is it possible to show the arrow-button permanently? I alrady came across BasicComboBoxUI.createArrowButton() etc., but I did not find out the mechanism of hiding / showing the arrow-button.
Can anyoune give me a hint how to show the arrow-button permanently ?
Can you add below code as first line in your main method.
Toolkit.getDefaultToolkit().setDesktopProperty("win.xpstyle.themeActive",Boolean.FALSE);
and then check your program.
sorry for the inconvenience. Everything is clear now. In have been told that we use a special framework which changes the behaviour. This information would have been useful if given to me earlier... :-(

extension of eclipse XMLMultiPageEditorPart - trigger refresh of tree-view manually

I am working on an eclipse-plugin which makes use of a custom XMLMultiPageEditor by extending XMLMultiPageEditorPart and XMLTableTreeView by extending XMLTableTreeViewer the second one as well implements a IResourceChangeListener.
I provide this plugin in eclipse-mars and eclipse-neon, however the wired behavior only shows up in eclipse-neon.
The editor works fine so far, the only problem is, that the tree-view is completely blank when a related xml-document is opened with it:
I can even modify the document in the source-view and save it .. the tree-view stays blank.
The only events which bring the tree-view to life are:
re-size the editor-window with the mouse
open some other document and than switch back to the tab of the open xml-doc.
After that, the tree-view works like it should. If I now change the xml in the source-view, the tree-view is updated immediately.
Any ideas how I could trigger a refresh of the tree-view manually ?
Is this maybe a bug in eclipse-neon ?
Ok, the problem seems to be, that the x/y size of the TreeViewer in eclipse-neon is initialized with (0,0). Here a hack to fix that:
...
public class MyXMLTableTreeViewer extends XMLTableTreeViewer implements IResourceChangeListener{
....
public MyXMLTableTreeViewer(Composite parent, IEditorPart parentEditor)
{
super(parent);
....
Point size = getControl().getSize();
size.x = 1000;
getControl().setSize(size);
}
It seems to be sufficient to only set x to some value ... 10 already gives an image, but the "node" section than looks a bit pressed, so I picket 1000.
Even if it is just internal API, it looks like a bug for me. So if you are further interested, take a look to the eclipse bugreport.
Both XMLMultiPageEditorPart and XMLTableTreeViewer are in internal packages. This means that they are not part of the Eclipse APIs and can be changed by the Eclipse developers without warning (see Eclipse API Rules of Engagement).
It may well be the case that something was changed between Eclipse Mars and Neon. You cannot rely on internal classes working the same between releases. It is not an Eclipse bug because you are not using official APIs.

Autoscroll code isn't working: cannot find symbol

I'm trying to use the standard auto-scroll code I've been seeing copypasta'd everywhere:
DefaultCaret caret = (DefaultCaret)textarea.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
It's placed in the same place I've seen it placed in other codes, right after the creation of the textarea it's associated with.
However, when I compile the code, it gives me the error "cannot find symbol", and points at all instances of DefaultCaret, much like if I had not imported the proper thing into my code.
I have imported ALL of javax.swing, after doing some researching it seems like the code works fine for everyone else.
Seems like I'm missing something simple, but I have no clue what it could be.
Am I supposed to define it earlier in the code?
The DefaultCaret class is not in the javax.swing package. It is in the javax.swing.text package.
Reference: http://docs.oracle.com/javase/7/docs/api/javax/swing/text/DefaultCaret.html
If you're still having problems, please post a Minimal Complete Example that demonstrates the problem. The code snippet you provided is likely not enough for others to help you should your problem persist.

Eclipse content assist not working in some parts of code

I am using Eclipse Juno and have never had any problems with it, until its content assist stopped working only in some parts of my code. The code below shows what I am talking about:
mWTBatch.setText("Here content assist works");
medCopyBtn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
mWTBatch.setText(mRTBatch.getText());
mWTExp.setText(mRTExp.getText());
mWTName.setText(mRTName.getText());
mWTQuantity.setText(mRTQuantity.getText());
/* Here content assist is not working */
}
});
mWTBatch.setText("Here it is working again");
That piece of code is just inside one method of my class. The problem is that it works fine inside the methods of the class, but inside objects (new ActionListener(){}) it returns "No default proposals". It has this behavior when I either use "Ctrl+space" or type in "." after the object I want to get suggestions of. I've already searched here for the solution and googled it, but couldn't find a solution. What I have already tried:
Window->Preferences->Editor->Content Assist->Advanced and checked Java Proposals. It didn't work. I've even tried checking it myself, without just using Restore Defaults. I also tried the Java Proposals from the other table. Nothing. At last I tried checking all the fields with Java on them. Nothing worked.
Deleted my workspace folder completely, created a new one and imported my project. As my project is from an SVN repository, I used the project folder inside "trunk" folder, but I didn't copy the content of the folder to the workspace when importing (I need it to be in the repository). Still nothing, it continues with the error.
I reproduced the same situation of the code above into another class of another different project, which was also imported to the workspace, but having its content copied to it. The content assist worked for that one.
I then re-imported the project with the original code from above, but this time copying its content to workspace (which means it had nothing to do anymore with the SVN repository). It didn't work either.
I also checked if the ctrl+space is bind to the content assist on Eclipse settings and it is ok. I also checked if it had nothing to do with advanced key settings of Windows 7 language bar. I had seen on the internet that could be problem, but it was not my case.
I even created a new Java project on the workspace and copied the .java files one by one from the old project, set all the build path manually and in the end it still doesn't work.
For all the first four cases above I also cleaned the projects and closed and reopened them, not forgetting to refresh it after each action. Could anyone tell me how to fix this? I would like to find a solution to this problem, so that others may not be like me on it for 2 days. I think my question is important because I am gathering here many probable solutions found by googling the problem and from StackOverflow, and nothing solved it.
I stumbled into this issue the other day, and after seeing this post thought that I'd have to just live with it.
However, I did find a "hack" around it:
mWTBatch.setText("Here content assist works");
medCopyBtn.addActionListener( //<---------------------- Problem arises because we're inside a function declaration ...
new ActionListener()
{ // <--------------------------------------------- ... yet we're trying to write a function
public void actionPerformed(ActionEvent e)
{
/* Here content assist is not working */
}
}
);
mWTBatch.setText("Here it is working again");
From the content assistants point of view, this is just plain wrong, so we need to give it a little help:
mWTBatch.setText("Here content assist works");
medCopyBtn.addActionListener(
new ActionListener()
// <--------------------------------------------- CURLY BRACKET MISSING
public void actionPerformed(ActionEvent e)
{
/* Here content assist IS WORKING */
}
}
);
mWTBatch.setText("Here it is still working");
This will obviously give you an error upon compilation time, but it gives you full access to the content assist for the rest of the function declaration.
Also, it doesn't matter which curly bracket you remove from inside the function declaration, so long as it's an opening curly bracket.
One other point, if you only remove the opening curly bracket like I did above, then eclipse will NOT add in another closing curly bracket automatically for most cases (because by the time you enter the new opening curly bracket, you've equalised the opening vr closing of curly brackets). You can get around this by deleting the closing curly bracket as well, but then you have to remember to put two curly brackets back.
Hope that helps the 1165 views this question has garnered over the past year =)
Do a search for "Change display language" on the start menu. 'Change keyboards' > Look to see if you have any non English keyboards under 'General' > 'Installed services'. If you have more than just English then pressing Ctrl+Spacebar is changing your focus from Eclipse to the language selector on the taskbar. Remove any other keyboard languages from the list if that is your problem.

Reposition declarations in Netbeans GUIBuilder

So, I am designing a small Interface for an application with the netbeans GUI-Builder,
and my problem is, that the position of the Swing-Elements - declarations is not changeable? Or at least I don't know how.
My ScrollPane needs the Textarea "inside" it as parameter for construction, but in the generated code the TextArea is declared below the Scrollpane.
I tried changing it with N++ and it worked, but everytime I change the custom code section it replaces the declaration again.
Is there any way to accomplish a custom positioning?
AFAIK, there is unfortunately no way to re-position auto generated code in NetBeans. Have you considered perhaps moving the constructors functionality to another method and calling that after the auto-generated code is finished? Something like scrollPane.setTextArea(textArea);?
There is a similar question concerning moving code on the Oracle forums here.

Categories