use of org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem in project titan.EclipsePlug-ins by eclipse.
the class ExecuteSectionDropTargetListener method drop.
@Override
public void drop(final DropTargetEvent event) {
if (ExecuteItemTransfer.getInstance().isSupportedType(event.currentDataType)) {
if (event.item != null && viewer.getInput() != null) {
ExecuteSectionHandler executeSectionHandler = (ExecuteSectionHandler) viewer.getInput();
ExecuteItem element = (ExecuteItem) event.item.getData();
ExecuteItem[] items = (ExecuteItem[]) event.data;
int baseindex = executeSectionHandler.getExecuteitems().indexOf(element);
final ParseTree parent = executeSectionHandler.getLastSectionRoot();
ConfigTreeNodeUtilities.removeChild(parent, element.getRoot());
ConfigTreeNodeUtilities.addChild(parent, element.getRoot(), baseindex);
if (items.length > 0) {
for (int i = 0; i < items.length - 1; i++) {
executeSectionHandler.getExecuteitems().add(++baseindex, items[i]);
}
executeSectionHandler.getExecuteitems().add(++baseindex, items[items.length - 1]);
}
viewer.refresh(true);
editor.setDirty();
}
}
}
use of org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem in project titan.EclipsePlug-ins by eclipse.
the class ExecuteItemTransfer method nativeToJava.
@Override
protected ExecuteItem[] nativeToJava(final TransferData transferData) {
byte[] bytes = (byte[]) super.nativeToJava(transferData);
DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
try {
int n = in.readInt();
ExecuteItem[] items = new ExecuteItem[n];
String moduleName;
String testcaseName;
String hiddenBefore;
for (int i = 0; i < n; i++) {
items[i] = new ExecuteSectionHandler.ExecuteItem();
final ParseTree root = new ParserRuleContext();
items[i].setRoot(root);
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
moduleName = in.readUTF();
final ParseTree moduleNameNode = new AddedParseTree(moduleName);
items[i].setModuleName(moduleNameNode);
ConfigTreeNodeUtilities.addChild(root, moduleNameNode);
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("."));
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
testcaseName = in.readUTF();
final ParseTree testcaseNameNode = new AddedParseTree(testcaseName);
items[i].setTestcaseName(testcaseNameNode);
ConfigTreeNodeUtilities.addChild(root, testcaseNameNode);
}
return items;
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
return new ExecuteItem[] {};
}
}
use of org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem in project titan.EclipsePlug-ins by eclipse.
the class ExecuteItemTransfer method javaToNative.
@Override
protected void javaToNative(final Object object, final TransferData transferData) {
ExecuteItem[] items = (ExecuteItem[]) object;
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteOut);
byte[] bytes = null;
try {
out.writeInt(items.length);
for (int i = 0; i < items.length; i++) {
out.writeUTF(convertToString(items[i].getRoot()));
}
out.close();
bytes = byteOut.toByteArray();
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
}
if (bytes != null) {
super.javaToNative(bytes, transferData);
}
}
use of org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem in project titan.EclipsePlug-ins by eclipse.
the class ExecuteSectionDragSourceListener method dragSetData.
@Override
public void dragSetData(final DragSourceEvent event) {
if (ExecuteItemTransfer.getInstance().isSupportedType(event.dataType)) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
List<ExecuteItem> items = new ArrayList<ExecuteItem>();
if (!selection.isEmpty()) {
for (Iterator<?> it = selection.iterator(); it.hasNext(); ) {
Object element = it.next();
if (element instanceof ExecuteItem) {
items.add((ExecuteItem) element);
}
}
event.data = items.toArray(new ExecuteItem[items.size()]);
}
}
}
use of org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem in project titan.EclipsePlug-ins by eclipse.
the class ExecuteSectionDragSourceListener method dragStart.
@Override
public void dragStart(final DragSourceEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
event.doit = !selection.isEmpty() && (selection.getFirstElement() instanceof ExecuteItem);
}
Aggregations