blob: 3b40e816ed9513b9f82ede1ecbb59b998f089bf4 (
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
|
/*******************************************************************************
* Copyright (c) 2007 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.equinox.internal.provisional.p2.ui.dialogs;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
import org.eclipse.equinox.internal.provisional.p2.ui.model.RepositoryElement;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.dialogs.PropertyPage;
/**
* PropertyPage that shows a repository's properties
*
* @since 3.4
*/
public class RepositoryPropertyPage extends PropertyPage {
private RepositoryElement repositoryElement;
private Composite composite;
private Text name;
private Text url;
private Text description;
protected Control createContents(Composite parent) {
this.repositoryElement = getRepositoryElement();
if (repositoryElement == null) {
Label label = new Label(parent, SWT.DEFAULT);
label.setText(ProvUIMessages.RepositoryPropertyPage_NoRepoSelected);
return label;
}
noDefaultAndApplyButton();
composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
GridData data = new GridData();
data.widthHint = 350;
composite.setLayoutData(data);
Label urlLabel = new Label(composite, SWT.NONE);
urlLabel.setText(ProvUIMessages.RepositoryPropertyPage_URLFieldLabel);
url = new Text(composite, SWT.WRAP | SWT.READ_ONLY);
url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label nameLabel = new Label(composite, SWT.NONE);
nameLabel.setText(ProvUIMessages.RepositoryPropertyPage_NameFieldLabel);
name = new Text(composite, SWT.WRAP | SWT.READ_ONLY);
name.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label descriptionLabel = new Label(composite, SWT.NONE);
descriptionLabel.setText(ProvUIMessages.RepositoryPropertyPage_DescriptionFieldLabel);
data = new GridData();
data.verticalAlignment = SWT.TOP;
descriptionLabel.setLayoutData(data);
description = new Text(composite, SWT.WRAP | SWT.READ_ONLY);
data = new GridData(GridData.FILL_HORIZONTAL);
data.verticalAlignment = SWT.TOP;
data.grabExcessVerticalSpace = true;
description.setLayoutData(data);
initializeFields();
Dialog.applyDialogFont(composite);
return composite;
}
private void initializeFields() {
// Shouldn't happen since we checked this before creating any controls
if (repositoryElement == null)
return;
url.setText(repositoryElement.getLocation().toExternalForm());
name.setText(repositoryElement.getName());
description.setText(repositoryElement.getDescription());
}
protected RepositoryElement getRepositoryElement() {
if (repositoryElement == null) {
repositoryElement = (RepositoryElement) ProvUI.getAdapter(getElement(), RepositoryElement.class);
}
return repositoryElement;
}
}
|