Search in sources :

Example 1 with ComponentSectionHandler

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

the class ComponentSectionDropTargetListener method drop.

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

Aggregations

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