Search in sources :

Example 1 with DefineSectionHandler

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

the class DefineSectionDropTargetListener method drop.

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

Aggregations

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