KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > ui > properties > FeatureLicensePropertyPage


1 /*******************************************************************************
2  * Copyright (c) 2005 IBM Corporation and others.
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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.internal.ui.properties;
12
13 import java.net.*;
14
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.jface.dialogs.Dialog;
17 import org.eclipse.swt.*;
18 import org.eclipse.swt.events.*;
19 import org.eclipse.swt.layout.*;
20 import org.eclipse.swt.widgets.*;
21 import org.eclipse.ui.*;
22 import org.eclipse.ui.dialogs.*;
23 import org.eclipse.update.core.*;
24 import org.eclipse.update.internal.ui.model.*;
25 import org.eclipse.update.internal.ui.parts.*;
26 import org.eclipse.update.internal.ui.UpdateUI;
27 import org.eclipse.update.internal.ui.UpdateUIMessages;
28
29
30 public class FeatureLicensePropertyPage extends PropertyPage implements IWorkbenchPropertyPage {
31     public FeatureLicensePropertyPage() {
32         noDefaultAndApplyButton();
33     }
34
35     protected Control createContents(Composite parent) {
36         try {
37             Composite composite = new Composite(parent, SWT.NULL);
38             composite.setLayout(new GridLayout());
39
40             IFeatureAdapter adapter = (IFeatureAdapter)getElement();
41             IFeature feature = adapter.getFeature(null);
42             IURLEntry license = feature.getLicense();
43             String JavaDoc annotation = (license != null) ? license.getAnnotation() : null;
44             
45             if (annotation != null && annotation.length() > 0) {
46                 Text text = new Text(composite, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.WRAP);
47                 GridData gd = new GridData(GridData.FILL_BOTH);
48                 gd.heightHint = 200;
49                 gd.widthHint = 350;
50                 text.setLayoutData(gd);
51                 text.setText(annotation);
52                 text.setEditable(false);
53                 final URL url = license.getURL();
54                 String JavaDoc filename = (url != null) ? url.getFile() : null;
55                 if (filename != null && (filename.endsWith(".htm") || url.getFile().endsWith(".html"))) { //$NON-NLS-1$ //$NON-NLS-2$
56
Button button = new Button(composite, SWT.PUSH);
57                     button.setText(UpdateUIMessages.FeatureLicensePropertyPage_showInBrowser);
58                     button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
59                     SWTUtil.setButtonDimensionHint(button);
60                     button.addSelectionListener(new SelectionAdapter() {
61                         public void widgetSelected(SelectionEvent e) {
62                             UpdateUI.showURL(url.toExternalForm());
63                         }
64                     });
65                 }
66             } else {
67                 Label label = new Label(composite, SWT.NULL);
68                 label.setText(UpdateUIMessages.FeatureLicensePropertyPage_noLicense);
69             }
70             
71             Dialog.applyDialogFont(parent);
72             
73             return composite;
74             
75         } catch (CoreException e) {
76         }
77         return null;
78     }
79 }
80
Popular Tags