1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
19 } from 'bpmn-js/lib/util/ModelUtil';
\r
23 * A basic color picker implementation.
\r
25 * @param {EventBus} eventBus
\r
26 * @param {ContextPad} contextPad
\r
27 * @param {CommandStack} commandStack
\r
29 export default function ColorPicker(eventBus, contextPad, commandStack) {
\r
31 contextPad.registerProvider(this);
\r
33 commandStack.registerHandler('shape.updateColor', UpdateColorHandler);
\r
35 function changeColor(event, element) {
\r
37 var color = window.prompt('type a color code');
\r
39 commandStack.execute('shape.updateColor', { element: element, color: color });
\r
43 this.getContextPadEntries = function(element) {
\r
45 if (is(element, 'bpmn:Event')) {
\r
49 className: 'icon-red',
\r
50 title: 'Change element color',
\r
63 * A handler updating an elements color.
\r
65 function UpdateColorHandler() {
\r
67 this.execute = function(context) {
\r
68 context.oldColor = context.element.color;
\r
69 context.element.color = context.color;
\r
71 return context.element;
\r
74 this.revert = function(context) {
\r
75 context.element.color = context.oldColor;
\r
77 return context.element;
\r