📄 newmidletwizardpage.java
字号:
/**
* Copyright (c) 2003-2005 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.ui.internal.wizards;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import eclipseme.core.IEclipseMECoreConstants;
import eclipseme.ui.EclipseMEUIStrings;
import eclipseme.ui.internal.EclipseMEUIPlugin;
/**
* Wizard page for the creation of a new Midlet subclass.
* <p />
* Copyright (c) 2003-2005 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision: 1.5 $
* <br>
* $Date: 2006/02/11 21:27:11 $
* <br>
* @author Craig Setera
*/
public class NewMidletWizardPage extends NewTypeWizardPage
{
/** The name this page is registered as within the wizard */
public static final String PAGE_NAME = "NewMidletClass";
// Dialog settings constants
private static final String SETTINGS_ADD_TO_JAD = "addToJad";
private static final String SETTINGS_CONSTRUCTORS = "constructors";
private static final String SETTINGS_UNIMPLEMENTED = "unimplemented";
// Controls
private Button addToJadButton;
private Button constructorsButton;
private Button unimplementedButton;
/**
* @param isClass
* @param pageName
*/
public NewMidletWizardPage() {
super(true, PAGE_NAME);
setTitle(EclipseMEUIStrings.getString(
"wiz.newmidlet.title"));
setDescription(EclipseMEUIStrings.getString(
"wiz.newmidlet.description"));
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite= new Composite(parent, SWT.NONE);
int nColumns = 4;
GridLayout layout = new GridLayout();
layout.numColumns = nColumns;
composite.setLayout(layout);
// pick & choose the wanted UI components
createContainerControls(composite, nColumns);
createPackageControls(composite, nColumns);
createEnclosingTypeControls(composite, nColumns);
createSeparator(composite, nColumns);
createTypeNameControls(composite, nColumns);
createModifierControls(composite, nColumns);
createSuperClassControls(composite, nColumns);
createSuperInterfacesControls(composite, nColumns);
createMethodStubSelectionControls(composite, nColumns);
createAddToJADSelectionControl(composite, nColumns);
boolean addToJad = true;
boolean constructors = true;
boolean unimplemented = true;
IDialogSettings section = getDialogSettings().getSection(PAGE_NAME);
if (section != null) {
addToJad = section.getBoolean(SETTINGS_ADD_TO_JAD);
constructors = section.getBoolean(SETTINGS_CONSTRUCTORS);
unimplemented = section.getBoolean(SETTINGS_UNIMPLEMENTED);
}
addToJadButton.setSelection(addToJad);
constructorsButton.setSelection(constructors);
unimplementedButton.setSelection(unimplemented);
setControl(composite);
Dialog.applyDialogFont(composite);
}
/**
* The wizard owning this page is responsible for calling this method with the
* current selection. The selection is used to initialize the fields of the wizard
* page.
*
* @param selection used to initialize the fields
*/
public void init(IStructuredSelection selection) {
IJavaElement jelem = getInitialJavaElement(selection);
initContainerPage(jelem);
initTypePage(jelem);
setSuperClass(IEclipseMECoreConstants.MIDLET_SUPERCLASS, true);
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
*/
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
setFocus();
}
}
/**
* Return a boolean indicating whether the "add to jad" button was
* selected.
*
* @return
*/
boolean isAddToJadSelected() {
return addToJadButton.getSelection();
}
/**
* @see org.eclipse.jdt.ui.wizards.NewTypeWizardPage#createTypeMembers(org.eclipse.jdt.core.IType, org.eclipse.jdt.ui.wizards.NewTypeWizardPage.ImportsManager, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void createTypeMembers(
IType newType,
ImportsManager imports,
IProgressMonitor monitor)
throws CoreException
{
createInheritedMethods(
newType,
constructorsButton.getSelection(),
unimplementedButton.getSelection(),
imports,
new SubProgressMonitor(monitor, 1));
IDialogSettings section =
EclipseMEUIPlugin.getDialogSettings(getDialogSettings(), PAGE_NAME);
section.put(SETTINGS_ADD_TO_JAD, addToJadButton.getSelection());
section.put(SETTINGS_CONSTRUCTORS, constructorsButton.getSelection());
section.put(SETTINGS_UNIMPLEMENTED, unimplementedButton.getSelection());
}
/**
* Create the "Add to JAD" selection control.
*
* @param parent
* @param numColumns
*/
private void createAddToJADSelectionControl(Composite parent, int numColumns) {
new Label(parent, SWT.NONE);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalSpan = numColumns - 1;
composite.setLayoutData(gridData);
addToJadButton = new Button(composite, SWT.CHECK);
addToJadButton.setText("Add To Application Descriptor?");
}
/**
* Create the controls for method stub selection.
*
* @param composite
*/
private void createMethodStubSelectionControls(
Composite parent,
int numColumns)
{
new Label(parent, SWT.NONE);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalSpan = numColumns - 1;
composite.setLayoutData(gridData);
Label l = new Label(composite, SWT.NONE);
l.setText(
EclipseMEUIStrings.getString("wiz.newmidlet.which_methods"));
constructorsButton = new Button(composite, SWT.CHECK);
constructorsButton.setText(
EclipseMEUIStrings.getString("wiz.newmidlet.super_const"));
constructorsButton.setSelection(true);
unimplementedButton = new Button(composite, SWT.CHECK);
unimplementedButton.setText(
EclipseMEUIStrings.getString("wiz.newmidlet.unimplemented"));
unimplementedButton.setSelection(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -