use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject in project convertigo by convertigo.
the class TreeDropAdapter method validateDrop.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
*/
@Override
public boolean validateDrop(Object target, int operation, TransferData transferType) {
if (TextTransfer.getInstance().isSupportedType(transferType)) {
if (getCurrentOperation() == DND.DROP_MOVE) {
Object targetObject = getCurrentTarget();
Object sourceObject = getSelectedObject();
if (targetObject != null && targetObject instanceof TreeObject) {
TreeObject targetTreeObject = (TreeObject) targetObject;
if (sourceObject != null && sourceObject instanceof TreeObject) {
TreeObject sourceTreeObject = (TreeObject) sourceObject;
boolean isFocus = sourceTreeObject.viewer.getControl().isFocusControl();
if (isFocus && (sourceObject == targetObject || targetTreeObject.isChildOf(sourceTreeObject))) {
return false;
}
}
if (targetObject instanceof DatabaseObjectTreeObject) {
try {
String xmlData = TextTransfer.getInstance().nativeToJava(transferType).toString();
List<Object> list = ConvertigoPlugin.clipboardManagerDND.read(xmlData);
DatabaseObject databaseObject = (DatabaseObject) list.get(0);
DatabaseObject targetDatabaseObject = ((DatabaseObjectTreeObject) target).getObject();
if (DatabaseObjectsManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
return true;
}
DatabaseObject parentDatabaseObject = targetDatabaseObject.getParent();
if (parentDatabaseObject != null && DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
return true;
}
return false;
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
}
return true;
}
if (StepSourceTransfer.getInstance().isSupportedType(transferType)) {
if (target instanceof TreeObject) {
TreeObject targetTreeObject = (TreeObject) target;
// Check for drop to a step which contains a stepSource definition
// if (targetTreeObject.getObject() instanceof IStepSourceContainer) {
Object ob = targetTreeObject.getObject();
if (ob instanceof Step && ((Step) ob).canWorkOnSource() || ob instanceof IStepSourceContainer) {
StepSource stepSource = StepSourceTransfer.getInstance().getStepSource();
if (stepSource != null) {
Step targetStep = (Step) ((ob instanceof StepVariable) ? ((StepVariable) ob).getParent() : ob);
// Check for drop to a step in the same sequence
Long key = Long.valueOf(stepSource.getPriority());
Step sourceStep = targetStep.getSequence().loadedSteps.get(key);
if ((sourceStep != null) && (!targetStep.equals(sourceStep))) {
// Check for drop on a 'following' step
try {
List<TreeObject> siblings = new ArrayList<TreeObject>();
getNextSiblings(siblings, targetTreeObject.getProjectTreeObject(), sourceStep);
// System.out.println("siblings: "+siblings.toString());
return siblings.contains(targetTreeObject);
} catch (Exception e) {
e.printStackTrace(System.out);
}
;
}
}
}
}
}
if (PaletteSourceTransfer.getInstance().isSupportedType(transferType)) {
if (target instanceof TreeObject) {
TreeObject targetTreeObject = (TreeObject) target;
PaletteSource paletteSource = PaletteSourceTransfer.getInstance().getPaletteSource();
if (paletteSource != null) {
try {
String xmlData = paletteSource.getXmlData();
List<Object> list = ConvertigoPlugin.clipboardManagerDND.read(xmlData);
DatabaseObject databaseObject = (DatabaseObject) list.get(0);
if (targetTreeObject instanceof ObjectsFolderTreeObject) {
ObjectsFolderTreeObject folderTreeObject = (ObjectsFolderTreeObject) targetTreeObject;
if (!ProjectExplorerView.folderAcceptMobileComponent(folderTreeObject.folderType, databaseObject)) {
return false;
}
// continue
targetTreeObject = folderTreeObject.getParent();
}
if (targetTreeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject targetDatabaseObject = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
if (targetDatabaseObject != null) {
if (!DatabaseObjectsManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
return false;
}
if (targetTreeObject instanceof MobileComponentTreeObject) {
if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
return false;
}
if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(targetDatabaseObject, databaseObject)) {
return false;
}
}
if (targetTreeObject instanceof NgxComponentTreeObject) {
if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
return false;
}
if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(targetDatabaseObject, databaseObject)) {
return false;
}
}
return true;
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
}
if (MobileSourceTransfer.getInstance().isSupportedType(transferType)) {
MobileSource mobileSource = MobileSourceTransfer.getInstance().getMobileSource();
if (mobileSource != null) {
if (target instanceof MobileUIComponentTreeObject) {
MobileUIComponentTreeObject mcto = GenericUtils.cast(target);
com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource mss = com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.valueOf(mobileSource.getJsonString());
if (mss == null || !mss.isDroppableInto(mcto.getObject())) {
return false;
}
for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
if (descriptor instanceof MobileSmartSourcePropertyDescriptor) {
if (!((MobileSmartSourcePropertyDescriptor) descriptor).isReadOnly()) {
return true;
}
}
}
}
if (target instanceof NgxUIComponentTreeObject) {
NgxUIComponentTreeObject mcto = GenericUtils.cast(target);
com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource mss = com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.valueOf(mobileSource.getJsonString());
if (mss == null || !mss.isDroppableInto(mcto.getObject())) {
return false;
}
for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
if (descriptor instanceof NgxSmartSourcePropertyDescriptor) {
if (!((NgxSmartSourcePropertyDescriptor) descriptor).isReadOnly()) {
return true;
}
}
}
}
}
}
return false;
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject in project convertigo by convertigo.
the class DisableMobileUIComponentAction 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) {
DatabaseObjectTreeObject treeObject = null;
UIComponent component = null;
TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
for (int i = treeObjects.length - 1; i >= 0; i--) {
treeObject = (DatabaseObjectTreeObject) treeObjects[i];
if (treeObject instanceof MobileUIComponentTreeObject) {
MobileUIComponentTreeObject componentTreeObject = (MobileUIComponentTreeObject) treeObject;
component = (UIComponent) componentTreeObject.getObject();
component.setEnabled(false);
componentTreeObject.setEnabled(false);
componentTreeObject.hasBeenModified(true);
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", true, false);
explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
explorerView.refreshSelectedTreeObjects();
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to disable component!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations