public void insertElement(Point whereTo) {
// if activity is selected
if (isActivityButtonSelected()) {
if (!getGraphManager().doesRootParticipantExist()) {
JaWEFrame frame = JaWEManager.getInstance().getJaWEController().getJaWEFrame();
JOptionPane.showMessageDialog(frame, getGraphController().getSettings().getLanguageDependentString(
"WarningInvalidOperation"), frame.getAppTitle(),
JOptionPane.WARNING_MESSAGE);
} else {
GraphParticipantInterface gpar = getGraphManager().findParentActivityParticipantForLocation(whereTo, null,
null);
Point partLoc = getGraphManager().getBounds(gpar, null).getBounds().getLocation();
Point off = new Point(whereTo.x - partLoc.x, whereTo.y - partLoc.y);
String partId = gpar.getPropertyObject().get("Id").toValue();
Activities acts = (Activities) getGraph().getXPDLObject().get("Activities");
Activity act = JaWEManager.getInstance().getXPDLObjectFactory().createXPDLObject(acts, subType, false);
GraphUtilities.setOffsetPoint(act, off);
GraphUtilities.setParticipantId(act, partId);
int acttype = act.getActivityType();
if (acttype == XPDLConstants.ACTIVITY_TYPE_NO || acttype == XPDLConstants.ACTIVITY_TYPE_TOOL) {
if (!partId.equals(FreeTextExpressionParticipant.getInstance().getId())) {
act.setPerformer(partId);
}
}
graphController.setUpdateInProgress(true);
JaWEManager.getInstance().getJaWEController().startUndouableChange();
acts.add(act);
getGraphManager().insertActivity(act);
List toSelect = new ArrayList();
toSelect.add(act);
JaWEManager.getInstance().getJaWEController().endUndouableChange(toSelect);
getGraph().selectActivity(act, false);
graphController.setUpdateInProgress(false);
}
} // if start button is selected
else if (isStartButtonSelected()) {
if (!getGraphManager().doesRootParticipantExist()) {
JaWEFrame frame = JaWEManager.getInstance().getJaWEController().getJaWEFrame();
JOptionPane.showMessageDialog(frame, getGraphController().getSettings().getLanguageDependentString(
"WarningInvalidOperation"), frame.getAppTitle(),
JOptionPane.WARNING_MESSAGE);
} else {
GraphParticipantInterface gpar = getGraphManager().findParentActivityParticipantForLocation(whereTo, null,
null);
Point partLoc = getGraphManager().getBounds(gpar, null).getBounds().getLocation();
Point offset = new Point(whereTo.x - partLoc.x, whereTo.y - partLoc.y);
String partId = gpar.getPropertyObject().get("Id").toValue();
graphController.setUpdateInProgress(true);
JaWEManager.getInstance().getJaWEController().startUndouableChange();
ExtendedAttribute ea = GraphUtilities.createStartOrEndExtendedAttribute(getGraph().getXPDLObject(), true, partId, offset, subType,
true);
getGraphManager().insertStart(ea);
List toSelect = new ArrayList();
toSelect.add(ea);
JaWEManager.getInstance().getJaWEController().endUndouableChange(toSelect);
getGraph().selectBubble(ea, false);
graphController.setUpdateInProgress(false);
}
}
// if end button is selected
if (isEndButtonSelected()) {
if (!getGraphManager().doesRootParticipantExist()) {
JaWEFrame frame = JaWEManager.getInstance().getJaWEController().getJaWEFrame();
JOptionPane.showMessageDialog(frame, getGraphController().getSettings().getLanguageDependentString(
"WarningInvalidOperation"), frame.getAppTitle(),
JOptionPane.WARNING_MESSAGE);
} else {
GraphParticipantInterface gpar = getGraphManager().findParentActivityParticipantForLocation(whereTo, null,
null);