use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class NgxUIComponentTreeObject method handleSharedActionChanged.
protected void handleSharedActionChanged(UIActionStack sharedAction, Set<Object> done) {
if (sharedAction != null) {
// a uic has changed/added/removed from a shared action referenced by this UIDynamicInvoke
if (getObject() instanceof UIDynamicInvoke) {
UIDynamicInvoke udi = (UIDynamicInvoke) getObject();
if (udi.getSharedActionQName().equals(sharedAction.getQName())) {
UIActionStack uisa = udi.getSharedAction();
UISharedComponent uisc = udi.getSharedComponent();
// udi inside a shared action
if (uisa != null && !uisa.equals(sharedAction)) {
notifyDataseObjectPropertyChanged(uisa, "", null, null, done);
} else // udi inside a shared component
if (uisc != null) {
notifyDataseObjectPropertyChanged(uisc, "", null, null, done);
} else // udi inside a page or menu
{
try {
markMainAsDirty(udi, done);
} catch (EngineException e) {
e.printStackTrace();
}
}
}
}
}
}
use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class MobileUIComponentTreeObject method handlesBeanNameChanged.
protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
int update = treeObjectEvent.update;
if (update != TreeObjectEvent.UPDATE_NONE) {
// Case a UIStackVariable has been renamed
if (databaseObject instanceof UIStackVariable) {
UIStackVariable variable = (UIStackVariable) databaseObject;
UIActionStack stack = variable.getSharedAction();
if (stack != null) {
// rename variable for InvokeAction
if (getObject() instanceof UIDynamicInvoke) {
UIDynamicInvoke udi = (UIDynamicInvoke) getObject();
if (udi.getSharedActionQName().equals(stack.getQName())) {
boolean isLocalProject = variable.getProject().equals(udi.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = udi.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlVariable) {
UIControlVariable uicv = (UIControlVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(udi);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for InvokeAction !");
}
}
}
}
}
}
}
}
}
// Case a UICompVariable has been renamed
if (databaseObject instanceof UICompVariable) {
UICompVariable variable = (UICompVariable) databaseObject;
UISharedComponent comp = variable.getSharedComponent();
if (comp != null) {
// rename variable for UseShared
if (getObject() instanceof UIUseShared) {
UIUseShared uus = (UIUseShared) getObject();
if (uus.getSharedComponentQName().equals(comp.getQName())) {
boolean isLocalProject = variable.getProject().equals(uus.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = uus.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlVariable) {
UIControlVariable uicv = (UIControlVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(uus);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for UseShared !");
}
}
}
}
}
}
}
}
} else // Case a RequestableVariable has been renamed
if (databaseObject instanceof RequestableVariable) {
RequestableVariable variable = (RequestableVariable) databaseObject;
DatabaseObject parent = variable.getParent();
if (getObject() instanceof UIDynamicAction) {
UIDynamicAction uia = (UIDynamicAction) getObject();
IonBean ionBean = uia.getIonBean();
if (ionBean != null) {
// rename variable for CallSequenceAction
if (ionBean.getName().equals("CallSequenceAction")) {
Object p_val = ionBean.getProperty("requestable").getValue();
if (!p_val.equals(false)) {
if (parent.getQName().equals(p_val.toString())) {
boolean isLocalProject = variable.getProject().equals(uia.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = uia.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlVariable) {
UIControlVariable uicv = (UIControlVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(uia);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for CallSequenceAction !");
}
}
}
}
}
}
}
}
}
}
}
}
}
use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class ProjectTreeObject method checkForImports.
private void checkForImports(List<String> missingList, List<Step> steps) {
String targetProjectName;
for (Step step : steps) {
if (step instanceof StepWithExpressions) {
checkForImports(missingList, ((StepWithExpressions) step).getSteps());
} else {
if (step instanceof TransactionStep) {
TransactionStep transactionStep = ((TransactionStep) step);
targetProjectName = transactionStep.getProjectName();
if (!targetProjectName.equals(getName())) {
try {
transactionStep.getSequence().getLoadedProject(targetProjectName);
} catch (EngineException e) {
if (!missingList.contains(targetProjectName))
missingList.add(targetProjectName);
}
}
} else if (step instanceof SequenceStep) {
SequenceStep sequenceStep = ((SequenceStep) step);
targetProjectName = sequenceStep.getProjectName();
if (!targetProjectName.equals(getName())) {
try {
sequenceStep.getSequence().getLoadedProject(targetProjectName);
} catch (EngineException e) {
if (!missingList.contains(targetProjectName))
missingList.add(targetProjectName);
}
}
}
}
}
}
use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class StatementTreeObject method handlesBeanNameChanged.
protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
Statement statement = getObject();
boolean change = false;
if (databaseObject instanceof ScreenClass) {
String oldScreenClassName = StringUtils.normalize((String) oldValue);
String newScreenClassName = StringUtils.normalize((String) newValue);
// ScreenClass and Statement must have the same connector!
if (statement.getConnector().equals(databaseObject.getConnector())) {
// Modify screenclass handlers name
if (statement instanceof ScHandlerStatement) {
ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
if (scHandlerStatement.getNormalizedScreenClassName().equals(oldScreenClassName)) {
String handlerType = scHandlerStatement.getHandlerType();
String beanName = "on" + newScreenClassName + handlerType;
try {
scHandlerStatement.setName(beanName);
scHandlerStatement.setNormalizedScreenClassName(newScreenClassName);
change = true;
} catch (EngineException e) {
ConvertigoPlugin.logWarning(e, "Could not rename ScHandlerStatement from \"" + scHandlerStatement.getName() + "\" to \"" + beanName + "\" !");
}
}
}
if (statement instanceof ITriggerOwner) {
ITriggerOwner ito = (ITriggerOwner) statement;
AbstractTrigger atrigger = ito.getTrigger().getTrigger();
if (atrigger instanceof ScreenClassTrigger) {
ScreenClassTrigger sct = (ScreenClassTrigger) atrigger;
List<String> screenClasses = sct.getScreenClasses();
for (int i = 0; i < screenClasses.size(); i++) if (screenClasses.get(i).equals(oldScreenClassName) && (change = true))
screenClasses.set(i, newScreenClassName);
if (change)
ito.setTrigger(new TriggerXMLizer(sct));
}
}
}
} else // Case of connector rename
if (databaseObject instanceof SiteClipperConnector) {
if (statement instanceof ContinueWithSiteClipperStatement) {
boolean isLocalProject = statement.getProject().equals(databaseObject.getProject());
boolean isSameValue = ((ContinueWithSiteClipperStatement) statement).getSiteClipperConnectorName().equals(oldValue);
if (isSameValue && isLocalProject) {
((ContinueWithSiteClipperStatement) statement).setSiteClipperConnectorName((String) newValue);
hasBeenModified(true);
viewer.refresh();
// refresh editors (e.g labels in combobox)
getDescriptors();
}
}
}
if (statement instanceof CallFunctionStatement && databaseObject.getClass().equals(FunctionStatement.class) && ((FunctionStatement) databaseObject).getParentTransaction().equals(statement.getParentTransaction())) {
CallFunctionStatement callfunction = (CallFunctionStatement) statement;
if (callfunction.getFunctionName().equals(oldValue) && (change = true))
callfunction.setFunctionName(newValue.toString());
}
if (change)
try {
hasBeenModified(true);
getProjectExplorerView().refreshTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not refresh in tree ScHandlerStatement \"" + statement.getName() + "\" !");
}
}
use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class TransactionTreeObject method treeObjectPropertyChanged.
@Override
public void treeObjectPropertyChanged(TreeObjectEvent treeObjectEvent) {
super.treeObjectPropertyChanged(treeObjectEvent);
String propertyName = (String) treeObjectEvent.propertyName;
propertyName = ((propertyName == null) ? "" : propertyName);
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
// If a bean name has changed
if ("name".equals(propertyName)) {
handlesBeanNameChanged(treeObjectEvent);
} else if ("sqlQuery".equals(propertyName)) {
if (treeObject.equals(this)) {
try {
SqlTransaction sqlTransaction = (SqlTransaction) databaseObject;
sqlTransaction.initializeQueries(true);
String oldValue = (String) treeObjectEvent.oldValue;
detectVariables(sqlTransaction.getSqlQuery(), oldValue, sqlTransaction.getVariablesList());
getProjectExplorerView().reloadTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not reload in tree Transaction \"" + databaseObject.getName() + "\" !");
}
}
} else if ("subDir".equals(propertyName)) {
if (treeObject.equals(this)) {
try {
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
AbstractHttpTransaction httpTransaction = (AbstractHttpTransaction) databaseObject;
List<String> oldPathVariableList = AbstractHttpTransaction.getPathVariableList(oldValue.toString());
List<String> newPathVariableList = AbstractHttpTransaction.getPathVariableList(newValue.toString());
// Check for variables to be renamed
if (oldValue.toString().replaceAll("\\{([a-zA-Z0-9_]+)\\}", "{}").equals(newValue.toString().replaceAll("\\{([a-zA-Z0-9_]+)\\}", "{}"))) {
for (int i = 0; i < oldPathVariableList.size(); i++) {
String oldVariableName = oldPathVariableList.get(i);
String newVariableName = newPathVariableList.get(i);
if (!oldVariableName.equals(newVariableName)) {
RequestableHttpVariable httpVariable = (RequestableHttpVariable) httpTransaction.getVariable(oldVariableName);
if (httpVariable != null) {
try {
VariableTreeObject2 vto = (VariableTreeObject2) findTreeObjectByUserObject(httpVariable);
int update = TreeObjectEvent.UPDATE_NONE;
CustomDialog customDialog = new CustomDialog(viewer.getControl().getShell(), "Update object references", "Do you want to update " + "variable" + " references ?\n You can replace '" + oldVariableName + "' by '" + newVariableName + "' in all loaded projects \n or replace '" + oldVariableName + "' by '" + newVariableName + "' in current project only.", 670, 200, new ButtonSpec("Replace in all loaded projects", true), new ButtonSpec("Replace in current project", false), new ButtonSpec("Do not replace anywhere", false));
int response = customDialog.open();
if (response == 0) {
update = TreeObjectEvent.UPDATE_ALL;
}
if (response == 1) {
update = TreeObjectEvent.UPDATE_LOCAL;
}
if (update != 0) {
httpVariable.setName(newVariableName);
httpVariable.hasChanged = true;
TreeObjectEvent toEvent = new TreeObjectEvent(vto, "name", oldVariableName, newVariableName, update);
getProjectExplorerView().fireTreeObjectPropertyChanged(toEvent);
}
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not rename variable for Transaction \"" + databaseObject.getName() + "\" !");
}
}
}
}
} else {
// Check for variables to be added
for (String variableName : newPathVariableList) {
if (httpTransaction.getVariable(variableName) == null) {
RequestableHttpVariable httpVariable = new RequestableHttpVariable();
httpVariable.setName(variableName);
httpVariable.setHttpMethod("GET");
httpVariable.setHttpName("");
httpVariable.bNew = true;
httpVariable.hasChanged = true;
httpTransaction.addVariable(httpVariable);
httpTransaction.hasChanged = true;
}
}
// Check for variables to be deleted
for (String variableName : oldPathVariableList) {
RequestableHttpVariable httpVariable = (RequestableHttpVariable) httpTransaction.getVariable(variableName);
if (httpVariable != null) {
if (!newPathVariableList.contains(variableName)) {
try {
MessageBox messageBox = new MessageBox(viewer.getControl().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Do you want to delete the variable \"" + variableName + "\"?");
messageBox.setText("Delete \"" + variableName + "\"?");
if (messageBox.open() == SWT.YES) {
httpVariable.delete();
httpTransaction.hasChanged = true;
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error when deleting the variable \"" + variableName + "\"");
}
}
}
}
}
if (httpTransaction.hasChanged) {
getProjectExplorerView().reloadTreeObject(this);
}
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not reload in tree Transaction \"" + databaseObject.getName() + "\" !");
}
}
}
}
}
Aggregations