blob: 3ea3ba95507a701b09d3f38160927bac48a8cbd6 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*******************************************************************************
* Copyright (c) 2010, 2012 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.debug.internal.ui.views.variables.details;
import org.eclipse.debug.internal.ui.SWTFactory;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDetailPane;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbenchPartSite;
/**
* A detail pane that displays a message in a wrapped label. Not contributed by an extension
* point - used internally to display messages.
*
* @since 3.6
*/
public class MessageDetailPane implements IDetailPane {
public static final String ID = IDebugUIConstants.PLUGIN_ID + ".detailpanes.message"; //$NON-NLS-1$
public static final String NAME = DetailMessages.MessageDetailPane_0;
public static final String DESCRIPTION = DetailMessages.MessageDetailPane_1;
/**
* Composite that contains the label that has margins.
*/
private Composite fControlParent;
/**
* Label control
*/
private Label fLabel;
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPane#init(org.eclipse.ui.IWorkbenchPartSite)
*/
@Override
public void init(IWorkbenchPartSite partSite) {
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPane#dispose()
*/
@Override
public void dispose() {
fControlParent.dispose();
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPane#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public Control createControl(Composite parent) {
fControlParent = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
fControlParent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
fLabel = SWTFactory.createWrapLabel(fControlParent, "", 1); //$NON-NLS-1$
return fControlParent;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPane#setFocus()
*/
@Override
public boolean setFocus() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPane#display(org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
public void display(IStructuredSelection selection) {
// re-create controls if the layout has changed
if (selection != null && selection.size() == 1) {
Object input = selection.getFirstElement();
if (input instanceof String) {
String message = (String) input;
fLabel.setText(message);
fControlParent.layout(true);
}
} else if (selection == null || selection.isEmpty()) {
// clear the message
fLabel.setText(""); //$NON-NLS-1$
fControlParent.layout(true);
}
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPane#getID()
*/
@Override
public String getID() {
return ID;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPane#getName()
*/
@Override
public String getName() {
return NAME;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDetailPane#getDescription()
*/
@Override
public String getDescription() {
return DESCRIPTION;
}
}
|