--- /dev/null
+/* Copyright (c) 2019 AT&T Intellectual Property. #\r
+# #\r
+# Licensed under the Apache License, Version 2.0 (the "License"); #\r
+# you may not use this file except in compliance with the License. #\r
+# You may obtain a copy of the License at #\r
+# #\r
+# http://www.apache.org/licenses/LICENSE-2.0 #\r
+# #\r
+# Unless required by applicable law or agreed to in writing, software #\r
+# distributed under the License is distributed on an "AS IS" BASIS, #\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #\r
+# See the License for the specific language governing permissions and #\r
+# limitations under the License. #\r
+##############################################################################*/\r
+\r
+\r
+import {\r
+ is\r
+ } from 'bpmn-js/lib/util/ModelUtil';\r
+ \r
+ \r
+ /**\r
+ * A basic color picker implementation.\r
+ *\r
+ * @param {EventBus} eventBus\r
+ * @param {ContextPad} contextPad\r
+ * @param {CommandStack} commandStack\r
+ */\r
+ export default function ColorPicker(eventBus, contextPad, commandStack) {\r
+ \r
+ contextPad.registerProvider(this);\r
+ \r
+ commandStack.registerHandler('shape.updateColor', UpdateColorHandler);\r
+ \r
+ function changeColor(event, element) {\r
+ \r
+ var color = window.prompt('type a color code');\r
+ \r
+ commandStack.execute('shape.updateColor', { element: element, color: color });\r
+ }\r
+ \r
+ \r
+ this.getContextPadEntries = function(element) {\r
+ \r
+ if (is(element, 'bpmn:Event')) {\r
+ return {\r
+ 'changeColor': {\r
+ group: 'edit',\r
+ className: 'icon-red',\r
+ title: 'Change element color',\r
+ action: {\r
+ click: changeColor\r
+ }\r
+ }\r
+ };\r
+ }\r
+ };\r
+ }\r
+ \r
+ \r
+ \r
+ /**\r
+ * A handler updating an elements color.\r
+ */\r
+ function UpdateColorHandler() {\r
+ \r
+ this.execute = function(context) {\r
+ context.oldColor = context.element.color;\r
+ context.element.color = context.color;\r
+ \r
+ return context.element;\r
+ };\r
+ \r
+ this.revert = function(context) {\r
+ context.element.color = context.oldColor;\r
+ \r
+ return context.element;\r
+ };\r
+ \r
+ }
\ No newline at end of file