Search in sources :

Example 1 with ExecuteItem

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();
        }
    }
}
Also used : ExecuteItem(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem) ExecuteSectionHandler(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 2 with ExecuteItem

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[] {};
    }
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) ExecuteItem(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ByteArrayInputStream(java.io.ByteArrayInputStream) ExecuteItem(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem) ExecuteSectionHandler(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 3 with 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);
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) ExecuteItem(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 4 with ExecuteItem

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()]);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ExecuteItem(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 5 with ExecuteItem

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);
}
Also used : ExecuteItem(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

ExecuteItem (org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem)8 ParseTree (org.antlr.v4.runtime.tree.ParseTree)3 IOException (java.io.IOException)2 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)2 ExecuteSectionHandler (org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 ArrayList (java.util.ArrayList)1 ICellModifier (org.eclipse.jface.viewers.ICellModifier)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1