use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject in project convertigo by convertigo.
the class SetDefaultConnectorAction method selectionChanged.
public void selectionChanged(IAction action, ISelection selection) {
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
if (treeObject instanceof ConnectorTreeObject) {
DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
action.setChecked(actionModel.isChecked);
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject in project convertigo by convertigo.
the class SetDefaultConnectorAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) explorerView.getFirstSelectedTreeObject();
Connector connector = (Connector) connectorTreeObject.getObject();
Project project = connector.getProject();
// Report from 4.5: fix #401
ConnectorTreeObject defaultConnectorTreeObject = null;
Connector defaultConnector = project.getDefaultConnector();
if (defaultConnector != null) {
defaultConnectorTreeObject = (ConnectorTreeObject) explorerView.findTreeObjectByUserObject(defaultConnector);
}
project.setDefaultConnector(connector);
if (defaultConnectorTreeObject != null) {
defaultConnectorTreeObject.isDefault = false;
defaultConnectorTreeObject.hasBeenModified(true);
}
connectorTreeObject.isDefault = true;
connectorTreeObject.hasBeenModified(true);
// Updating the tree
explorerView.refreshTreeObject(connectorTreeObject.getParentDatabaseObjectTreeObject());
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to set connector to default one!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject in project convertigo by convertigo.
the class ViewExecuteSelectedAction method run.
@Override
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
if ((treeObject != null) && (treeObject instanceof DesignDocumentViewTreeObject)) {
DesignDocumentViewTreeObject viewTreeObject = (DesignDocumentViewTreeObject) treeObject;
DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) viewTreeObject.getTreeObjectOwner();
ConnectorTreeObject cto = (ConnectorTreeObject) ddto.getOwnerDatabaseObjectTreeObject();
ProjectTreeObject projectTreeObject = cto.getProjectTreeObject();
CouchDbConnector connector = (CouchDbConnector) cto.getObject();
cto.openConnectorEditor();
ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
if (connectorEditor != null) {
// activate connector's editor
getActivePage().activate(connectorEditor);
// set transaction's parameters
Transaction transaction = connector.getTransactionByName(CouchDbConnector.internalView);
((GetViewTransaction) transaction).setViewname(viewTreeObject.getDocViewName());
Variable view_reduce = ((GetViewTransaction) transaction).getVariable(CouchParam.prefix + "reduce");
view_reduce.setValueOrNull(viewTreeObject.hasReduce() ? isReduceRequested() : false);
// execute view transaction
connectorEditor.getDocument(CouchDbConnector.internalView, isStubRequested());
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to execute the selected view!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject in project convertigo by convertigo.
the class ReferencesView method handleConnectorSelection.
private void handleConnectorSelection(Object firstElement) {
ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) firstElement;
Connector connectorSelected = connectorTreeObject.getObject();
String connectorSelectedName = connectorSelected.getName();
Project projectConnectorSelected = connectorSelected.getProject();
String connectorProjectName = connectorSelected.getProject().getName();
List<Transaction> transactions = connectorSelected.getTransactionsList();
try {
Project project = null;
List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
treeViewer.setInput(null);
RootNode root = new RootNode();
ConnectorNode connectorNode = null;
connectorNode = getConnectorNode(root, connectorSelected);
root.addChild(connectorNode);
IsUsedByNode isUsedByNode = new IsUsedByNode(connectorNode, "Is used by");
RequiresNode requiresNode = new RequiresNode(connectorNode, "Requires");
ProjectNode projectFolder = null;
// Search handlers are that referenced by the selected connector for continue with site Clipper
if (connectorSelected instanceof HtmlConnector) {
ProjectNode projectNode = new ProjectNode(requiresNode, connectorProjectName, projectConnectorSelected);
for (Transaction transaction : transactions) {
List<Statement> statements = ((HtmlTransaction) transaction).getStatements();
List<String> siteClipperConnectorNames = new ArrayList<String>();
for (Statement statement : statements) {
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 = projectConnectorSelected.getConnectorByName(siteClipperconnectorName);
ConnectorNode connectorSiteClipperNode = new SiteClipperConnectorNode(projectNode, siteClipperconnectorName, siteClipperConnector);
projectNode.addChild(connectorSiteClipperNode);
}
}
}
}
}
if (projectNode.hasChildren()) {
requiresNode.addChild(projectNode);
}
} else if (connectorSelected instanceof SiteClipperConnector) {
List<Connector> connectors = projectConnectorSelected.getConnectorsList();
ProjectNode projectNode = new ProjectNode(isUsedByNode, connectorProjectName, projectConnectorSelected);
for (Connector connector : connectors) {
if (connector instanceof HtmlConnector) {
List<Transaction> transactionList = ((HtmlConnector) connector).getTransactionsList();
for (Transaction transaction : transactionList) {
List<Statement> statements = ((HtmlTransaction) transaction).getStatements();
for (Statement statement : statements) {
List<Statement> statementList = ((FunctionStatement) statement).getStatements();
for (Statement st : statementList) {
if (st instanceof ContinueWithSiteClipperStatement) {
String sourceSiteClipperConnectorName = ((ContinueWithSiteClipperStatement) st).getSiteClipperConnectorName();
if (sourceSiteClipperConnectorName.equals(connectorSelectedName)) {
ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
HtmlConnectorNode htmlConnectorNode = new HtmlConnectorNode(projectNode, connector.getName(), connector);
projectNode.addChild(htmlConnectorNode);
TransactionNode transactionNode = new TransactionNode(htmlConnectorNode, transaction.getName(), continueWithSiteClipperStatement);
htmlConnectorNode.addChild(transactionNode);
}
}
}
}
}
}
}
if (projectNode.hasChildren()) {
isUsedByNode.addChild(projectNode);
}
}
// Searching all objects that are referenced by the selected connector
for (String projectName : projectNames) {
project = getProject(projectName, projectExplorerView);
if (project != null) {
projectFolder = new ProjectNode(isUsedByNode, projectName, 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.startsWith(projectConnectorSelected + "." + connectorSelectedName + ".")) {
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> steps = sequence.getSteps();
SequenceNode sequenceNode = new SequenceNode(projectFolder, sequence.getName(), sequence);
for (Step step : steps) {
getConnectorReferencingIsUsedBy(step, projectExplorerView, sequenceNode, transactions, connectorProjectName, connectorSelectedName);
}
if (sequenceNode.hasChildren()) {
projectFolder.addChild(sequenceNode);
}
}
if (projectFolder.hasChildren()) {
isUsedByNode.addChild(projectFolder);
}
}
}
if (requiresNode.hasChildren()) {
connectorNode.addChild(requiresNode);
}
if (isUsedByNode.hasChildren()) {
connectorNode.addChild(isUsedByNode);
}
if (!connectorNode.hasChildren()) {
connectorNode.addChild(new InformationNode(connectorNode, "This connector is not used by any other objects"));
}
treeViewer.setInput(root);
treeViewer.expandAll();
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject in project convertigo by convertigo.
the class DatabaseObjectDeleteAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
treeNodesToUpdate = new ArrayList<>();
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject[] selectedTreeObjects = explorerView.getSelectedTreeObjects();
if (selectedTreeObjects != null) {
Collection<DatabaseObjectTreeObject> treeObjects = new HashSet<>(selectedTreeObjects.length);
for (TreeObject t : Arrays.asList(selectedTreeObjects)) {
if (t instanceof DatabaseObjectTreeObject) {
treeObjects.add((DatabaseObjectTreeObject) t);
}
}
;
if (treeObjects.size() > 1) {
for (DatabaseObjectTreeObject t : new ArrayList<>(treeObjects)) {
TreeObject parent = t.getParent();
while (parent != null) {
if (treeObjects.contains(parent)) {
treeObjects.remove(t);
parent = null;
} else {
parent = parent.getParent();
}
}
}
;
}
if (treeObjects.size() > 1) {
List<DatabaseObjectTreeObject> list = new ArrayList<>(treeObjects);
Collections.sort(list, new Comparator<DatabaseObjectTreeObject>() {
@Override
public int compare(DatabaseObjectTreeObject o1, DatabaseObjectTreeObject o2) {
if (o1 instanceof ProjectTreeObject) {
if (o2 instanceof ProjectTreeObject) {
return o1.getName().compareTo(o2.getName());
}
return -1;
} else if (o2 instanceof ProjectTreeObject) {
return 1;
}
return o1.getName().compareTo(o2.getName());
}
});
treeObjects = list;
}
MultipleDeletionDialog dialog = new MultipleDeletionDialog(shell, "Object Deletion", treeObjects.size() != 1);
for (DatabaseObjectTreeObject treeObject : treeObjects) {
String message = java.text.MessageFormat.format("Do you really want to delete the {0} \"{1}\" and all its sub-objects?", treeObject instanceof ProjectTreeObject ? "project" : "object", treeObject.getName());
if (treeObject instanceof ProjectTreeObject) {
message += "\nProject location: " + ((Project) treeObject.getObject()).getDirPath();
dialog.setToggle("Delete project content on disk (cannot be undone)", false);
} else {
dialog.removeToggle();
}
if (!dialog.shouldBeDeleted(message)) {
continue;
}
try {
if (treeObject instanceof ProjectTreeObject) {
((ProjectTreeObject) treeObject).closeAllEditors();
} else if (treeObject instanceof SequenceTreeObject) {
((ProjectTreeObject) ((SequenceTreeObject) treeObject).getParent().getParent()).closeSequenceEditors((Sequence) treeObject.getObject());
} else if (treeObject instanceof ConnectorTreeObject) {
((ProjectTreeObject) ((ConnectorTreeObject) treeObject).getParent().getParent()).closeConnectorEditors((Connector) treeObject.getObject());
} else if (treeObject instanceof StepTreeObject) {
// We close the editor linked with the SimpleStep (=SequenceJsStep)
if (treeObject.getObject() instanceof SimpleStep) {
boolean find = false;
SimpleStep simpleStep = (SimpleStep) treeObject.getObject();
IWorkbenchPage page = this.getActivePage();
IEditorReference[] editors = page.getEditorReferences();
int _i = 0;
while (find != true && _i < editors.length) {
IEditorReference editor = editors[_i];
IEditorInput input = editor.getEditorInput();
if (input instanceof JScriptEditorInput) {
if (simpleStep.equals(((JScriptEditorInput) input).getDatabaseObject())) {
find = true;
IEditorPart editorPart = page.findEditor(input);
if (editorPart != null) {
page.activate(editorPart);
page.closeEditor(editorPart, false);
}
}
}
++_i;
}
}
} else if (treeObject instanceof MobileComponentTreeObject) {
((MobileComponentTreeObject) treeObject).closeAllEditors(false);
}
if (treeObject instanceof ProjectTreeObject) {
explorerView.removeProjectTreeObject(treeObject);
final Project project = (Project) treeObject.getObject();
Job rmProject = new Job("Remove '" + project.getName() + "' project") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
delete(project, dialog.getToggleState());
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to delete the '" + project.getName() + "' project.");
return new MultiStatus(ConvertigoPlugin.PLUGIN_UNIQUE_ID, IStatus.ERROR, "Failed to remove the '" + project.getName() + "' project.", e);
}
return Status.OK_STATUS;
}
};
rmProject.schedule();
} else {
delete(treeObject);
// prevents treeObject and its childs to receive further TreeObjectEvents
if (treeObject instanceof TreeObjectListener) {
explorerView.removeTreeObjectListener(treeObject);
}
treeObject.removeAllChildren();
}
explorerView.fireTreeObjectRemoved(new TreeObjectEvent(treeObject));
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to delete the current selected object.");
}
}
;
// Updating the tree and the properties panel
Enumeration<DatabaseObjectTreeObject> enumeration = Collections.enumeration(treeNodesToUpdate);
DatabaseObjectTreeObject parentTreeObject;
while (enumeration.hasMoreElements()) {
parentTreeObject = enumeration.nextElement();
if (parentTreeObject != null) {
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(parentTreeObject);
}
}
// Refresh tree to show potential 'broken' steps
explorerView.refreshTree();
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to delete object!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations