| 1 | package WiX3::XML::Shortcut; | ||
| 2 | |||
| 3 | use 5.008003; | ||
| 4 | |||
| 5 | # Must be done before Moose, or it won't get picked up. | ||
| 6 | use metaclass ( | ||
| 7 | metaclass => 'Moose::Meta::Class', | ||
| 8 | error_class => 'WiX3::Util::Error', | ||
| 9 | ); | ||
| 10 | use Moose 2; | ||
| 11 | use Params::Util qw( _STRING ); | ||
| 12 | use MooseX::Types::Moose qw( Str Int Maybe ); | ||
| 13 | use WiX3::Types qw( YesNoType ); | ||
| 14 | use WiX3::Util::StrictConstructor; | ||
| 15 | |||
| 16 | our $VERSION = '0.011'; | ||
| 17 | |||
| 18 | # http://wix.sourceforge.net/manual-wix3/wix_xsd_shortcut.htm | ||
| 19 | |||
| 20 | with 'WiX3::XML::Role::Tag'; | ||
| 21 | |||
| 22 | ## Allows no child tags. | ||
| 23 | |||
| 24 | has id => ( | ||
| 25 | is => 'ro', | ||
| 26 | isa => Str, | ||
| 27 | reader => 'get_id', | ||
| 28 | required => 1, | ||
| 29 | ); | ||
| 30 | |||
| 31 | has advertise => ( | ||
| 32 | is => 'ro', | ||
| 33 | isa => Maybe [YesNoType], | ||
| 34 | reader => '_get_advertise', | ||
| 35 | default => undef, | ||
| 36 | ); | ||
| 37 | |||
| 38 | has arguments => ( | ||
| 39 | is => 'ro', | ||
| 40 | isa => Maybe [Str], | ||
| 41 | reader => '_get_arguments', | ||
| 42 | default => undef, | ||
| 43 | ); | ||
| 44 | |||
| 45 | has description => ( | ||
| 46 | is => 'ro', | ||
| 47 | isa => Maybe [Str], | ||
| 48 | reader => '_get_description', | ||
| 49 | default => undef, | ||
| 50 | ); | ||
| 51 | |||
| 52 | has descriptionresourcedll => ( | ||
| 53 | is => 'ro', | ||
| 54 | isa => Maybe [Str], | ||
| 55 | reader => '_get_descriptionresourcedll', | ||
| 56 | default => undef, | ||
| 57 | ); | ||
| 58 | |||
| 59 | has descriptionresourceid => ( | ||
| 60 | is => 'ro', | ||
| 61 | isa => Maybe [Int], | ||
| 62 | reader => '_get_descriptionresourceid', | ||
| 63 | default => undef, | ||
| 64 | ); | ||
| 65 | |||
| 66 | has directory => ( | ||
| 67 | is => 'ro', | ||
| 68 | isa => Maybe [Str], | ||
| 69 | reader => '_get_directory', | ||
| 70 | default => undef, | ||
| 71 | ); | ||
| 72 | |||
| 73 | has displayresourcedll => ( | ||
| 74 | is => 'ro', | ||
| 75 | isa => Maybe [Str], | ||
| 76 | reader => '_get_displayresourcedll', | ||
| 77 | default => undef, | ||
| 78 | ); | ||
| 79 | |||
| 80 | has displayresourceid => ( | ||
| 81 | is => 'ro', | ||
| 82 | isa => Maybe [Int], | ||
| 83 | reader => '_get_displayresourceid', | ||
| 84 | default => undef, | ||
| 85 | ); | ||
| 86 | |||
| 87 | has hotkey => ( | ||
| 88 | is => 'ro', | ||
| 89 | isa => Maybe [Int], | ||
| 90 | reader => '_get_hotkey', | ||
| 91 | default => undef, | ||
| 92 | ); | ||
| 93 | |||
| 94 | has icon => ( | ||
| 95 | is => 'ro', | ||
| 96 | isa => Maybe [Str], | ||
| 97 | reader => '_get_icon', | ||
| 98 | default => undef, | ||
| 99 | ); | ||
| 100 | |||
| 101 | has iconindex => ( | ||
| 102 | is => 'ro', | ||
| 103 | isa => Maybe [Int], | ||
| 104 | reader => '_get_iconindex', | ||
| 105 | default => undef, | ||
| 106 | ); | ||
| 107 | |||
| 108 | has name => ( | ||
| 109 | is => 'ro', | ||
| 110 | isa => Maybe [Str], | ||
| 111 | reader => '_get_name', | ||
| 112 | required => 1, | ||
| 113 | ); | ||
| 114 | |||
| 115 | has shortname => ( | ||
| 116 | is => 'ro', | ||
| 117 | isa => Maybe [Str], | ||
| 118 | reader => '_get_shortname', | ||
| 119 | default => undef, | ||
| 120 | ); | ||
| 121 | |||
| 122 | has show => ( | ||
| 123 | is => 'ro', | ||
| 124 | isa => Maybe [Str], | ||
| 125 | reader => '_get_show', | ||
| 126 | default => undef, | ||
| 127 | ); | ||
| 128 | |||
| 129 | has target => ( | ||
| 130 | is => 'ro', | ||
| 131 | isa => Maybe [Str], | ||
| 132 | reader => '_get_target', | ||
| 133 | default => undef, | ||
| 134 | ); | ||
| 135 | |||
| 136 | has workingdirectory => ( | ||
| 137 | is => 'ro', | ||
| 138 | isa => Maybe [Str], | ||
| 139 | reader => '_get_workingdirectory', | ||
| 140 | default => undef, | ||
| 141 | ); | ||
| 142 | |||
| 143 | ##################################################################### | ||
| 144 | # Methods to implement the Tag role. | ||
| 145 | |||
| 146 | sub as_string { | ||
| 147 | my $self = shift; | ||
| 148 | |||
| 149 | my $id = 'S_' . $self->get_id(); | ||
| 150 | |||
| 151 | my $string; | ||
| 152 | $string = '<Shortcut'; | ||
| 153 | |||
| 154 | my @attribute = ( | ||
| 155 | [ 'Id' => $id, ], | ||
| 156 | [ 'Advertise' => $self->_get_advertise(), ], | ||
| 157 | [ 'Arguments' => $self->_get_arguments(), ], | ||
| 158 | [ 'Description' => $self->_get_description(), ], | ||
| 159 | [ 'DescriptionResourceDll' => | ||
| 160 | $self->_get_descriptionresourcedll(), | ||
| 161 | ], | ||
| 162 | [ 'DescriptionResourceId' => $self->_get_descriptionresourceid(), ], | ||
| 163 | [ 'Directory' => $self->_get_directory(), ], | ||
| 164 | [ 'DisplayResourceDll' => $self->_get_displayresourcedll(), ], | ||
| 165 | [ 'DisplayResourceId' => $self->_get_displayresourceid(), ], | ||
| 166 | [ 'Hotkey' => $self->_get_hotkey(), ], | ||
| 167 | [ 'Icon' => $self->_get_icon(), ], | ||
| 168 | [ 'IconIndex' => $self->_get_iconindex(), ], | ||
| 169 | [ 'Name' => $self->_get_name(), ], | ||
| 170 | [ 'ShortName' => $self->_get_shortname(), ], | ||
| 171 | [ 'Show' => $self->_get_show(), ], | ||
| 172 | [ 'Target' => $self->_get_target(), ], | ||
| 173 | [ 'WorkingDirectory' => $self->_get_workingdirectory(), ], | ||
| 174 | ); | ||
| 175 | |||
| 176 | my ( $k, $v ); | ||
| 177 | |||
| 178 | foreach my $ref (@attribute) { | ||
| 179 | ( $k, $v ) = @{$ref}; | ||
| 180 | $string .= $self->print_attribute( $k, $v ); | ||
| 181 | } | ||
| 182 | |||
| 183 | $string .= qq{ />\n}; | ||
| 184 | |||
| 185 | return $string; | ||
| 186 | |||
| 187 | } ## end sub as_string | ||
| 188 | |||
| 189 | sub get_namespace { | ||
| 190 | return q{xmlns='http://schemas.microsoft.com/wix/2006/wi'}; | ||
| 191 | } | ||
| 192 | |||
| 193 | no Moose; | ||
| 194 | __PACKAGE__->meta->make_immutable; | ||
| 195 | |||
| 196 | 1; | ||
| 197 | |||
| 198 | __END__ |