use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class ComponentInfoWizardPage method fillTree.
public void fillTree(Class<? extends DatabaseObject> beanClass) {
treeItemName = null;
tree.removeAll();
if (parentObject instanceof Transaction) {
Connector connector = (Connector) ((Transaction) parentObject).getParent();
boolean isScreenClassAware = connector instanceof IScreenClassContainer<?>;
if (beanClass.equals(ScEntryHandlerStatement.class) || beanClass.equals(ScExitHandlerStatement.class)) {
if (isScreenClassAware) {
if (connector instanceof HtmlConnector) {
HtmlConnector htmlConnector = (HtmlConnector) connector;
ScreenClass defaultScreenClass = htmlConnector.getDefaultScreenClass();
TreeItem branch = new TreeItem(tree, SWT.NONE);
branch.setText(defaultScreenClass.getName());
List<ScreenClass> screenClasses = defaultScreenClass.getInheritedScreenClasses();
for (ScreenClass screenClass : screenClasses) {
getInHeritedScreenClass(screenClass, branch);
}
} else if (connector instanceof JavelinConnector) {
JavelinConnector javelinConnector = (JavelinConnector) connector;
ScreenClass defaultScreenClass = javelinConnector.getDefaultScreenClass();
TreeItem branch = new TreeItem(tree, SWT.NONE);
branch.setText(defaultScreenClass.getName());
List<ScreenClass> screenClasses = defaultScreenClass.getInheritedScreenClasses();
for (ScreenClass screenClass : screenClasses) {
getInHeritedScreenClass(screenClass, branch);
}
}
tree.setVisible(true);
}
} else if (beanClass.equals(HandlerStatement.class)) {
TreeItem branch;
branch = new TreeItem(tree, SWT.NONE);
branch.setText(HandlerStatement.EVENT_TRANSACTION_STARTED);
branch = new TreeItem(tree, SWT.NONE);
branch.setText(HandlerStatement.EVENT_XML_GENERATED);
tree.setVisible(true);
} else
tree.setVisible(false);
}
}
use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class Get method getServiceResult.
@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
// Load the plugin.xml where the representation of the context menu is described
getPluginDocument();
String[] qnames = request.getParameterValues("qnames[]");
String[] folderTypes = request.getParameterValues("folderTypes[]");
String refQnameFolder = request.getParameter("refQnameFolder");
// Create the response : success or fail
Element eResponse = document.createElement("response");
Element eRoot = document.getDocumentElement();
eRoot.appendChild(eResponse);
// Select (folder + database object) or (multiple folders) = no menu generated
if (folderTypes != null && (qnames != null || folderTypes.length > 1)) {
// It is not really an error but it's ok
noEntryMessage(eResponse);
return;
}
Element eContextMenu = null;
// Generate the menu for database objects
if (qnames != null) {
List<Node> menus = new ArrayList<>(qnames.length);
for (String qname : qnames) {
// Create menu for the dbo
DatabaseObject dbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (dbo != null) {
Element menu = createDboMenu(dbo, document);
menus.add(menu);
} else {
eResponse.setAttribute("state", "error");
eResponse.setAttribute("message", "One of the qname is invalid.");
return;
}
}
// Generate the new menu with all generated menus
eContextMenu = generateFilteredMenu(document, menus);
} else // Generate the menu for folders
if (folderTypes != null && !refQnameFolder.isEmpty()) {
DatabaseObject dbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(refQnameFolder);
// Generate the menu if we found the related dbo
boolean generateMenu = dbo != null;
// In case of Screen Class, if the Criteria folder is selected
if (generateMenu && dbo instanceof ScreenClass && "Criteria".equals(folderTypes[0])) {
ScreenClass sc = (ScreenClass) dbo;
// Generate the menu "New->Criteria" if it is not the default Screen Class
generateMenu = sc.getDepth() != 0;
}
if (generateMenu) {
eContextMenu = document.createElement("menu");
String folderTypeValue = folderNameToTypeValue.get(folderTypes[0]);
if (folderTypeValue != null) {
// Get the object contribution related to the folder
Element eObjectContribution = (Element) xpathApi.selectNode(pluginDocument, "/plugin/extension[@point='org.eclipse.ui.popupMenus']/objectContribution[@objectClass='com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject']");
// Search the action of the folder
List<Node> nActions = xpathApi.selectList(eObjectContribution, "/*");
boolean foundAction = false;
for (int i = 0; !foundAction && i < nActions.size(); ++i) {
Element eAction = (Element) nActions.get(i);
/*
* If we have the right action, we add it to the menu and stop looping.
* In the Studio, we display other actions as disabled but here we only
* display the specific action. In face we can only have one action
* so it is useless to display the others.
*/
if (foundAction = evaluateFolderCondition(folderTypeValue, eAction)) {
String menubarPath = eAction.getAttribute("menubarPath");
// Create the action
Element eNewAction = createElementActionBaseAttr(document, eAction.getAttribute("id"), eAction.getAttribute("label"), eAction.getAttribute("class"), true, menubarPath);
// Create the sub menu
int index = menubarPath.indexOf("/");
createSubMenu(menubarPath, index, document, eContextMenu, eNewAction, eObjectContribution.getAttribute("id"));
}
}
}
}
}
// Create response
if (eContextMenu != null && eContextMenu.hasChildNodes()) {
eResponse.setAttribute("state", "success");
eResponse.setAttribute("message", "Context menu has been generated.");
eRoot.appendChild(eContextMenu);
} else {
noEntryMessage(eResponse);
}
}
use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class Get method createCategories.
private void createCategories(Document document, DatabaseObject dbo, Class<? extends DatabaseObject> databaseObjectClass, Element root) throws Exception {
Element response = document.createElement("response");
try {
List<String> defaultDboList = new ArrayList<>();
Class<? extends DatabaseObject> parentObjectClass = dbo.getClass();
Map<String, DboCategoryData> categoryNameToDboCategory = new HashMap<>();
DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
for (DboGroup group : manager.getGroups()) {
for (DboCategory category : group.getCategories()) {
for (DboBeans beansCategory : category.getBeans()) {
for (DboBean bean : beansCategory.getBeans()) {
// Skip if bean is disabled
if (!bean.isEnable()) {
continue;
}
String className = bean.getClassName();
try {
Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
DboCategoryInfo dboCategoryInfo = DatabaseObject.getDboGroupInfo(beanClass);
if (dboCategoryInfo == null) {
continue;
}
// If one of these cases, do not add the category
if (dbo instanceof ScreenClass) {
ScreenClass sc = (ScreenClass) dbo;
// Do not show Criteria category if it is the default Screen Class
if (sc.getDepth() == 0 && dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Criteria.class))) {
continue;
}
} else if (dbo instanceof CicsConnector) {
// Do not show Pool category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
continue;
}
} else if (dbo instanceof JavelinConnector) {
// Do not show ScreenClass category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
continue;
}
} else if (dbo instanceof SqlConnector) {
// Do not show Pool category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
continue;
}
} else if (dbo instanceof HtmlConnector) {
// Do not show Pool and ScreenClass categories
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class)) || dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
continue;
}
} else if (dbo instanceof HttpConnector) {
// Do not show Pool category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
continue;
}
} else if (dbo instanceof SiteClipperConnector) {
// Do not show Pool and ScreenClass categories
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class)) || dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
continue;
}
} else if (dbo instanceof Transaction) {
// Do not show Statement category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Statement.class))) {
continue;
}
}
if (bean.isDefault()) {
defaultDboList.add(className);
}
// The bean should derived from
// DatabaseObject...
boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
if (isDatabaseObject) {
// ... and should derived from the specified class
boolean isFromSpecifiedClass = (databaseObjectClass == null || (databaseObjectClass != null && databaseObjectClass.isAssignableFrom(beanClass)));
if (isFromSpecifiedClass) {
// Check parent
boolean bFound = DatabaseObjectsManager.checkParent(parentObjectClass, bean);
if (bFound) {
String technology = DboUtils.getTechnology(dbo, beanClass);
// Check technology if needed
if (technology != null) {
Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
continue;
}
}
String beanInfoClassName = className + "BeanInfo";
Class<BeanInfo> beanInfoClass = GenericUtils.cast(Class.forName(beanInfoClassName));
if (beanInfoClass != null) {
String categoryName = dboCategoryInfo.getCategoryName();
// Create category
DboCategoryData dboCategoryData = categoryNameToDboCategory.get(categoryName);
if (dboCategoryData == null) {
dboCategoryData = new DboCategoryData(dboCategoryInfo.getCategoryId(), categoryName, dboCategoryInfo.getIconClassCSS());
categoryNameToDboCategory.put(categoryName, dboCategoryData);
}
// Beans name
String beansName = beansCategory.getName();
if (beansName.length() == 0) {
beansName = categoryName;
}
// Create beans
DboBeansData dboBeansData = dboCategoryData.getDboBeans(beansName);
if (dboBeansData == null) {
dboBeansData = new DboBeansData(beansName);
dboCategoryData.addDboBeans(beansName, dboBeansData);
}
// Create bean
DboBeanData dboBeanData = new DboBeanData(beanInfoClass.getConstructor().newInstance());
dboBeansData.addDboBean(dboBeanData);
} else {
String message = java.text.MessageFormat.format("The \"{0}\" does not exist.", new Object[] { beanInfoClassName });
throw new Exception(message);
}
}
}
} else {
String message = java.text.MessageFormat.format("The \"{0}\" class is not a Convertigo database object.", new Object[] { className });
throw new Exception(message);
}
} catch (ClassNotFoundException e) {
String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" class.\n\nClass not found: {1}", new Object[] { className, e.getMessage() });
throw new Exception(message);
} catch (Throwable e) {
String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" Convertigo database object.", new Object[] { className });
throw new Exception(message);
}
}
}
}
}
// Find the default selected bean for each categories
for (DboCategoryData dboCategory : categoryNameToDboCategory.values()) {
boolean defaultDboFound = false;
List<DboBeanData> dboBeansList = dboCategory.getAllDboBean(true);
// By default, we chose the first bean as default selected bean
DboBeanData defaultSelectedBean = dboBeansList.get(0);
// Find the default selected bean
for (int i = 0; i < dboBeansList.size() && !defaultDboFound; ++i) {
Class<DatabaseObject> beanClass = dboBeansList.get(i).getBeanClass();
// Another bean is set as default selected bean
if (defaultDboFound = defaultDboList.contains(beanClass.getName())) {
defaultSelectedBean = dboBeansList.get(i);
}
}
defaultSelectedBean.setSelectedByDefault(true);
}
// XmlLize
for (DboCategoryData dboCategory : categoryNameToDboCategory.values()) {
response.appendChild(dboCategory.toXml(document));
}
} catch (Exception e) {
throw new Exception("Unable to load database objects properties.");
}
root.appendChild(response);
}
use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class GetChildren method getChildren.
public static void getChildren(String qname, Element parent, int depth) throws Exception {
DatabaseObject dbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
List<DatabaseObject> children = dbo.getDatabaseObjectChildren();
// Get all children of the dbo
Element elt = createDboElement(parent.getOwnerDocument(), dbo, !children.isEmpty());
/*
* In case of ScreenClass, we have to get Criteria, ExtractionRule and Sheets manually.
* If fact, if the dbo is an inherited screen class, inherited Criteria, ExtractionRule and Sheets,
* won't be retrieved by the method #getDatabaseObjectChildren.
*/
if (dbo instanceof ScreenClass) {
ScreenClass sc = (ScreenClass) dbo;
boolean hasChildren = false;
// Get all Criteria
List<Criteria> criteria = sc.getCriterias();
for (Criteria criterion : criteria) {
children.remove(criterion);
Element eltCriterion = createScreenClassChildElement(parent.getOwnerDocument(), criterion, dbo);
elt.appendChild(eltCriterion);
hasChildren = true;
}
// Get all Extraction Rules
List<ExtractionRule> extractionRules = sc.getExtractionRules();
for (ExtractionRule extractionRule : extractionRules) {
children.remove(extractionRule);
Element eltExtractionRule = createScreenClassChildElement(parent.getOwnerDocument(), extractionRule, dbo);
elt.appendChild(eltExtractionRule);
hasChildren = true;
}
// Get all Sheets
List<Sheet> sheets = sc.getSheets();
for (Sheet sheet : sheets) {
children.remove(sheet);
Element eltSheet = createScreenClassChildElement(parent.getOwnerDocument(), sheet, dbo);
elt.appendChild(eltSheet);
hasChildren = true;
}
// In case of JavelinScreenClass, we also have to get the block factory manually
if (dbo instanceof JavelinScreenClass) {
JavelinScreenClass jsc = (JavelinScreenClass) sc;
BlockFactory blockFactory = jsc.getBlockFactory();
children.remove(blockFactory);
Element eltBlockFactory = createScreenClassChildElement(parent.getOwnerDocument(), blockFactory, dbo);
elt.appendChild(eltBlockFactory);
hasChildren = true;
}
if (hasChildren) {
elt.setAttribute("hasChildren", "true");
}
}
parent.appendChild(elt);
if (depth > 0) {
for (DatabaseObject child : children) {
getChildren(child.getQName(), elt, depth - 1);
}
}
}
use of com.twinsoft.convertigo.beans.core.ScreenClass 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;
}
Aggregations