📄 midletsuitepropertieswizardpage.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.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import eclipseme.core.internal.EclipseMECorePlugin;
import eclipseme.core.model.device.DeviceRegistry;
import eclipseme.core.model.device.IDevice;
import eclipseme.core.model.impl.MidletSuiteProject;
import eclipseme.core.persistence.PersistenceException;
import eclipseme.ui.devices.DeviceSelector;
/**
* Wizard page used to define the initial properties
* for the created Midlet suite.
* <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.2 $
* <br>
* $Date: 2006/02/11 21:27:11 $
* <br>
* @author Craig Setera
*/
public class MidletSuitePropertiesWizardPage extends WizardPage
{
/** The key used to register this page in the wizard */
public static final String PAGE_NAME = "MidletSuiteProperties";
// Widget variables
private DeviceSelector deviceSelector;
private Text jadFileNameText;
private boolean jadNameInitialized;
/**
* Constructor
*
* @param pageName
*/
public MidletSuitePropertiesWizardPage() {
super(PAGE_NAME);
setTitle("Midlet Suite Properties");
setDescription("Choose the initial properties for the Midlet Suite.");
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Font font = parent.getFont();
Composite composite = new Composite(parent, SWT.NONE);
composite.setFont(font);
setControl(composite);
initializeDialogUnits(parent);
composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Create the device selection controls
deviceSelector = new DeviceSelector();
deviceSelector.createContents(composite, true);
deviceSelector.setSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateStatus();
}
});
(new Label(composite, SWT.NONE)).setText("Application Descriptor:");
jadFileNameText = new Text(composite, SWT.BORDER);
jadFileNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
jadFileNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updateStatus();
}
});
updateStatus();
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#dispose()
*/
public void dispose() {
deviceSelector.dispose();
super.dispose();
}
/**
* Return the device selected by the user.
*
* @return
*/
public IDevice getSelectedDevice() {
return deviceSelector.getSelectedDevice();
}
/**
* Return the JAD file name specified by the user.
*
* @return
*/
public String getJadFileName() {
return jadFileNameText.getText();
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
*/
public void setVisible(boolean visible) {
if (visible) {
if (!jadNameInitialized) {
jadFileNameText.setText(getDefaultJadName());
jadNameInitialized = true;
}
}
super.setVisible(visible);
}
/**
* Return the default JAD file name.
*
* @return
*/
private String getDefaultJadName() {
IProject project = ((NewJ2MEProjectWizard) getWizard()).getCreatedProjectHandle();
return MidletSuiteProject.getDefaultJadFileName(project);
}
/**
* Set the status based on the current values on the page.
*/
private void updateStatus() {
String message = null;
DeviceRegistry registry = DeviceRegistry.singleton;
int deviceCount = 0;
try {
deviceCount = registry.getDeviceCount();
} catch (PersistenceException e) {
EclipseMECorePlugin.log(IStatus.WARNING, "Error retrieving device count", e);
}
if (deviceCount == 0) {
message = "There are no devices defined.\n Please use device management to create some devices.";
} else if (getSelectedDevice() == null) {
message = "No Device Selected";
} else {
String jadFileName = getJadFileName();
if (jadFileName.length() == 0) {
message = "JAD file name must be specified";
} else if (jadFileName.charAt(0) == '/') {
message = "JAD file name must be relative and must not start with '/'";
} else if (jadFileName.charAt(0) == '\\') {
message = "JAD file name must be relative and must not start with '\'";
} else if (!jadFileName.endsWith(".jad")) {
message = "JAD file name must end with .jad";
}
}
setErrorMessage(message);
setPageComplete(message == null);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -