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 417829 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jubula.app/src/org/eclipse/jubula/app/core/JubulaWorkbenchAdvisor.java (-3 / +5 lines)
Lines 28-34 import org.eclipse.jubula.app.i18n.Messages; Link Here
28
import org.eclipse.jubula.client.core.businessprocess.progress.OperationCanceledUtil;
28
import org.eclipse.jubula.client.core.businessprocess.progress.OperationCanceledUtil;
29
import org.eclipse.jubula.client.ui.constants.Constants;
29
import org.eclipse.jubula.client.ui.constants.Constants;
30
import org.eclipse.jubula.client.ui.rcp.Plugin;
30
import org.eclipse.jubula.client.ui.rcp.Plugin;
31
import org.eclipse.jubula.client.ui.rcp.Plugin.ClientStatus;
31
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher;
32
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher.ClientStatus;
32
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
33
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
33
import org.eclipse.jubula.tools.constants.StringConstants;
34
import org.eclipse.jubula.tools.constants.StringConstants;
34
import org.eclipse.jubula.tools.exception.JBFatalException;
35
import org.eclipse.jubula.tools.exception.JBFatalException;
Lines 371-378 public class JubulaWorkbenchAdvisor extends WorkbenchAdvisor { Link Here
371
     * {@inheritDoc}
372
     * {@inheritDoc}
372
     */
373
     */
373
    public boolean preShutdown() {
374
    public boolean preShutdown() {
374
        try {
375
        try {
375
            Plugin.getDefault().setClientStatus(ClientStatus.STOPPING);
376
            GuiEventDispatcher.getInstance().fireClientStatusChanged(
377
                    ClientStatus.STOPPING);
376
            // Close all open editors
378
            // Close all open editors
377
            IWorkbenchWindow[] allWW = PlatformUI.getWorkbench()
379
            IWorkbenchWindow[] allWW = PlatformUI.getWorkbench()
378
                .getWorkbenchWindows();
380
                .getWorkbenchWindows();
(-)a/org.eclipse.jubula.client.alm.mylyn.ui.bridge/src/org/eclipse/jubula/client/alm/mylyn/ui/bridge/monitor/EditorInteractionMonitor.java (-4 / +14 lines)
Lines 16-28 import org.eclipse.jubula.client.alm.mylyn.ui.bridge.constants.ContentType; Link Here
16
import org.eclipse.jubula.client.core.model.IAUTMainPO;
16
import org.eclipse.jubula.client.core.model.IAUTMainPO;
17
import org.eclipse.jubula.client.core.model.INodePO;
17
import org.eclipse.jubula.client.core.model.INodePO;
18
import org.eclipse.jubula.client.core.model.IPersistentObject;
18
import org.eclipse.jubula.client.core.model.IPersistentObject;
19
import org.eclipse.jubula.client.ui.rcp.Plugin;
20
import org.eclipse.jubula.client.ui.rcp.Plugin.ClientStatus;
21
import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
19
import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
22
import org.eclipse.jubula.client.ui.rcp.editors.CentralTestDataEditor;
20
import org.eclipse.jubula.client.ui.rcp.editors.CentralTestDataEditor;
23
import org.eclipse.jubula.client.ui.rcp.editors.IJBEditor;
21
import org.eclipse.jubula.client.ui.rcp.editors.IJBEditor;
24
import org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingMultiPageEditor;
22
import org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingMultiPageEditor;
25
import org.eclipse.jubula.client.ui.rcp.editors.PersistableEditorInput;
23
import org.eclipse.jubula.client.ui.rcp.editors.PersistableEditorInput;
24
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher.ClientStatus;
25
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher.IClientStatusListener;
26
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
26
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
27
import org.eclipse.mylyn.context.core.ContextCore;
27
import org.eclipse.mylyn.context.core.ContextCore;
28
import org.eclipse.mylyn.context.core.IInteractionContext;
28
import org.eclipse.mylyn.context.core.IInteractionContext;
Lines 37-43 import org.eclipse.ui.IEditorPart; Link Here
37
 * @author BREDEX GmbH
37
 * @author BREDEX GmbH
38
 * @created Nov 10, 2010
38
 * @created Nov 10, 2010
39
 */
39
 */
40
public class EditorInteractionMonitor extends AbstractEditorTracker {
40
public class EditorInteractionMonitor extends AbstractEditorTracker implements
41
    IClientStatusListener {
41
    /**
42
    /**
42
     * <code>CTDE_ORIGIN_ID</code>
43
     * <code>CTDE_ORIGIN_ID</code>
43
     */
44
     */
Lines 46-51 public class EditorInteractionMonitor extends AbstractEditorTracker { Link Here
46
     * <code>CDTE_HANDLE</code>
47
     * <code>CDTE_HANDLE</code>
47
     */
48
     */
48
    private static final String CDTE_HANDLE = "00000000000000000000000000000005"; //$NON-NLS-1$
49
    private static final String CDTE_HANDLE = "00000000000000000000000000000005"; //$NON-NLS-1$
50
    /**
51
     * the status
52
     */
53
    private ClientStatus m_status;
49
54
50
    /** {@inheritDoc} */
55
    /** {@inheritDoc} */
51
    protected void editorBroughtToTop(IEditorPart part) {
56
    protected void editorBroughtToTop(IEditorPart part) {
Lines 54-60 public class EditorInteractionMonitor extends AbstractEditorTracker { Link Here
54
59
55
    /** {@inheritDoc} */
60
    /** {@inheritDoc} */
56
    protected void editorClosed(IEditorPart part) {
61
    protected void editorClosed(IEditorPart part) {
57
        if (Plugin.getDefault().getClientStatus() == ClientStatus.STOPPING
62
        if (m_status == ClientStatus.STOPPING
58
                || TasksUi.getTaskActivityManager().getActiveTask() == null) {
63
                || TasksUi.getTaskActivityManager().getActiveTask() == null) {
59
            return;
64
            return;
60
        }
65
        }
Lines 155-158 public class EditorInteractionMonitor extends AbstractEditorTracker { Link Here
155
        return new InteractionEvent(InteractionEvent.Kind.SELECTION,
160
        return new InteractionEvent(InteractionEvent.Kind.SELECTION,
156
                ContentType.OM_EDITOR, id, id);
161
                ContentType.OM_EDITOR, id, id);
157
    }
162
    }
163
164
    /** {@inheritDoc} */
165
    public void handleClientStateChanged(ClientStatus status) {
166
        m_status = status;
167
    }
158
}
168
}
(-)a/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF (+1 lines)
Lines 75-77 Require-Bundle: org.eclipse.jubula.tools;bundle-version="[2.3.0,2.4.0)", Link Here
75
 org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)"
75
 org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)"
76
Bundle-ActivationPolicy: lazy
76
Bundle-ActivationPolicy: lazy
77
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
77
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
78
Import-Package: org.eclipse.e4.ui.model.application.ui.basic
(-)a/org.eclipse.jubula.client.ui.rcp/plugin.xml (-32 / +67 lines)
Lines 2839-2861 Link Here
2839
          class="org.eclipse.jubula.client.ui.rcp.handlers.GoToNextTestResultErrorHandler"
2839
          class="org.eclipse.jubula.client.ui.rcp.handlers.GoToNextTestResultErrorHandler"
2840
          commandId="org.eclipse.jubula.client.ui.commands.GoToNextError">
2840
          commandId="org.eclipse.jubula.client.ui.commands.GoToNextError">
2841
       <activeWhen>
2841
       <activeWhen>
2842
          <with
2842
          <or>
2843
                variable="activePartId">
2843
            <with
2844
             <equals
2844
                    variable="activePartId">
2845
                   value="org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView">
2845
                 <equals
2846
             </equals>
2846
                       value="org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView">
2847
          </with></activeWhen>
2847
                 </equals>
2848
             </with>
2849
             <reference
2850
                 definitionId="org.eclipse.jubula.client.ui.reference.distinct.activeWhen.TRTreeViewIsNotHidden">
2851
             </reference>
2852
          </or>
2853
       </activeWhen>
2848
    </handler>
2854
    </handler>
2849
    <handler
2855
    <handler
2850
          class="org.eclipse.jubula.client.ui.rcp.handlers.GoToPreviousTestResultErrorHandler"
2856
          class="org.eclipse.jubula.client.ui.rcp.handlers.GoToPreviousTestResultErrorHandler"
2851
          commandId="org.eclipse.jubula.client.ui.commands.GoToPreviousError">
2857
          commandId="org.eclipse.jubula.client.ui.commands.GoToPreviousError">
2852
       <activeWhen>
2858
       <activeWhen>
2853
          <with
2859
          <or>
2854
                variable="activePartId">
2860
              <with
2855
             <equals
2861
                    variable="activePartId">
2856
                   value="org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView">
2862
                 <equals
2857
             </equals>
2863
                       value="org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView">
2858
          </with></activeWhen>
2864
                 </equals>
2865
              </with>
2866
              <reference
2867
                 definitionId="org.eclipse.jubula.client.ui.reference.distinct.activeWhen.TRTreeViewIsNotHidden">
2868
             </reference>
2869
          </or>
2870
        </activeWhen>
2859
    </handler>
2871
    </handler>
2860
  </extension>
2872
  </extension>
2861
  <extension point="org.eclipse.ui.commandImages">
2873
  <extension point="org.eclipse.ui.commandImages">
Lines 3919-3924 Link Here
3919
        priorityLevel="workbench" />
3931
        priorityLevel="workbench" />
3920
    </sourceProvider>
3932
    </sourceProvider>
3921
    <sourceProvider
3933
    <sourceProvider
3934
      provider="org.eclipse.jubula.client.ui.rcp.sourceprovider.TestResultSourceProvider">
3935
      <variable
3936
        name="org.eclipse.jubula.client.ui.rcp.variable.isPartToViewTestResultOpen"
3937
        priorityLevel="workbench" />
3938
      <variable
3939
        name="org.eclipse.jubula.client.ui.rcp.variable.isTRTreeViewHidden"
3940
        priorityLevel="workbench" />
3941
      <variable
3942
        name="org.eclipse.jubula.client.ui.variable.mayTestResultViewerBeHidden"
3943
        priorityLevel="workbench" />
3944
    </sourceProvider>
3945
    <sourceProvider
3922
      provider="org.eclipse.jubula.client.ui.rcp.sourceprovider.TestExecutionSourceProvider">
3946
      provider="org.eclipse.jubula.client.ui.rcp.sourceprovider.TestExecutionSourceProvider">
3923
      <variable
3947
      <variable
3924
        name="org.eclipse.jubula.client.ui.rcp.variable.isTestRunning"
3948
        name="org.eclipse.jubula.client.ui.rcp.variable.isTestRunning"
Lines 4063-4099 Link Here
4063
           id="org.eclipse.jubula.client.ui.reference.distinct.visibleWhen.TestResultToolbar">
4087
           id="org.eclipse.jubula.client.ui.reference.distinct.visibleWhen.TestResultToolbar">
4064
        <or>
4088
        <or>
4065
           <with
4089
           <with
4066
                 variable="activeEditorId">
4090
                 variable="org.eclipse.jubula.client.ui.rcp.variable.isPartToViewTestResultOpen">
4067
              <equals
4091
              <equals
4068
                    value="org.eclipse.jubula.client.ui.editors.TestResultViewer">
4092
                    value="true">
4069
              </equals>
4070
           </with>
4071
           <with
4072
                 variable="activePartId">
4073
              <equals
4074
                    value="org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView">
4075
              </equals>
4093
              </equals>
4076
           </with>
4094
           </with>
4077
        </or>
4095
        </or>
4078
     </definition>
4096
     </definition>
4079
     <definition
4097
     <definition
4080
           id="org.eclipse.jubula.client.ui.reference.distinct.activeWhen.GoToTestResultError">
4098
           id="org.eclipse.jubula.client.ui.reference.distinct.activeWhen.GoToTestResultError">
4081
        <and>
4099
               <and>
4100
                   <with
4101
                         variable="activeEditorId">
4102
                      <equals
4103
                            value="org.eclipse.jubula.client.ui.editors.TestResultViewer">
4104
                      </equals>
4105
                   </with>
4106
                   <not>
4107
                      <with
4108
                            variable="activePartId">
4109
                         <equals
4110
                               value="org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView">
4111
                         </equals>
4112
                      </with>
4113
                   </not>
4114
                   <not>
4115
                      <with
4116
                            variable="org.eclipse.jubula.client.ui.variable.mayTestResultViewerBeHidden">
4117
                         <equals
4118
                               value="true">
4119
                         </equals>
4120
                      </with>
4121
                   </not>
4122
                </and>
4123
     </definition>
4124
     <definition
4125
           id="org.eclipse.jubula.client.ui.reference.distinct.activeWhen.TRTreeViewIsNotHidden">
4082
           <with
4126
           <with
4083
                 variable="activeEditorId">
4127
                 variable="org.eclipse.jubula.client.ui.rcp.variable.isTRTreeViewHidden">
4084
              <equals
4128
              <equals
4085
                    value="org.eclipse.jubula.client.ui.editors.TestResultViewer">
4129
                 value="false">
4086
              </equals>
4130
              </equals>
4087
           </with>
4131
           </with>
4088
           <not>
4089
              <with
4090
                    variable="activePartId">
4091
                 <equals
4092
                       value="org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView">
4093
                 </equals>
4094
              </with>
4095
           </not>
4096
        </and>
4097
     </definition>
4132
     </definition>
4098
  </extension>
4133
  </extension>
4099
</plugin>
4134
</plugin>
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/Plugin.java (-36 / +55 lines)
Lines 15-26 import java.util.ArrayList; Link Here
15
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.List;
16
import java.util.List;
17
import java.util.Map;
17
import java.util.Map;
18
import java.util.concurrent.atomic.AtomicReference;
18
19
19
import javax.persistence.PersistenceException;
20
import javax.persistence.PersistenceException;
20
21
21
import org.apache.commons.lang.Validate;
22
import org.apache.commons.lang.Validate;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.NullProgressMonitor;
25
import org.eclipse.core.runtime.NullProgressMonitor;
23
import org.eclipse.core.runtime.Platform;
26
import org.eclipse.core.runtime.Platform;
27
import org.eclipse.core.runtime.Status;
28
import org.eclipse.core.runtime.jobs.Job;
24
import org.eclipse.core.runtime.preferences.InstanceScope;
29
import org.eclipse.core.runtime.preferences.InstanceScope;
25
import org.eclipse.jface.action.IStatusLineManager;
30
import org.eclipse.jface.action.IStatusLineManager;
26
import org.eclipse.jface.action.StatusLineManager;
31
import org.eclipse.jface.action.StatusLineManager;
Lines 48-63 import org.eclipse.jubula.client.ui.rcp.businessprocess.ProblemsBP; Link Here
48
import org.eclipse.jubula.client.ui.rcp.businessprocess.ToolkitBP;
53
import org.eclipse.jubula.client.ui.rcp.businessprocess.ToolkitBP;
49
import org.eclipse.jubula.client.ui.rcp.businessprocess.WorkingLanguageBP;
54
import org.eclipse.jubula.client.ui.rcp.businessprocess.WorkingLanguageBP;
50
import org.eclipse.jubula.client.ui.rcp.controllers.TestExecutionContributor;
55
import org.eclipse.jubula.client.ui.rcp.controllers.TestExecutionContributor;
56
import org.eclipse.jubula.client.ui.rcp.controllers.TestResultPartsTracker;
51
import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
57
import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
52
import org.eclipse.jubula.client.ui.rcp.editors.AbstractTestCaseEditor;
58
import org.eclipse.jubula.client.ui.rcp.editors.AbstractTestCaseEditor;
53
import org.eclipse.jubula.client.ui.rcp.editors.IJBEditor;
59
import org.eclipse.jubula.client.ui.rcp.editors.IJBEditor;
54
import org.eclipse.jubula.client.ui.rcp.editors.TestJobEditor;
60
import org.eclipse.jubula.client.ui.rcp.editors.TestJobEditor;
61
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher;
62
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher.ClientStatus;
55
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
63
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
56
import org.eclipse.jubula.client.ui.rcp.provider.contentprovider.DirtyStarListContentProvider;
64
import org.eclipse.jubula.client.ui.rcp.provider.contentprovider.DirtyStarListContentProvider;
57
import org.eclipse.jubula.client.ui.rcp.provider.labelprovider.DirtyStarListLabelProvider;
65
import org.eclipse.jubula.client.ui.rcp.provider.labelprovider.DirtyStarListLabelProvider;
58
import org.eclipse.jubula.client.ui.rcp.search.query.AbstractQuery;
66
import org.eclipse.jubula.client.ui.rcp.search.query.AbstractQuery;
59
import org.eclipse.jubula.client.ui.rcp.widgets.StatusLineContributionItem;
67
import org.eclipse.jubula.client.ui.rcp.widgets.StatusLineContributionItem;
60
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
68
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
69
import org.eclipse.jubula.client.ui.utils.JobUtils;
61
import org.eclipse.jubula.client.ui.views.IJBPart;
70
import org.eclipse.jubula.client.ui.views.IJBPart;
62
import org.eclipse.jubula.tools.constants.StringConstants;
71
import org.eclipse.jubula.tools.constants.StringConstants;
63
import org.eclipse.jubula.tools.exception.JBException;
72
import org.eclipse.jubula.tools.exception.JBException;
Lines 65-70 import org.eclipse.jubula.tools.exception.JBFatalException; Link Here
65
import org.eclipse.jubula.tools.exception.JBRuntimeException;
74
import org.eclipse.jubula.tools.exception.JBRuntimeException;
66
import org.eclipse.jubula.tools.i18n.CompSystemI18n;
75
import org.eclipse.jubula.tools.i18n.CompSystemI18n;
67
import org.eclipse.jubula.tools.messagehandling.MessageIDs;
76
import org.eclipse.jubula.tools.messagehandling.MessageIDs;
77
import org.eclipse.jubula.tools.utils.TimeUtil;
68
import org.eclipse.osgi.util.NLS;
78
import org.eclipse.osgi.util.NLS;
69
import org.eclipse.search.ui.IQueryListener;
79
import org.eclipse.search.ui.IQueryListener;
70
import org.eclipse.search.ui.ISearchQuery;
80
import org.eclipse.search.ui.ISearchQuery;
Lines 141-148 public class Plugin extends AbstractUIPlugin implements IProgressConsole { Link Here
141
    private static final String AUT_TOOLKIT_STATUSLINE_ITEM = "autToolKitInfo"; //$NON-NLS-1$
151
    private static final String AUT_TOOLKIT_STATUSLINE_ITEM = "autToolKitInfo"; //$NON-NLS-1$
142
    /** <code>LANG_STATUSLINE_ITEM</code> */
152
    /** <code>LANG_STATUSLINE_ITEM</code> */
143
    private static final String LANG_STATUSLINE_ITEM = "lang"; //$NON-NLS-1$
153
    private static final String LANG_STATUSLINE_ITEM = "lang"; //$NON-NLS-1$
144
    /** the client status */
145
    private ClientStatus m_status = ClientStatus.STARTING;
146
    /** the preference store for this bundle */
154
    /** the preference store for this bundle */
147
    private ScopedPreferenceStore m_preferenceStore = null;
155
    private ScopedPreferenceStore m_preferenceStore = null;
148
    /** the console */
156
    /** the console */
Lines 171-213 public class Plugin extends AbstractUIPlugin implements IProgressConsole { Link Here
171
    }
179
    }
172
    
180
    
173
    /**
181
    /**
174
     * The Client Status
175
     */
176
    public enum ClientStatus {
177
        /**
178
         * Jubula is launched completely
179
         */
180
        RUNNING,
181
        /**
182
         * Jubula is starting up
183
         */
184
        STARTING,
185
        /**
186
         * Jubula is shutting down
187
         */
188
        STOPPING
189
    }
190
    
191
    /**
192
     * 
193
     * @param statust - the new ClientStatus (RUNNING,STOPPING,STARTING)
194
     */
195
    public void setClientStatus(ClientStatus statust) {
196
        m_status = statust;
197
    }
198
    
199
    /**
200
     * 
201
     * @return the actual ClientStatus (RUNNING,STARTING,STOPPING)
202
     */
203
    public ClientStatus getClientStatus() {
204
        return m_status;
205
    }
206
    
207
    /**
208
     * {@inheritDoc}
182
     * {@inheritDoc}
209
     */
183
     */
210
    public void stop(BundleContext context) throws Exception {
184
    public void stop(BundleContext context) throws Exception {
185
        GuiEventDispatcher.getInstance().
186
            removeClientStatusListener(TestResultPartsTracker.getInstance());
211
        super.stop(context);
187
        super.stop(context);
212
    }
188
    }
213
189
Lines 1056-1061 public class Plugin extends AbstractUIPlugin implements IProgressConsole { Link Here
1056
     * - ComponentNamesListBP
1032
     * - ComponentNamesListBP
1057
     */
1033
     */
1058
    private void registerPermanentServices() {
1034
    private void registerPermanentServices() {
1035
        registerWorkbenchStartupListenerJob();
1036
1059
        // register problem view listeners
1037
        // register problem view listeners
1060
        ProblemsBP.getInstance();
1038
        ProblemsBP.getInstance();
1061
1039
Lines 1086-1091 public class Plugin extends AbstractUIPlugin implements IProgressConsole { Link Here
1086
        
1064
        
1087
        // register service for toolkit
1065
        // register service for toolkit
1088
        ToolkitBP.getInstance();
1066
        ToolkitBP.getInstance();
1067
        
1068
        // setup view tracker
1069
        TestResultPartsTracker.getInstance();
1070
    }
1071
1072
    /**
1073
     * setup the test result viewer tracker
1074
     */
1075
    private void registerWorkbenchStartupListenerJob() {
1076
        JobUtils.executeJob(new Job("Register Workbench Startup Listener") {
1077
            @Override
1078
            protected IStatus run(IProgressMonitor monitor) {
1079
                monitor.beginTask("registering listener",
1080
                        IProgressMonitor.UNKNOWN);
1081
                final AtomicReference<Object> ref = 
1082
                        new AtomicReference<Object>();
1083
                ref.set(null);
1084
                Display defaultDisplay = Display.getDefault();
1085
                while (ref.get() == null) {
1086
                    if (monitor.isCanceled()) {
1087
                        break;
1088
                    }
1089
                    TimeUtil.delay(1000);
1090
                    defaultDisplay.syncExec(new Runnable() {
1091
                        public void run() {
1092
                            // important!
1093
                            ref.set(Plugin.getActivePage());
1094
                        }
1095
                    });
1096
                }
1097
                monitor.done();
1098
                defaultDisplay.syncExec(new Runnable() {
1099
                    public void run() {
1100
                        GuiEventDispatcher.getInstance()
1101
                            .fireClientStatusChanged(
1102
                                ClientStatus.RUNNING);
1103
                    }
1104
                });
1105
                return Status.OK_STATUS;
1106
            }
1107
        }, null, 1000);
1089
    }
1108
    }
1090
1109
1091
    /**
1110
    /**
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/TestResultPartsTracker.java (+375 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2012 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.controllers;
12
13
import java.util.ArrayList;
14
import java.util.LinkedList;
15
import java.util.List;
16
import org.eclipse.jubula.client.ui.constants.Constants;
17
import org.eclipse.jubula.client.ui.editors.TestResultViewer;
18
import org.eclipse.jubula.client.ui.rcp.Plugin;
19
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher;
20
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher.ClientStatus;
21
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher.IClientStatusListener;
22
import org.eclipse.jubula.client.ui.rcp.sourceprovider.TestResultSourceProvider;
23
import org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView;
24
import org.eclipse.ui.IEditorPart;
25
import org.eclipse.ui.IPartListener;
26
import org.eclipse.ui.IPerspectiveDescriptor;
27
import org.eclipse.ui.IViewPart;
28
import org.eclipse.ui.IViewReference;
29
import org.eclipse.ui.IWorkbenchPage;
30
import org.eclipse.ui.IWorkbenchPart;
31
import org.eclipse.ui.part.ViewPart;
32
import org.eclipse.ui.part.WorkbenchPart;
33
34
/**
35
 * @author BREDEX GmbH
36
 */
37
public class TestResultPartsTracker implements IClientStatusListener {
38
    
39
    /**
40
     * the current perspective descriptor of the active page
41
     */
42
    private static IPerspectiveDescriptor currPesrpDescriptor;
43
    
44
    /**
45
     * singleton instance
46
     */
47
    private static TestResultPartsTracker instance = null;
48
49
    /**
50
     * the list of open test result viewers
51
     */
52
    private List<TestResultViewer> m_trViewers = 
53
            new ArrayList<TestResultViewer>();
54
    
55
    /**
56
     * state is false is Test Result Tree View is hidden
57
     * the value of this member is used to define if GoToNext/Previous Error Buttons should be disabled
58
     */
59
    private boolean m_isTRTreeViewHidden = true;
60
    
61
    /**
62
     *it is not currently tracked if the TestResultViewer
63
     *is hidden or visible, and when it might be hidden
64
     *GoToErrorButtons should be disabled
65
     */
66
    private boolean m_trViewerMayBeHidden = true;
67
    
68
    /**
69
     * the ordered by activation time list of open test result viewers and test result view
70
     */
71
    private List<WorkbenchPart> m_trParts = 
72
            new LinkedList<WorkbenchPart>();
73
74
    /**
75
     * the test result tree view
76
     */
77
    private TestResultTreeView m_trTreeView = null;
78
    
79
    /**
80
    * the source provider
81
    */
82
    private TestResultSourceProvider m_provider = null;
83
    
84
85
    /**
86
     * private Constructor
87
     */
88
    private TestResultPartsTracker() {
89
        GuiEventDispatcher.getInstance()
90
            .addClientStatusListener(this);
91
    }
92
    
93
    /**
94
     * sets the value of the current perspective descriptor of the active page
95
     * @param pDescr the value to set
96
     */
97
    private static void setCurrentPesrpective(IPerspectiveDescriptor pDescr) {
98
        currPesrpDescriptor = pDescr;
99
    }
100
    
101
    /**
102
     *@return the value of the current perspective descriptor of the active page
103
     */
104
    private static IPerspectiveDescriptor getCurrentPesrpective() {
105
        return currPesrpDescriptor;
106
    }
107
    
108
    /**
109
     * @param page the page for which state of Test Result Tree View is tracked and handled
110
     */
111
    private void handleTestResultTreeViewInitialState(IWorkbenchPage page) {
112
        for (IViewReference viewRef : page.getViewReferences()) {
113
            if (viewRef.getId().equals(Constants.TESTRE_ID)) {
114
                addTRTreeView((TestResultTreeView)viewRef.getPart(true));
115
                setTRTreeViewHiddenStateTo(true);
116
            }
117
        }
118
    }
119
    
120
    /**
121
     * @author BREDEX The PartListener for tracking the state of Parts to view Test Result 
122
     * (TestResultViewer or TestResultTreeView)
123
     */
124
    private class PartListenerToTrackTRParts implements IPartListener {
125
        /** {@inheritDoc} */
126
        public void partActivated(IWorkbenchPart part) {
127
            handlePerspectiveChange();
128
            if (part instanceof TestResultTreeView) {
129
                setTRTreeViewHiddenStateTo(false);
130
            }
131
            if (part instanceof IEditorPart) {
132
                setTRViewerMayBeHiddenStateTo(
133
                        !(part instanceof TestResultViewer));
134
            }
135
        }
136
137
        /** {@inheritDoc} */
138
        public void partOpened(IWorkbenchPart part) {
139
            if (partIsTestResultPart(part)) {
140
                changeTRPartHiddenStateTo(part, false);
141
                if (part instanceof TestResultTreeView) {
142
                    addTRTreeView((TestResultTreeView)part);
143
                } else {
144
                    addTRViewer((TestResultViewer)part);
145
                }
146
            }
147
        }
148
        
149
        /** {@inheritDoc} */
150
        public void partDeactivated(IWorkbenchPart part) {
151
            //do nothing
152
        }
153
        
154
        /** {@inheritDoc} */
155
        public void partClosed(IWorkbenchPart part) {
156
            if (partIsTestResultPart(part)) {
157
                if (part instanceof TestResultTreeView) {
158
                    removeTRTreeView((TestResultTreeView)part);
159
                } else {
160
                    removeTRViewer((TestResultViewer)part);
161
                }
162
                changeTRPartHiddenStateTo(part, true);
163
            }
164
        }
165
166
        /** {@inheritDoc} */
167
        public void partBroughtToTop(IWorkbenchPart part) {
168
            if (part instanceof TestResultTreeView) {
169
                setTRTreeViewHiddenStateTo(false);
170
            }
171
            if (!((part instanceof TestResultTreeView)
172
                  || (part instanceof TestResultViewer))) {
173
                if (part instanceof IViewPart) {
174
                    IWorkbenchPage actPage = Plugin.getActivePage();
175
                    if (actPage != null) {
176
                        IViewPart[] stackedViews =
177
                                actPage.getViewStack((ViewPart)part);
178
                        for (IViewPart iViewPart : stackedViews) {
179
                            if (iViewPart instanceof TestResultTreeView) {
180
                                setTRTreeViewHiddenStateTo(true);
181
                            }
182
                        }
183
                    }
184
                }
185
            }
186
        }
187
        
188
        /**
189
         * @param part the part for which hidden state will be changed
190
         * @param state the new value of the part hidden state 
191
         */
192
        private void changeTRPartHiddenStateTo(IWorkbenchPart part, 
193
                boolean state) {
194
            if (part instanceof TestResultTreeView) {
195
                setTRTreeViewHiddenStateTo(state);
196
            } else {
197
                setTRViewerMayBeHiddenStateTo(state);
198
            }
199
        }
200
201
        /**
202
         * @param part the part to check
203
         * @return true if the part is the one to view test results
204
         * (TestResultTreeView or TestResultViewer)
205
         */
206
        private boolean partIsTestResultPart(IWorkbenchPart part) {
207
            return (part instanceof TestResultTreeView) 
208
                    || (part instanceof TestResultViewer);
209
        }
210
        
211
        /**
212
         * handle availability of GoToErrorButtons on change of the current perspective
213
         */
214
        private void handlePerspectiveChange() {
215
            IWorkbenchPage actPage = Plugin.getActivePage();
216
            if (actPage != null) {
217
                if (!actPage.getPerspective().equals(getCurrentPesrpective())) {
218
                    setTRViewerMayBeHiddenStateTo(true);
219
                    setTRTreeViewHiddenStateTo(true);
220
                    setCurrentPesrpective(actPage.getPerspective());
221
                }
222
            }
223
        }
224
        
225
        
226
    }
227
228
    /**
229
     * get single instance
230
     * 
231
     * @return single instance of ImportFileBP
232
     */
233
    public static TestResultPartsTracker getInstance() {
234
        if (instance == null) {
235
            instance = new TestResultPartsTracker();
236
        }
237
        return instance;
238
    }
239
240
    /**
241
     * Add a test result viewer to this tracker.
242
     * @param testResultViewer The test result viewer to add.
243
     */
244
    public void addTRViewer(TestResultViewer testResultViewer) {
245
        if (testResultViewer != null) {
246
            m_trViewers.add(testResultViewer);
247
            m_trParts.add(testResultViewer);
248
            fireStateChanged();
249
        }
250
    }
251
    
252
    /**
253
     * Add a test result tree view to this tracker.
254
     * @param testResultTreeView The test result tree view to add.
255
     */
256
    public void addTRTreeView(TestResultTreeView testResultTreeView) {
257
        if (testResultTreeView != null) {
258
            m_trTreeView = testResultTreeView;
259
            m_trParts.add(testResultTreeView);
260
            m_isTRTreeViewHidden = false;
261
            fireStateChanged();
262
        }
263
    }
264
265
    /**
266
     * @param provider the provider to set
267
     */
268
    public void setProvider(TestResultSourceProvider provider) {
269
        m_provider = provider;
270
    }
271
    
272
    /**
273
     * set m_isTRTreeViewHidden to true or false
274
     * @param state the state to what of m_isTRTreeViewHidden will be set
275
     */
276
    public void setTRTreeViewHiddenStateTo(boolean state) {
277
        m_isTRTreeViewHidden = state;
278
        fireStateChanged();
279
    }
280
    
281
    /**
282
     * set m_isTRTreeViewHidden to true or false
283
     * @param state the state to what of m_isTRTreeViewHidden will be set
284
     */
285
    public void setTRViewerMayBeHiddenStateTo(boolean state) {
286
        m_trViewerMayBeHidden = state;
287
        fireStateChanged();
288
    }
289
    
290
    /**
291
     * @return the currently open instances of the Test Result Viewer editor
292
     */
293
    public List<TestResultViewer> getOpenTRViewers() {
294
        List<TestResultViewer> trvs = new ArrayList<TestResultViewer>();
295
        for (TestResultViewer trv : m_trViewers) {
296
            trvs.add(trv);
297
        }
298
        return trvs;
299
    }
300
    
301
    /**
302
     * @return the list of open parts to view test result
303
     * (test result tree view or test result viewers)
304
     * ordered by their activation
305
     */
306
    public List<WorkbenchPart> getTRParts() {
307
        List<WorkbenchPart> trParts = new LinkedList<WorkbenchPart>();
308
        for (WorkbenchPart trv : m_trParts) {
309
            trParts.add(trv);
310
        }
311
        return trParts;
312
    }
313
    
314
    /**
315
     * @return the currently open instance of the Test Result Tree View
316
     */
317
    public TestResultTreeView getTRTreeView() {
318
        return m_trTreeView;
319
    }
320
    
321
    /**
322
     * @return the value of m_isTRTreeViewHidden (true if Test Result Tree View is hidden)
323
     */
324
    public boolean isTRTreeViewHidden() {
325
        return m_isTRTreeViewHidden;
326
    }
327
328
    /**
329
     * @return the value of m_areButtonsDisabled
330
     */
331
    public boolean mayTRViewerBeHidden() {
332
        return m_trViewerMayBeHidden;
333
    }
334
    
335
    /**
336
     * Remove a test result tree view from this tracker.
337
     * @param testResultViewer The test result tree view to remove.
338
     */
339
    public void removeTRViewer(TestResultViewer testResultViewer) {
340
        m_trViewers.remove(testResultViewer);
341
        m_trParts.remove(testResultViewer);
342
        fireStateChanged();
343
    }
344
    
345
    /**
346
     * Remove a test result tree view from this tracker.
347
     * @param testResultTreeView The test result tree view to remove.
348
     */
349
    public void removeTRTreeView(TestResultTreeView testResultTreeView) {
350
        m_trParts.remove(testResultTreeView);
351
        m_trTreeView = null;
352
        fireStateChanged();
353
    }
354
355
    /**
356
     * fire data changed events
357
     */
358
    private void fireStateChanged() {
359
        if (m_provider != null) {
360
            m_provider.externalFireSourceChanged();
361
        }
362
    }
363
364
    /** {@inheritDoc} */
365
    public void handleClientStateChanged(ClientStatus status) {
366
        if (status.equals(ClientStatus.RUNNING)) {
367
            IWorkbenchPage actPage = Plugin.getActivePage();
368
            if (actPage != null) {
369
                actPage.addPartListener(new PartListenerToTrackTRParts());
370
                setCurrentPesrpective(actPage.getPerspective());
371
                handleTestResultTreeViewInitialState(actPage);
372
            }
373
        }
374
    }
375
}
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/events/GuiEventDispatcher.java (-1 / +68 lines)
Lines 36-41 public class GuiEventDispatcher { Link Here
36
                boolean isDirty);
36
                boolean isDirty);
37
    }
37
    }
38
    
38
    
39
    /** to notify clients about changes client status */
40
    public interface IClientStatusListener {
41
        /**
42
         * @param status the status of the client
43
         */
44
        public void handleClientStateChanged(ClientStatus status);
45
    }
46
    
39
    /** logger */
47
    /** logger */
40
    private static final Logger LOG = 
48
    private static final Logger LOG = 
41
        LoggerFactory.getLogger(GuiEventDispatcher.class);
49
        LoggerFactory.getLogger(GuiEventDispatcher.class);
Lines 46-51 public class GuiEventDispatcher { Link Here
46
     */
54
     */
47
    private static GuiEventDispatcher instance = null;
55
    private static GuiEventDispatcher instance = null;
48
56
57
//    /** the listener of client status*/
58
//    private static IClientStatusListener clStatusListener;
59
    
60
    /**
61
     * <code>m_editorDirtyStateListeners</code> listener for notification 
62
     * about change of the dirty state of an editor
63
     */
64
    private Set<IClientStatusListener> m_clStatusListeners =
65
        new HashSet<IClientStatusListener>();
66
    
49
    /**
67
    /**
50
     * <code>m_editorDirtyStateListeners</code> listener for notification 
68
     * <code>m_editorDirtyStateListeners</code> listener for notification 
51
     * about change of the dirty state of an editor
69
     * about change of the dirty state of an editor
Lines 60-72 public class GuiEventDispatcher { Link Here
60
    private Set<IEditorDirtyStateListener> m_editorDirtyStateListenersPost =
78
    private Set<IEditorDirtyStateListener> m_editorDirtyStateListenersPost =
61
        new HashSet<IEditorDirtyStateListener>();
79
        new HashSet<IEditorDirtyStateListener>();
62
    
80
    
81
    /** the Client Status */
82
    public enum ClientStatus {
83
        /**
84
         * Jubula is launched completely
85
         */
86
        RUNNING,
87
        /**
88
         * Jubula is starting up
89
         */
90
        STARTING,
91
        /**
92
         * Jubula is shutting down
93
         */
94
        STOPPING
95
    }
96
    
63
    /**
97
    /**
64
     * private constructor
98
     * private constructor
65
     */
99
     */
66
    private GuiEventDispatcher() {
100
    private GuiEventDispatcher() {
67
        // Nothing to initialize
101
        // Nothing to initialize
68
    }
102
    }
69
    
103
70
    /**
104
    /**
71
     * @return the single instance
105
     * @return the single instance
72
     */
106
     */
Lines 131-134 public class GuiEventDispatcher { Link Here
131
            }
165
            }
132
        }
166
        }
133
    }
167
    }
168
169
    /**
170
     * fire client status changed events
171
     * 
172
     * @param status the new status
173
     */
174
    public void fireClientStatusChanged(ClientStatus status) {
175
        for (IClientStatusListener l : m_clStatusListeners) {
176
            try {
177
                l.handleClientStateChanged(status);
178
            } catch (Throwable t) {
179
                LOG.error(Messages.UnhandledExceptionCallingListeners, t);
180
            }
181
        }
182
    }
183
184
    /**
185
     * add client status listener
186
     * 
187
     * @param l the listener to add
188
     */
189
    public void addClientStatusListener(IClientStatusListener l) {
190
        m_clStatusListeners.add(l);
191
    }
192
    
193
    /**
194
     * remove client status listener
195
     * 
196
     * @param l the listener to remove
197
     */
198
    public void removeClientStatusListener(IClientStatusListener l) {
199
        m_clStatusListeners.remove(l);
200
    }
134
}
201
}
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/GoToNextTestResultErrorHandler.java (-8 / +18 lines)
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.rcp.handlers;
11
package org.eclipse.jubula.client.ui.rcp.handlers;
12
12
13
import java.util.List;
14
15
import org.eclipse.jface.viewers.TreeViewer;
13
import org.eclipse.jface.viewers.TreeViewer;
14
import org.eclipse.jubula.client.ui.editors.TestResultViewer;
16
import org.eclipse.jubula.client.ui.handlers.AbstractGoToTestResultErrorHandler;
15
import org.eclipse.jubula.client.ui.handlers.AbstractGoToTestResultErrorHandler;
16
import org.eclipse.jubula.client.ui.rcp.controllers.TestResultPartsTracker;
17
import org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView;
17
import org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView;
18
import org.eclipse.ui.IWorkbenchPart;
18
import org.eclipse.ui.IWorkbenchPart;
19
19
Lines 33-43 public class GoToNextTestResultErrorHandler extends Link Here
33
        return true;
33
        return true;
34
    }
34
    }
35
35
36
    /**
36
    @Override
37
     * {@inheritDoc}
37
    protected TreeViewer handleTestResultPart(IWorkbenchPart part) {
38
     */
38
        TreeViewer viewer = null;
39
    protected TreeViewer handleActiveWorkbenchParts(List<IWorkbenchPart> list) {
39
        if (part instanceof TestResultTreeView) {
40
        list.get(0).setFocus();
40
            if (!(TestResultPartsTracker.getInstance().
41
        return ((TestResultTreeView) list.get(0)).getTreeViewer();
41
                    isTRTreeViewHidden())) {
42
                part.setFocus();
43
                TestResultTreeView trTreeView = (TestResultTreeView)part;
44
                viewer = trTreeView.getTreeViewer();
45
            }
46
        } else if (part instanceof TestResultViewer) { 
47
            part.setFocus();
48
            TestResultViewer trViewer = (TestResultViewer)part;
49
            viewer = trViewer.getTreeViewer();
50
        }
51
        return viewer;
42
    }
52
    }
43
}
53
}
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/GoToPreviousTestResultErrorHandler.java (-16 / +1 lines)
Lines 10-22 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.rcp.handlers;
11
package org.eclipse.jubula.client.ui.rcp.handlers;
12
12
13
import java.util.List;
14
15
import org.eclipse.jface.viewers.TreeViewer;
16
import org.eclipse.jubula.client.ui.handlers.AbstractGoToTestResultErrorHandler;
17
import org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView;
18
import org.eclipse.ui.IWorkbenchPart;
19
20
/**
13
/**
21
 * Handler for navigating to the "previous" error in a Test Result.
14
 * Handler for navigating to the "previous" error in a Test Result.
22
 * 
15
 * 
Lines 24-30 import org.eclipse.ui.IWorkbenchPart; Link Here
24
 * @created September 10, 2013
17
 * @created September 10, 2013
25
 */
