Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
Issue #362
  • Loading branch information
rsoika committed Nov 21, 2024
1 parent 3558d1c commit d890b7f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export class BPMNPropertyPanel extends AbstractUIExtension implements IDiagramSt
}

/**
* This helper method is responsible to refresh teh property panel.
* This helper method is responsible to refresh the property panel.
* The method loads the element from the root model context and updates
* the JsonForms schemata.
*
Expand All @@ -348,7 +348,7 @@ export class BPMNPropertyPanel extends AbstractUIExtension implements IDiagramSt

// return if we do not yet have a body DIV.
if (!this.bodyDiv) {
console.log(' ------ no body div!!');
// console.log(' ------ no body div --------');
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ public void buildPropertiesForm(final BPMNElement bpmnElement, final DataBuilder
@Override
public boolean updatePropertiesData(final JsonObject json, final String category, final BPMNElement bpmnElement,
final GModelElement gNodeElement) {
boolean _update = false;
boolean updateClient = false;
// we are only interested in category general and lanes
if (!"General".equals(category) && !"Lanes".equals(category)) {
return _update;
return updateClient;
}

long l = System.currentTimeMillis();
Expand Down Expand Up @@ -155,8 +155,7 @@ public boolean updatePropertiesData(final JsonObject json, final String category
// this is a new lane - construct the lane in the BPMN model first..
Lane bpmnLane = process.addLane("Lane " + (process.getLanes().size() + 1));
laneDataIDs.add(bpmnLane.getId());
modelState.reset();
_update = true;
updateClient = true;
}
}
// now we need to delete all lanes no longer part of the laneSetValues
Expand All @@ -181,7 +180,7 @@ public boolean updatePropertiesData(final JsonObject json, final String category

logger.debug("laneSet update in " + (System.currentTimeMillis() - l) + "ms");

return _update;
return updateClient;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.openbpmn.glsp.BPMNDiagramConfiguration;
import org.openbpmn.glsp.elements.CreateBPMNNodeOperationHandler;
import org.openbpmn.glsp.model.BPMNGModelState;
import org.openbpmn.glsp.operations.BPMNPropertiesUpdateAction;

import com.google.inject.Inject;

Expand Down Expand Up @@ -103,13 +102,12 @@ public void executeOperation(final CreateNodeOperation operation) {
}
}
}
modelState.reset();

if (updateClient) {
modelState.reset();
// select event
actionDispatcher.dispatchAfterNextUpdate(new SelectAction(List.of(eventID)));
// send an update for the property panel...
actionDispatcher
.dispatchAfterNextUpdate(new BPMNPropertiesUpdateAction());
modelState.refreshSelection(eventID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.glsp.graph.GGraph;
import org.eclipse.glsp.graph.GModelElement;
import org.eclipse.glsp.server.actions.ActionDispatcher;
import org.eclipse.glsp.server.model.DefaultGModelState;
import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.exceptions.BPMNInvalidReferenceException;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.openbpmn.bpmn.util.BPMNModelFactory;
import org.openbpmn.glsp.operations.BPMNPropertiesUpdateAction;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

Expand Down Expand Up @@ -55,6 +58,9 @@ public class BPMNGModelState extends DefaultGModelState {
@Inject
protected BPMNGModelFactory bpmnGModelFactory;

@Inject
protected ActionDispatcher actionDispatcher;

public BPMNGModelState() {
resetRevisions();
}
Expand Down Expand Up @@ -231,4 +237,28 @@ public void refreshGModelState() {
this.execute(new SetDirtyCommand());
}

/**
* This method sends a PropertyUpdateAction to the client to refresh the
* property panel.
*
* @param elementID
*/
public void refreshSelection(String elementID) {
refreshGModelState();
GModelElement gModelElement = getIndex().get(elementID).orElse(null);
if (gModelElement == null) {
// reset to root (Default Process)
gModelElement = getRoot();

}
if (gModelElement != null) {
// Refresh the Data, Schema and UISchema (this could be changed by an extension)
String _data = gModelElement.getArgs().get("JSONFormsData").toString();
// logger.info(" -> new JSON String=" + _data);
String _schema = gModelElement.getArgs().get("JSONFormsSchema").toString();
String _uiSchema = gModelElement.getArgs().get("JSONFormsUISchema").toString();
actionDispatcher.dispatch(new BPMNPropertiesUpdateAction(gModelElement.getId(), _data, _schema,
_uiSchema));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,11 @@ private void executeOperation(final BPMNPropertiesApplyOperation operation) {
}
}

// Refresh the Data, Schema and UISchema (this could be changed by an extension)
String _data = gModelElement.getArgs().get("JSONFormsData").toString();
logger.debug(" -> new JSON String=" + _data);
String _schema = gModelElement.getArgs().get("JSONFormsSchema").toString();
String _uiSchema = gModelElement.getArgs().get("JSONFormsUISchema").toString();

// Finally dispatch an BPMNPropertiesUpdateAction event to refresh the
// property panel. This action is only dispatched in case at least one extension
// has signaled an update.
if (clientUpdate) {
actionDispatcher.dispatch(new BPMNPropertiesUpdateAction(_data, _schema,
_uiSchema));
modelState.refreshSelection(gModelElement.getId());
}
logger.debug("....execute Update " + operation.getId() + " in " +
(System.currentTimeMillis() - l) + "ms");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@
public class BPMNPropertiesUpdateAction extends Action {

public static final String KIND = "BPMNPropertiesUpdateAction";
private String id;
private String data;
private String schema;
private String uiSchema;

public BPMNPropertiesUpdateAction() {
super(KIND);
}

public BPMNPropertiesUpdateAction(String data, String schema, String uiSchema) {
public BPMNPropertiesUpdateAction(String id, String data, String schema, String uiSchema) {
super(KIND);
this.id = id;
this.data = data;
this.schema = schema;
this.uiSchema = uiSchema;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getData() {
return data;
}
Expand Down

0 comments on commit d890b7f

Please sign in to comment.