use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class ReferencesView method handleTransactionSelection.
private void handleTransactionSelection(Object firstElement) {
TransactionTreeObject transactionTreeObject = (TransactionTreeObject) firstElement;
Transaction transaction = transactionTreeObject.getObject();
String transactionName = transactionTreeObject.getName();
// Get the referencing sequence steps
String transactionProjectName = transaction.getProject().getName();
String transactionConnectorName = transaction.getParent().getName();
try {
Project project = null;
List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
treeViewer.setInput(null);
RootNode root = new RootNode();
TransactionNode transactionFolder = new TransactionNode(root, transactionName, transaction);
root.addChild(transactionFolder);
IsUsedByNode isUsedByNode = new IsUsedByNode(transactionFolder, "Is used by");
RequiresNode requiresNode = new RequiresNode(transactionFolder, "Requires");
ProjectNode projectFolder = null;
// Searching all objects are required transaction selected
Connector connector = transaction.getConnector();
if (connector instanceof HtmlConnector) {
Project proj = ((HtmlConnector) connector).getProject();
ProjectNode projectNode = new ProjectNode(requiresNode, transactionProjectName, proj);
HtmlTransaction htmlTransaction = (HtmlTransaction) transaction;
List<Statement> statements = htmlTransaction.getStatements();
List<ScreenClass> screenClassList = new ArrayList<ScreenClass>();
List<String> siteClipperConnectorNames = new ArrayList<String>();
for (Statement statement : statements) {
if (statement instanceof ScHandlerStatement) {
ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
String screenClassName = scHandlerStatement.getNormalizedScreenClassName();
ScreenClass screenClass = ((HtmlConnector) connector).getScreenClassByName(screenClassName);
if (screenClass != null) {
if (!screenClassList.contains(screenClass)) {
screenClassList.add(screenClass);
requiresNode.addChild(new ScreenClassNode(requiresNode, screenClassName, screenClass));
}
}
}
List<Statement> statementList = ((FunctionStatement) statement).getStatements();
for (Statement st : statementList) {
if (st instanceof ContinueWithSiteClipperStatement) {
ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
String siteClipperconnectorName = continueWithSiteClipperStatement.getSiteClipperConnectorName();
if (!siteClipperConnectorNames.contains(siteClipperconnectorName)) {
siteClipperConnectorNames.add(siteClipperconnectorName);
Connector siteClipperConnector = proj.getConnectorByName(siteClipperconnectorName);
ConnectorNode connectorSiteClipperNode = new SiteClipperConnectorNode(projectNode, siteClipperconnectorName, siteClipperConnector);
projectNode.addChild(connectorSiteClipperNode);
}
}
}
}
if (projectNode.hasChildren()) {
requiresNode.addChild(projectNode);
}
} else if (connector instanceof JavelinConnector) {
JavelinTransaction javelinTransaction = (JavelinTransaction) transaction;
String handlers = javelinTransaction.handlers;
List<JavelinScreenClass> screenClasses = ((JavelinConnector) connector).getAllScreenClasses();
List<JavelinScreenClass> screenClassList = new ArrayList<JavelinScreenClass>();
for (JavelinScreenClass screenClass : screenClasses) {
if (handlers.indexOf("function on" + screenClass.getName()) != -1) {
if (!screenClassList.contains(screenClass)) {
screenClassList.add(screenClass);
requiresNode.addChild(new ScreenClassNode(requiresNode, screenClass.getName(), screenClass));
}
}
}
}
// Searching all objects are used transaction selected
for (String projectName : projectNames) {
project = getProject(projectName, projectExplorerView);
if (project != null) {
projectFolder = new ProjectNode(isUsedByNode, project.getName(), project);
UrlMapper urlMapper = project.getUrlMapper();
if (urlMapper != null) {
MapperNode mapperNode = new MapperNode(projectFolder, urlMapper.getName(), urlMapper);
List<UrlMapping> mappings = urlMapper.getMappingList();
for (UrlMapping mapping : mappings) {
MappingPathNode pathNode = new MappingPathNode(mapperNode, mapping.getPath(), mapping);
List<UrlMappingOperation> operations = mapping.getOperationList();
for (UrlMappingOperation operation : operations) {
String targetRequestable = operation.getTargetRequestable();
if (targetRequestable.equals(transactionProjectName + "." + transactionConnectorName + "." + transactionName)) {
MappingOperationNode operationNode = new MappingOperationNode(pathNode, operation.getName(), operation);
pathNode.addChild(operationNode);
}
}
if (pathNode.hasChildren()) {
mapperNode.addChild(pathNode);
}
}
if (mapperNode.hasChildren()) {
projectFolder.addChild(mapperNode);
}
}
List<Sequence> sequences = project.getSequencesList();
for (Sequence sequence : sequences) {
List<Step> stepList = sequence.getAllSteps();
SequenceNode sequenceNode = new SequenceNode(projectFolder, sequence.getName(), sequence);
for (Step step : stepList) {
getTransactionReferencing(step, projectExplorerView, sequenceNode, transactionProjectName, transactionConnectorName, transactionName);
}
if (sequenceNode.hasChildren()) {
projectFolder.addChild(sequenceNode);
}
}
if (projectFolder.hasChildren()) {
isUsedByNode.addChild(projectFolder);
}
}
}
if (requiresNode.hasChildren()) {
transactionFolder.addChild(requiresNode);
}
if (isUsedByNode.hasChildren()) {
transactionFolder.addChild(isUsedByNode);
}
if (!transactionFolder.hasChildren()) {
transactionFolder.addChild(new InformationNode(projectFolder, "This transaction is not used in any sequence"));
}
treeViewer.setInput(root);
treeViewer.expandAll();
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
}
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class DboUtils method getTechnology.
public static String getTechnology(DatabaseObject parentObject, Class<? extends DatabaseObject> objectClass) {
String technology = null;
DatabaseObject parent = parentObject;
if (parent != null) {
// case of Variable
if (Variable.class.isAssignableFrom(objectClass)) {
return technology = parent.getClass().getName();
}
// parent is a connector
if (parent instanceof Connector) {
return technology = ((Connector) parent).getClass().getName();
}
// parent is a sequence
if (parent instanceof Sequence) {
return technology = ((Sequence) parent).getClass().getName();
}
// parent is a statement
if (parent instanceof Statement) {
return technology = "com.twinsoft.convertigo.beans.statements.BlockStatement";
}
// parent is a step
if (parent instanceof Step) {
technology = "com.twinsoft.convertigo.beans.steps.BlockStep";
if (getClassName(parent.getClass()).startsWith("XML")) {
technology = parent.getClass().getName();
}
return technology;
}
// parent is a transaction
if (parent instanceof Transaction) {
if (parent instanceof HtmlTransaction) {
return technology = "com.twinsoft.convertigo.beans.transactions.HtmlTransaction";
} else if (parent instanceof SiteClipperTransaction) {
return technology = "com.twinsoft.convertigo.beans.transactions.SiteClipperTransaction";
}
}
// parent is a screenclass
if (parent instanceof ScreenClass) {
while ((parent = parent.getParent()) instanceof ScreenClass) {
;
}
if (parent instanceof JavelinConnector)
technology = ((JavelinConnector) parent).getEmulatorTechnology();
if (parent instanceof HtmlConnector)
technology = "com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass";
if (parent instanceof SiteClipperConnector)
technology = "com.twinsoft.convertigo.beans.screenclasses.SiteClipperScreenClass";
}
}
return technology;
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class StatementTreeObject method treeObjectRemoved.
@Override
public void treeObjectRemoved(TreeObjectEvent treeObjectEvent) {
super.treeObjectRemoved(treeObjectEvent);
// Avoid the cast between "UnloadedProjectTreeObject" and "DatabaseObjectTreeObject
if (!(treeObjectEvent.getSource() instanceof UnloadedProjectTreeObject)) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Statement statement = getObject();
boolean change = false;
// Case this is a screen class
if (databaseObject instanceof ScreenClass) {
ScreenClassTreeObject sto = (ScreenClassTreeObject) treeObjectEvent.getSource();
String screenClassName = StringUtils.normalize(databaseObject.getName());
// ScreenClass and Statement must have the same connector!
if (statement.getConnector().equals(sto.getConnectorTreeObject().getObject())) {
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(screenClassName)) {
screenClasses.remove(i);
change = true;
}
}
// Add default root screen class if all have been removed
if (screenClasses.isEmpty()) {
IScreenClassContainer<?> iscc = (IScreenClassContainer<?>) sto.getConnectorTreeObject().getObject();
String defaultScreenClassName = StringUtils.normalize(iscc.getDefaultScreenClass().getName());
screenClasses.add(defaultScreenClassName);
change = true;
}
if (change)
ito.setTrigger(new TriggerXMLizer(sct));
}
}
}
}
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.beans.core.Statement 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.beans.core.Statement in project convertigo by convertigo.
the class ContainerStatement method executeNextStatement.
public boolean executeNextStatement(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (hasStatements()) {
if (currentChildStatement < numberOfStatements()) {
Statement st = (Statement) getStatements().get(currentChildStatement);
executeNextStatement(st, javascriptContext, scope);
if (bContinue)
return executeNextStatement(javascriptContext, scope);
}
}
return true;
}
return false;
}
Aggregations