Custom Eclipse project type doesn't save (Plugin development) - eclipse-pde

I've been following this tutorial to create my own custom project type and for the most part it works. Unfortunately when stepping through the my new project wizard it doesn't create a new project on "Finish".
My first thought was that I had missed this step:
Have performFinish() return true.
But I definitely have that done.
public class NewProjectWizard extends Wizard implements INewWizard {
#Override
public boolean performFinish() {
return true;
}
}
There isn't much else to do. The test environment can create other project types just fine - like "Java" - their folders are created in runtime-EclipseApplication home folder correctly. I tried the Alt+Shift+F1 trick to look at other plugins' source and cannot see what the crucial step is.
What is missing? Are there other good resources which cover this? Nothing shows in the Error Log view, is there another log somewhere?

You have to do the actual work of creating the project in the performFinish() implementation. If you only seek to create a new Project, maybe you'd like to extend org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard instead of the plain "Wizard"?

Related

UI Toolkit Custom Inspector Disappeared in Playmode Unity

I have created a custom inspector using the UI Toolkit. The way I initialize the UI Document is as follows:
public VisualTreeAsset uXML;
This uXML is assigned through the inspector. Then in CreateInspectorGUI:
root = new VisualElement();
if (uXML == null)
{
Debug.Log("UI Document is " + documentName + " null");
return root;
}
uXML.CloneTree(root);
The root is the main root of the UI document (I am using UI Toolkit).
The problem is that when I enter play mode, the Inspectors disappears as shown:
I’m going to assume that you used a “Default Reference” for your editor script. Unfortunately, the default reference is only deserialised when you're in "Edit" mode. As soon as you go to "Play" mode, the reference is null.
The general way to get around the issue is to search for your asset when you create the inspector window:AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/PathToYourFiles/YourFile.uxml")
Unfortunately, if you move your files somewhere else, you need to go in an update the string file location. Because it's a string path, there's no reference to follow the file if you move or rename the file. It's not clean, but it's easy, and gives you your inspector when in Play mode.
I did a quick search on the issue. Looking at this document, it seems Unity also suggest using Addressables or the Resources folder.
Because you don't really want the assets to follow you into a final build, I prefer placing them into an Editor folder, and just making sure I'm careful when moving or renaming the files. In one project, I made an automated process that "found" the file for me. It involved using a ScriptableObject and Assembly Reloads but I'm still in two minds whether the effort was worth it.

Integrating EMF and view in plugin project

I created an EMF project and tested using <>.editor project generated by .genmodel file by creating a new project and a file through "Example EMF Model Creation Wizards". Is there any way that a view (in plugin project) can be created directly (probably project & file are automatically created when user runs the application)? I dont want the user to create these things. It should be automated and presented in a view.
In the .genmodel file, set .genmodel --> All ---> Runtime Platform to RCP. This creates an RCP app that does not use all the plugins of the IDE. If you want, you can generate your app to run in the IDE... However, for this answer I will simplify and assume you generated an RCP app. Go into the XXX.editor generated plugin, and into the .plugin file --> extensions. Add a new (org.eclipse.ui.views) View by declaring a new View extension -- see the Sample View for a template. Make sure to keep track of the ID you give this new View extension. Similarly add a new PerspectiveExtension extension. Add a reference to this new PerspectiveExtension with your unique View ID. In the View extension, click on the class link, this will create a skeleton ViewPart class. It is a good idea to put a public static final String YOUR_VIEW_ID = "com.yourplugin.ViewID" in that class.
This will get you started and if you added your new view to your perspective, it should be visible when running your EMF based RCP app.

Change display name of unit tests in JUnit Eclipse plugin

Is it possible for an Eclipse plugin to change the display name of unit tests run by the default Eclipse JUnit plugin?
Some background: I'm trying to create a plugin which will display unit test names (in the JUnit view in Eclipse) a bit different from the actual method name. If the actual test method name is "anEmptyCollectionHasSizeZero" I want it to be displayed in the Eclipse JUnit view as "An empty collection has size zero".
I've managed to display the test method names in the way described above as a separate view in a plugin, but would as I said like to get this feature integrated in the normal JUnit view. I tried to see if I could find a related extension point, but could not find anything. Is it possible to do this?
Also, is there a plugin which already does this, or similar?
I don't know the exact answer, but the best place to start is likely by looking at the code for org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart (in the plug-in org.eclipse.jdt.junit). That ViewPart is the JUnit view that you see in Eclipse.
It looks like org.eclipse.jdt.internal.junit.model.TestCaseElement.getTestMethodName() might be the place where the name is obtained from. Maybe you can trace how/when those elements are created and inject some other name. It looks like the implementation class is internal though (org.eclipse.jdt.internal.junit.model.TestElement), so you might be out of luck.
I'd suggest asking on the JDT forums about the possibility of doing this.
There don't seem to be any plugable way to change the label or the colors used.
(I had hoped the label provider used for the TestViewer was based on a PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator() so the image, label and color could be decorated, but that does not seem to be the case...)
You may want to look at the jnario sources. They have implemented something like that, where the JUnit window displays something that is surely not a stack frame.
You may use the setName() method of the class junit.framework.TestCase (or the constructor with the name parameter).
public MyTestCase() {
super("This is my JUnit test");
By default a TestCase defines the methods to be executed by it's name, which we have just overwritten. To make it runnable we have to overwrite the run method like this.
#Override
protected void runTest() throws Throwable {
testMyTest();
}

How to use GWT designer with Eclipse GWT plugin?

Sorry but I see no way to use it at all!
If I create GWT project with sample code, then SDK is generating a page with a HTML table where positions for sample TextBox-es and Button are already marked. So, if I open sample file with GWT designer and move button slightly down-right, I will get errors during run.
If I create GWT project without sample code, then GWT designer appears to be unable to open file with empty GUI.
Is there any way to design GUI from scratch or to see GWT designer usage sample?
Thanks
The problem is when you want GWT to create sample code for you, it puts the container parts of layout hard-coded in your projects html file. The generated sample uses RootPanel.get("someId").add(someWidget); to access these containers. When you open designer and move these widgets around, designer generates RootPanel.get("someId").add(someWidget,left,top); which doesn't work with this method.
On another note, when you want to create a class from scratch and open it with designer, you can simply add a reference to RootPanel to get around "this is not a gui class issue" such as :
public class SimpleClass {
RootPanel r = RootPanel.get();
public SimpleClass() {}
}

Programmatically showing a View from an Eclipse Plug-in

I have a plug-in to an Eclipse RCP application that has a view. After an event occurs in the RCP application, the plug-in is instantiated, its methods are called to populate the plug-in's model, but I cannot find how to make the view appear without going to the "Show View..." menu.
I would think that there would be something in the workbench singleton that could handle this, but I have not found out how anywhere.
You are probably looking for this:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("viewId");
If called from handler of a command
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(viewId);
would be better, as I know.
I found the need to bring the view to the front after it had been opened and pushed to the background. The activate method does the trick.
PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.activate(workbenchPartToActivate);
NOTE: The workbenchPartToActivate is an instance of IWorkbenchPart.
In e4, the EPartService is responsible for opening Parts. This can also be used to open e3 ViewParts. Instantiate the following class through your IEclipseContext, call the openPart-Method, and you should see the Eclipse internal browser view.
public class Opener {
#Inject
EPartService partService;
public void openPart() {
MPart part = partService.createPart("org.eclipse.ui.browser.view");
part.setLabel("Browser");
partService.showPart(part, PartState.ACTIVATE);
}
}
Here you can find an example of how this works together with your Application.e4xmi.