Search in sources :

Example 6 with Component

use of org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component in project titan.EclipsePlug-ins by eclipse.

the class ComponentItemTransfer method nativeToJava.

@Override
protected Component[] nativeToJava(final TransferData transferData) {
    byte[] bytes = (byte[]) super.nativeToJava(transferData);
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
    try {
        int n = in.readInt();
        Component[] items = new Component[n];
        String componentName;
        String hostName;
        String hiddenBefore;
        for (int i = 0; i < n; i++) {
            items[i] = new Component();
            final ParseTree root = new ParserRuleContext();
            items[i].setRoot(root);
            hiddenBefore = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
            componentName = in.readUTF();
            final ParseTree componentNameNode = new AddedParseTree(componentName);
            items[i].setComponentName(componentNameNode);
            ConfigTreeNodeUtilities.addChild(root, componentNameNode);
            hiddenBefore = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(":="));
            hiddenBefore = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
            hostName = in.readUTF();
            final ParseTree hostNameNode = new AddedParseTree(hostName);
            items[i].setHostName(hostNameNode);
            ConfigTreeNodeUtilities.addChild(root, hostNameNode);
        }
        return items;
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
        return new Component[] {};
    }
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) Component(org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 7 with Component

use of org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component in project titan.EclipsePlug-ins by eclipse.

the class ComponentItemTransfer method javaToNative.

@Override
protected void javaToNative(final Object object, final TransferData transferData) {
    Component[] items = (Component[]) 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) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Component(org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component)

Example 8 with Component

use of org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component in project titan.EclipsePlug-ins by eclipse.

the class ComponentsSubPage method removeSelectedComponents.

public void removeSelectedComponents() {
    if (componentsTableViewer == null || componentsSectionHandler == null) {
        return;
    }
    StructuredSelection selection = (StructuredSelection) componentsTableViewer.getSelection();
    // remove the selected elements
    for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) {
        Component component = (Component) iterator.next();
        if (component != null) {
            ConfigTreeNodeUtilities.removeChild(componentsSectionHandler.getLastSectionRoot(), component.getRoot());
            componentsSectionHandler.getComponents().remove(component);
        }
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Component(org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component)

Example 9 with Component

use of org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component in project titan.EclipsePlug-ins by eclipse.

the class ComponentsSubPage method createNewComponent.

private Component createNewComponent() {
    if (componentsSectionHandler == null) {
        return null;
    }
    final Component newcomponent = new Component();
    final ParseTree root = new ParserRuleContext();
    newcomponent.setRoot(root);
    final ParseTree componentName = new AddedParseTree("component_name");
    final ParseTree hostName = new AddedParseTree("host_name");
    newcomponent.setComponentName(componentName);
    newcomponent.setHostName(hostName);
    ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode("\n"));
    ConfigTreeNodeUtilities.addChild(root, componentName);
    ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(" := "));
    ConfigTreeNodeUtilities.addChild(root, hostName);
    ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode("\n"));
    return newcomponent;
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) Component(org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

Component (org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component)9 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 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 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1