This repository was archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec_setup.pl
More file actions
75 lines (61 loc) · 2.36 KB
/
Copy pathec_setup.pl
File metadata and controls
75 lines (61 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use XML::LibXML;
if ($promoteAction eq 'promote') {
#### Add to Commander Menu ###
$view->add("DSL IDE",{position=>10, url => 'plugins/@PLUGIN_KEY@-@PLUGIN_VERSION@/index.html'});
#### Add to Flow Menu ###
my $flowMenuPath = "/server/ec_ui/flowMenuExtension";
# Test whether the Flow menu property exists
my $menuXml;
eval {$menuXml = $commander->getProperty($flowMenuPath)->findvalue("//value")};
if ($@ or $menuXml eq "") { # If menu is not present create the menu XML
# Create new menu definition
$menuXml = qq(<?xml version="1.0" encoding="UTF-8"?><menu></menu>);
}
my $parser = XML::LibXML->new();
my $doc = $parser->parse_string($menuXml);
# Remove old DSL IDE menu entry if present
if ( my ($childnode) = $doc->findnodes('//tab[./label = "DSL IDE"]') ) {
my $parent = $childnode->parentNode;
$parent->removeChild( $childnode );
}
# Add menu tab for DSL IDE
# <tab>
# <label>DSL IDE</label>
# <url>plugins/EC-DSLIDE-<version>/index.html</url>
# </tab>
if( my ($node) = $doc->findnodes("//menu") )
{
my $new_node = $doc->createElement("tab");
my $new_label = $doc->createElement("label");
my $new_url = $doc->createElement("url");
$node->addChild($new_node);
$new_node->addChild($new_label);
$new_label->appendText('DSL IDE');
$new_node->addChild($new_url);
$new_url->appendText('plugins/@PLUGIN_KEY@-@PLUGIN_VERSION@/index.html');
}
$commander->setProperty("/server/ec_ui/flowMenuExtension",{value => $doc->toString(0)});
} elsif ($promoteAction eq 'demote') {
#### Remove from Commander Menu ###
$view->remove("DSL IDE");
#### Remove from Commander Menu ###
my $flowMenuPath = "/server/ec_ui/flowMenuExtension";
# Test whether the Flow menu property exists
my $menuXml;
eval {$commander->getProperty($flowMenuPath)};
if ($@) {
# Create new menu definition
$menuXml = qq(<?xml version="1.0" encoding="UTF-8"?><menu></menu>);
} else {
# Work with existing menu definition
$menuXml = $commander->getProperty($flowMenuPath)->findvalue("//value");
}
my $parser = XML::LibXML->new();
my $doc = $parser->parse_string($menuXml);
# Remove old DSL IDE menu entry if present
if ( my ($childnode) = $doc->findnodes('//tab[./label = "DSL IDE"]') ) {
my $parent = $childnode->parentNode;
$parent->removeChild( $childnode );
}
$commander->setProperty("/server/ec_ui/flowMenuExtension",{value => $doc->toString(0)});
}