Refresh Navigation View in eclipse application - java

I want to Refresh Navigation View in eclipse application. The project explorer in the eclipse application does not show the projects , untill it is refreshed or right clicked on it. How to refresh it programmatically? And where to put this code?

If at all possible you should use the create methods of org.eclipse.core.resources.IFile and IFolder to create files and folders.
If that is not possible use the refreshLocal method of IProject or IFolder to update the workspace.
All these calls will generate one or more IResourceChangeEvent events which will be seen by views and anything else that needs to know about resource changes. The view will update automatically when it sees these events.
To reduce the number of resource change events generated enclose your modifications in a WorkspaceJob or WorkspaceModifyOperation or IWorkspaceRunnable.

Thanks for the reply #greg-449. refreshLocal is useful, but i was missing a small piece of code and refrshing was not needed. Eventually i figured out the answer. I had to ovverride a function as I mentioned in one of my comments. I was trying to use the getDefaultPageInput in a wrong way and hence i was getting errors. Eventually i removed the erroneous code in my project and added following to WorkbenchAdvisor.java
#Override
public IWorkspaceRoot getDefaultPageInput()
{
return ResourcesPlugin.getWorkspace().getRoot();
}

Related

Execution issue with Maven/Tycho

I have an eclipse RCP application based on the 3.x API. My application consists of several perspectives where each contains several views and editors. The first perspective starts on the start up of the application and the navigation view is defined in the main plug-in. The problem is with the other perspectives where the views are defined in different plug-ins for a better code maintenance.
I add my views within the main plug-in with a perspective extension and the following piece of code:
public class Perspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
layout.addView(NavigationView.ID, IPageLayout.TOP,
IPageLayout.RATIO_MAX, IPageLayout.ID_EDITOR_AREA);
}
}
The strange thing is that it all works perfectly when I run the application within eclipse, but as soon as I make a build with Maven/Tycho and execute the created application all the perspectives defined in the plug-ins don't work anymore.
The issue is when I add a new perspective this perspective opens but it doesn't contain any views, just a grey background.
I already added a few println() statements for debugging purposes and it seems as the Activator of my respective plug-in, which contains the view, is never invoked. That would also explain why I cannot see any views in my perspective because the application cannot find the respective view defined in the view extension of the respective plug-in.
I added the following println() statement to my createInitialLayout method from above:
System.err.println(layout.getViewLayout(NavigationView.ID));
The output was null, which strengthen my previous point.
The problem is now what could be the reason for that? Why doesn't my plug-in start?
I also already did another experiment where I directly called one of the methods defined in the plug-in and again the Activator of the plug-in wasn't called.
The Bundle-ActivationPolicy of the plug-in is set to lazy.
Any suggestion what my next steps could be to track the problem down?
Maven/Tycho doesn't report any problems and I use the same target platform for both, eclipse and Maven/Tycho, so I can also exclude any dependency problems.
I really would appreciate any help/support :)
Best regards,
Tom

RCP Start the product with Clear Workspace

So I've come across this weird bug in RCP Apps.
I've created a new RCP App with the Mail Template. I've added a new org.eclipse.ui.menus extension with a menuContribution with locationURI:toolbar:org.eclipse.ui.main.toolbar. To that, I've added a command with a little icon.
Now, if I start the app without Clear Workspace in the Debug Configurations, my action appears AFTER the Quick Access text widget. Not only that, but a few other bugs come along (e.g. views aren't closing, too many views are opening at once). This is not a one-time thing, i.e. I have to start the app with Clear Workspace each time.
This method of adding actions on the coolBar is non-deprecated. Why does it behave like a spoiled brat?
Without Clear Workspace:
With Clear Workspace:
There is a long discussion on the Eclipse forums about this here with a bug filed as a result here.
The bug is not scheduled to be fixed until Eclipse 4.4M5 but using one of the workarounds to remove the Quick Access control discussed here should help.

Unable to add Servlet in eclipse

I am setting up a simple server project in eclipse (using a Glassfish as a server if it's relevant). I cannot seem to add a Servlet though. Unlike another question I've seen where a project cannot be selected I can select the project, but the finish or next buttons remain disabled. I tried manually creating a class that extends HttpServlet ahead of time and selecting but it the finish and next buttons are still disabled:
I am running Eclipse 4.3, and I have tried starting it with -clean. Beyond that I'm not sure what to try.
EDIT:
As I said I orginally tried to create a new class using the dialog and only when that did not work did I create my WebService class. Here is what I orignally tried (using NewWebService as the name since WebService now already exists)
Although the question is already marked as answered. There could be other reason to have "next" or "finish" buttons grayed out in "Create Servlet" Dialog.
This could happen, if the PROJECTNAME/WebContent/WEB-INF/web.xml file is corrupt by i.e. misspelled tags or attributes.
#Fr33dan: Check if dynamic web Module is checked in in your project facets.Also is this a maven project?
In the screen shot you provided it seems like you are checking the box Use an existing Servlet class or JSP. Just uncheck it and it should work fine, you will be able to create new class.

RCP Application coundn't find new added view

I am using Eclipse Juno for RCP RAP developer. I have created a Plug-in Project with a single view and it runs normally. But whenever I tried to add a new view into that workbench, the window dosent update. Also if I change the id of the current view, it also not working. And if I delete the current view, it also showing it. As a whole, the view part is not updating of the application. Anybody knows any answer ?
Your changes doesn't get applied correctly.
Eclipse 4 persists certain user changes in your application. During
development this might lead to situations where changes are not
correctly applied and displayed, e.g. you define a new menu entry and
this entry is not displayed in your application.
You have to add -clearPersistedState as a program argument for your application or set the Clear flag in the Main tab of your Run configuration.
Take a look here for further information and a more detailed description.

Eclipse RCP: Why is the view missing when running as a Product?

I'm brushing up my Eclipse RCP skill by trying to enhance my one-year-old side RCP application. This application has one perspective, and this perspective has 3 views, and I'm adding another view into the same perspective. To add this new view, I added it in the MANIFEST.MF file under Extensions tab and created the Java file for it.
When I run it as an Application, it works. I see all 4 views in the application. But, when I run it as a Product, that new view is missing. It almost seems like the new view is not registered in the Product. There's no error in the console log either. I think I must be missing a step here, but I can't seem figure out here... pretty frustrating!
Note: The views are added into the perspective programmatically (in Java code), not through MANIFEST.MF file. I just realized that even when I change the existing view's layout (ex: size, or location), it doesn't get reflected when running as a Product either, but it works when running as an Application... sigh!
Note: I commented out all the code in my perspective class, in another word, all the views are removed from the perspective. When I launch the Product, I'm still seeing 3 views in the application. I'm thinking there's something to do with caching, but I'm just bummed now.
Any helps are greatly appreciated here! Thanks much,
Okay, after aimlessly clicking around, I figured out the solution. The workspace data needs to be cleared to pick up changes from the perspective.
To do so...
Right click the product file
Choose "Run Configurations..."
Under "Main" tab, check "Clear" checkbox and "workspace" radio button.
Run it.
Hope this will save some of you from troubles.
I've been bitten by this a couple of times until I figured out the easiest workaround: it's sufficient to reset the perspective. There are two ways to achieve this:
Right-click on your perspective in the perspective selector bar at the top right and click on Reset.
Switch to your perspective and then go to Window | Reset perspective....
After that, the changes to your perspective should be picked up.

Categories

Resources