use of com.twinsoft.convertigo.beans.connectors.SqlConnector in project convertigo by convertigo.
the class ConnectorEditorPart method createCompositeDesign.
/**
* This method initializes compositeDesign
*/
private void createCompositeDesign() {
if (Engine.hasXulRunner() && connector instanceof HtmlConnector) {
try {
compositeDesign = new HtmlConnectorDesignComposite(connector, tabFolderOutputDesign, SWT.NONE);
} catch (MaxCvsExceededException e) {
String message = "You have reached the maximum allowed number of simultaneous HTML connectors; check your license keys.\n\n" + "Notice: according to your license key, the maximum allowed number of simultaneous HTML connectors is 2. " + "As you have more than 2 HTML connectors open, you will not be able to open another one nor run any transaction on this connector.\n\n" + "Please close unnecessary connectors.";
ConvertigoPlugin.logError(message, true);
compositeDesign = new Composite(tabFolderOutputDesign, SWT.NONE);
labelNoDesign = new Label(compositeDesign, SWT.NONE | SWT.WRAP);
labelNoDesign.setBounds(new org.eclipse.swt.graphics.Rectangle(10, 10, 300, 200));
labelNoDesign.setFont(new Font(null, "Tahoma", 10, 0));
labelNoDesign.setText("\n" + message);
Control[] children = tabFolderOutputDesign.getChildren();
if ((children.length >= 2) && (children[1] instanceof HtmlConnectorDesignComposite))
children[1].moveBelow(null);
} catch (KeyExpiredException e) {
String message = "Your HTML license key has expired; check your license keys.\n\n" + "Notice: according to your license key, your trial period has expired. " + "You will not be able to open an HTML connector nor run any transaction on this connector.\n\n";
ConvertigoPlugin.logError(message, true);
compositeDesign = new Composite(tabFolderOutputDesign, SWT.NONE);
labelNoDesign = new Label(compositeDesign, SWT.NONE | SWT.WRAP);
labelNoDesign.setBounds(new org.eclipse.swt.graphics.Rectangle(10, 10, 300, 200));
labelNoDesign.setFont(new Font(null, "Tahoma", 10, 0));
labelNoDesign.setText("\n" + message);
Control[] children = tabFolderOutputDesign.getChildren();
if ((children.length >= 2) && (children[1] instanceof HtmlConnectorDesignComposite))
children[1].moveBelow(null);
}
} else if (connector instanceof SapJcoConnector) {
try {
compositeDesign = new SapJcoConnectorDesignComposite(connector, tabFolderOutputDesign, SWT.NONE);
} catch (Exception e) {
e.printStackTrace();
}
} else if (connector instanceof SqlConnector) {
try {
compositeDesign = new SqlConnectorDesignComposite(connector, tabFolderOutputDesign, SWT.NONE);
} catch (Exception e) {
e.printStackTrace();
}
} else {
compositeDesign = new Composite(tabFolderOutputDesign, SWT.NONE);
labelNoDesign = new Label(compositeDesign, SWT.NONE | SWT.WRAP);
labelNoDesign.setFont(new Font(null, "Tahoma", 10, 0));
labelNoDesign.setBounds(new org.eclipse.swt.graphics.Rectangle(10, 10, 300, 200));
labelNoDesign.setText("This connector does not provide any design tool");
}
}
use of com.twinsoft.convertigo.beans.connectors.SqlConnector in project convertigo by convertigo.
the class NewObjectWizard method addBeanPages.
private void addBeanPages(String objectExplorerPageTitle, String objectExplorerPageMessage, Class<DatabaseObject> beanClass) {
objectExplorerPage = new ObjectExplorerWizardPage(parentObject, beanClass, xpath);
objectExplorerPage.setTitle(objectExplorerPageTitle);
objectExplorerPage.setMessage(objectExplorerPageMessage);
this.addPage(objectExplorerPage);
objectInfoPage = new ObjectInfoWizardPage(parentObject);
this.addPage(objectInfoPage);
if ((xpath != null) && (dom != null)) {
if (beanClass.equals(ExtractionRule.class)) {
this.addPage(new XMLTableWizardPage(xpath, dom));
}
}
if (parentObject instanceof SqlConnector) {
sqlQueriesWizardPage = new SQLQueriesWizardPage();
this.addPage(sqlQueriesWizardPage);
}
if (beanClass.equals(Connector.class)) {
// add emulator technology wizard page
EmulatorTechnologyWizardPage emulatorTechnologyPage = new EmulatorTechnologyWizardPage();
this.addPage(emulatorTechnologyPage);
// add service code wizard page
ServiceCodeWizardPage serviceCodePage = new ServiceCodeWizardPage();
this.addPage(serviceCodePage);
}
if (beanClass.equals(Reference.class)) {
ProjectSchemaWizardPage projectSchemaWizardPage = new ProjectSchemaWizardPage(parentObject);
this.addPage(projectSchemaWizardPage);
XsdSchemaFileWizardPage xsdSchemaFileWizardPage = new XsdSchemaFileWizardPage(parentObject);
this.addPage(xsdSchemaFileWizardPage);
WsdlSchemaFileWizardPage wsdlSchemaWizardPage = new WsdlSchemaFileWizardPage(parentObject);
this.addPage(wsdlSchemaWizardPage);
WebServiceWizardPage soapServiceWizardPage = new WebServiceWizardPage(parentObject);
this.addPage(soapServiceWizardPage);
RestServiceWizardPage restServiceWizardPage = new RestServiceWizardPage(parentObject);
this.addPage(restServiceWizardPage);
}
if (beanClass.equals(UrlMapping.class)) {
UrlMappingWizardPage urlMappingWizardPage = new UrlMappingWizardPage(parentObject);
this.addPage(urlMappingWizardPage);
}
}
use of com.twinsoft.convertigo.beans.connectors.SqlConnector 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.connectors.SqlConnector in project convertigo by convertigo.
the class ConnectorEditorPart method createToolBar.
/**
* This method initializes toolBar
*/
private void createToolBar() {
int incr = 0;
getConnectorCompositeClass();
GridData gridData5 = new org.eclipse.swt.layout.GridData();
gridData5.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData5.grabExcessHorizontalSpace = true;
gridData5.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING;
toolBar = new ToolBar(compositeOutputHeader, SWT.FLAT);
toolBar.setLayoutData(gridData5);
toolItemRenewConnector = new ToolItem(toolBar, SWT.PUSH);
toolItemRenewConnector.setImage(imageRenew);
toolItemRenewConnector.setToolTipText("Renew the connector");
toolItemRenewConnector.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
compositeConnector.renew();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Renew", Integer.valueOf(incr));
incr++;
if (IConnectable.class.isAssignableFrom(compositeConnectorClass)) {
toolItemConnect = new ToolItem(toolBar, SWT.PUSH);
toolItemConnect.setToolTipText("Connect the connector");
toolItemConnect.setImage(imageConnect);
toolItemConnect.setDisabledImage(imageDisableConnect);
toolItemConnect.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
((IConnectable) compositeConnector).connect();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Connect", Integer.valueOf(incr));
incr++;
toolItemDisconnect = new ToolItem(toolBar, SWT.PUSH);
toolItemDisconnect.setImage(imageDisconnect);
toolItemDisconnect.setToolTipText("Disconnect the connector");
toolItemDisconnect.setDisabledImage(imageDisableDisconnect);
toolItemDisconnect.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
((IConnectable) compositeConnector).disconnect();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Disconnect", Integer.valueOf(incr));
incr++;
}
if (IRefreshable.class.isAssignableFrom(compositeConnectorClass)) {
toolItemRefresh = new ToolItem(toolBar, SWT.PUSH);
toolItemRefresh.setImage(imageRefresh);
toolItemRefresh.setToolTipText("Refresh connector content");
toolItemRefresh.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
((IRefreshable) compositeConnector).refresh();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Refresh", Integer.valueOf(incr));
incr++;
}
if (IResetable.class.isAssignableFrom(compositeConnectorClass)) {
toolItemReset = new ToolItem(toolBar, SWT.PUSH);
toolItemReset.setImage(imageReset);
toolItemReset.setToolTipText("Reset the connector");
toolItemReset.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
((IResetable) compositeConnector).reset();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Reset", Integer.valueOf(incr));
incr++;
}
if ((IScreenClassAware.class.isAssignableFrom(compositeConnectorClass)) || (IScreenClassContainer.class.isAssignableFrom(connector.getClass()))) {
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
toolItemDebug = new ToolItem(toolBar, SWT.CHECK);
toolItemDebug.setImage(imageDebug);
toolItemDebug.setDisabledImage(imageDisableDebug);
toolItemDebug.setToolTipText("Debug mode");
toolItemDebug.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (ConvertigoPlugin.projectManager.currentProject == null)
return;
if (toolItemDebug.getSelection()) {
try {
ConvertigoPlugin.getDefault().debugConsoleStream.write("Starting debug mode in step by step state...\n");
} catch (IOException ex) {
}
// Studio.theApp.consolePanel.jTabbedPane.setSelectedComponent(Studio.theApp.consolePanel.jScrollPaneDebug);
bDebug = true;
bDebugStepByStep = Boolean.valueOf(true);
toolItemRun.setEnabled(true);
toolItemPause.setEnabled(false);
toolItemStep.setEnabled(true);
connector.markAsDebugging(true);
} else {
try {
ConvertigoPlugin.getDefault().debugConsoleStream.write("Stopping debug mode.\n");
} catch (IOException ex) {
}
bDebug = false;
bDebugStepByStep = Boolean.valueOf(false);
toolItemRun.setEnabled(false);
toolItemPause.setEnabled(false);
toolItemStep.setEnabled(false);
synchronized (debugDatabaseObject) {
debugDatabaseObject.notify();
}
connector.markAsDebugging(false);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Debug", Integer.valueOf(incr));
incr++;
toolItemRun = new ToolItem(toolBar, SWT.PUSH);
toolItemRun.setImage(imageRun);
toolItemRun.setDisabledImage(imageDisableRun);
toolItemRun.setToolTipText("Continuous debug mode");
toolItemRun.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (ConvertigoPlugin.projectManager.currentProject == null)
return;
synchronized (bDebugStepByStep) {
try {
ConvertigoPlugin.getDefault().debugConsoleStream.write("Changing debug state to continuous\n");
} catch (IOException ex) {
}
bDebugStepByStep = Boolean.valueOf(false);
toolItemRun.setEnabled(false);
toolItemStep.setEnabled(false);
toolItemPause.setEnabled(true);
}
synchronized (debugDatabaseObject) {
debugDatabaseObject.notify();
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Run", Integer.valueOf(incr));
incr++;
toolItemPause = new ToolItem(toolBar, SWT.PUSH);
toolItemPause.setImage(imagePause);
toolItemPause.setDisabledImage(imageDisablePause);
toolItemPause.setToolTipText("Pause the debug process");
toolItemPause.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (ConvertigoPlugin.projectManager.currentProject == null)
return;
synchronized (bDebugStepByStep) {
try {
ConvertigoPlugin.getDefault().debugConsoleStream.write("Changing debug state to step by step\n");
} catch (IOException ex) {
}
bDebugStepByStep = Boolean.valueOf(true);
toolItemRun.setEnabled(true);
toolItemStep.setEnabled(true);
toolItemPause.setEnabled(false);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Pause", Integer.valueOf(incr));
incr++;
toolItemStep = new ToolItem(toolBar, SWT.PUSH);
toolItemStep.setImage(imageStep);
toolItemStep.setDisabledImage(imageDisableStep);
toolItemStep.setToolTipText("Step by step debug mode");
toolItemStep.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (ConvertigoPlugin.projectManager.currentProject == null)
return;
synchronized (debugDatabaseObject) {
debugDatabaseObject.notify();
toolItemStep.setEnabled(false);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Step", Integer.valueOf(incr));
incr++;
}
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
toolItemGenerateXml = new ToolItem(toolBar, SWT.PUSH);
toolItemGenerateXml.setImage(imageGenerateXml);
toolItemGenerateXml.setToolTipText("Generate XML");
toolItemGenerateXml.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
getDocument();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("GenerateXML", Integer.valueOf(incr));
incr++;
toolItemStopTransaction = new ToolItem(toolBar, SWT.PUSH);
toolItemStopTransaction.setDisabledImage(imageStop);
toolItemStopTransaction.setToolTipText("Stop the current transaction");
toolItemStopTransaction.setImage(imageDisableStop);
toolItemStopTransaction.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
try {
/*
* if
* (Engine.getProperty(EngineProperties.ConfigurationProperties
* .
* DOCUMENT_THREADING_USE_STOP_METHOD).equalsIgnoreCase("true"
* )) { runningTransaction.runningThread.stop(); } else {
* runningTransaction.runningThread.bContinue = false; }
*/
context.abortRequestable();
// semaphore
if (connector instanceof JavelinConnector) {
// force creation of a
context = getStudioContext(true);
// new context
contextID = context.contextID;
projectName = context.projectName;
}
} catch (NullPointerException npe) {
// Silently ignore: means the runningTransaction pointer has
// been set to null
// because of normal transaction termination...
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("StopTransaction", Integer.valueOf(incr));
incr++;
if (IScreenClassAware.class.isAssignableFrom(compositeConnectorClass)) {
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
ToolItem toolItemGotoCurrentScreenClass = new ToolItem(toolBar, SWT.PUSH);
toolItemGotoCurrentScreenClass.setImage(imageShowScreenclass);
toolItemGotoCurrentScreenClass.setToolTipText("Go to current screen class object");
toolItemGotoCurrentScreenClass.setText("");
toolItemGotoCurrentScreenClass.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
((IScreenClassAware) compositeConnector).goToCurrentScreenClass();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("GoToCurrentScreenClass", Integer.valueOf(incr));
incr++;
if (ILinkable.class.isAssignableFrom(compositeConnectorClass)) {
toolItemLink = new ToolItem(toolBar, SWT.PUSH);
toolItemLink.setImage(imageLink);
// toolItemLink.setDisabledImage(imageDisableLink);
toolItemLink.setToolTipText("Link current selection to highlighted property in Properties panel");
toolItemLink.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
((ILinkable) compositeConnector).link();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
// toolItemLink.setEnabled(false);
toolItemLink.setEnabled(true);
toolItemsIds.put("Link", Integer.valueOf(incr));
incr++;
}
if (IAddable.class.isAssignableFrom(compositeConnectorClass)) {
toolItemAdd = new ToolItem(toolBar, SWT.PUSH);
toolItemAdd.setImage(imageAddFromSelection);
toolItemAdd.setDisabledImage(imageDisableAddFromSelection);
toolItemAdd.setToolTipText("Add element from current selection to highlighted property in Properties panel");
toolItemAdd.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
((IAddable) compositeConnector).add();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemAdd.setEnabled(false);
toolItemsIds.put("Add", Integer.valueOf(incr));
incr++;
}
}
if (connector instanceof SqlConnector) {
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
toolTestConnection = new ToolItem(toolBar, SWT.PUSH);
toolTestConnection.setImage(imageTestConnection);
toolTestConnection.setToolTipText("Test SQL connection");
toolTestConnection.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
Thread t = Thread.currentThread();
ClassLoader cl = t.getContextClassLoader();
try {
t.setContextClassLoader(connector.getProject().getProjectClassLoader());
((SqlConnector) connector).open();
MessageBox mb = new MessageBox(getParent().getShell(), SWT.ICON_WORKING | SWT.OK);
mb.setMessage("Connection parameters are correct.");
mb.open();
} catch (Exception e1) {
Engine.logBeans.error("Test connection failed!" + e1.getMessage());
MessageBox mb = new MessageBox(getParent().getShell(), SWT.ICON_ERROR | SWT.OK);
mb.setMessage("Failed to connect to the database! \n" + e1.getMessage());
mb.open();
} finally {
t.setContextClassLoader(cl);
((SqlConnector) connector).close();
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Test SQL Connection", Integer.valueOf(incr));
incr++;
}
if (IBlockizable.class.isAssignableFrom(compositeConnectorClass)) {
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
toolItemShowBlocks = new ToolItem(toolBar, SWT.CHECK);
toolItemShowBlocks.setImage(imageShowBlocks);
toolItemShowBlocks.setToolTipText("Show Blocks");
toolItemShowBlocks.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (ConvertigoPlugin.projectManager.currentProject == null)
return;
if (toolItemShowBlocks.getSelection()) {
bShowBlocks = true;
((IBlockizable) compositeConnector).showBlocks(true);
} else {
bShowBlocks = false;
((IBlockizable) compositeConnector).showBlocks(false);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("ShowBlocks", Integer.valueOf(incr));
incr++;
}
if (IScreenClassAware.class.isAssignableFrom(compositeConnectorClass)) {
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
tooItemNewScreenClassFromSelectionZone = new ToolItem(toolBar, SWT.PUSH);
tooItemNewScreenClassFromSelectionZone.setImage(imageNewScreenclass);
tooItemNewScreenClassFromSelectionZone.setDisabledImage(imageDisableNewScreenclass);
tooItemNewScreenClassFromSelectionZone.setToolTipText("New ScreenClass");
tooItemNewScreenClassFromSelectionZone.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
createScreenClassFromSelectionZoneAction.run();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("NewScreenClass", Integer.valueOf(incr));
incr++;
tooItemNewTagNameFromSelectionZone = new ToolItem(toolBar, SWT.PUSH);
tooItemNewTagNameFromSelectionZone.setImage(imageNewTagName);
tooItemNewTagNameFromSelectionZone.setToolTipText("New TagName");
tooItemNewTagNameFromSelectionZone.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
createTagNameFromSelectionZoneAction.run();
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("NewTagName", Integer.valueOf(incr));
incr++;
tooItemNewWaitAtFromSelectionZone = new ToolItem(toolBar, SWT.PUSH);
tooItemNewWaitAtFromSelectionZone.setImage(imageNewWaitAt);
tooItemNewWaitAtFromSelectionZone.setDisabledImage(imageDisableNewWaitAt);
tooItemNewWaitAtFromSelectionZone.setToolTipText("New WaitAt");
tooItemNewWaitAtFromSelectionZone.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (compositeConnector instanceof JavelinConnectorComposite) {
((JavelinConnectorComposite) compositeConnector).createWaitAtFromSelectionZone();
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("NewWaitAt", Integer.valueOf(incr));
incr++;
}
if (IRecordable.class.isAssignableFrom(compositeConnectorClass)) {
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
toolItemRecord = new ToolItem(toolBar, SWT.CHECK);
toolItemRecord.setImage(imageRecord);
toolItemRecord.setToolTipText("Record trace");
toolItemRecord.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (ConvertigoPlugin.projectManager.currentProject == null)
return;
if (toolItemRecord.getSelection()) {
((IRecordable) compositeConnector).record(true);
} else {
((IRecordable) compositeConnector).record(false);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Record", Integer.valueOf(incr));
incr++;
}
if ((ILearnable.class.isAssignableFrom(compositeConnectorClass)) && (!HttpConnectorComposite.class.equals(compositeConnectorClass)) && (!SiteClipperConnectorComposite.class.equals(compositeConnectorClass))) {
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
toolLearn = new ToolItem(toolBar, SWT.CHECK);
toolLearn.setToolTipText("Learn");
toolLearn.setImage(imageLearn);
toolLearn.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (toolLearn.getSelection()) {
compositeConnector.startLearn();
toolAccumulate.setEnabled(true);
} else {
compositeConnector.stopLearn();
toolAccumulate.setSelection(false);
toolAccumulate.setEnabled(false);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Learn", Integer.valueOf(incr));
incr++;
toolAccumulate = new ToolItem(toolBar, SWT.CHECK);
toolAccumulate.setToolTipText("Accumulate learning mode");
toolAccumulate.setImage(imageAccumulate);
toolAccumulate.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (toolAccumulate.getSelection())
compositeConnector.setAccumulate(true);
else
compositeConnector.setAccumulate(false);
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
toolItemsIds.put("Accumulate", Integer.valueOf(incr));
incr++;
new ToolItem(toolBar, SWT.SEPARATOR);
incr++;
}
toolItemFullResult = new ToolItem(toolBar, SWT.PUSH);
toolItemFullResult.setDisabledImage(imageDisabledFullResult);
toolItemFullResult.setToolTipText("Show the full result");
toolItemFullResult.setImage(imageFullResult);
toolItemFullResult.setEnabled(false);
toolItemFullResult.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
String x = (String) xmlView.getData("full");
if (x != null) {
xmlView.getDocument().set(x);
toolItemFullResult.setEnabled(false);
}
}
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
});
incr++;
}
use of com.twinsoft.convertigo.beans.connectors.SqlConnector in project convertigo by convertigo.
the class NewProjectWizard method createFromBlankProject.
private Project createFromBlankProject(IProgressMonitor monitor) throws Exception {
String newProjectName = projectName;
String oldProjectName = projectUrlParser.getProjectName();
monitor.setTaskName("Creating new project");
monitor.worked(1);
if (Engine.theApp.databaseObjectsManager.existsProject(newProjectName)) {
throw new EngineException("Unable to create new project ! A project with the same name (\"" + newProjectName + "\") already exists.");
}
monitor.setTaskName("Loading the projet");
monitor.worked(1);
projectUrlParser.setProjectName(projectName);
Project newProject = Engine.theApp.referencedProjectManager.importProject(projectUrlParser, true);
monitor.worked(1);
try {
// set values of elements to configure on the new project
String newEmulatorTechnology = "";
String emulatorTechnologyName = "";
String newIbmTerminalType = "";
switch(wizardId) {
case "com.twinsoft.convertigo.eclipse.wizards.New3270ConnectorWizard":
case "com.twinsoft.convertigo.eclipse.wizards.New3270WebWizard":
newEmulatorTechnology = Session.SNA;
newIbmTerminalType = "IBM-3279";
emulatorTechnologyName = "IBM3270";
break;
case "com.twinsoft.convertigo.eclipse.wizards.New5250ConnectorWizard":
case "com.twinsoft.convertigo.eclipse.wizards.New5250WebWizard":
newEmulatorTechnology = Session.AS400;
newIbmTerminalType = "IBM-3179";
emulatorTechnologyName = "IBM5250";
break;
case "com.twinsoft.convertigo.eclipse.wizards.NewDKUConnectorWizard":
case "com.twinsoft.convertigo.eclipse.wizards.NewDKUWebWizard":
newEmulatorTechnology = Session.DKU;
emulatorTechnologyName = "BullDKU7107";
break;
case "com.twinsoft.convertigo.eclipse.wizards.NewVT220ConnectorWizard":
newEmulatorTechnology = Session.VT;
emulatorTechnologyName = "UnixVT220";
break;
}
monitor.setTaskName("Reset project version");
monitor.worked(1);
newProject.setVersion("");
monitor.setTaskName("Change connector name");
monitor.worked(1);
String oldConnectorName = "void";
String newConnectorName = "void";
boolean connectorChanged = false;
if (page2 != null) {
newConnectorName = page2.getConnectorName();
monitor.setTaskName("Connector renamed");
monitor.worked(1);
oldConnectorName = newProject.getDefaultConnector().getName();
newProject.getDefaultConnector().setName(newConnectorName);
connectorChanged = true;
}
if (page5 != null) {
CicsConnector cicsConnector = (CicsConnector) newProject.getDefaultConnector();
monitor.setTaskName("Update connector mainframe name");
monitor.worked(1);
cicsConnector.setMainframeName(page5.getCtgName());
monitor.setTaskName("Update connector server");
monitor.worked(1);
cicsConnector.setServer(page5.getCtgServer());
monitor.setTaskName("Update connector port");
monitor.worked(1);
try {
cicsConnector.setPort(Integer.parseInt(page5.getCtgPort()));
} catch (Exception e) {
}
}
if (page6 != null) {
monitor.setTaskName("Update connector server");
monitor.worked(1);
// change connector server and port,
// change https mode
// and change proxy server and proxy port
HttpConnector httpConnector = (HttpConnector) newProject.getDefaultConnector();
httpConnector.setServer(page6.getHttpServer());
monitor.setTaskName("Update connector port");
monitor.worked(1);
try {
httpConnector.setPort(Integer.parseInt(page6.getHttpPort()));
} catch (Exception e) {
}
monitor.setTaskName("Update connector https mode");
monitor.worked(1);
httpConnector.setHttps(page6.isBSSL());
}
if (page7 != null) {
// change emulator technology
// and change service code
monitor.setTaskName("Set connector service code");
monitor.worked(1);
JavelinConnector javelinConnector = (JavelinConnector) newProject.getDefaultConnector();
javelinConnector.setServiceCode(page7.getServiceCode());
monitor.setTaskName("Set connector emulator technology");
monitor.worked(1);
javelinConnector.setEmulatorTechnology(newEmulatorTechnology);
monitor.setTaskName("Set terminal type");
monitor.worked(1);
javelinConnector.setIbmTerminalType(newIbmTerminalType);
// rename emulatorTechnology criteria
monitor.setTaskName("Rename emulator technology criteria");
monitor.worked(1);
javelinConnector.getDefaultScreenClass().getLocalCriterias().get(0).setName(emulatorTechnologyName);
}
if (page11 != null) {
SiteClipperConnector scConnector = (SiteClipperConnector) newProject.getDefaultConnector();
monitor.setTaskName("Update connector certificates policy");
monitor.worked(1);
scConnector.setTrustAllServerCertificates(page11.isTrustAllServerCertificates());
monitor.setTaskName("Update host url");
monitor.worked(1);
scConnector.getDefaultTransaction().setTargetURL(page11.getTargetURL());
}
if (configureSQLConnectorPage != null) {
SqlConnector sqlConnector = (SqlConnector) newProject.getDefaultConnector();
monitor.setTaskName("Update JDBC URL");
monitor.worked(1);
sqlConnector.setJdbcURL(configureSQLConnectorPage.getJdbcURL());
monitor.setTaskName("Update JDBC driver");
monitor.worked(1);
sqlConnector.setJdbcDriverClassName(configureSQLConnectorPage.getJdbcDriver());
monitor.setTaskName("Update Username");
monitor.worked(1);
sqlConnector.setJdbcUserName(configureSQLConnectorPage.getUsername());
monitor.setTaskName("Update Password");
monitor.worked(1);
sqlConnector.setJdbcUserPassword(configureSQLConnectorPage.getPassword());
}
if (configureSAPConnectorPage != null) {
SapJcoConnector sapConnector = (SapJcoConnector) newProject.getDefaultConnector();
// Application Server Host
monitor.setTaskName("Update application Server Host");
monitor.worked(1);
sapConnector.setAsHost(configureSAPConnectorPage.getAsHost());
// System Number
monitor.setTaskName("Update system number");
monitor.worked(1);
sapConnector.setSystemNumber(configureSAPConnectorPage.getSystemNumber());
// Client
monitor.setTaskName("Update client");
monitor.worked(1);
sapConnector.setClient(configureSAPConnectorPage.getClient());
// User
monitor.setTaskName("Update user");
monitor.worked(1);
sapConnector.setUser(configureSAPConnectorPage.getUser());
// Password
monitor.setTaskName("Update password");
monitor.worked(1);
sapConnector.setPassword(configureSAPConnectorPage.getPassword());
// Language
monitor.setTaskName("Update language");
monitor.worked(1);
sapConnector.setLanguage(configureSAPConnectorPage.getLanguage());
}
monitor.setTaskName("Saving updated project");
monitor.worked(1);
Engine.theApp.databaseObjectsManager.exportProject(newProject);
monitor.setTaskName("New project saved");
monitor.worked(1);
try {
File eProject = new File(newProject.getDirPath(), ".project");
if (eProject.exists()) {
String txt = FileUtils.readFileToString(eProject, StandardCharsets.UTF_8);
txt = txt.replaceFirst("(<name>)(.*?)(</name>)", "$1" + newProjectName + "$3");
FileUtils.writeStringToFile(eProject, txt, StandardCharsets.UTF_8);
}
String xsdInternalPath = newProject.getDirPath() + "/" + Project.XSD_FOLDER_NAME + "/" + Project.XSD_INTERNAL_FOLDER_NAME;
File xsdInternalDir = new File(xsdInternalPath).getCanonicalFile();
if (xsdInternalDir.exists() && connectorChanged) {
boolean needConnectorRename = !oldConnectorName.equals(newConnectorName);
if (needConnectorRename) {
File srcDir = new File(xsdInternalDir, oldConnectorName);
File destDir = new File(xsdInternalDir, newConnectorName);
if (oldConnectorName.equalsIgnoreCase(newConnectorName)) {
File destDirTmp = new File(xsdInternalDir, "tmp" + oldConnectorName).getCanonicalFile();
FileUtils.moveDirectory(srcDir, destDirTmp);
srcDir = destDirTmp;
}
FileUtils.moveDirectory(srcDir, destDir);
}
for (File connectorDir : xsdInternalDir.listFiles()) {
if (connectorDir.isDirectory()) {
String connectorName = connectorDir.getName();
for (File transactionXsdFile : connectorDir.listFiles()) {
String xsdFilePath = transactionXsdFile.getCanonicalPath();
ProjectUtils.xsdRenameProject(xsdFilePath, oldProjectName, newProjectName);
if (needConnectorRename && connectorName.equals(newConnectorName)) {
ProjectUtils.xsdRenameConnector(xsdFilePath, oldConnectorName, newConnectorName);
}
}
}
}
}
monitor.setTaskName("Schemas updated");
monitor.worked(1);
updateProjectTreeView();
} catch (Exception e) {
Engine.logDatabaseObjectManager.error("An error occured while updating transaction schemas", e);
}
} catch (Exception e) {
// Delete everything
try {
Engine.logBeans.error("An error occured while creating project, everything will be deleted. Please see Studio logs for more informations.", null);
// TODO : see if we can delete oldProjectName : a real project
// could exist with this oldProjectName ?
// Engine.theApp.databaseObjectsManager.deleteProject(oldProjectName,
// false, false);
Engine.theApp.databaseObjectsManager.deleteProject(newProjectName, false, false);
projectName = null;
} catch (Exception ex) {
}
throw new Exception("Unable to create project from template", e);
}
return newProject;
}
Aggregations