blob: eceacc0701ae7cbed171166169272a8d89f62ccf (
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
|
/*******************************************************************************
* Copyright (c) 2004-2009 Red Hat, Inc.
* 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:
* Red Hat - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.rpm.ui.propertypage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.linuxtools.rpm.core.utils.RPMQuery;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.statushandlers.StatusAdapter;
import org.eclipse.ui.statushandlers.StatusManager;
public class SpecFileHeaderPage extends PropertyPage {
private static final String RPM_QI = Messages
.getString("SpecFileHeaderPage.info"); //$NON-NLS-1$
private static final int QI_FIELD_WIDTH = 80;
private static final int QI_FIELD_HEIGHT = 40;
private Text rpm_qiText;
/**
* Constructor for RPMPropertyPage.
*/
public SpecFileHeaderPage() {
super();
}
private void addInfoField(Composite parent) {
Composite composite = createDefaultComposite(parent);
// RPM labels and text fields setup
Label rpmDescriptionLabel = new Label(composite, SWT.NONE);
rpmDescriptionLabel.setText(RPM_QI);
rpm_qiText = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY
| SWT.V_SCROLL | SWT.WRAP);
GridData gdQI = new GridData();
gdQI.widthHint = convertWidthInCharsToPixels(QI_FIELD_WIDTH);
gdQI.heightHint = convertWidthInCharsToPixels(QI_FIELD_HEIGHT);
rpm_qiText.setLayoutData(gdQI);
// Populate RPM text field
try {
String rpm_qi = RPMQuery.getHeaderInfo((IFile) getElement());
rpm_qiText.setText(rpm_qi);
} catch (CoreException e) {
StatusManager.getManager().handle(new StatusAdapter(e.getStatus()),
StatusManager.LOG | StatusManager.SHOW);
}
}
/**
* @see PreferencePage#createContents(Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL);
data.grabExcessHorizontalSpace = true;
composite.setLayoutData(data);
addInfoField(composite);
return composite;
}
private Composite createDefaultComposite(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
composite.setLayoutData(data);
return composite;
}
}
|