use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject in project convertigo by convertigo.
the class MobilePickerComposite method setCurrentInput.
public void setCurrentInput(Object selected, String source) {
if (isUpdating)
return;
currentMC = null;
setWidgetsEnabled(true);
if (selected instanceof MobileComponentTreeObject) {
UIComponent uic = null;
if (selected instanceof MobilePageComponentTreeObject) {
currentMC = ((MobilePageComponentTreeObject) selected).getObject();
} else if (selected instanceof MobileUIComponentTreeObject) {
uic = ((MobileUIComponentTreeObject) 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) {
MobilePickerContentProvider contentProvider = (MobilePickerContentProvider) 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.MobileComponentTreeObject 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.MobileComponentTreeObject in project convertigo by convertigo.
the class DatabaseObjectDeleteAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
treeNodesToUpdate = new ArrayList<>();
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject[] selectedTreeObjects = explorerView.getSelectedTreeObjects();
if (selectedTreeObjects != null) {
Collection<DatabaseObjectTreeObject> treeObjects = new HashSet<>(selectedTreeObjects.length);
for (TreeObject t : Arrays.asList(selectedTreeObjects)) {
if (t instanceof DatabaseObjectTreeObject) {
treeObjects.add((DatabaseObjectTreeObject) t);
}
}
;
if (treeObjects.size() > 1) {
for (DatabaseObjectTreeObject t : new ArrayList<>(treeObjects)) {
TreeObject parent = t.getParent();
while (parent != null) {
if (treeObjects.contains(parent)) {
treeObjects.remove(t);
parent = null;
} else {
parent = parent.getParent();
}
}
}
;
}
if (treeObjects.size() > 1) {
List<DatabaseObjectTreeObject> list = new ArrayList<>(treeObjects);
Collections.sort(list, new Comparator<DatabaseObjectTreeObject>() {
@Override
public int compare(DatabaseObjectTreeObject o1, DatabaseObjectTreeObject o2) {
if (o1 instanceof ProjectTreeObject) {
if (o2 instanceof ProjectTreeObject) {
return o1.getName().compareTo(o2.getName());
}
return -1;
} else if (o2 instanceof ProjectTreeObject) {
return 1;
}
return o1.getName().compareTo(o2.getName());
}
});
treeObjects = list;
}
MultipleDeletionDialog dialog = new MultipleDeletionDialog(shell, "Object Deletion", treeObjects.size() != 1);
for (DatabaseObjectTreeObject treeObject : treeObjects) {
String message = java.text.MessageFormat.format("Do you really want to delete the {0} \"{1}\" and all its sub-objects?", treeObject instanceof ProjectTreeObject ? "project" : "object", treeObject.getName());
if (treeObject instanceof ProjectTreeObject) {
message += "\nProject location: " + ((Project) treeObject.getObject()).getDirPath();
dialog.setToggle("Delete project content on disk (cannot be undone)", false);
} else {
dialog.removeToggle();
}
if (!dialog.shouldBeDeleted(message)) {
continue;
}
try {
if (treeObject instanceof ProjectTreeObject) {
((ProjectTreeObject) treeObject).closeAllEditors();
} else if (treeObject instanceof SequenceTreeObject) {
((ProjectTreeObject) ((SequenceTreeObject) treeObject).getParent().getParent()).closeSequenceEditors((Sequence) treeObject.getObject());
} else if (treeObject instanceof ConnectorTreeObject) {
((ProjectTreeObject) ((ConnectorTreeObject) treeObject).getParent().getParent()).closeConnectorEditors((Connector) treeObject.getObject());
} else if (treeObject instanceof StepTreeObject) {
// We close the editor linked with the SimpleStep (=SequenceJsStep)
if (treeObject.getObject() instanceof SimpleStep) {
boolean find = false;
SimpleStep simpleStep = (SimpleStep) treeObject.getObject();
IWorkbenchPage page = this.getActivePage();
IEditorReference[] editors = page.getEditorReferences();
int _i = 0;
while (find != true && _i < editors.length) {
IEditorReference editor = editors[_i];
IEditorInput input = editor.getEditorInput();
if (input instanceof JScriptEditorInput) {
if (simpleStep.equals(((JScriptEditorInput) input).getDatabaseObject())) {
find = true;
IEditorPart editorPart = page.findEditor(input);
if (editorPart != null) {
page.activate(editorPart);
page.closeEditor(editorPart, false);
}
}
}
++_i;
}
}
} else if (treeObject instanceof MobileComponentTreeObject) {
((MobileComponentTreeObject) treeObject).closeAllEditors(false);
}
if (treeObject instanceof ProjectTreeObject) {
explorerView.removeProjectTreeObject(treeObject);
final Project project = (Project) treeObject.getObject();
Job rmProject = new Job("Remove '" + project.getName() + "' project") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
delete(project, dialog.getToggleState());
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to delete the '" + project.getName() + "' project.");
return new MultiStatus(ConvertigoPlugin.PLUGIN_UNIQUE_ID, IStatus.ERROR, "Failed to remove the '" + project.getName() + "' project.", e);
}
return Status.OK_STATUS;
}
};
rmProject.schedule();
} else {
delete(treeObject);
// prevents treeObject and its childs to receive further TreeObjectEvents
if (treeObject instanceof TreeObjectListener) {
explorerView.removeTreeObjectListener(treeObject);
}
treeObject.removeAllChildren();
}
explorerView.fireTreeObjectRemoved(new TreeObjectEvent(treeObject));
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to delete the current selected object.");
}
}
;
// Updating the tree and the properties panel
Enumeration<DatabaseObjectTreeObject> enumeration = Collections.enumeration(treeNodesToUpdate);
DatabaseObjectTreeObject parentTreeObject;
while (enumeration.hasMoreElements()) {
parentTreeObject = enumeration.nextElement();
if (parentTreeObject != null) {
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(parentTreeObject);
}
}
// Refresh tree to show potential 'broken' steps
explorerView.refreshTree();
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to delete object!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject in project convertigo by convertigo.
the class EditMobileComponentClassAction 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;
mpcto.editAppComponentTsFile();
} else if (treeObject instanceof MobilePageComponentTreeObject) {
MobilePageComponentTreeObject mpcto = (MobilePageComponentTreeObject) treeObject;
mpcto.editPageTsFile();
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to edit mobile component class!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject 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