18
 */
26
public class GoToPreviousTestResultErrorHandler extends
19
public class GoToPreviousTestResultErrorHandler extends
27
        AbstractGoToTestResultErrorHandler {
20
        GoToNextTestResultErrorHandler {
28
21
29
    /**
22
    /**
30
     * {@inheritDoc}
23
     * {@inheritDoc}
Lines 32-43 public class GoToPreviousTestResultErrorHandler extends Link Here
32
    protected boolean isForwardIteration() {
25
    protected boolean isForwardIteration() {
33
        return false;
26
        return false;
34
    }
27
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39
    protected TreeViewer handleActiveWorkbenchParts(List<IWorkbenchPart> list) {
40
        list.get(0).setFocus();
41
        return ((TestResultTreeView) list.get(0)).getTreeViewer();
42
    }
43
}
28
}
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/sourceprovider/TestResultSourceProvider.java (+116 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 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.sourceprovider;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
import org.eclipse.jubula.client.ui.rcp.controllers.TestResultPartsTracker;
16
import org.eclipse.ui.ISources;
17
18
/**
19
 * Provides variables related to the Test Result Viewers and Test Result Tree View.
20
 *
21
 * @author BREDEX GmbH
22
 * @created Dec 09, 2013
23
 */
24
public class TestResultSourceProvider extends AbstractJBSourceProvider {
25
    /** 
26
     * ID of variable that indicates whether at least one part to view test result 
27
     * (test result tree view or test result viewer) is open.
28
     */
29
    public static final String IS_PART_TO_VIEW_TEST_RESULT_OPEN =
30
        "org.eclipse.jubula.client.ui.rcp.variable.isPartToViewTestResultOpen"; //$NON-NLS-1$
31
    
32
    /** 
33
     * ID of definition that indicates whether Go to Next/Previous Error Buttons should be disabled
34
     * (the value depends on if open Test Result Tree View is hidden or not)
35
     */
36
    public static final String IS_TEST_RESULT_TREE_VIEW_HIDDEN =
37
        "org.eclipse.jubula.client.ui.rcp.variable.isTRTreeViewHidden"; //$NON-NLS-1$
38
    
39
    /** 
40
     * ID of definition that indicates whether Go to Next/Previous Error Buttons should be disabled
41
     * (the value depends on if open Test Result Tree View is hidden or not)
42
     */
43
    public static final String TEST_RESLT_VIEWER_MAY_BE_HIDDEN =
44
        "org.eclipse.jubula.client.ui.variable.mayTestResultViewerBeHidden"; //$NON-NLS-1$
45
    
46
    /**
47
     * Constructor.
48
     */
49
    public TestResultSourceProvider() {
50
        TestResultPartsTracker.getInstance().setProvider(this);
51
    }
52
53
    /**
54
     * 
55
     * {@inheritDoc}
56
     */
57
    public void dispose() {
58
        TestResultPartsTracker.getInstance().setProvider(null);
59
    }
60
61
    /**
62
     * 
63
     * {@inheritDoc}
64
     */
65
    public Map getCurrentState() {
66
        Map<String, Object> currentState = new HashMap<String, Object>();
67
        currentState.put(IS_PART_TO_VIEW_TEST_RESULT_OPEN,
68
                TestResultPartsTracker.getInstance().
69
                    getTRParts().size() > 0);
70
        currentState.put(IS_TEST_RESULT_TREE_VIEW_HIDDEN,
71
                TestResultPartsTracker.getInstance().
72
                    isTRTreeViewHidden());
73
        currentState.put(TEST_RESLT_VIEWER_MAY_BE_HIDDEN,
74
                TestResultPartsTracker.getInstance().mayTRViewerBeHidden());
75
        return currentState;
76
    }
77
78
    /**
79
     * 
80
     * {@inheritDoc}
81
     */
82
    public String[] getProvidedSourceNames() {
83
        return new String[] {   IS_PART_TO_VIEW_TEST_RESULT_OPEN,
84
                                IS_TEST_RESULT_TREE_VIEW_HIDDEN,
85
                                TEST_RESLT_VIEWER_MAY_BE_HIDDEN};
86
    }
87
88
    /**
89
     * Fires a source changed event for
90
     * <code>IS_PART_TO_VIEW_TEST_RESULT_OPEN</code> and
91
     * <code>IS_TEST_RESULT_TREE_VIEW_HIDDEN</code>
92
     * <code>TEST_RESLT_VIEWER_MAY_BE_HIDDEN</code>
93
     */
94
    private void fireSourceChanged() {
95
        gdFireSourceChanged(ISources.WORKBENCH,
96
                IS_PART_TO_VIEW_TEST_RESULT_OPEN,
97
              TestResultPartsTracker.getInstance().
98
                  getTRParts().size() > 0);
99
        gdFireSourceChanged(ISources.WORKBENCH,
100
                IS_TEST_RESULT_TREE_VIEW_HIDDEN,
101
              TestResultPartsTracker.getInstance().
102
                  isTRTreeViewHidden());
103
        gdFireSourceChanged(ISources.WORKBENCH,
104
                TEST_RESLT_VIEWER_MAY_BE_HIDDEN,
105
              TestResultPartsTracker.getInstance().
106
                  mayTRViewerBeHidden());        
107
    }
108
    
109
    /**
110
     * specified in Listener
111
     * callback method
112
     */
113
    public void externalFireSourceChanged() {
114
        fireSourceChanged();
115
    }
116
}
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java (+4 lines)
Lines 74-79 public interface Constants { Link Here
74
    public static final String TESTRE_ID = 
74
    public static final String TESTRE_ID = 
75
        "org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView"; //$NON-NLS-1$
75
        "org.eclipse.jubula.client.ui.rcp.views.TestResultTreeView"; //$NON-NLS-1$
76
    
76
    
77
    /** the ID of the test result viewer */
78
    public static final String TESTRE_VIEWER_ID =
79
        "org.eclipse.jubula.client.ui.editors.TestResultViewer"; //$NON-NLS-1$
80
    
77
    /** the ID of the test case browser */
81
    /** the ID of the test case browser */
78
    public static final String TC_BROWSER_ID = 
82
    public static final String TC_BROWSER_ID = 
79
        "org.eclipse.jubula.client.ui.rcp.views.TestCaseBrowser"; //$NON-NLS-1$
83
        "org.eclipse.jubula.client.ui.rcp.views.TestCaseBrowser"; //$NON-NLS-1$
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/AbstractGoToTestResultErrorHandler.java (-15 / +68 lines)
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.handlers;
11
package org.eclipse.jubula.client.ui.handlers;
12
12
13
import java.util.LinkedList;
14
import java.util.List;
15
16
import org.eclipse.core.commands.AbstractHandler;
13
import org.eclipse.core.commands.AbstractHandler;
17
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.core.commands.ExecutionEvent;
18
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.commands.ExecutionException;
Lines 21-29 import org.eclipse.jface.viewers.ITreeContentProvider; Link Here
21
import org.eclipse.jface.viewers.StructuredSelection;
18
import org.eclipse.jface.viewers.StructuredSelection;
22
import org.eclipse.jface.viewers.TreeViewer;
19
import org.eclipse.jface.viewers.TreeViewer;
23
import org.eclipse.jubula.client.core.model.TestResultNode;
20
import org.eclipse.jubula.client.core.model.TestResultNode;
21
import org.eclipse.jubula.client.ui.constants.Constants;
22
import org.eclipse.jubula.client.ui.editors.TestResultViewer;
24
import org.eclipse.jubula.client.ui.utils.TreeViewerIterator;
23
import org.eclipse.jubula.client.ui.utils.TreeViewerIterator;
24
import org.eclipse.ui.IEditorReference;
25
import org.eclipse.ui.IViewReference;
26
import org.eclipse.ui.IWorkbenchPage;
25
import org.eclipse.ui.IWorkbenchPart;
27
import org.eclipse.ui.IWorkbenchPart;
26
import org.eclipse.ui.handlers.HandlerUtil;
28
import org.eclipse.ui.PlatformUI;
27
29
28
30
29
/**
31
/**
Lines 40-52 public abstract class AbstractGoToTestResultErrorHandler Link Here
40
     */
42
     */
41
    public final Object execute(ExecutionEvent event) 
43
    public final Object execute(ExecutionEvent event) 
42
        throws ExecutionException {
44
        throws ExecutionException {
43
45
        activateTestResultTreeView();
44
        List<IWorkbenchPart> listOfPossibleParts =
46
        TreeViewer viewer = handleTestResultPart(
45
                new LinkedList<IWorkbenchPart>();
47
                getTestResultPartToExecuteGoToOn());
46
        listOfPossibleParts.add(HandlerUtil.getActivePart(event));
47
        listOfPossibleParts.add(HandlerUtil.getActiveEditor(event));
48
        TreeViewer viewer = handleActiveWorkbenchParts(listOfPossibleParts);
49
        
50
        IStructuredSelection selection = 
48
        IStructuredSelection selection = 
51
            (IStructuredSelection)viewer.getSelection();
49
            (IStructuredSelection)viewer.getSelection();
52
        ITreeContentProvider contentProvider = 
50
        ITreeContentProvider contentProvider = 
Lines 87-92 public abstract class AbstractGoToTestResultErrorHandler Link Here
87
    }
85
    }
88
86
89
    /**
87
    /**
88
     * @return part to Execute GoTo on
89
     * the active TestResultViewer or TestResultTreeView is selected to be a part 
90
     * if both TestResultViewer and TestResultTreeView or none of them are active, 
91
     * the part is considered to be a TestResultViewer
92
     */
93
    private IWorkbenchPart getTestResultPartToExecuteGoToOn() {
94
        IWorkbenchPage actPage = PlatformUI.getWorkbench().
95
                getActiveWorkbenchWindow().getActivePage();
96
        //part is an active TestResultTreeView
97
        if (actPage.getViewReferences().length > 0) {
98
            for (IViewReference viewRef : actPage.getViewReferences()) {
99
                if ((viewRef.getId().equals(Constants.TESTRE_ID)) 
100
                        && (viewRef.equals(actPage.getActivePartReference()))) {
101
                    return (IWorkbenchPart)viewRef.getView(true);
102
                }
103
            }
104
        }
105
        //part is an active TestResultViewer 
106
        if (actPage.getEditorReferences().length > 0) {
107
            for (IEditorReference edRef : actPage.getEditorReferences()) {
108
                if ((edRef.getId().equals(Constants.TESTRE_VIEWER_ID))
109
                        && (edRef.getEditor(true).
110
                                equals(actPage.getActiveEditor()))) {
111
                    return (IWorkbenchPart)edRef.getEditor(true);
112
                }
113
            }
114
        //part is any of open TestResultViewers
115
            for (IEditorReference edRef : actPage.getEditorReferences()) {
116
                if (edRef.getId().equals(Constants.TESTRE_VIEWER_ID)) {
117
                    return (IWorkbenchPart)edRef.getEditor(true);
118
                }
119
            }
120
        }
121
        return null;
122
    }
123
124
    /**
125
     * unlike Editors (for which value of last active editor is 
126
     * remembered even if Editor loses focus)
127
     * last active view is not remembered and need to be activated
128
     * at the beginning of GoToTestResultErrorHandler execution
129
     */
130
    private void activateTestResultTreeView() {
131
        IWorkbenchPage actPage = PlatformUI.getWorkbench().
132
                getActiveWorkbenchWindow().getActivePage();
133
        if (!(actPage.getActiveEditor() instanceof TestResultViewer)) {
134
            for (IViewReference viewRef : actPage.getViewReferences()) {
135
                if (viewRef.getId().equals(Constants.TESTRE_ID)) {
136
                    actPage.activate(viewRef.getView(true));
137
                }
138
            }
139
        }
140
    }
141
142
    /**
90
     * 
143
     * 
91
     * @param node The node to check.
144
     * @param node The node to check.
92
     * @return <code>true</code> if the node is considered an error node.
145
     * @return <code>true</code> if the node is considered an error node.
Lines 104-112 public abstract class AbstractGoToTestResultErrorHandler Link Here
104
    protected abstract boolean isForwardIteration();
157
    protected abstract boolean isForwardIteration();
105
    
158
    
106
    /**
159
    /**
107
     * @param listOfPossibleParts a list of two possible parts to execute the GoTo on
160
     * @param part a part to execute the GoTo on
108
     * @return the TreeViewer of the active part
161
     * @return the TreeViewer of the part to execute the GoTo on
109
     */
162
     */
110
    protected abstract TreeViewer handleActiveWorkbenchParts(
163
    protected abstract TreeViewer handleTestResultPart(
111
            List<IWorkbenchPart> listOfPossibleParts);  
164
            IWorkbenchPart part);  
112
}
165
}
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/GoToNextTestResultErrorHandler.java (-8 / +21 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.handlers;
11
package org.eclipse.jubula.client.ui.handlers;
12
12
13
import java.util.List;
14
15
import org.eclipse.jface.viewers.TreeViewer;
13
import org.eclipse.jface.viewers.TreeViewer;
16
import org.eclipse.jubula.client.ui.editors.TestResultViewer;
14
import org.eclipse.jubula.client.ui.editors.TestResultViewer;
15
import org.eclipse.ui.IWorkbenchPage;
17
import org.eclipse.ui.IWorkbenchPart;
16
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.PlatformUI;
18
18
19
/**
19
/**
20
 * Handler for navigating to the "next" error in a Test Result.
20
 * Handler for navigating to the "next" error in a Test Result.
Lines 32-42 public class GoToNextTestResultErrorHandler extends Link Here
32
        return true;
32
        return true;
33
    }
33
    }
34
34
35
    /**
35
    @Override
36
     * {@inheritDoc}
36
    protected TreeViewer handleTestResultPart(IWorkbenchPart part) {
37
     */
37
        TestResultViewer trViewer = null;
38
    protected TreeViewer handleActiveWorkbenchParts(List<IWorkbenchPart> list) {
38
        boolean existActTRViewer = false;
39
        list.get(1).setFocus();
39
        IWorkbenchPage actPage = PlatformUI.getWorkbench().
40
        return ((TestResultViewer) list.get(1)).getTreeViewer();
40
                getActiveWorkbenchWindow().getActivePage();
41
        if ((part instanceof TestResultViewer) 
42
                && (part.equals(actPage.getActiveEditor()))) {
43
            part.setFocus();
44
            trViewer = (TestResultViewer) part;
45
            existActTRViewer = true;
46
        }
47
        if (!existActTRViewer) {
48
            if (part instanceof TestResultViewer) { 
49
                part.setFocus();
50
                trViewer = (TestResultViewer) part;
51
            }
52
        }
53
        return trViewer.getTreeViewer();
41
    }
54
    }
42
}
55
}
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/GoToPreviousTestResultErrorHandler.java (-15 / +1 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.handlers;
11
package org.eclipse.jubula.client.ui.handlers;
12
12
13
import java.util.List;
14
15
import org.eclipse.jface.viewers.TreeViewer;
16
import org.eclipse.jubula.client.ui.editors.TestResultViewer;
17
import org.eclipse.ui.IWorkbenchPart;
18
13
19
/**
14
/**
20
 * Handler for navigating to the "previous" error in a Test Result.
15
 * Handler for navigating to the "previous" error in a Test Result.
Lines 23-29 import org.eclipse.ui.IWorkbenchPart; Link Here
23
 * @created May 17, 2010
18
 * @created May 17, 2010
24
 */
19
 */
25
public class GoToPreviousTestResultErrorHandler extends
20
public class GoToPreviousTestResultErrorHandler extends
26
        AbstractGoToTestResultErrorHandler {
21
    GoToNextTestResultErrorHandler {
27
22
28
    /**
23
    /**
29
     * {@inheritDoc}
24
     * {@inheritDoc}
Lines 31-42 public class GoToPreviousTestResultErrorHandler extends Link Here
31
    protected boolean isForwardIteration() {
26
    protected boolean isForwardIteration() {
32
        return false;
27
        return false;
33
    }
28
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    protected TreeViewer handleActiveWorkbenchParts(List<IWorkbenchPart> list) {
39
        list.get(1).setFocus();
40
        return ((TestResultViewer) list.get(1)).getTreeViewer();
41
    }
42
}
29
}
43
- 

Return to bug 417829