use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject in project convertigo by convertigo.
the class CreateNgxUIComponentAction method selectionChanged.
public void selectionChanged(IAction action, ISelection selection) {
try {
boolean enable = true;
super.selectionChanged(action, selection);
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
if (treeObject instanceof ObjectsFolderTreeObject) {
ObjectsFolderTreeObject oft = (ObjectsFolderTreeObject) treeObject;
if (oft.folderType == ObjectsFolderTreeObject.FOLDER_TYPE_PAGES) {
enable = false;
} else {
TreeParent treeParent = oft.getParent();
enable = treeParent != null && treeParent instanceof NgxComponentTreeObject;
}
} else if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
enable = actionModel.isEnabled;
}
action.setEnabled(enable);
} catch (Exception e) {
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject in project convertigo by convertigo.
the class NgxPickerComposite method setCurrentInput.
public void setCurrentInput(Object selected, String source) {
if (isUpdating)
return;
currentMC = null;
setWidgetsEnabled(true);
if (selected instanceof NgxComponentTreeObject) {
UIComponent uic = null;
if (selected instanceof NgxPageComponentTreeObject) {
currentMC = ((NgxPageComponentTreeObject) selected).getObject();
} else if (selected instanceof NgxUIComponentTreeObject) {
uic = ((NgxUIComponentTreeObject) selected).getObject();
// currentMC = uic.getPage() != null ? uic.getPage() : (uic.getMenu() != null ? uic.getMenu() : uic.getApplication());
currentMC = currentMC == null ? uic.getPage() : currentMC;
currentMC = currentMC == null ? uic.getMenu() : currentMC;
currentMC = currentMC == null ? uic.getSharedAction() : currentMC;
currentMC = currentMC == null ? uic.getSharedComponent() : currentMC;
currentMC = currentMC == null ? uic.getApplication() : currentMC;
}
if (currentMC == null) {
resetViewers();
} else {
if (!currentMC.equals(checkboxTreeViewer.getInput())) {
resetViewers();
checkboxTreeViewer.setInput(currentMC);
initTreeSelection(checkboxTreeViewer, null);
}
MobileSmartSource cs = MobileSmartSource.valueOf(source);
if (cs != null) {
NgxPickerContentProvider contentProvider = (NgxPickerContentProvider) checkboxTreeViewer.getContentProvider();
if (isParentDialog) {
// when dbo's property edition
contentProvider.setSelectedDbo(uic);
}
ToolItem buttonToSelect = btnSequence;
currentSource = source;
Filter filter = cs.getFilter();
if (Filter.Sequence.equals(filter)) {
buttonToSelect = btnSequence;
}
if (Filter.Database.equals(filter)) {
buttonToSelect = btnDatabase;
}
if (Filter.Action.equals(filter)) {
buttonToSelect = btnAction;
}
if (Filter.Shared.equals(filter)) {
buttonToSelect = btnShared;
}
if (Filter.Iteration.equals(filter)) {
buttonToSelect = btnIteration;
}
if (Filter.Form.equals(filter)) {
buttonToSelect = btnForm;
}
if (Filter.Global.equals(filter)) {
buttonToSelect = btnGlobal;
}
buttonToSelect.notifyListeners(SWT.Selection, null);
}
}
updateMessage();
} else {
resetViewers();
updateMessage();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject 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.NgxComponentTreeObject in project convertigo by convertigo.
the class EditNgxComponentClassAction 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 treeObject = explorerView.getFirstSelectedTreeObject();
if (treeObject instanceof NgxComponentTreeObject) {
if (treeObject instanceof NgxApplicationComponentTreeObject) {
NgxApplicationComponentTreeObject mpcto = GenericUtils.cast(treeObject);
mpcto.editAppComponentTsFile();
} else if (treeObject instanceof NgxPageComponentTreeObject) {
NgxPageComponentTreeObject mpcto = GenericUtils.cast(treeObject);
mpcto.editPageTsFile();
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to edit ngx component class!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject in project convertigo by convertigo.
the class ExecuteMobileBuilderClassAction 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 treeObject = explorerView.getFirstSelectedTreeObject();
if (treeObject instanceof MobileComponentTreeObject) {
if (treeObject instanceof MobileApplicationComponentTreeObject) {
MobileApplicationComponentTreeObject mpcto = (MobileApplicationComponentTreeObject) treeObject;
com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditor editor = mpcto.activeEditor(false);
editor.launchBuilder(forceInstall, forceClean);
}
} else if (treeObject instanceof NgxComponentTreeObject) {
if (treeObject instanceof NgxApplicationComponentTreeObject) {
NgxApplicationComponentTreeObject mpcto = (NgxApplicationComponentTreeObject) treeObject;
com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditor editor = mpcto.activeEditor(false);
editor.launchBuilder(forceInstall, forceClean);
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to open the mobile builder!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations