use of com.twinsoft.convertigo.eclipse.popup.actions.DatabaseObjectDecreasePriorityAction in project convertigo by convertigo.
the class TreeDropAdapter method performDrop.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerDropAdapter#performDrop(java.lang.Object)
*/
@Override
public boolean performDrop(Object data) {
MobileBuilder mb = null;
Engine.logStudio.info("---------------------- Drop started ----------------------");
try {
Object targetObject = getCurrentTarget();
IEditorPart editorPart = ConvertigoPlugin.getDefault().getApplicationComponentEditor();
if (editorPart != null) {
IEditorInput input = editorPart.getEditorInput();
if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
mb = editorInput.getApplication().getProject().getMobileBuilder();
}
if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
mb = editorInput.getApplication().getProject().getMobileBuilder();
}
}
// Handle tree objects reordering with Drag and Drop
if (data instanceof String) {
boolean insertBefore = (feedback & DND.FEEDBACK_INSERT_BEFORE) != 0;
boolean insertAfter = (feedback & DND.FEEDBACK_INSERT_AFTER) != 0;
if (insertBefore || insertAfter) {
Object sourceObject = getSelectedObject();
TreeParent targetTreeParent = ((TreeObject) targetObject).getParent();
List<? extends TreeObject> children = targetTreeParent.getChildren();
int destPosition = children.indexOf(targetObject);
int srcPosition = children.indexOf(sourceObject);
int delta = destPosition - srcPosition;
int count = (delta < 0) ? (insertBefore ? delta : delta + 1) : (insertBefore ? delta - 1 : delta);
if (count != 0) {
if (mb != null) {
mb.prepareBatchBuild();
}
BatchOperationHelper.start();
if (count < 0) {
new DatabaseObjectIncreasePriorityAction(Math.abs(count)).run();
} else {
new DatabaseObjectDecreasePriorityAction(Math.abs(count)).run();
}
BatchOperationHelper.stop();
}
return true;
}
}
// Handle objects copy or move with Drag and drop
if (targetObject instanceof TreeObject) {
TreeObject targetTreeObject = (TreeObject) targetObject;
if (targetTreeObject != null) {
ProjectExplorerView explorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
Document document = null;
try {
Shell shell = Display.getDefault().getActiveShell();
try {
// Try to parse text data into an XML document
String source = data.toString();
document = XMLUtils.getDefaultDocumentBuilder().parse(new InputSource(new StringReader(source)));
if (mb != null) {
mb.prepareBatchBuild();
}
BatchOperationHelper.start();
ClipboardAction.dnd.paste(source, shell, explorerView, targetTreeObject, true);
BatchOperationHelper.stop();
return true;
} catch (SAXException sax) {
BatchOperationHelper.cancel();
if (mb != null) {
mb.prepareBatchBuild();
}
BatchOperationHelper.start();
// Parse failed probably because data was not XML but an XPATH String
// in this case, create DatabaseObjects of the correct Type according to the folder where the XPATH is dropped on
performDrop(data, explorerView, targetTreeObject);
BatchOperationHelper.stop();
return true;
}
} catch (Exception e) {
BatchOperationHelper.cancel();
if (e instanceof ObjectWithSameNameException) {
document = null;
}
if (e instanceof InvalidOperationException) {
document = null;
}
// Case of unauthorized databaseObject paste
if (document != null) {
try {
if (!(targetTreeObject instanceof IPropertyTreeObject)) {
Element rootElement = document.getDocumentElement();
NodeList nodeList = rootElement.getChildNodes();
boolean unauthorized = false;
int len = nodeList.getLength();
Node node;
// case of folder, retrieve owner object
targetTreeObject = explorerView.getFirstSelectedDatabaseObjectTreeObject(targetTreeObject);
if (detail == DND.DROP_COPY) {
for (int i = 0; i < len; i++) {
node = (Node) nodeList.item(i);
if (node.getNodeType() != Node.TEXT_NODE) {
// Special objects paste
if (!paste(node, targetTreeObject)) {
// Real unauthorized databaseObject paste
unauthorized = true;
}
}
}
reloadTreeObject(explorerView, targetTreeObject);
} else if (detail == DND.DROP_MOVE) {
for (int i = 0; i < len; i++) {
node = (Node) nodeList.item(i);
if (node.getNodeType() != Node.TEXT_NODE) {
// Special objects move
if (!move(node, targetTreeObject)) {
// Real unauthorized databaseObject move
unauthorized = true;
}
}
}
reloadTreeObject(explorerView, targetTreeObject);
} else {
// Real unauthorized databaseObject
unauthorized = true;
}
if (unauthorized) {
throw e;
}
return true;
}
} catch (Exception ex) {
ConvertigoPlugin.errorMessageBox(ex.getMessage());
return false;
}
} else {
ConvertigoPlugin.errorMessageBox(e.getMessage());
return false;
}
}
}
}
return false;
} finally {
Engine.logStudio.info("---------------------- Drop ended ----------------------");
BatchOperationHelper.cancel();
}
}
use of com.twinsoft.convertigo.eclipse.popup.actions.DatabaseObjectDecreasePriorityAction in project convertigo by convertigo.
the class ProjectExplorerView method makeActions.
private void makeActions() {
tracePlayAction = new TracePlayAction();
doubleClickAction = new Action() {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
TreeObject treeObject = (TreeObject) selection.getFirstElement();
if (treeObject instanceof UnloadedProjectTreeObject) {
loadProject((UnloadedProjectTreeObject) treeObject);
} else if (treeObject instanceof ConnectorTreeObject) {
((ConnectorTreeObject) treeObject).launchEditor();
} else if (treeObject instanceof SequenceTreeObject) {
((SequenceTreeObject) treeObject).launchEditor();
} else if (treeObject instanceof StepTreeObject) {
showStepInPickerAction.run();
if (treeObject instanceof IEditableTreeObject) {
((IEditableTreeObject) treeObject).launchEditor(null);
}
} else if (treeObject instanceof VariableTreeObject2) {
if (treeObject.getObject() instanceof StepVariable) {
showStepInPickerAction.run();
}
} else if (treeObject instanceof IEditableTreeObject) {
((IEditableTreeObject) treeObject).launchEditor(null);
} else if (treeObject instanceof TraceTreeObject) {
tracePlayAction.run();
}
}
};
undoAction = new UndoAction();
redoAction = new RedoAction();
copyAction = new ClipboardCopyAction();
cutAction = new ClipboardCutAction();
pasteAction = new ClipboardPasteAction();
deleteDatabaseObjectAction = new DatabaseObjectDeleteAction();
deletePropertyTableRowAction = new DeletePropertyTableRowAction();
deletePropertyTableColumnAction = new DeletePropertyTableColumnAction();
projectExplorerSaveAllAction = new ProjectExplorerSaveAllAction();
decreasePriorityAction = new DatabaseObjectDecreasePriorityAction();
increasePriorityAction = new DatabaseObjectIncreasePriorityAction();
executeTransaction = new TransactionExecuteSelectedAction();
executeDefaultTransaction = new TransactionExecuteDefaultAction();
transactionEditHandlersAction = new TransactionEditHandlersAction();
executeSequence = new SequenceExecuteSelectedAction();
executeTestCase = new TestCaseExecuteSelectedAction();
showStepInPickerAction = new ShowStepInPickerAction();
}
Aggregations