Use of IPageLayout.addActionSet() - menu

I'm defining my own perspective using:
<extension point="org.eclipse.ui.perspectives">
In my implementation of IPerspectiveFactory::createInitialLayout() I want to use IPageLayout.addActionSet() which points to a new actionset. But actionsets are deprecated; what is the recommended alternative?
The reason I want to add a new actionset is I want the Run menu to display debug actions, but not run actions. If I use layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET) I get both. So I figured I'd define my own actionset with just the debug variants in. But I'd like to use a non deprecated API. What's the recom

The alternative is to use the org.eclipse.ui.menus extension point for menu items. However you can't add this to a perspective, instead you have to use the visibleWhen element to control when the menu is shown.
For example this is how the PDE plugin adds a menu to the Navigate menu when the plugin development perspective is active or the search action set is in use:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:navigate?after=open.ext2">
<separator
name="org.eclipse.pde.ui.openPluginArtifactSeparator"
visible="true">
</separator>
<command
commandId="org.eclipse.pde.ui.openPluginArtifact"
icon="$nl$/icons/obj16/open_artifact_obj.gif"
label="%pluginsearch.action.menu.name">
<visibleWhen>
<or>
<with
variable="activeWorkbenchWindow.currentPerspective">
<equals
value="org.eclipse.pde.ui.PDEPerspective">
</equals>
</with>
<with
variable="activeContexts">
<iterate
operator="or">
<equals
value="org.eclipse.pde.ui.SearchActionSet">
</equals>
</iterate>
</with>
</or>
</visibleWhen>
</command>
</menuContribution>
Although action sets are deprecated they are not going to be removed for a long time as a lot of Eclipse code still uses them, so you may just want to stick with them.

Related

Alfresco replace component advsearch

i successfully modified alfresco advseach.
Now i have to replace the original. I really don't know how can i do this, until this moment i was working in share/target but i can't do that anymore. I need to somehow rewrite default url of advsearch. I need that Alfresco call my advsearch instead of default advsearch after clean installation or after command mvnclean.
I think that this should working:
<extension>
<modules>
<module>
<id>ADVSearchExt</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<components>
<component>
<region-id>search</region-id>
<source-id>advsearch</source-id>
<scope>page</scope>
<url>/comp/advsearchext</url>
</component>
</components>
</module>
</modules>
</extension>
It looks like you've created an alternative WebScript for the Component and you wish to swap it out. It's not possible to reconfigure an existing Component configuration as you are trying to do. What you actually need to do is to create one extension to remove the default component (see this blog post) and then provide another component to render your WebScript (see this blog post).
NOTE: On subsequent reading of the question, I've realised that this original answer doesn't directly answer the question, however it does contain useful related information... I'll try and answer the actual question as well!
Assuming you're using Alfresco 5.0 or 5.1 then the only way of accessing the advanced search page (via standard navigation) would be via the drop-down menu option in the header bar.
The header bar is an rendered by Aikau and it is a relatively simple exercise to customize the header bar to navigate to an alternative page when you click on that "Advanced Search..." menu item.
This blog post is the first in a 3-part series describing how you can customize the header bar.
The widget that you need to customize is the "alfresco/header/SearchBox" widget. Unfortunately, at the moment it doesn't off a simple configuration option for changing the page to navigate to. In this scenario you could raise an issue on the Aikau Github page to make a request for this feature to be added. This would require that you wait for the feature to be included in a future release (releases are weekly) and then make use of that new configuration option.
The alternative would be to extend the default SearchBox widget and create a new extension module that swaps out the default SearchBox with your custom version. You would need to extend the postCreate function and remove alfresco/menus/AlfMenuItem that is created and replace it with one that has an appropriate targetUrl.
Unfortunately this is neither the most future proof or simplest solution, but is is possible. The most future proof solution (in terms of working with future upgrades to Alfresco) would be to make the feature request as clearly there are benefits to being able to reconfigure the advanced search page.

Two JSF libraries providing the same renderer

Short Version:
If two JSF library jar files both include a custom renderer for the same family and type, is there any way from within the library itself (i.e. not from the containing app) of specifying which one should be used? Something like assigning a priority, with higher ones used in preference to lower ones?
Longer Version:
I'm using Primefaces in a project and trying to override the provided head renderer with my own:
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>javax.faces.Head</renderer-type>
<renderer-class>com.example.MyHeadRenderer</renderer-class>
</renderer>
</render-kit>
If I put that into the WEB-INF/faces-config.xml of the war file then it's all good, and my renderer gets used.
However, if I try to deploy my code as part of a library jar (my-utils.jar), with the renderer defined in META-INF/faces-config.xml, then the Primefaces one is used. This contains exactly the same definition, so I'm guessing it just depends on the order they get loaded. Indeed, renaming my library to "xx-comps.jar" works, so it would appear that JSF is loading faces-config.xml files from all jar files in alphabetical order, with later entries just overwriting earlier ones.
Is there any way of forcing the selection to my library?
So far, I have these options:
Put my renderer directly into the WEB-INF/faces-config.xml of the war.
Build a custom Primefaces jar with that one renderer definition
removed.
Rename my library and rely on some (undocumented as far as I can
see) behaviour from the JSF loader.
Add a custom renderkit which extends the standard one, and reference
that from my war WEB-INF/faces-config.xml.
The first three all work but are not ideal, as (1) and (2) require changes outside my library, and (3) just looks dodgy as hell....
The fourth is just an idea as I've never written a render kit before so not aware of the effort involved. No idea if it is practical or would work, but it is better than (1) because at least the application only references a single render kit, and does not need to be updated if/when new renderers are added. Happy to put more effort into researching this approach if it seems a reasonable solution.
Also, I'd ideally prefer to use annotations rather than XML:
#FacesRenderer(componentFamily = "javax.faces.Output", rendererType = "javax.faces.Head")
public class MyHeadRenderer extends Renderer {
...
}
Thanks
You can specify the ordering via <ordering> in faces-config.xml of the JAR.
E.g. if you want your utility library to be loaded after all others, then just do so:
<ordering>
<after>
<others />
</after>
</ordering>
If you want to force an explicit ordering, then hook on specifically PrimeFaces, which has a <name>primefaces</name> in its faces-config.xml:
<ordering>
<after>
<name>primefaces</name>
</after>
</ordering>

Ribbon button value rule depending on statecode value

I added a new custom button to quote form ribbon. This button should only appear, if the statecode is active (Value: 1).
I created following CommandDefinition:
<CommandDefinition Id="mySolution.quote.Form.MyButton.Command">
<EnableRules />
<DisplayRules>
<DisplayRule Id="mySolution.QuoteIsActive" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="myFunction" Library="$webresource:new_myLibrary" />
</Actions>
</CommandDefinition>
And following DisplayRule:
<DisplayRule Id="mySolution.QuoteIsActive">
<ValueRule Field="statecode" Value="1" Default="true" />
</DisplayRule>
But if I use this DisplayRule my button never appears. If I remove the rule from CommandDefinition the button is always visible.
I also tried to use 'Active' as value (as shown at the bottom of this post, with the same result.
What is the trick to define a rule depending on statecode? Or did I miss something?
Try using Status text values ("Open", "Draft", "Active", ect.) instead of number values. I have a similar case with Status Reasons. Hope it will help!
I couldn't find anything to verify this, but display rules seem to have issues in the command bar. I had better luck using enable rules, and those actually act like you would expect display rules to act in the command bar. In other words, if a button in the command bar is disabled then it's not displayed. You can read about it in the MSDN documentation.
I think your problem here is that your EnableRules is empty.
However, are you doing that modifications by hand?
If so, use CRM 2011 Visual Ribbon Editor, this tool will do almost all job for you.
I think that your problem is that Statecode should be 0, not 1. Do a sql query on statecode and statecodename (use FilteredView).
Just add simple .js script for updating ribbon. Ribbon updates only on page load. Thats why your button became always unvisible. Here is code sample:
function refreshRibbonOnChange()
{
Xrm.Page.ui.refreshRibbon();
}
Then add web resource and attach it to button click. Simple!

Creating toolbar items pulldown menu-entries programmatically

I searched all over the net but couldn't find a working solution how to create pull-down menu entries for a menu item in a toolbar in Eclipse programmatically. To create them using plugin.xml is smooth, but is there some way to do it from code? Why to do that?
I want to create a little plugin which offers the user the possibility to create a random number of entries which should be accessible thru a single menu item (button) with a pull-down menu in the main toolbar.
I'm quite new to Eclipse plugin development. As I already said doing in plugin.xml is no problem :
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar id="pulldown.items.toolbars.sampleToolbar">
<command
commandId="pulldown.items.commands.sampleCommand"
icon="icons/sample.gif"
tooltip="Say hello world"
id="pulldown.items.toolbars.sampleCommand"
style="pulldown">
</command>
</toolbar>
</menuContribution>
<menuContribution locationURI="menu:pulldown.items.toolbars.sampleCommand">
<command
commandId="pulldown.items.commands.sampleCommand"
label="Message 1" style="push">
<parameter name="pulldown.items.msg" value="Some message"/>
</command>
<separator name="nothing" visible="false"/>
<command
commandId="pulldown.items.commands.sampleCommand"
label="Message 2" style="push">
<parameter name="pulldown.items.msg" value="Some other message"/>
</command>
</menuContribution>
</extension>
I tried to find the information about this commands in the following objects but couldn't find any. Don't bother me using getWorkbenchWindows()[0] this code is executed on plugin startup and there is no active window available.
Activator act = Activator.getDefault();
IWorkbench workbench = act.getWorkbench();
WorkbenchWindow window = (WorkbenchWindow)workbench.getWorkbenchWindows()[0];
CoolBarManager cbm = window.getCoolBarManager();
ToolBarContributionItem item =
(ToolBarContributionItem)cbm.find("pulldown.items.toolbars.SampleToolbar");
IToolBarManager tbm = item.getToolBarManager();
CommandContributionItem citem =
(CommandContributionItem)tbm.find("pulldown.items.toolbars.sampleCommand");
ParameterizedCommand cmd = citem.getCommand();
All objects are valid but they contain neither one of the above defined parameterized commands. All parameters in the commands I could find are only containing the definition but no value is specified.
Have a look at the class attribute of the menuContribution element. Via a this you can write a Java class (extending org.eclipse.ui.menus.ExtensionContributionFactory) that will contribute the wanted menu entries dynamically. In this case all sub-elements of the menuContribution will be ignored.
As an alternative to providing an entire ExtensionsContributionFactory (which would work fine), you could add the dynamic element in your existing XML and then supply a CompoundContributionItem to create the dynamic part of your toolitem dropdown.

I need a WPF split toggle button

Can anobody point me to where I might find one? Pref. free, I dont need to buy an entire control library for one control...
It should look like this (common on ribbon bars), and behave support toggle mode (like radio button, where only one button in the group can be depressed at a time).
I know this is older but I had the same question. In WPF .Net 4.0 you can set the RibbonSplitButton value IsCheckable to True and you get what you are looking for.
<ribbon:RibbonSplitButton Label="Disk" Name="RibbonToggleButtonDisk" LargeImageSource="/Images/drive_med.png" IsCheckable="True" >
<ribbon:RibbonToggleButton Label="Used" Name="RibbonToggleButtonDiskUsed" SmallImageSource="/Images/drive_med.png" IsEnabled="false" IsChecked="True" />
<ribbon:RibbonToggleButton Label="Free" Name="RibbonToggleButtonDiskFree" SmallImageSource="/Images/drive_med.png" IsEnabled="False" />
<ribbon:RibbonToggleButton Label="Total" Name="RibbonToggleButtonDiskTotal" SmallImageSource="/Images/drive_med.png" IsEnabled="False" IsChecked="True" />
</ribbon:RibbonSplitButton>

Resources