Search in sources :

Example 6 with ModuleParameter

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

the class ModuleParameterSectionDragSourceListener method dragStart.

@Override
public void dragStart(final DragSourceEvent event) {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    event.doit = !selection.isEmpty() && (selection.getFirstElement() instanceof ModuleParameter);
}
Also used : ModuleParameter(org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler.ModuleParameter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 7 with ModuleParameter

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

the class ModuleParameterSectionPage method createNewParameter.

public static ModuleParameter createNewParameter(final String aModuleName, final String aParameterName, final String aValue) {
    ModuleParameter newModuleParameter = new ModuleParameterSectionHandler.ModuleParameter();
    final ParseTree root = new ParserRuleContext();
    newModuleParameter.setRoot(root);
    ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("\n"));
    newModuleParameter.setModuleName(new AddedParseTree(aModuleName));
    ConfigTreeNodeUtilities.addChild(root, newModuleParameter.getModuleName());
    final boolean isModuleNameEmpty = aModuleName == null || aModuleName.isEmpty();
    newModuleParameter.setSeparator(new AddedParseTree(isModuleNameEmpty ? "" : "."));
    ConfigTreeNodeUtilities.addChild(root, newModuleParameter.getSeparator());
    newModuleParameter.setParameterName(new AddedParseTree(aParameterName));
    ConfigTreeNodeUtilities.addChild(root, newModuleParameter.getParameterName());
    ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(" := "));
    newModuleParameter.setValue(new AddedParseTree(aValue));
    ConfigTreeNodeUtilities.addChild(root, newModuleParameter.getValue());
    return newModuleParameter;
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) ModuleParameter(org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler.ModuleParameter) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 8 with ModuleParameter

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

the class ModuleParameterSectionPage 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 | SWT.H_SCROLL | SWT.V_SCROLL);
    parameterValueText.setLayoutData(new GridData(GridData.FILL_BOTH));
    parameterValueText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            StructuredSelection selection = (StructuredSelection) moduleParametersTableViewer.getSelection();
            Iterator<?> iterator = selection.iterator();
            if (!iterator.hasNext()) {
                return;
            }
            ModuleParameter moduleParameter = (ModuleParameter) iterator.next();
            ConfigTreeNodeUtilities.setText(moduleParameter.getValue(), parameterValueText.getText());
            if (valueChanged) {
                valueChanged = false;
                return;
            }
            editor.setDirty();
        }
    });
    parameterValueText.setEnabled(moduleParametersHandler != null);
    section.setText("Module parameter value");
    section.setDescription("Specify the concrete value for the actually selected module 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) ModuleParameter(org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler.ModuleParameter) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) 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 9 with ModuleParameter

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

the class ModuleParameterSectionPage method removeSelectedParameters.

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

Aggregations

ModuleParameter (org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler.ModuleParameter)9 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