use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class ClipboardAction method paste.
public void paste(String source, Shell shell, ProjectExplorerView explorerView, TreeObject selectedTreeObject, boolean isDND) throws ConvertigoException, IOException, ParserConfigurationException, SAXException, CoreException {
if ((explorerView != null) && (selectedTreeObject != null)) {
TreeObject targetTreeObject = null;
Object targetObject = null;
if (selectedTreeObject instanceof FolderTreeObject) {
if (selectedTreeObject.getParent() instanceof IDesignTreeObject) {
selectedTreeObject = selectedTreeObject.getParent();
}
}
if (selectedTreeObject instanceof IPropertyTreeObject) {
targetTreeObject = selectedTreeObject;
targetObject = selectedTreeObject;
} else if (selectedTreeObject instanceof IDesignTreeObject) {
targetTreeObject = selectedTreeObject;
targetObject = selectedTreeObject;
if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_DOCUMENT) {
targetTreeObject = ((IDesignTreeObject) selectedTreeObject).getTreeObjectOwner();
targetObject = (DatabaseObject) targetTreeObject.getObject();
}
} else {
// case of folder, retrieve owner object
targetTreeObject = explorerView.getFirstSelectedDatabaseObjectTreeObject(selectedTreeObject);
targetObject = (DatabaseObject) targetTreeObject.getObject();
// i.e. without having to select the parent database object.
if (clipboardManager.objectsType == ProjectExplorerView.getTreeObjectType(new TreePath(targetTreeObject))) {
// it must be different from the currently selected object.
if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_SCREEN_CLASS) {
CustomDialog customDialog = new CustomDialog(shell, "Paste a Screenclass", "Do you want to paste the Screenclass as a sibling or as an inherited ScreenClass?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As an iherited", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
int response = customDialog.open();
if (response == 0)
targetObject = ((DatabaseObject) targetObject).getParent();
else if (response == 2)
return;
} else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STATEMENT_WITH_EXPRESSIONS) {
if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_FUNCTION) {
targetObject = ((DatabaseObject) targetObject).getParent();
} else {
CustomDialog customDialog = new CustomDialog(shell, "Paste a statement", "Do you want to paste the statement as a sibling or a child statement?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
int response = customDialog.open();
if (response == 0) {
targetObject = ((DatabaseObject) targetObject).getParent();
} else if (response == 2) {
return;
}
}
} else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_MOBILE_UICOMPONENT) {
if (!clipboardManager.isCut) {
CustomDialog customDialog = new CustomDialog(shell, "Paste a Component", "Do you want to paste the Component as a sibling or as a child component?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
int response = customDialog.open();
if (response == 0) {
targetObject = ((DatabaseObject) targetObject).getParent();
} else if (response == 2) {
return;
}
}
} else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP_WITH_EXPRESSIONS || clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP) {
targetObject = pasteStep(shell, source, (DatabaseObject) targetObject);
if (targetObject == null)
return;
} else if (isDND && clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_SEQUENCE) {
// Do not change target to parent
} else {
targetObject = ((DatabaseObject) targetObject).getParent();
}
targetTreeObject = explorerView.findTreeObjectByUserObject(((DatabaseObject) targetObject));
} else {
if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP_WITH_EXPRESSIONS || clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP) {
targetObject = pasteStep(shell, source, (DatabaseObject) targetObject);
if (targetObject == null)
return;
}
}
}
if (clipboardManager.isCut) {
TreeParent targetTreeParent = null;
String targetPath = targetTreeObject.getPath();
if (targetTreeObject instanceof DatabaseObjectTreeObject) {
targetTreeParent = ((DatabaseObjectTreeObject) targetTreeObject).getOwnerDatabaseObjectTreeObject();
} else if (targetTreeObject instanceof IPropertyTreeObject) {
targetTreeParent = ((IPropertyTreeObject) targetTreeObject).getTreeObjectOwner();
} else if (targetTreeObject instanceof IDesignTreeObject) {
targetTreeParent = ((IDesignTreeObject) targetTreeObject).getTreeObjectOwner();
}
for (int i = 0; i < clipboardManager.objects.length; i++) {
// Cut & paste
clipboardManager.cutAndPaste(clipboardManager.objects[i], targetTreeObject);
// Updating the tree
// Report 4.5: fix #401
// explorerView.reloadTreeObject(clipboardManager.parentTreeNodeOfCutObjects[i]);
TreeObject parentTreeNodeOfCutObjects = clipboardManager.parentTreeNodeOfCutObjects[i];
parentTreeNodeOfCutObjects.getProjectTreeObject().hasBeenModified(true);
if (!(parentTreeNodeOfCutObjects instanceof IDesignTreeObject)) {
explorerView.reloadTreeObject(parentTreeNodeOfCutObjects);
}
}
if (targetTreeObject != null) {
if (targetTreeObject.getParent() == null)
targetTreeObject = explorerView.findTreeObjectByPath(targetTreeParent, targetPath);
if (targetTreeObject != null)
// Report 4.5: fix #401
targetTreeObject.getProjectTreeObject().hasBeenModified(true);
}
clipboardManager.reset();
} else if (source != null) {
// Paste
clipboardManager.paste(source, targetObject, true);
// Case of project copy
if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_PROJECT) {
Object[] pastedObjects = clipboardManager.pastedObjects;
for (int i = 0; i < pastedObjects.length; i++) {
Object object = pastedObjects[i];
if ((object != null) && (object instanceof Project)) {
Project project = (Project) object;
String oldName = project.getName();
try {
Project importedProject = importProjectTempArchive(oldName, explorerView);
if (importedProject != null) {
String newName = importedProject.getName();
explorerView.importProjectTreeObject(newName, true, oldName);
} else
throw new EngineException("Unable to import project temporary archive");
} catch (Exception e) {
throw new EngineException("Unable to paste project", e);
}
}
}
}
}
// Updating the tree
if (targetTreeObject != null) {
TreeObject treeObjectToReload = targetTreeObject;
TreeObject treeObjectToSelect = targetTreeObject;
if (targetTreeObject instanceof IPropertyTreeObject) {
treeObjectToSelect = ((IPropertyTreeObject) targetTreeObject).getTreeObjectOwner();
treeObjectToReload = treeObjectToSelect;
if (treeObjectToReload instanceof DatabaseObjectTreeObject) {
treeObjectToReload = treeObjectToReload.getParent();
if (treeObjectToReload instanceof FolderTreeObject)
treeObjectToReload = treeObjectToReload.getParent();
}
}
if (targetTreeObject instanceof IDesignTreeObject) {
treeObjectToSelect = ((IDesignTreeObject) targetTreeObject).getTreeObjectOwner();
treeObjectToReload = treeObjectToSelect;
if (treeObjectToReload instanceof DatabaseObjectTreeObject) {
treeObjectToReload = treeObjectToReload.getParent();
if (treeObjectToReload instanceof FolderTreeObject)
treeObjectToReload = treeObjectToReload.getParent();
}
}
if (treeObjectToReload != null) {
// explorerView.reloadTreeObject(targetTreeObject);
// explorerView.setSelectedTreeObject(targetTreeObject);
explorerView.objectChanged(new CompositeEvent(treeObjectToReload.getObject(), treeObjectToSelect.getPath()));
}
}
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class CreateDesignDocumentFilterAction 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) {
DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) explorerView.getFirstSelectedTreeObject();
DesignDocumentFilterTreeObject ddfto = ddto.addNewFilter();
if (ddto.hasChanged()) {
TreeParent treeParent = ddto.getParent();
if (treeParent instanceof FolderTreeObject)
treeParent = treeParent.getParent();
explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), ddfto.getPath()));
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create a new filter!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class CreateDesignDocumentValidateAction 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) {
DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) explorerView.getFirstSelectedTreeObject();
DesignDocumentValidateTreeObject ddvto = ddto.addNewValidate();
if (ddto.hasChanged()) {
TreeParent treeParent = ddto.getParent();
if (treeParent instanceof FolderTreeObject)
treeParent = treeParent.getParent();
explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), ddvto.getPath()));
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create a new Validate!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class CreateDesignDocumentUpdateAction 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) {
DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) explorerView.getFirstSelectedTreeObject();
DesignDocumentUpdateTreeObject dduto = ddto.addNewUpdate();
if (ddto.hasChanged()) {
TreeParent treeParent = ddto.getParent();
if (treeParent instanceof FolderTreeObject)
treeParent = treeParent.getParent();
explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), dduto.getPath()));
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create a new update!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.
the class CreatePropertyTableRowAction 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) {
PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) explorerView.getFirstSelectedTreeObject();
TreeParent owner = propertyTableTreeObject.getTreeObjectOwner();
IPropertyTreeObject pto = propertyTableTreeObject.addNewRow();
if (owner instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) owner;
if (databaseObjectTreeObject.hasChanged()) {
TreeParent treeParent = databaseObjectTreeObject.getParent();
if (treeParent instanceof FolderTreeObject)
treeParent = treeParent.getParent();
// explorerView.reloadTreeObject(treeParent);
explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), pto.getPath()));
}
} else
explorerView.refreshTreeObject(owner, true);
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to create a new row!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations