use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject 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.views.projectexplorer.model.IDesignTreeObject in project convertigo by convertigo.
the class DeleteDesignDocumentFunctionAction 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) {
TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
if (treeObjects != null) {
HashSet<TreeParent> treeParentToReload = new HashSet<TreeParent>();
HashSet<TreeParent> treeParentToRefresh = new HashSet<TreeParent>();
int len = treeObjects.length;
for (int i = 0; i < len; i++) {
try {
DesignDocumentFunctionTreeObject ddfto = (DesignDocumentFunctionTreeObject) treeObjects[i];
if (ddfto != null) {
MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION | SWT.APPLICATION_MODAL);
String message = java.text.MessageFormat.format("Do you really want to delete the object \"{0}\" and all its sub-objects?", new Object[] { ddfto.getName() });
messageBox.setMessage(message);
if (messageBox.open() == SWT.YES) {
TreeParent owner = ddfto.getTreeObjectOwner();
IDesignTreeObject dto = ddfto.getParentDesignTreeObject();
if (dto != null) {
dto.remove(ddfto);
}
if (owner != null) {
if (owner instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) owner;
if (databaseObjectTreeObject.hasChanged()) {
TreeParent treeParent = databaseObjectTreeObject.getParent();
if (treeParent instanceof FolderTreeObject)
treeParent = treeParent.getParent();
treeParentToReload.add(treeParent);
}
} else
treeParentToRefresh.add(owner);
}
}
}
} catch (ClassCastException e) {
}
}
for (TreeParent treeParent : treeParentToReload) {
explorerView.reloadTreeObject(treeParent);
}
for (TreeParent owner : treeParentToRefresh) {
explorerView.refreshTreeObject(owner, true);
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to delete function!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject in project convertigo by convertigo.
the class ProjectExplorerView method edit.
private void edit(TreeObject treeObject) {
final Tree tree = viewer.getTree();
final TreeEditor editor = new TreeEditor(tree);
final Color black = getSite().getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK);
TreeItem[] items = tree.getSelection();
if (items.length > 0) {
final TreeItem item = items[0];
final TreeObject theTreeObject = treeObject;
if (treeObject instanceof ProjectTreeObject) {
if (((ProjectTreeObject) treeObject).getModified()) {
// Project need to be saved to avoid xsd/wsdl modification errors - Fix ticket #2265
ConvertigoPlugin.warningMessageBox("Please save project before renaming it.");
return;
}
}
if (treeObject.getObject() instanceof HandlerStatement) {
return;
}
if ((item != null) && lastItem.length > 0 && (item == lastItem[0])) {
boolean isCarbon = SWT.getPlatform().equals("carbon");
final Composite composite = new Composite(tree, SWT.NONE);
if (!isCarbon) {
composite.setBackground(black);
}
final Text text = new Text(composite, SWT.NONE);
final int inset = isCarbon ? 0 : 1;
composite.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
Rectangle rect = composite.getClientArea();
text.setBounds(rect.x + inset, rect.y + inset, rect.width - inset * 2, rect.height - inset * 2);
}
});
Listener textListener = new Listener() {
public void handleEvent(final Event e) {
MobileBuilder mba = null;
MobileBuilder mbo = null;
IEditorPart editorPart = ConvertigoPlugin.getDefault().getApplicationComponentEditor();
if (editorPart != null) {
IEditorInput input = editorPart.getEditorInput();
if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
mba = editorInput.getApplication().getProject().getMobileBuilder();
}
if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
mba = editorInput.getApplication().getProject().getMobileBuilder();
}
}
if (theTreeObject instanceof DatabaseObjectTreeObject) {
mbo = ((DatabaseObjectTreeObject) theTreeObject).getObject().getProject().getMobileBuilder();
}
String newName = null;
String oldName = null;
boolean needRefresh = false;
boolean needProjectReload = false;
if (theTreeObject instanceof DatabaseObjectTreeObject) {
oldName = ((DatabaseObject) ((DatabaseObjectTreeObject) theTreeObject).getObject()).getName();
} else if (theTreeObject instanceof TraceTreeObject) {
oldName = ((TraceTreeObject) theTreeObject).getName();
} else if (theTreeObject instanceof DesignDocumentViewTreeObject) {
oldName = ((DesignDocumentViewTreeObject) theTreeObject).getName();
} else if (theTreeObject instanceof DesignDocumentFunctionTreeObject) {
oldName = ((DesignDocumentFunctionTreeObject) theTreeObject).getName();
}
switch(e.type) {
case SWT.FocusOut:
editingTextCtrl = null;
composite.dispose();
break;
case SWT.Verify:
String newText = text.getText();
String leftText = newText.substring(0, e.start);
String rightText = newText.substring(e.end, newText.length());
GC gc = new GC(text);
Point size = gc.textExtent(leftText + e.text + rightText);
gc.dispose();
size = text.computeSize(size.x, SWT.DEFAULT);
editor.horizontalAlignment = SWT.LEFT;
Rectangle itemRect = item.getBounds(), rect = tree.getClientArea();
editor.minimumWidth = Math.max(size.x, itemRect.width) + inset * 2;
int left = itemRect.x, right = rect.x + rect.width;
editor.minimumWidth = Math.min(editor.minimumWidth, right - left);
editor.minimumHeight = size.y + inset * 2;
editor.layout();
break;
case SWT.Traverse:
switch(e.detail) {
case SWT.TRAVERSE_RETURN:
Engine.logStudio.info("---------------------- Rename started ----------------------");
if (mba != null) {
mba.prepareBatchBuild();
}
newName = text.getText();
// Save and close editors
if (theTreeObject instanceof IClosableTreeObject) {
((IClosableTreeObject) theTreeObject).closeAllEditors(true);
}
if (theTreeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject dbObjectTreeObject = (DatabaseObjectTreeObject) theTreeObject;
if (dbObjectTreeObject.rename(newName, Boolean.TRUE)) {
item.setText(newName);
needRefresh = true;
if (theTreeObject instanceof ProjectTreeObject) {
needProjectReload = true;
}
}
} else if (theTreeObject instanceof TraceTreeObject) {
TraceTreeObject traceTreeObject = (TraceTreeObject) theTreeObject;
traceTreeObject.rename(newName);
if (traceTreeObject.hasChanged) {
item.setText(newName);
traceTreeObject.hasChanged = false;
needRefresh = true;
}
} else if (theTreeObject instanceof DesignDocumentViewTreeObject) {
DesignDocumentViewTreeObject ddvto = (DesignDocumentViewTreeObject) theTreeObject;
if (ddvto.rename(newName, Boolean.TRUE)) {
item.setText(newName);
needRefresh = true;
}
} else if (theTreeObject instanceof DesignDocumentFunctionTreeObject) {
DesignDocumentFunctionTreeObject ddfto = (DesignDocumentFunctionTreeObject) theTreeObject;
if (ddfto.rename(newName, Boolean.TRUE)) {
item.setText(newName);
needRefresh = true;
}
}
// FALL THROUGH
case SWT.TRAVERSE_ESCAPE:
editingTextCtrl = null;
composite.dispose();
e.doit = false;
}
break;
}
if (needRefresh) {
boolean updateDlg = false;
boolean updateReferences = false;
int update = 0;
// Updates references to object if needed
if ((theTreeObject instanceof ProjectTreeObject) || (theTreeObject instanceof SequenceTreeObject) || (theTreeObject instanceof ConnectorTreeObject) || (theTreeObject instanceof TransactionTreeObject) || (theTreeObject instanceof VariableTreeObject2) || (theTreeObject instanceof IDesignTreeObject) || (theTreeObject instanceof MobilePageComponentTreeObject) || (theTreeObject instanceof MobileUIComponentTreeObject) || (theTreeObject instanceof NgxPageComponentTreeObject) || (theTreeObject instanceof NgxUIComponentTreeObject)) {
String objectType = "";
if (theTreeObject instanceof ProjectTreeObject) {
objectType = "project";
updateDlg = true;
} else if (theTreeObject instanceof SequenceTreeObject) {
objectType = "sequence";
updateDlg = true;
} else if (theTreeObject instanceof ConnectorTreeObject) {
objectType = "connector";
updateDlg = true;
} else if (theTreeObject instanceof TransactionTreeObject) {
objectType = "transaction";
updateDlg = true;
} else if (theTreeObject instanceof VariableTreeObject2) {
objectType = "variable";
updateDlg = ((DatabaseObject) theTreeObject.getObject()) instanceof RequestableVariable ? true : false;
} else if (theTreeObject instanceof DesignDocumentTreeObject) {
objectType = "document";
updateDlg = true;
} else if (theTreeObject instanceof DesignDocumentViewTreeObject) {
objectType = "view";
updateDlg = true;
} else if (theTreeObject instanceof DesignDocumentFilterTreeObject) {
objectType = "filter";
updateDlg = true;
} else if (theTreeObject instanceof DesignDocumentUpdateTreeObject) {
objectType = "update";
updateDlg = true;
} else if (theTreeObject instanceof DesignDocumentValidateTreeObject) {
objectType = "validate";
updateDlg = true;
} else if (theTreeObject instanceof MobilePageComponentTreeObject) {
objectType = "page";
updateDlg = true;
} else if (theTreeObject instanceof NgxPageComponentTreeObject) {
objectType = "page";
updateDlg = true;
} else if (theTreeObject instanceof MobileUIComponentTreeObject) {
DatabaseObject dbo = (DatabaseObject) theTreeObject.getObject();
if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) {
objectType = "menu";
updateDlg = true;
}
if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
objectType = "shared action";
updateDlg = true;
}
if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) {
objectType = "shared component";
updateDlg = true;
}
if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UIStackVariable) {
objectType = "variable";
updateDlg = true;
}
if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UICompVariable) {
objectType = "variable";
updateDlg = true;
}
} else if (theTreeObject instanceof NgxUIComponentTreeObject) {
DatabaseObject dbo = (DatabaseObject) theTreeObject.getObject();
if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) {
objectType = "menu";
updateDlg = true;
}
if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
objectType = "shared action";
updateDlg = true;
}
if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) {
objectType = "shared component";
updateDlg = true;
}
if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UIStackVariable) {
objectType = "variable";
updateDlg = true;
}
if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UICompVariable) {
objectType = "variable";
updateDlg = true;
}
}
if (updateDlg) {
Shell shell = Display.getDefault().getActiveShell();
CustomDialog customDialog = new CustomDialog(shell, "Update object references", "Do you want to update " + objectType + " references ?\n You can replace '" + oldName + "' by '" + newName + "' in all loaded projects \n or replace '" + oldName + "' by '" + newName + "' in current project only.", 670, 200, new ButtonSpec("Replace in all loaded projects", true), new ButtonSpec("Replace in current project", false), new ButtonSpec("Do not replace anywhere", false));
int response = customDialog.open();
if (response == 0) {
updateReferences = true;
update = TreeObjectEvent.UPDATE_ALL;
}
if (response == 1) {
updateReferences = true;
update = TreeObjectEvent.UPDATE_LOCAL;
}
}
}
TreeObjectEvent treeObjectEvent = null;
if (updateReferences) {
treeObjectEvent = new TreeObjectEvent(theTreeObject, "name", oldName, newName, update);
} else {
treeObjectEvent = new TreeObjectEvent(theTreeObject, "name", oldName, newName);
}
BatchOperationHelper.start();
ProjectExplorerView.this.refreshTree();
ProjectExplorerView.this.setSelectedTreeObject(theTreeObject);
ProjectExplorerView.this.fireTreeObjectPropertyChanged(treeObjectEvent);
if (updateReferences && needProjectReload) {
((ProjectTreeObject) theTreeObject).save(false);
}
if (mbo != null) {
if (theTreeObject instanceof MobilePageComponentTreeObject) {
try {
mbo.pageRenamed((com.twinsoft.convertigo.beans.mobile.components.PageComponent) theTreeObject.getObject(), oldName);
} catch (EngineException e1) {
e1.printStackTrace();
}
}
if (theTreeObject instanceof NgxPageComponentTreeObject) {
try {
mbo.pageRenamed((com.twinsoft.convertigo.beans.ngx.components.PageComponent) theTreeObject.getObject(), oldName);
} catch (EngineException e1) {
e1.printStackTrace();
}
}
}
BatchOperationHelper.stop();
Engine.logStudio.info("---------------------- Rename ended ----------------------");
StructuredSelection structuredSelection = new StructuredSelection(theTreeObject);
ISelectionListener listener = null;
// refresh properties view
listener = ConvertigoPlugin.getDefault().getPropertiesView();
if (listener != null)
listener.selectionChanged((IWorkbenchPart) ProjectExplorerView.this, structuredSelection);
// refresh references view
listener = ConvertigoPlugin.getDefault().getReferencesView();
if (listener != null)
listener.selectionChanged((IWorkbenchPart) ProjectExplorerView.this, structuredSelection);
}
if (needProjectReload) {
Engine.theApp.databaseObjectsManager.clearCache(newName);
reloadProject(theTreeObject);
refreshTree();
}
}
};
text.addListener(SWT.FocusOut, textListener);
text.addListener(SWT.Traverse, textListener);
text.addListener(SWT.Verify, textListener);
editor.setEditor(composite, item);
if (theTreeObject instanceof DatabaseObjectTreeObject) {
text.setText(((DatabaseObjectTreeObject) theTreeObject).getName());
} else if (theTreeObject instanceof TraceTreeObject) {
text.setText(((TraceTreeObject) theTreeObject).getName());
} else if (theTreeObject instanceof DesignDocumentViewTreeObject) {
text.setText(((DesignDocumentViewTreeObject) theTreeObject).getName());
} else if (theTreeObject instanceof DesignDocumentFunctionTreeObject) {
text.setText(((DesignDocumentFunctionTreeObject) theTreeObject).getName());
}
text.selectAll();
text.setFocus();
editingTextCtrl = text;
}
lastItem[0] = item;
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject in project convertigo by convertigo.
the class ClipboardManager method copy.
public String copy(TreePath[] treePaths) throws EngineException {
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
clipboardDocument = XMLUtils.getDefaultDocumentBuilder().newDocument();
ProcessingInstruction pi = clipboardDocument.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"ISO-8859-1\"");
clipboardDocument.appendChild(pi);
clipboardRootElement = clipboardDocument.createElement("convertigo-clipboard");
clipboardDocument.appendChild(clipboardRootElement);
TreePath[] selectedPaths = ((treePaths == null) ? projectExplorerView.getSelectionPaths() : treePaths);
treeObjectsList = new ArrayList<TreeObject>();
treeParentsList = new ArrayList<TreeObject>();
for (int i = 0; i < selectedPaths.length; i++) {
TreeObject treeObject = (TreeObject) selectedPaths[i].getLastPathComponent();
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) treeObject;
DatabaseObjectTreeObject parentDatabaseObjectTreeObject = databaseObjectTreeObject.getParentDatabaseObjectTreeObject();
treeObjectsList.add(databaseObjectTreeObject);
treeParentsList.add(parentDatabaseObjectTreeObject);
copyDatabaseObject((DatabaseObject) databaseObjectTreeObject.getObject());
} else if (treeObject instanceof IPropertyTreeObject) {
IPropertyTreeObject propertyTreeObject = (IPropertyTreeObject) treeObject;
treeObjectsList.add(treeObject);
treeParentsList.add(((IPropertyTreeObject) treeObject).getTreeObjectOwner());
copyPropertyObject(propertyTreeObject);
} else if (treeObject instanceof IDesignTreeObject) {
IDesignTreeObject designTreeObject = (IDesignTreeObject) treeObject;
treeObjectsList.add(treeObject);
treeParentsList.add(((IDesignTreeObject) treeObject).getTreeObjectOwner());
copyDesignObject(designTreeObject);
} else {
throw new EngineException("Tree item not supported :" + treeObject.getClass().getName());
}
}
objects = treeObjectsList.toArray(new Object[selectedPaths.length]);
parentTreeNodeOfCutObjects = treeParentsList.toArray(new TreeObject[selectedPaths.length]);
String strObject = XMLUtils.prettyPrintDOM(clipboardDocument);
return strObject;
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject in project convertigo by convertigo.
the class ClipboardManager method cutAndPaste.
public void cutAndPaste(Object object, TreeObject targetTreeObject) throws ConvertigoException {
// Ignore cut paste on itself
if (object.equals(targetTreeObject)) {
return;
}
// Check for cut paste into itself
if (object instanceof TreeObject) {
if (targetTreeObject.isChildOf((TreeObject) object)) {
throw new InvalidOperationException("You cannot cut and paste this object into itself");
}
}
if (object instanceof DatabaseObjectTreeObject) {
if (targetTreeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject sourceTreeObject = (DatabaseObjectTreeObject) object;
DatabaseObject databaseObject = (DatabaseObject) sourceTreeObject.getObject();
DatabaseObject targetObject = (DatabaseObject) targetTreeObject.getObject();
String oldQName = databaseObject.getQName();
cutAndPaste(databaseObject, targetObject);
String newQName = databaseObject.getQName();
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
if (projectExplorerView != null) {
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(sourceTreeObject, "qname", oldQName, newQName, TreeObjectEvent.UPDATE_ALL);
projectExplorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
} else if (object instanceof IPropertyTreeObject) {
if (targetTreeObject instanceof IPropertyTreeObject) {
IPropertyTreeObject tpo = (IPropertyTreeObject) object;
IPropertyTreeObject ttpo = (IPropertyTreeObject) targetTreeObject;
if (tpo.getParent().equals(ttpo.getParent())) {
return;
}
if (tpo.getParent().equals(ttpo)) {
return;
}
tpo.remove(object);
ttpo.add(object, false);
}
} else if (object instanceof IDesignTreeObject) {
if (targetTreeObject instanceof IDesignTreeObject) {
IDesignTreeObject tpo = (IDesignTreeObject) object;
IDesignTreeObject ttpo = (IDesignTreeObject) targetTreeObject;
if (tpo.getParent().equals(ttpo.getParent())) {
return;
}
if (tpo.getParent().equals(ttpo)) {
return;
}
if (ttpo.canPaste(object)) {
tpo.remove(object);
ttpo.add(object, false);
}
}
}
}
Aggregations