KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > ui > wizards > NewInterfaceWizardPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.jdt.ui.wizards;
12
13 import org.eclipse.core.runtime.IStatus;
14
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.layout.GridLayout;
17 import org.eclipse.swt.widgets.Composite;
18
19 import org.eclipse.jface.dialogs.Dialog;
20 import org.eclipse.jface.viewers.IStructuredSelection;
21
22 import org.eclipse.ui.PlatformUI;
23
24 import org.eclipse.jdt.core.IJavaElement;
25
26 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
27 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
28
29 /**
30  * Wizard page to create a new interface.
31  * <p>
32  * Note: This class is not intended to be subclassed, but clients can instantiate.
33  * To implement a different kind of a new interface wizard page, extend <code>NewTypeWizardPage</code>.
34  * </p>
35  *
36  * @since 2.0
37  */

38 public class NewInterfaceWizardPage extends NewTypeWizardPage {
39     
40     private final static String JavaDoc PAGE_NAME= "NewInterfaceWizardPage"; //$NON-NLS-1$
41

42     /**
43      * Create a new <code>NewInterfaceWizardPage</code>
44      */

45     public NewInterfaceWizardPage() {
46         super(false, PAGE_NAME);
47         
48         setTitle(NewWizardMessages.NewInterfaceWizardPage_title);
49         setDescription(NewWizardMessages.NewInterfaceWizardPage_description);
50     }
51
52     // -------- Initialization ---------
53

54     /**
55      * The wizard owning this page is responsible for calling this method with the
56      * current selection. The selection is used to initialize the fields of the wizard
57      * page.
58      *
59      * @param selection used to initialize the fields
60      */

61     public void init(IStructuredSelection selection) {
62         IJavaElement jelem= getInitialJavaElement(selection);
63             
64         initContainerPage(jelem);
65         initTypePage(jelem);
66         doStatusUpdate();
67     }
68     
69     // ------ validation --------
70

71     private void doStatusUpdate() {
72         // all used component status
73
IStatus[] status= new IStatus[] {
74             fContainerStatus,
75             isEnclosingTypeSelected() ? fEnclosingTypeStatus : fPackageStatus,
76             fTypeNameStatus,
77             fModifierStatus,
78             fSuperInterfacesStatus
79         };
80         
81         // the mode severe status will be displayed and the OK button enabled/disabled.
82
updateStatus(status);
83     }
84
85             
86     /*
87      * @see NewContainerWizardPage#handleFieldChanged
88      */

89     protected void handleFieldChanged(String JavaDoc fieldName) {
90         super.handleFieldChanged(fieldName);
91         
92         doStatusUpdate();
93     }
94     
95     
96     // ------ UI --------
97

98     /*
99      * @see WizardPage#createControl
100      */

101     public void createControl(Composite parent) {
102         initializeDialogUnits(parent);
103         
104         Composite composite= new Composite(parent, SWT.NONE);
105         composite.setFont(parent.getFont());
106         
107         int nColumns= 4;
108         
109         GridLayout layout= new GridLayout();
110         layout.numColumns= nColumns;
111         composite.setLayout(layout);
112         
113         createContainerControls(composite, nColumns);
114         createPackageControls(composite, nColumns);
115         createEnclosingTypeControls(composite, nColumns);
116                 
117         createSeparator(composite, nColumns);
118         
119         createTypeNameControls(composite, nColumns);
120         createModifierControls(composite, nColumns);
121
122         createSuperInterfacesControls(composite, nColumns);
123         
124         createCommentControls(composite, nColumns);
125         enableCommentControl(true);
126         
127         setControl(composite);
128         
129         Dialog.applyDialogFont(composite);
130         PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.NEW_INTERFACE_WIZARD_PAGE);
131     }
132
133     /*
134      * @see WizardPage#becomesVisible
135      */

136     public void setVisible(boolean visible) {
137         super.setVisible(visible);
138         if (visible) {
139             setFocus();
140         }
141     }
142     
143 }
144
Popular Tags