Package org.jbpm.formbuilder.client.bus

Examples of org.jbpm.formbuilder.client.bus.UndoableEvent


     * gets the next action in the history and redoes it
     */
    public synchronized void redo() {
        if (canRedo()) {
            index++;
            UndoableEvent event = undoRedoWindow.get(index);
            event.getRollbackHandler().doAction(event);
            bus.fireEvent(new UndoRedoEvent());
        }
    }
View Full Code Here


                dataSnapshot.put("newAction", event.getAction());
                dataSnapshot.put("newProcessId", event.getProcessId());
                dataSnapshot.put("newTaskId", event.getTaskId());
                dataSnapshot.put("newMethod", event.getMethod());
                dataSnapshot.put("newEnctype", event.getEnctype());
                bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() {
                    @Override
                    public void onEvent(UndoableEvent event) {  }
                    @Override
                    public void undoAction(UndoableEvent event) {
                        String name = (String) event.getData("oldName");
                        String action = (String) event.getData("oldAction");
                        String taskId = (String) event.getData("oldTaskId");
                        String processId = (String) event.getData("oldProcessId");
                        String method = (String) event.getData("oldMethod");
                        String enctype = (String) event.getData("oldEnctype");
                        populateFormData(action, processId, taskId, name, method, enctype);
                    }
                    @Override
                    public void doAction(UndoableEvent event) {
                        String name = (String) event.getData("newName");
                        String action = (String) event.getData("newAction");
                        String taskId = (String) event.getData("newTaskId");
                        String processId = (String) event.getData("newProcessId");
                        String method = (String) event.getData("newMethod");
                        String enctype = (String) event.getData("newEnctype");
                        populateFormData(action, processId, taskId, name, method, enctype);
                    }
                }));
            }
        });
        this.bus.addHandler(TaskSelectedEvent.TYPE, new TaskSelectedHandler() {
            @Override
            public void onSelectedTask(TaskSelectedEvent event) {
                Map<String, Object> dataSnapshot = new HashMap<String, Object>();
                dataSnapshot.put("oldTaskID", layoutView.getFormDisplay().getTaskId());
                dataSnapshot.put("oldProcessID", layoutView.getFormDisplay().getProcessId());
                dataSnapshot.put("oldTaskInputs", layoutView.getFormDisplay().getInputs());
                dataSnapshot.put("oldTaskOutputs", layoutView.getFormDisplay().getOutputs());
                if (event.getSelectedTask() != null) {
                    dataSnapshot.put("newTaskID", event.getSelectedTask().getTaskId());
                    Map<String, InputData> inputs = new HashMap<String, InputData>();
                    Map<String, OutputData> outputs = new HashMap<String, OutputData>();
                    if (event.getSelectedTask().getInputs() != null) {
                        for (TaskPropertyRef input : event.getSelectedTask().getInputs()) {
                            InputData in = new InputData();
                            in.setName(input.getName());
                            in.setValue(input.getSourceExpresion());
                            inputs.put(input.getName(), in);
                        }
                    }
                    if (event.getSelectedTask().getOutputs() != null) {
                        for (TaskPropertyRef output : event.getSelectedTask().getOutputs()) {
                            OutputData out = new OutputData();
                            out.setName(output.getName());
                            out.setValue(output.getSourceExpresion());
                            outputs.put(output.getName(), out);
                        }
                    }
                    dataSnapshot.put("newTaskInputs", inputs);
                    dataSnapshot.put("newTaskOutputs", outputs);
                }
                dataSnapshot.put("newTaskID", event.getSelectedTask() == null ? null : event.getSelectedTask().getTaskId());
                dataSnapshot.put("newProcessID", event.getSelectedTask() == null ? null : event.getSelectedTask().getProcessId());
                dataSnapshot.put("newTaskInputs", event.getSelectedTask() == null ? null : event.getSelectedTask().getInputs());
                dataSnapshot.put("newTaskOutputs", event.getSelectedTask() == null ? null : event.getSelectedTask().getOutputs());
                bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() {
                    @Override
                    public void onEvent(UndoableEvent event) { }
                    @Override
                    @SuppressWarnings("unchecked")
                    public void doAction(UndoableEvent event) {
                        String value = (String) event.getData("newTaskID");
                        String procId = (String) event.getData("newProcessID");
                        List<TaskPropertyRef> inputs = (List<TaskPropertyRef>) event.getData("newTaskInputs");
                        List<TaskPropertyRef> outputs = (List<TaskPropertyRef>) event.getData("newTaskOutputs");
                        layoutView.getFormDisplay().setTaskId(value);
                        layoutView.getFormDisplay().setProcessId(procId);
                        layoutView.getFormDisplay().setInputs(toInputs(inputs));
                        layoutView.getFormDisplay().setOutputs(toOutputs(outputs));
                    }
                    @Override
                    @SuppressWarnings("unchecked")
                    public void undoAction(UndoableEvent event) {
                        String value = (String) event.getData("oldTaskID");
                        String procId = (String) event.getData("oldProcessID");
                        List<TaskPropertyRef> inputs = (List<TaskPropertyRef>) event.getData("oldTaskInputs");
                        List<TaskPropertyRef> outputs = (List<TaskPropertyRef>) event.getData("oldTaskOutputs");
                        layoutView.getFormDisplay().setTaskId(value);
                        layoutView.getFormDisplay().setProcessId(procId);
                        layoutView.getFormDisplay().setInputs(toInputs(inputs));
                        layoutView.getFormDisplay().setOutputs(toOutputs(outputs));
                    }
                }));
            }
        });
       
        bus.addHandler(FormSavedEvent.TYPE, new FormSavedHandler() {
            @Override
            public void onEvent(FormSavedEvent event) {
                layoutView.getFormDisplay().setSaved(true);
            }
        });
       
        bus.addHandler(UpdateFormViewEvent.TYPE, new UpdateFormViewHandler() {
            @Override
            public void onEvent(UpdateFormViewEvent event) {
                Map<String, Object> dataSnapshot = new HashMap<String, Object>();
                dataSnapshot.put("newForm", event.getFormRepresentation());
                dataSnapshot.put("oldForm", layoutView.getFormDisplay().createRepresentation());
                bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() {
                    @Override
                    public void undoAction(UndoableEvent event) {
                        FormRepresentation oldForm = (FormRepresentation) event.getData("oldForm");
                        try {
                            layoutView.getFormDisplay().populate(oldForm);
View Full Code Here

                  public void execute() {
                      Map<String, Object> dataSnapshot = new HashMap<String, Object>();
                      dataSnapshot.put("menuItem", CustomMenuItem.this);
                      dataSnapshot.put("groupName", groupName);
                      final EventBus bus = CommonGlobals.getInstance().getEventBus();
                      bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() {
                          @Override
                          public void onEvent(UndoableEvent event) { }
                          @Override
                          public void undoAction(UndoableEvent event) {
                              FBMenuItem item = (FBMenuItem) event.getData("menuItem");
View Full Code Here

TOP

Related Classes of org.jbpm.formbuilder.client.bus.UndoableEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.