use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject in project convertigo by convertigo.
the class CreatePropertyTableColumnAction 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) {
PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) explorerView.getFirstSelectedTreeObject();
TreeParent owner = propertyTableRowTreeObject.getTreeObjectOwner();
IPropertyTreeObject pto = propertyTableRowTreeObject.addNewColumn();
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 column!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject 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.IPropertyTreeObject in project convertigo by convertigo.
the class ClipboardManager method paste.
public void paste(String xmlData, Object parentObject, boolean bChangeName) throws EngineException, SAXException, IOException {
Document document = XMLUtils.getDefaultDocumentBuilder().parse(new InputSource(new StringReader(xmlData)));
Element rootElement = document.getDocumentElement();
NodeList nodeList = rootElement.getChildNodes();
int len = nodeList.getLength();
Node node;
pastedSteps.clear();
pastedComponents.clear();
pastedObjects = new Object[] {};
if (len > 0) {
pastedObjects = new Object[len];
}
Object object = null;
for (int i = 0; i < len; i++) {
node = (Node) nodeList.item(i);
if (node.getNodeType() != Node.TEXT_NODE) {
if (parentObject instanceof IPropertyTreeObject) {
object = paste(node, (IPropertyTreeObject) parentObject, bChangeName);
} else if (parentObject instanceof IDesignTreeObject) {
object = paste(node, (IDesignTreeObject) parentObject, bChangeName);
} else {
object = paste(node, (DatabaseObject) parentObject, bChangeName);
}
pastedObjects[i] = object;
}
}
for (Entry<String, Step> entry : pastedSteps.entrySet()) {
Step step = entry.getValue();
step.getSequence().fireStepCopied(new StepEvent(step, entry.getKey()));
}
for (Object ob : pastedObjects) {
// MOBILE COMPONENTS
if (ob instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
if (ob instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
com.twinsoft.convertigo.beans.mobile.components.PageComponent page = GenericUtils.cast(ob);
for (Entry<String, MobileObject> entry : pastedComponents.entrySet()) {
if (page.updateSmartSources(entry.getKey(), String.valueOf(entry.getValue().priority))) {
page.markPageAsDirty();
}
}
} else if (ob instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
com.twinsoft.convertigo.beans.mobile.components.UIComponent uic = GenericUtils.cast(ob);
for (Entry<String, MobileObject> entry : pastedComponents.entrySet()) {
if (uic.updateSmartSources(entry.getKey(), String.valueOf(entry.getValue().priority))) {
uic.markAsDirty();
}
}
}
}
// NGX COMPONENTS
if (ob instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
if (ob instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
com.twinsoft.convertigo.beans.ngx.components.PageComponent page = GenericUtils.cast(ob);
for (Entry<String, MobileObject> entry : pastedComponents.entrySet()) {
if (page.updateSmartSources(entry.getKey(), String.valueOf(entry.getValue().priority))) {
page.markPageAsDirty();
}
}
} else if (ob instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
com.twinsoft.convertigo.beans.ngx.components.UIComponent uic = GenericUtils.cast(ob);
for (Entry<String, MobileObject> entry : pastedComponents.entrySet()) {
if (uic.updateSmartSources(entry.getKey(), String.valueOf(entry.getValue().priority))) {
uic.markAsDirty();
}
}
}
}
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject in project convertigo by convertigo.
the class ClipboardManager method paste.
public Object paste(Node node, IPropertyTreeObject parentPropertyTreeObject, boolean bChangeName) throws EngineException {
Object object = read(node);
if (object instanceof PropertyData) {
PropertyData propertyData = (PropertyData) object;
IPropertyTreeObject propertyTreeObject = parentPropertyTreeObject.add(propertyData, bChangeName);
if (propertyTreeObject != null) {
NodeList childNodes = node.getChildNodes();
int len = childNodes.getLength();
Node childNode;
String childNodeName;
for (int i = 0; i < len; i++) {
childNode = childNodes.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
childNodeName = childNode.getNodeName();
if (!(childNodeName.equalsIgnoreCase("property"))) {
paste(childNode, propertyTreeObject, bChangeName);
}
}
return propertyTreeObject;
}
}
return null;
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject in project convertigo by convertigo.
the class TreeDropAdapter method dragOver.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerDropAdapter#dragOver(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public void dragOver(DropTargetEvent event) {
super.dragOver(event);
// Overrides feedback: by default is DND.FEEDBACK_SELECT
feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
boolean shouldFeedBack = true;
if (PaletteSourceTransfer.getInstance().isSupportedType(event.currentDataType)) {
int currentLocation = getCurrentLocation();
switch(currentLocation) {
case LOCATION_BEFORE:
feedback = DND.FEEDBACK_INSERT_BEFORE;
break;
case LOCATION_AFTER:
feedback = DND.FEEDBACK_INSERT_AFTER;
break;
case LOCATION_ON:
default:
break;
}
shouldFeedBack = false;
}
// Handles feedback for objects that can be ordered
if (shouldFeedBack && getCurrentOperation() == DND.DROP_MOVE) {
Object targetObject = getCurrentTarget();
Object sourceObject = getSelectedObject();
if ((sourceObject != null) && (targetObject != null)) {
// Source and target objects must be different
if (!sourceObject.equals(targetObject)) {
if ((sourceObject instanceof TreeObject) && (targetObject instanceof TreeObject)) {
// Source and target objects can be ordered
if ((sourceObject instanceof IOrderableTreeObject) && (targetObject instanceof IOrderableTreeObject)) {
// Source and target objects must have the same parent
boolean srcInherited = false;
if (sourceObject instanceof DatabaseObjectTreeObject)
srcInherited = ((DatabaseObjectTreeObject) sourceObject).isInherited;
else if (sourceObject instanceof IPropertyTreeObject)
srcInherited = ((IPropertyTreeObject) sourceObject).isInherited();
// Source object musn't be inherited
if (!srcInherited) {
int currentLocation = getCurrentLocation();
switch(currentLocation) {
case LOCATION_BEFORE:
feedback = DND.FEEDBACK_INSERT_BEFORE;
break;
case LOCATION_AFTER:
feedback = DND.FEEDBACK_INSERT_AFTER;
break;
case LOCATION_ON:
default:
break;
}
}
}
}
}
}
}
// Set feedback
event.feedback = feedback;
}
Aggregations