Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 77d16452558009bef193cc976ac328b7707651ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*******************************************************************************
 * Copyright (c) 2008 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0 
 * which accompanies this distribution, and is available at 
 * http://www.eclipse.org/legal/epl-v10.html 
 *  
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tm.internal.tcf.debug.ui.adapters;

import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.tm.internal.tcf.debug.model.TCFLaunch;
import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;

class TCFLaunchLabelProvider implements IElementLabelProvider {

    public void update(ILabelUpdate[] updates) {
        for (int i = 0; i < updates.length; i++) {
            ILabelUpdate result = updates[i];
            TCFLaunch launch = (TCFLaunch)result.getElement();
            result.setImageDescriptor(ImageCache.getImageDescriptor(ImageCache.IMG_TCF), 0);
            String status = "";
            if (launch.isConnecting()) {
                status = "Connecting";
            }
            else if (launch.isExited()) {
                status = "Exited";
                int code = launch.getExitCode();
                if (code > 0) status += ", exit code " + code;
                if (code < 0) status += ", signal " + (-code); // TODO: signal name
            }
            else if (launch.isDisconnected()) {
                status = "Disconnected";
            }
            Throwable error = launch.getError();
            if (error != null) {
                String msg = error.getLocalizedMessage();
                if (msg == null || msg.length() == 0) msg = error.getClass().getName();
                else msg = msg.replace('\n', '|');
                status += " - " + msg;
                result.setForeground(new RGB(255, 0, 0), 0);
            }
            if (status.length() > 0) status = " (" + status + ")";
            String name = "?";
            ILaunchConfiguration cfg = launch.getLaunchConfiguration();
            if (cfg != null) name = cfg.getName();
            result.setLabel(name + status, 0);
            result.done();
        }
    }
}

Back to the top