My question is almost same as this.
The only difference is that I want the custom menu on top, like File -> New -> CustomMenu. CustomMenu should be the first in the New option.
I saw the answer to the linked question. It says
To add to the list of new wizards shown in the main part of the New menu you must use the org.eclipse.ui.perspectiveExtensions extension point to define a newWizardShortcut for your new wizard.
Well, I tried this but I could only get my Wizard in "Other", not in the list visible directly.
Can anyone tell me how to get the custom menu on the top?
The relative part of my plugin.xml is as follows:
<extension
point="org.eclipse.ui.newWizards">
<wizard
class="plugin.com.MyWizard"
id="plugin.com.MyWizard"
name="Inception">
</wizard>
<category
id="plugin.com.myCategory"
name="myCategory"
parentCategory="org.eclipse.pde.PDE">
</category>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.pde.ui.PDEPerspective">
<newWizardShortcut
id="plugin.com.MyWizard">
</newWizardShortcut>
</perspectiveExtension>
</extension>
"plugin.com" is my plugin project name here. I may not be following the naming conventions but that is not the concern here.
Also, is category needed?
Related
In a mixed mode Eclipse RCP application, I'd like to change the application window title to something like "Great App v1.3.22".
I basically have application (3.x based) and product (4.5 (Mars) based) split up into two plugins (following a helpful blog post describing how to use 3.x views in Eclipse 4, I need the CNF).
At the moment, the title is "got" from the org.eclipse.core.runtime.products extension point defined in the product plugin:
<extension
id="my_product_id"
point="org.eclipse.core.runtime.products">
<product
name="Great App"
application="my.application">
</product>
</extension>
Can I use a variable in the <product name> property? If so, what variables are available? Or can this be achieved by "overriding" the window title via the Trimmed Window entry in Application.e4xmi, and again what variables would be available? Or do I have to resort to ancient ways and set the title programmatically in the old ApplicationWorkbenchWindowAdvisor (which, however, wouldn't be available if I was able to switch to a pure E4 app once the CNF is available as a native E4 plugin)?
There are no variables you can use.
You can change the main window title in the LifeCycle class. The #ProcessAdditions method is the earliest you can do this:
#ProcessAdditions
public void processAdditions(MApplication app, EModelService modelService, IApplicationContext applicationContext)
{
MWindow window = (MWindow)modelService.find("id of main trimmed window", app);
window.setLabel("new text");
}
I am not sure where you want to get the version from. One possibility is a property in the product definition:
<extension
id="my_product_id"
point="org.eclipse.core.runtime.products">
<product
name="Great App"
application="my.application">
<property
name="version"
value="1.3.22">
</property>
</product>
</extension>
You will have to maintain this property manually or do something in your build to set it.
You can access this using the IApplicationContext
applicationContext.getBrandingProperty("version")
Recently I need a function that when click the Project->clean item from the Eclipse menu and then do a re-validation to do some checking, so I need to add some code in a method which is triggered by clicking the Project-clean item. And I look up some materials, and seems that Builder and Nature can handle this, and I also try to add some extension in my plugin.xml like,
<extension id="nature" name="Nature" point="org.eclipse.core.resources.natures">
<runtime>
<run class="xxx.xxx.xxx"></run>
</runtime>
<builder id="MyDesigner.builder">
</builder>
</extension>
<extension id="builder" name="Builder" point="org.eclipse.core.resources.builders">
<builder hasNature="true" isConfigurable="false">
<run class="xxx.xxx.MyBuilder"></run>
</builder>
</extension>
And in the MyBuilder class, I add some code in the method "protected void clean(IProgressMonitor monitor) throws CoreException {...}"
After that I run the Eclipse Application to start the sub-studio, and then click the Project->Clean, but the clean method doesn't trigger? So is this way OK to achieve that? Or does anyone have any idea for it? Thanks a lot for all your help!
I have an RCP application based on the 3.x platform. The application enables the user to view and modify a single data set. Some ViewParts are only observers of part of the data set, whilst other can modify data. When a ViewPart modifies same data I want to be able to save the data set, preferably using the standard org.eclipse.ui.file.save command, independent of which ViewPart that currently has focus.
My approach is to define extensions to the plugin.xml like so:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.ui.main.toolbar">
<toolbar
id="se.file.maintoolbar"
label="File Toolbar">
<command
commandId="org.eclipse.ui.file.save"
label="&Save Project"
style="push"
tooltip="Save the project">
</command>
</toolbar>
</menuContribution>
</extension>
.
.
.
</plugin>
In my implementation of ActionBarAdvisor I register actions:
#Override
protected void makeActions(IWorkbenchWindow window) {
saveProjectAction = ActionFactory.SAVE.create(window);
register(saveProjectAction);
}
My ViewParts, three kinds, all implements the ISaveablePart2, it feels wrong, but haven't seen any other approach. Two of the views control their isDirty() function, so save buttons are enabled when they have focus and if they are dirty, but if one of them is dirty, save should be enabled in all views, not just the dirty view. Enabling save functionality for the third view, without indicating dirty, seems impossible.
Anybody know a better approach? I guess I can create my own handling of saving, but would be good to use standard as much as possible.
You could call firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY) in all the views that should be shown as dirty.
I've implemented a custom toolbar in my RCP application. I'm also using the org.eclipse.ui.menus extension to contribute commands to the custom toolbar.
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="toolbar:com.my.custom.toolbar.identifier.toolbar">
<command
commandId="com.my.command.id"
icon="icons/my_icon.png"
style="toggle"
tooltip="My Toggle Tooltip">
</command>
</menuContribution>
</extension>
I've written the code that finds these IConfigurationElements and turns them into CommandContributionItems which I use to add them to my custom toolbar.
I have some toolbar items that are of type toggle, and I need these to update their UI using the IElementUpdater interface that the command's handler implements.
I also contribute this command to a standard Eclipse menu... like "toolbar:org.eclipse.ui.main.toolbar" and its toggle state is updated via the IElementUpdater when appropriate.
I'm probably missing something in my custom toolbar that hooks it up to the IElementUpdater, but I have no idea where to start looking to make this work.
I've used the IElementUpdater, but not for cases to update the toggle state, as this should be done by the connection to the respective Command. There exist, however, some problems in Eclipse 4 which I have already started to point out in a blog article.
What Eclipse variant are you using? 3.x or 4.x? There exists a bug in 4.x concerning the synchronization of contributions and their command states.
Is it possible to override the layout of a built-in perspective in my Eclipse-RCP product?
In particular, I wish to add a custom view and change the layout of the Debug perspective. I know how to do it with a custom perspective (IPerspectiveFactory.createInitialLayout()). I'd want that my custom layout to be permanent -survive the "Reset perspective" command.
Create a class that implements IPerspectiveFactory.
Add a perspectives extension to your plugin.xml. Here's one of mine.
<extension point="org.eclipse.ui.perspectives">
<perspective
class="gov.bop.cobolsupport.perspectives.CobolPerspectiveFactory"
icon="icons/ispf_editor.gif"
id="gov.bop.cobolsupport.CobolPerspective"
name="Cobol"/>
</extension>
Your users can change your perspective, and save their changes if they wish. That's built into Eclipse.
However, when you extend your perspective, the Reset Perspective command resets the perspective to how you defined it in your Perspectivefactory class.
Extending a perspective is possible by using the extension point org.eclipse.ui.perspectiveExtensions.
Plug-ins can add their own action sets, views, and various shortcuts
to existing perspectives by contributing to the
org.eclipse.ui.perspectiveExtensions extension point.
To extend the default debug perspective paste the following code in your plugin.xml:
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.debug.ui.DebugPerspective">
<view
ratio="0.5"
relative="org.eclipse.ui.views.TaskList"
relationship="right"
id="com.jens.customdebug.views.SampleView">
</view>
</perspectiveExtension>
</extension>
You have to define a relative view (in my case the task view named org.eclipse.ui.views.TaskList) and the id of your own view (in my case com.jens.customdebug.views.SampleView)
Source:
To get further information how to use this extension point, take a look here.
For the configuration markup of this extension point you may also take a look at this page.