Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 418300 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java (-4 / +4 lines)
Lines 548-554 public class NodePM extends PersistenceManager { Link Here
548
     * doesn't know the parent.
548
     * doesn't know the parent.
549
     * 
549
     * 
550
     * @param tsGuid
550
     * @param tsGuid
551
     *            GUID of the test case being reused.
551
     *            GUID of the test suite being reused.
552
     * @param parentProjectId
552
     * @param parentProjectId
553
     *            ID of the parent project of the test case being reused.
553
     *            ID of the parent project of the test case being reused.
554
     * @return all ref test suites that reference the test suite with the given
554
     * @return all ref test suites that reference the test suite with the given
Lines 572-578 public class NodePM extends PersistenceManager { Link Here
572
    /**
572
    /**
573
     * 
573
     * 
574
     * @param tsGuid The GUID of the reused test suite.
574
     * @param tsGuid The GUID of the reused test suite.
575
     * @param parentProjectIds All returned test cases will have one of these as
575
     * @param parentProjectIds All returned test suites will have one of these as
576
     *                         their project parent ID.
576
     *                         their project parent ID.
577
     * @param s The session into which the test cases will be loaded.
577
     * @param s The session into which the test cases will be loaded.
578
     * @return list of test suites.
578
     * @return list of test suites.
Lines 592-599 public class NodePM extends PersistenceManager { Link Here
592
        queryBuffer.append(")"); //$NON-NLS-1$
592
        queryBuffer.append(")"); //$NON-NLS-1$
593
        Query q = s.createQuery(queryBuffer.toString());
593
        Query q = s.createQuery(queryBuffer.toString());
594
        q.setParameter("tsGuid", tsGuid); //$NON-NLS-1$
594
        q.setParameter("tsGuid", tsGuid); //$NON-NLS-1$
595
        List<IRefTestSuitePO> execTcList = q.getResultList();
595
        List<IRefTestSuitePO> refTestSuiteList = q.getResultList();
596
        return execTcList;
596
        return refTestSuiteList;
597
    }
597
    }
598
598
599
    /**
599
    /**
(-)a/org.eclipse.jubula.client.ui.rcp/plugin.xml (+18 lines)
Lines 1751-1756 Link Here
1751
             style="push">
1751
             style="push">
1752
       </command>
1752
       </command>
1753
       <command
1753
       <command
1754
             commandId="org.eclipse.jubula.client.ui.rcp.commands.ShowWhereUsed"
1755
             style="push">
1756
       </command>
1757
       <command
1754
             commandId="org.eclipse.jubula.client.ui.commands.ExpandTreeItem"
1758
             commandId="org.eclipse.jubula.client.ui.commands.ExpandTreeItem"
1755
             style="push">
1759
             style="push">
1756
       </command>
1760
       </command>
Lines 2342-2347 Link Here
2342
      </activeWhen>
2346
      </activeWhen>
2343
    </handler>
2347
    </handler>
2344
    <handler
2348
    <handler
2349
      class="org.eclipse.jubula.client.ui.rcp.handlers.showwhereused.TestSuiteShowWhereUsedHandler"
2350
      commandId="org.eclipse.jubula.client.ui.rcp.commands.ShowWhereUsed">
2351
      <activeWhen>
2352
        <and>
2353
          <count value="1" />
2354
          <iterate
2355
            ifEmpty="false"
2356
            operator="and">
2357
            <instanceof value="org.eclipse.jubula.client.core.model.ITestSuitePO" />
2358
          </iterate>
2359
        </and>
2360
      </activeWhen>
2361
    </handler>
2362
    <handler
2345
      class="org.eclipse.jubula.client.ui.rcp.handlers.showwhereused.ComponentNameShowWhereUsedHandler"
2363
      class="org.eclipse.jubula.client.ui.rcp.handlers.showwhereused.ComponentNameShowWhereUsedHandler"
2346
      commandId="org.eclipse.jubula.client.ui.rcp.commands.ShowWhereUsed">
2364
      commandId="org.eclipse.jubula.client.ui.rcp.commands.ShowWhereUsed">
2347
      <activeWhen>
2365
      <activeWhen>
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/showwhereused/TestSuiteShowWhereUsedHandler.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2013 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.rcp.handlers.showwhereused;
12
13
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.jubula.client.core.model.ITestSuitePO;
15
import org.eclipse.jubula.client.ui.rcp.search.query.ShowWhereUsedTestSuiteQuery;
16
import org.eclipse.search.ui.NewSearchUI;
17
18
19
/**
20
 * Class for test suite "Show where used" handler
21
 * 
22
 * @author BREDEX GmbH
23
 * @created 17.10.2013
24
 */
25
public class TestSuiteShowWhereUsedHandler extends
26
        AbstractShowWhereUsedHandler {
27
28
    /** {@inheritDoc} */
29
    public Object execute(ExecutionEvent event) {
30
        init(event);
31
        final Object first = getCurrentSelection().getFirstElement();
32
        ITestSuitePO testSuite = (ITestSuitePO)first;
33
        NewSearchUI.runQueryInBackground(
34
                new ShowWhereUsedTestSuiteQuery(testSuite));
35
        return null;
36
    }
37
}
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/Messages.java (+1 lines)
Lines 844-849 public class Messages extends NLS { Link Here
844
    public static String UIJobSearchingResponsibleCompNames;
844
    public static String UIJobSearchingResponsibleCompNames;
845
    public static String UIJobSearchingTestCases;
845
    public static String UIJobSearchingTestCases;
846
    public static String UIJobSearchingTestDataCube;
846
    public static String UIJobSearchingTestDataCube;
847
    public static String UIJobSearchingTestSuites;
847
    public static String UIJobStartTestJob;
848
    public static String UIJobStartTestJob;
848
    public static String UnexpectedDialogReturnCode;
849
    public static String UnexpectedDialogReturnCode;
849
    public static String UnexpectedError;
850
    public static String UnexpectedError;
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/i18n/messages.properties (+1 lines)
Lines 830-835 UIJobSearchingCompNames=Search for usage of Component Names Link Here
830
UIJobSearchingResponsibleCompNames=Search for responsible specification of Component Name
830
UIJobSearchingResponsibleCompNames=Search for responsible specification of Component Name
831
UIJobSearchingTestCases=Search for usage of Test Case
831
UIJobSearchingTestCases=Search for usage of Test Case
832
UIJobSearchingTestDataCube=Search for usage of Test Data Sets
832
UIJobSearchingTestDataCube=Search for usage of Test Data Sets
833
UIJobSearchingTestSuites=Search for usage of Test Suite
833
UIJobStartTestJob=Start Test Job
834
UIJobStartTestJob=Start Test Job
834
UnexpectedDialogReturnCode=Unexpected dialog return code
835
UnexpectedDialogReturnCode=Unexpected dialog return code
835
UnexpectedError=Unexpected error
836
UnexpectedError=Unexpected error
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/search/query/AbstractShowWhereUsedQuery.java (+44 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.rcp.search.query;
11
package org.eclipse.jubula.client.ui.rcp.search.query;
12
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.jubula.client.core.model.INodePO;
18
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
19
import org.eclipse.jubula.client.ui.rcp.provider.labelprovider.GeneralLabelProvider;
20
import org.eclipse.jubula.client.ui.rcp.search.result.BasicSearchResult.NodeSearchResultElementAction;
21
import org.eclipse.jubula.client.ui.rcp.search.result.BasicSearchResult.SearchResultElement;
22
import org.eclipse.osgi.util.NLS;
23
13
24
14
/**
25
/**
15
 * This class provides common methods for "show where used queries".
26
 * This class provides common methods for "show where used queries".
Lines 26-30 public abstract class AbstractShowWhereUsedQuery extends AbstractQuery { Link Here
26
    public AbstractShowWhereUsedQuery(String viewId) {
37
    public AbstractShowWhereUsedQuery(String viewId) {
27
        super(viewId);
38
        super(viewId);
28
    }
39
    }
40
    
41
    /**
42
     * gives a search result containing the parents of an array of INodePOs
43
     * 
44
     * @param monitor
45
     *              the monitor
46
     * @param reuse
47
     *              the array containing the INodePOs
48
     * @return the search result
49
     */
50
    protected List<SearchResultElement> getResultElementsFromNodes(
51
            IProgressMonitor monitor, INodePO[] reuse) {
52
        final List<SearchResultElement> reuseLoc = 
53
            new ArrayList<SearchResultElement>(reuse.length);
54
        List<INodePO> parentList = new ArrayList<INodePO>();
55
        
56
        for (INodePO node : reuse) {
57
            INodePO parent = node.getParentNode();
58
            if (parent != null) {
59
                Long id = node.getId();
60
                String nodeName = GeneralLabelProvider.getTextImpl(node);
61
                parentList.add(parent);
62
                reuseLoc.add(new SearchResultElement<Long>(NLS.bind(
63
                        Messages.SearchResultPageElementLabel, new Object[] {
64
                                parent.getName(), nodeName }), id,
65
                                GeneralLabelProvider.getImageImpl(node),
66
                        new NodeSearchResultElementAction(), node
67
                                .getComment()));
68
            }
69
            monitor.worked(1);
70
        }
71
        return reuseLoc;
72
    }
29
73
30
}
74
}
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/search/query/ShowWhereUsedSpecTcQuery.java (-27 / +7 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.rcp.search.query;
11
package org.eclipse.jubula.client.ui.rcp.search.query;
12
12
13
import java.util.ArrayList;
14
import java.util.LinkedList;
13
import java.util.LinkedList;
15
import java.util.List;
14
import java.util.List;
16
15
Lines 26-37 import org.eclipse.jubula.client.core.persistence.GeneralStorage; Link Here
26
import org.eclipse.jubula.client.core.persistence.NodePM;
25
import org.eclipse.jubula.client.core.persistence.NodePM;
27
import org.eclipse.jubula.client.core.persistence.ProjectPM;
26
import org.eclipse.jubula.client.core.persistence.ProjectPM;
28
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
27
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
29
import org.eclipse.jubula.client.ui.rcp.provider.labelprovider.GeneralLabelProvider;
30
import org.eclipse.jubula.client.ui.rcp.search.result.BasicSearchResult.NodeSearchResultElementAction;
31
import org.eclipse.jubula.client.ui.rcp.search.result.BasicSearchResult.SearchResultElement;
28
import org.eclipse.jubula.client.ui.rcp.search.result.BasicSearchResult.SearchResultElement;
32
import org.eclipse.jubula.tools.constants.StringConstants;
29
import org.eclipse.jubula.tools.constants.StringConstants;
33
import org.eclipse.jubula.tools.exception.JBException;
30
import org.eclipse.jubula.tools.exception.JBException;
34
import org.eclipse.osgi.util.NLS;
35
31
36
32
37
/**
33
/**
Lines 86-114 public class ShowWhereUsedSpecTcQuery Link Here
86
                // ignore
82
                // ignore
87
            }
83
            }
88
        }
84
        }
89
        List<IExecTestCasePO> reuse = NodePM.getExecTestCases(specTC.getGuid(),
85
        List<IExecTestCasePO> reuseList = 
90
                parentProjectIDs);
86
                NodePM.getExecTestCases(specTC.getGuid(), parentProjectIDs);
91
        final List<SearchResultElement> reuseLoc = 
87
        INodePO[] reuse = new INodePO[reuseList.size()];
92
            new ArrayList<SearchResultElement>(
88
        reuseList.toArray(reuse);
93
                reuse.size());
89
        monitor.beginTask("Searching for reusage of Test Case", reuseList.size()); //$NON-NLS-1$
94
        List<INodePO> parentList = new ArrayList<INodePO>();
90
        final List<SearchResultElement> reuseLoc = getResultElementsFromNodes(
95
        
91
                monitor, reuse);
96
        monitor.beginTask("Searching for reusage of Test Case", reuse.size()); //$NON-NLS-1$
97
        for (IExecTestCasePO execTC : reuse) {
98
            INodePO parent = execTC.getParentNode();
99
            if (parent != null) {
100
                Long id = execTC.getId();
101
                String nodeName = GeneralLabelProvider.getTextImpl(execTC);
102
                parentList.add(parent);
103
                reuseLoc.add(new SearchResultElement<Long>(NLS.bind(
104
                        Messages.SearchResultPageElementLabel, new Object[] {
105
                                parent.getName(), nodeName }), id,
106
                                GeneralLabelProvider.getImageImpl(execTC),
107
                        new NodeSearchResultElementAction(), execTC
108
                                .getComment()));
109
            }
110
            monitor.worked(1);
111
        }
112
        
92
        
113
        setSearchResult(reuseLoc);
93
        setSearchResult(reuseLoc);
114
        monitor.done();
94
        monitor.done();
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/search/query/ShowWhereUsedTestSuiteQuery.java (-1 / +96 lines)
Added Link Here
0
- 
1
/*******************************************************************************
2
 * Copyright (c) 2013 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.rcp.search.query;
12
13
import java.util.List;
14
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Status;
18
import org.eclipse.jubula.client.core.model.INodePO;
19
import org.eclipse.jubula.client.core.model.IProjectPO;
20
import org.eclipse.jubula.client.core.model.IRefTestSuitePO;
21
import org.eclipse.jubula.client.core.model.ITestSuitePO;
22
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
23
import org.eclipse.jubula.client.core.persistence.NodePM;
24
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
25
import org.eclipse.jubula.client.ui.rcp.search.result.BasicSearchResult.SearchResultElement;
26
import org.eclipse.jubula.tools.constants.StringConstants;
27
28
29
/**
30
 * @author BREDEX GmbH
31
 * @created 18.10.2013
32
 */
33
public class ShowWhereUsedTestSuiteQuery 
34
    extends AbstractShowWhereUsedQuery {
35
    /**
36
     * <code>m_specTC</code>
37
     */
38
    private ITestSuitePO m_testSuite;
39
    
40
    /**
41
     * @param testSuite
42
     *            the test suite to search the reuse for
43
     */
44
    public ShowWhereUsedTestSuiteQuery(ITestSuitePO testSuite) {
45
        super(null);
46
        m_testSuite = testSuite;
47
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52
    public IStatus run(IProgressMonitor monitor) {
53
        calculateReuseOfTestSuite(m_testSuite, monitor);
54
        return Status.OK_STATUS;
55
    }
56
    
57
    /**
58
     * calculates and show the places of reuse for a test suite
59
     * 
60
     * @param testSuite
61
     *            the test suite
62
     * @param monitor
63
     *            the progress monitor
64
     */
65
    private void calculateReuseOfTestSuite(ITestSuitePO testSuite,
66
            IProgressMonitor monitor) {
67
        IProjectPO currentProject = GeneralStorage.getInstance().getProject();
68
        List<IRefTestSuitePO> reuseList = NodePM.getInternalRefTestSuites(
69
                testSuite.getGuid(), currentProject.getId());
70
        INodePO[] reuse = new INodePO[reuseList.size()];
71
        reuseList.toArray(reuse);
72
        monitor.beginTask("Searching for reusage of Test Suite", reuseList.size()); //$NON-NLS-1$
73
        final List<SearchResultElement> reuseLoc = getResultElementsFromNodes(
74
                monitor, reuse);
75
        
76
        setSearchResult(reuseLoc);
77
        monitor.done();
78
    }
79
80
    /**
81
     * {@inheritDoc}
82
     */
83
    @SuppressWarnings("nls")
84
    public String getLabel() {
85
        StringBuilder sb = new StringBuilder();
86
        sb.append(getTimestamp());
87
        sb.append(StringConstants.COLON);
88
        sb.append(StringConstants.SPACE);
89
        sb.append(Messages.UIJobSearchingTestSuites);
90
        sb.append(" \"");
91
        sb.append(m_testSuite.getName());
92
        sb.append("\"");
93
        return sb.toString();
94
    }
95
    
96
}

Return to bug 418300