Search in sources :

Example 1 with TreeLeaf

use of org.eclipse.titan.executor.executors.TreeLeaf in project titan.EclipsePlug-ins by eclipse.

the class TestSetTab method createActions.

private void createActions() {
    newTestset = new Action("create new testset") {

        @Override
        public void run() {
            if (null == testsetViewer) {
                return;
            }
            TestsetDialog dialog = new TestsetDialog(getShell(), "Create new testset");
            if (dialog.open() != Window.OK) {
                return;
            }
            String testsetName = dialog.getTestsetName();
            List<ITreeLeaf> children = treeRoot.children();
            for (ITreeLeaf aChildren : children) {
                if (aChildren.name().equals(testsetName)) {
                    return;
                }
            }
            treeRoot.addChildToEnd(new TestsetTreeElement(testsetName));
            testsetViewer.refresh();
            updateLaunchConfigurationDialog();
            super.run();
        }
    };
    newTestset.setToolTipText("creates a new testset");
    newTestset.setEnabled(true);
    rename = new Action("rename testset") {

        @Override
        public void run() {
            if (null == testsetViewer || testsetViewer.getSelection().isEmpty()) {
                return;
            }
            IStructuredSelection selection = (IStructuredSelection) testsetViewer.getSelection();
            TestsetDialog dialog = new TestsetDialog(getShell(), "Rename testset");
            dialog.setTestsetName(((TestsetTreeElement) selection.getFirstElement()).name());
            if (dialog.open() != Window.OK) {
                return;
            }
            String testsetName = dialog.getTestsetName();
            List<ITreeLeaf> children = treeRoot.children();
            for (ITreeLeaf aChildren : children) {
                if (aChildren.name().equals(testsetName)) {
                    return;
                }
            }
            ((TestsetTreeElement) selection.getFirstElement()).name(testsetName);
            testsetViewer.refresh();
            updateLaunchConfigurationDialog();
            super.run();
        }
    };
    rename.setToolTipText("rename selected testset");
    rename.setEnabled(false);
    remove = new Action("remove") {

        @Override
        public void run() {
            if (null == testsetViewer || testsetViewer.getSelection().isEmpty()) {
                return;
            }
            testsetViewer.getTree().setRedraw(false);
            IStructuredSelection selection = (IStructuredSelection) testsetViewer.getSelection();
            for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) {
                TreeLeaf element = (TreeLeaf) iterator.next();
                if (null != element.parent()) {
                    ((TestsetTreeElement) element.parent()).remove(element);
                    element.dispose();
                }
            }
            testsetViewer.getTree().setRedraw(true);
            testsetViewer.refresh();
            updateLaunchConfigurationDialog();
            super.run();
        }
    };
    remove.setToolTipText("removes the selected elements");
    remove.setEnabled(false);
}
Also used : Action(org.eclipse.jface.action.Action) Iterator(java.util.Iterator) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf) TreeLeaf(org.eclipse.titan.executor.executors.TreeLeaf) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeLeaf(org.eclipse.titan.executor.executors.ITreeLeaf)

Example 2 with TreeLeaf

use of org.eclipse.titan.executor.executors.TreeLeaf in project titan.EclipsePlug-ins by eclipse.

the class TestsetTreeDropTargetListener method dragOver.

@Override
public void dragOver(final DropTargetEvent event) {
    if (null == event.item) {
        event.feedback = DND.FEEDBACK_SCROLL;
        event.detail = DND.DROP_NONE;
    } else {
        TreeLeaf element = (TreeLeaf) event.item.getData();
        if (element instanceof TestsetTreeElement) {
            event.feedback = DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL | DND.FEEDBACK_SELECT;
        } else {
            event.feedback = DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SCROLL;
        }
        if (event.detail == DND.DROP_NONE) {
            if (0 != (event.operations & DND.DROP_MOVE)) {
                event.detail = DND.DROP_MOVE;
            } else if (0 != (event.operations & DND.DROP_COPY)) {
                event.detail = DND.DROP_COPY;
            }
        }
    }
}
Also used : TreeLeaf(org.eclipse.titan.executor.executors.TreeLeaf)

Example 3 with TreeLeaf

use of org.eclipse.titan.executor.executors.TreeLeaf in project titan.EclipsePlug-ins by eclipse.

the class TestsetTreeDropTargetListener method drop.

@Override
public void drop(final DropTargetEvent event) {
    if (!TestcaseTransfer.getInstance().isSupportedType(event.currentDataType) || null == event.item) {
        return;
    }
    final TreeLeaf element = (TreeLeaf) event.item.getData();
    final TestCaseTreeElement[] treeElements = (TestCaseTreeElement[]) event.data;
    if (element instanceof TestsetTreeElement) {
        for (TestCaseTreeElement treeElement : treeElements) {
            ((TestsetTreeElement) element).addChildToEnd(treeElement);
        }
        testsetViewer.refresh(element);
    } else {
        for (TestCaseTreeElement treeElement : treeElements) {
            ((TestsetTreeElement) element.parent()).addChildBefore(treeElement, element);
        }
        testsetViewer.refresh(element.parent());
    }
    testsetTab.update();
}
Also used : TreeLeaf(org.eclipse.titan.executor.executors.TreeLeaf)

Aggregations

TreeLeaf (org.eclipse.titan.executor.executors.TreeLeaf)3 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Action (org.eclipse.jface.action.Action)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ITreeLeaf (org.eclipse.titan.executor.executors.ITreeLeaf)1