Search in sources :

Example 1 with ModuleParameterSectionHandler

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

the class ModuleParameterSectionDropTargetListener method drop.

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

Aggregations

ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 ModuleParameterSectionHandler (org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler)1 ModuleParameter (org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler.ModuleParameter)1