WiX Property Reference Another Property - reference

I am trying to create multiple shortcuts to my application that pass different arguments on the commandline by using the Arguments attribute of the Shortcut element. I want to be able to reference an existing property from another property in my WiX file.
I want to be able to create a shortcut by referencing the ARGUMENTS property via:
<Component Id="MyAppProgramMenuShortcut" Guid="MY-GUID-HERE">
<RegistryValue Root="HKCU"
Key="Software\[Manufacturer]\[ProductName]\MyAppShortcut" Type="string"
Value="" KeyPath="yes" />
<Shortcut Id="ProgramMenuShortcutMyApp" Directory="ProgramMenuDir"
Name="MyApp" Target="[SHORTCUT_TARGET]"
Arguments="-jar myApp.jar [ARGUMENTS]" WorkingDirectory="INSTALLDIR"
Icon="logo.ico" />
</Component>
I've tried something equivalent to:
<Property Id="PROGRAM_FILES">C:\Program Files</Property>
<Property Id="MY_APP_DIR">[PROGRAM_FILES]\MyApp</Property>
<Property Id="ARGUMENTS">[MY_APP_DIR]\fileA.xml [MY_APP_DIR]\fileB.xml</Property>
but then I get this warning when passing it through candle.exe:
warning CNDL1077 : The 'MY_APP_DIR' Property contains
'[PROGRAM_FILES]' in its value which is an illegal reference to
another property. If this value is a string literal, not a property
reference, please ignore this warning. To set a property with the
value of another property, use a CustomAction with Property and Value
attributes.
So, based on the suggestion in the warning I switched to something equivalent to:
<CustomAction Id="PROGRAM_FILES" Property="PROGRAM_FILES" Value="C:\Program Files"/>
<CustomAction Id="MY_APP_DIR" Property="MY_APP_DIR" Value="[PROGRAM_FILES]\MyApp"/>
<CustomAction Id="ARGUMENTS" Property="ARGUMENTS" Value="[MY_APP_DIR]\fileA.xml [MY_APP_DIR]\fileB.xml"/>
and I get no warnings or errors, but the problem is that when I install the application the shortcuts don't have the arguments in the target field.
Am I not doing something that I should be doing? Is there a way to do what I want to do?

You don't need properties for Program Files or your product's install directory. Use [#FileId] to refer to the complete path to that file.
Also, if you want multiple shortcuts, just have multiple Shortcut elements with different Arguments attributes. If you want one of several shortcuts, you can have multiple Components with Shortcuts and use a Condition to install only one of them.

Related

How to display and process "non model" properties in create-wizard in Backoffice

I am trying to create a new create-wizard for a custom item type and provide some "non model" fields in the wizard. These fields do not directly correspond to model attributes we are trying to create.
I would like to be able to process these values later (possibly from a prepare interceptor) where I can use these to do some lookup logic/processing and then set other attributes on the item.
I know I can technically add these "non model" properties to the actual item model itself, but I would like to avoid having unnecessary attributes that are only really needed for the wizard.
Is there any way to create a wizard as such, and be able to access these property values later (maybe in prepare interceptor for example) and process them as needed later? Without having to add these properties to the model itself?
<wz:step id="step1" label="create.custom.essential.label" sublabel="create.custom.essential.sublabel">
<wz:info id="step1.intro" position="top" label="create.custom.essential.intro" />
<wz:content id="step1.content">
<wz:property-list root="newItem">
<!-- actual model attributes -->
<wz:property qualifier="code" />
<wz:property qualifier="catalogVersion"/>
<!-- I'd like to have other fields here, that are NON model properties -->
<wz:property qualifier"nonModelAttribute1">
<wz:property qualifier"nonModelAttribute2">
...
</wz:property-list>
</wz:content>
</wz:step>
You can try to use SPEL
{#bean.method(#this) != null ? #bean.method(#this).getCode() : ''}

How can I readonly attribute in Backoffice config.xml dynamic

I want to set/unset readonly attribute of certain field in backoffice editor area based upon the property that is defined in local.properties.
I tried doing following:
<editorArea:attribute qualifier="xyz" readonly="spring.getBean('configurationService').getConfiguration().getBoolean('make.me.readonly')"/>
but there was schema validation error and also it didn't change the field attribute.
First you need to register "configurationService" so that it could be used in config.xml.
By default only the services mentioned in,
platformbackoffice.available.bean.names.for.spel=labelService,enumerationService,exceptionTranslationService,backofficeTypeUtils can be used within config.xml.
To include "configurationService" add the below piece of code to your backoffice-spring.xml.
<cng:list-extender bean="fixedBeanResolver" property="availableBeanNames">
<cng:add value-type="java.lang.String">
<value>configurationService</value>
</cng:add>
</cng:list-extender>
And then make the service call from config.xml,
<editorArea:attribute qualifier="xyz" readonly="#configurationService.getConfiguration().getBoolean('make.me.readonly')"/>

Use of IPageLayout.addActionSet()

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.

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.

Sharepoint List Definition that binds only to my Custom Content Type

I am developing a Sharepoint Solution, that implements a new list. This list has an event receiver attached to a Custom Content type.
I am using VSeWSS 1.3 for this task and it's going ok (the content type gets created, a list is created and bound to the content type, the event receiver triggers successfully.
My only concern is that in the created list, it always show the base Content Type (Item CT with Title field). Through the Web GUI I can hide this content type, but I can't find where to do that in my XML definitions, or make it on the solution to avoid double tasks when deploying.
Any suggestions??
You will have to edit the Schema.xml for your custom list. Find the <ContentTypes> tag and remove any you do not wish to be shown.
Your list definition will have a guid (eg. <Elements Id="0a8594c8-5cf1-492e-88ce-df943830c88c") that will specify the list from the schema xml (e.g.<List Name="... ...Id="0a8594c8-5cf1-492e-88ce-df943830c88c">)
I am not sure what the implementation is for, usually there is a feature.xml to combine the previous xml files together (e.g.<ElementManifests><ElementManifest Location="MyFeature\ListDefinition.xml" /><ElementFile Location="MyFeature\schema.xml" />)
In the schema.xml you need to make 2 changes
in the <List> element add the following attribute:
EnableContentTypes="TRUE"
the <ContentTypes> element should contain a <ContentType> element that specifes your custom Content type.
for example:
<?xml version="1.0"?>
<List
xmlns:ows="Microsoft SharePoint"
Title="List_Title"
FolderCreation="FALSE"
Direction="$Resources:Direction;"
Url="Lists/List_Title"
BaseType="0"
Name="List_Title"
Id="51D716AC-DF9D-4ebb-9F8E-9134EEBB7C39"
Type="100"
xmlns="http://schemas.microsoft.com/sharepoint/"
EnableContentTypes="TRUE"
>
<MetaData>
<ContentTypes>
<ContentTypeRef ID="0x01..." />
</ContentTypes>
Both answers helped me, but I found also that you need to specify the columns again in the List Definition (not only in the Content Type), because otherwise, they won't show up in the list.

Resources