Search in sources :

Example 6 with TestportParameter

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

the class TestportParameterSectionDragSourceListener method dragSetData.

@Override
public void dragSetData(final DragSourceEvent event) {
    if (TestportParameterTransfer.getInstance().isSupportedType(event.dataType)) {
        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
        List<TestportParameter> items = new ArrayList<TestportParameter>();
        if (!selection.isEmpty()) {
            for (Iterator<?> it = selection.iterator(); it.hasNext(); ) {
                Object element = it.next();
                if (element instanceof TestportParameter) {
                    items.add((TestportParameter) element);
                }
            }
            event.data = items.toArray(new TestportParameter[items.size()]);
        }
    }
}
Also used : TestportParameter(org.eclipse.titan.common.parsers.cfg.indices.TestportParameterSectionHandler.TestportParameter) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 7 with TestportParameter

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

the class TestportParameterSectionDropTargetListener method drop.

@Override
public void drop(final DropTargetEvent event) {
    if (TestportParameterTransfer.getInstance().isSupportedType(event.currentDataType)) {
        if (event.item != null && viewer.getInput() != null) {
            TestportParameterSectionHandler testportParameterSectionHandler = (TestportParameterSectionHandler) viewer.getInput();
            TestportParameter element = (TestportParameter) event.item.getData();
            TestportParameter[] items = (TestportParameter[]) event.data;
            int baseindex = testportParameterSectionHandler.getTestportParameters().indexOf(element);
            final ParseTree parent = testportParameterSectionHandler.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++) {
                    testportParameterSectionHandler.getTestportParameters().add(++baseindex, items[i]);
                }
                testportParameterSectionHandler.getTestportParameters().add(++baseindex, items[items.length - 1]);
            }
            viewer.refresh(true);
            editor.setDirty();
        }
    }
}
Also used : TestportParameter(org.eclipse.titan.common.parsers.cfg.indices.TestportParameterSectionHandler.TestportParameter) TestportParameterSectionHandler(org.eclipse.titan.common.parsers.cfg.indices.TestportParameterSectionHandler) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 8 with TestportParameter

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

the class TestportParametersSectionPage method createNewParameter.

private TestportParameter createNewParameter() {
    if (testportParametersHandler == null) {
        return null;
    }
    TestportParameter newTestportParameter = new TestportParameterSectionHandler.TestportParameter();
    final ParseTree root = new ParserRuleContext();
    newTestportParameter.setRoot(root);
    ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("\n"));
    newTestportParameter.setComponentName(new AddedParseTree("component_name"));
    ConfigTreeNodeUtilities.addChild(root, newTestportParameter.getComponentName());
    ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("."));
    newTestportParameter.setTestportName(new AddedParseTree("testport_name"));
    ConfigTreeNodeUtilities.addChild(root, newTestportParameter.getTestportName());
    ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("."));
    newTestportParameter.setParameterName(new AddedParseTree("parameter_name"));
    ConfigTreeNodeUtilities.addChild(root, newTestportParameter.getParameterName());
    ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(" := "));
    ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("\"value\""));
    return newTestportParameter;
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) TestportParameter(org.eclipse.titan.common.parsers.cfg.indices.TestportParameterSectionHandler.TestportParameter) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 9 with TestportParameter

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

the class TestportParametersSectionPage method createDetailsPart.

private void createDetailsPart(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
    section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    client.setLayout(layout);
    parameterValueText = toolkit.createText(client, "", SWT.MULTI | SWT.BORDER);
    parameterValueText.setLayoutData(new GridData(GridData.FILL_BOTH));
    parameterValueText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            StructuredSelection selection = (StructuredSelection) testportParametersTableViewer.getSelection();
            Iterator<?> iterator = selection.iterator();
            if (!iterator.hasNext()) {
                return;
            }
            TestportParameter testportParameter = (TestportParameter) iterator.next();
            ConfigTreeNodeUtilities.setText(testportParameter.getValue(), parameterValueText.getText());
            if (valueChanged) {
                valueChanged = false;
                return;
            }
            editor.setDirty();
        }
    });
    parameterValueText.setEnabled(testportParametersHandler != null);
    section.setText("Testport parameter details");
    section.setDescription("Specify the concrete value for the actually selected testport parameter.");
    section.setClient(client);
    section.setExpanded(true);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            form.reflow(false);
        }
    });
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.grabExcessVerticalSpace = true;
    section.setLayoutData(gd);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) TestportParameter(org.eclipse.titan.common.parsers.cfg.indices.TestportParameterSectionHandler.TestportParameter) GridData(org.eclipse.swt.layout.GridData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Iterator(java.util.Iterator) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 10 with TestportParameter

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

the class TestportParametersSectionPage method removeSelectedParameters.

public void removeSelectedParameters() {
    if (testportParametersTableViewer == null || testportParametersHandler == null) {
        return;
    }
    StructuredSelection selection = (StructuredSelection) testportParametersTableViewer.getSelection();
    Iterator<?> iterator = selection.iterator();
    // remove the selected elements
    for (; iterator.hasNext(); ) {
        TestportParameter testportParameter = (TestportParameter) iterator.next();
        if (testportParameter != null) {
            ConfigTreeNodeUtilities.removeChild(testportParametersHandler.getLastSectionRoot(), testportParameter.getRoot());
            testportParametersHandler.getTestportParameters().remove(testportParameter);
        }
    }
    testportParametersTableViewer.setSelection(null);
}
Also used : TestportParameter(org.eclipse.titan.common.parsers.cfg.indices.TestportParameterSectionHandler.TestportParameter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Aggregations

TestportParameter (org.eclipse.titan.common.parsers.cfg.indices.TestportParameterSectionHandler.TestportParameter)10 ParseTree (org.antlr.v4.runtime.tree.ParseTree)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 IOException (java.io.IOException)2 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)2 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)2 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)2 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)2 Section (org.eclipse.ui.forms.widgets.Section)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 Iterator (java.util.Iterator)1