KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > dialogs > DetailsDialogWithProjects


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.team.internal.ui.dialogs;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.jface.dialogs.IDialogConstants;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.*;
19
20 /**
21  * Display a message with a details that can contain a list of projects
22  */

23 public class DetailsDialogWithProjects extends DetailsDialog {
24     
25     private String JavaDoc message;
26     private String JavaDoc detailsTitle;
27     private IProject[] projects;
28     private org.eclipse.swt.widgets.List detailsList;
29
30     private boolean includeCancelButton;
31
32     /**
33      * Constructor for DetailsDialogWithProjects.
34      * @param parentShell
35      * @param dialogTitle
36      */

37     public DetailsDialogWithProjects(Shell parentShell, String JavaDoc dialogTitle, String JavaDoc dialogMessage, String JavaDoc detailsTitle, IProject[] projects, boolean includeCancelButton, String JavaDoc imageKey) {
38         super(parentShell, dialogTitle);
39         setImageKey(imageKey);
40         this.message = dialogMessage;
41         this.detailsTitle = detailsTitle;
42         this.projects = projects;
43         this.includeCancelButton = includeCancelButton;
44     }
45
46     /**
47      * @see DetailsDialog#createMainDialogArea(Composite)
48      */

49     protected void createMainDialogArea(Composite composite) {
50         Label label = new Label(composite, SWT.WRAP);
51         label.setText(message);
52         GridData data = new GridData(
53             GridData.GRAB_HORIZONTAL |
54             GridData.GRAB_VERTICAL |
55             GridData.HORIZONTAL_ALIGN_FILL |
56             GridData.VERTICAL_ALIGN_CENTER);
57         data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
58         label.setLayoutData(data);
59         updateEnablements();
60     }
61
62     /**
63      * @see DetailsDialog#createDropDownDialogArea(Composite)
64      */

65     protected Composite createDropDownDialogArea(Composite parent) {
66         // create a composite with standard margins and spacing
67
Composite composite = new Composite(parent, SWT.NONE);
68         GridLayout layout = new GridLayout();
69         layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
70         layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
71         layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
72         layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
73         composite.setLayout(layout);
74         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
75         
76         detailsList = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
77         GridData data = new GridData ();
78         data.heightHint = 75;
79         data.horizontalAlignment = GridData.FILL;
80         data.grabExcessHorizontalSpace = true;
81         detailsList.setLayoutData(data);
82         
83         if (detailsTitle != null) {
84             detailsList.add(detailsTitle);
85         }
86         
87         for (int i = 0; i < projects.length; i++) {
88             detailsList.add(projects[i].getName());
89         }
90         return composite;
91     }
92
93     /**
94      * @see DetailsDialog#updateEnablements()
95      */

96     protected void updateEnablements() {
97         setPageComplete(true);
98     }
99
100     /**
101      * @see DetailsDialog#includeCancelButton()
102      */

103     protected boolean includeCancelButton() {
104         return includeCancelButton;
105     }
106
107 }
108
Popular Tags