use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject 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);
}
}
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ProjectExplorerView method fireTreeObjectAdded.
public void fireTreeObjectAdded(TreeObjectEvent treeObjectEvent) {
// Guaranteed to return a non-null array
Object[] listeners = treeObjectListeners.getListenerList();
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == TreeObjectListener.class) {
try {
((TreeObjectListener) listeners[i + 1]).treeObjectAdded(treeObjectEvent);
} catch (Exception e) {
String message = "fireTreeObjectAdded failed for treeObject: " + ((TreeObject) listeners[i + 1]).getName();
ConvertigoPlugin.logException(e, message);
}
;
}
}
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
// Case of Project added
if (databaseObject instanceof Project) {
ProjectTreeObject projectTreeObject = (ProjectTreeObject) treeObject;
// Case of project copy : update references in steps if needed
if (treeObjectEvent.oldValue != null) {
String oldName = (String) treeObjectEvent.oldValue;
String newName = (String) treeObjectEvent.newValue;
boolean updateReferences = false;
int update = 0;
if (loadedProjectsHaveReferences()) {
Shell shell = Display.getDefault().getActiveShell();
CustomDialog customDialog = new CustomDialog(shell, "Update object references", "Do you want to update " + "project" + " 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;
}
}
if (updateReferences) {
treeObjectEvent.update = update;
fireTreeObjectPropertyChanged(treeObjectEvent);
projectTreeObject.save(false);
}
}
projectTreeObject.checkMissingProjects();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ProjectExplorerView method findTreeObjectByPath.
// private void loadTrace(TreeParent parentTreeObject, File dir) {
// FolderTreeObject folderTreeObject = new FolderTreeObject(viewer, "Traces");
// parentTreeObject.addChild(folderTreeObject);
//
// if (!dir.exists()) {
// if (!dir.mkdir())
// return;
// }
// File[] files = dir.listFiles(new FilenameFilter() {
// public boolean accept(File dir, String name) {
// if (new File(dir, name).isFile() && (name.endsWith(".etr"))) return true;
// return false;
// }
// });
// if (files == null) return;
//
// File file;
// TraceTreeObject traceTreeObject;
// for (int i = 0; i < files.length; i++) {
// file = files[i];
// traceTreeObject = new TraceTreeObject(viewer, file);
// folderTreeObject.addChild(traceTreeObject);
// }
// }
public TreeObject findTreeObjectByPath(TreeParent treeParent, String path) {
TreeObject foundObject = null;
if (treeParent == null)
return null;
String treeParentPath = treeParent.getPath();
if (treeParentPath.length() > path.length())
return null;
if (treeParent instanceof DatabaseObjectTreeObject) {
if (((DatabaseObjectTreeObject) treeParent).isInherited)
return null;
}
if (treeParent instanceof PropertyTableTreeObject) {
if (((PropertyTableTreeObject) treeParent).isInherited())
return null;
}
if (treeParentPath.equals(path))
return treeParent;
for (TreeObject treeObject : treeParent.getChildren()) {
if (treeObject instanceof TreeParent) {
foundObject = findTreeObjectByPath((TreeParent) treeObject, path);
if (foundObject != null)
break;
} else if (treeObject.getPath().equals(path)) {
foundObject = treeObject;
break;
}
}
return foundObject;
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ProjectExplorerView method objectDetected.
public void objectDetected(EngineEvent engineEvent) {
final Object source = engineEvent.getSource();
boolean highlightDetectedObject = ConvertigoPlugin.getHighlightDetectedObject();
if (source instanceof Step) {
try {
highlightDetectedObject = Boolean.TRUE.equals(RequestAttribute.debug.get(((Step) source).getSequence().context.httpServletRequest));
} catch (Exception e) {
// silently ignore
}
}
if (highlightDetectedObject) {
if (source instanceof DatabaseObject) {
getSite().getShell().getDisplay().syncExec(new Runnable() {
public void run() {
DatabaseObjectTreeObject databaseTreeObject = (DatabaseObjectTreeObject) findTreeObjectByUserObject((DatabaseObject) source);
if (databaseTreeObject != null) {
if (lastDetectedDatabaseObjectTreeObject != null) {
lastDetectedDatabaseObjectTreeObject.isDetectedObject = false;
updateTreeObject(lastDetectedDatabaseObjectTreeObject);
}
databaseTreeObject.isDetectedObject = true;
updateTreeObject(databaseTreeObject);
viewer.expandToLevel(databaseTreeObject, 0);
lastDetectedDatabaseObjectTreeObject = databaseTreeObject;
if (databaseTreeObject instanceof ScreenClassTreeObject) {
lastDetectedScreenClass = (ScreenClass) source;
lastDetectedScreenClassTreeObject = (ScreenClassTreeObject) databaseTreeObject;
}
}
}
});
}
} else {
if (source instanceof ScreenClass) {
lastDetectedScreenClass = (ScreenClass) source;
}
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject in project convertigo by convertigo.
the class ProjectExplorerView method reloadDatabaseObject.
public void reloadDatabaseObject(DatabaseObject databaseObject) throws EngineException, IOException {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) findTreeObjectByUserObject(databaseObject);
treeObject.hasBeenModified(databaseObject.hasChanged);
reloadTreeObject(treeObject);
}
Aggregations