⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jadrequiredpropertieseditorpage.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 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.editor.jad;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PlatformUI;

import eclipseme.core.internal.EclipseMECorePlugin;
import eclipseme.core.model.DescriptorPropertyDescription;
import eclipseme.core.model.IJADConstants;
import eclipseme.core.model.LibrarySpecification;

/**
 * JAD editor page for handling the required properties.
 * <p />
 * Copyright (c) 2003-2007 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.10 $
 * <br>
 * $Date: 2006/02/11 21:27:36 $
 * <br>
 * @author Craig Setera
 */
public class JADRequiredPropertiesEditorPage extends JADPropertiesEditorPage {
	public static final String ID = "required";
	
	/**
	 * Required property descriptors.
	 */
	private static final DescriptorPropertyDescription[] 
		REQUIRED_DESCRIPTORS = new DescriptorPropertyDescription[] {
			new DescriptorPropertyDescription(
				IJADConstants.JAD_MIDLET_JAR_URL,
				getResourceString("property.jad.midlet_jar_url"),
				DescriptorPropertyDescription.DATATYPE_URL),
			new DescriptorPropertyDescription(
				IJADConstants.JAD_MIDLET_NAME,
				getResourceString("property.jad.midlet_name"),
				DescriptorPropertyDescription.DATATYPE_STRING),
			new DescriptorPropertyDescription(
				IJADConstants.JAD_MIDLET_VENDOR,
				getResourceString("property.jad.midlet_vendor"),
				DescriptorPropertyDescription.DATATYPE_STRING),
			new DescriptorPropertyDescription(
				IJADConstants.JAD_MIDLET_VERSION,
				getResourceString("property.jad.midlet_version"),
				DescriptorPropertyDescription.DATATYPE_STRING),
			new ListDescriptorPropertyDescription(
				IJADConstants.JAD_MICROEDITION_CONFIG,
				getResourceString("property.jad.microedition_configuration"),
				getConfigurationNamesAndValues()),
			new ListDescriptorPropertyDescription(
				IJADConstants.JAD_MICROEDITION_PROFILE,
				getResourceString("property.jad.microedition_profile"),
				getProfileNamesAndValues()),
		};


	/**
	 * Return the J2ME configuration names and values.
	 * 
	 * @return
	 */
	private static String[][] getConfigurationNamesAndValues()
	{
		String[][] namesAndValues = null;

		try {
			LibrarySpecification[] specifications =
				EclipseMECorePlugin.getConfigurationSpecifications();
			
			namesAndValues = new String[specifications.length][];
			for (int i = 0; i < specifications.length; i++) {
				LibrarySpecification spec = specifications[i];
				namesAndValues[i] = new String[2];
				namesAndValues[i][0] = spec.getName();
				namesAndValues[i][1] = spec.getIdentifier();
			}
		} catch (CoreException e) {
			namesAndValues = new String[0][0];
			EclipseMECorePlugin.log(IStatus.WARNING, e);
		}
		
		return namesAndValues;
	}
	
	/**
	 * Return the J2ME profile names and values.
	 * 
	 * @return
	 */
	private static String[][] getProfileNamesAndValues()
	{
		String[][] namesAndValues = null;

		try {
			LibrarySpecification[] specifications =
				EclipseMECorePlugin.getProfileSpecifications();
			
			namesAndValues = new String[specifications.length][];
			for (int i = 0; i < specifications.length; i++) {
				LibrarySpecification spec = specifications[i];
				namesAndValues[i] = new String[2];
				namesAndValues[i][0] = spec.getName();
				namesAndValues[i][1] = spec.getIdentifier();
			}
		} catch (CoreException e) {
			namesAndValues = new String[0][0];
			EclipseMECorePlugin.log(IStatus.WARNING, e);
		}
		
		return namesAndValues;
	}
	
	// The current setting of the jar url after a setInput call.
	// If changed on save, we will trigger a clean build to cause
	// the jar file to be regenerated.
	private String loadedJarUrl;
	
	/**
	 * Constract a new required properties editor.
	 * 
	 * @param editor
	 */
	public JADRequiredPropertiesEditorPage(JADEditor editor) {
		super(editor, ID, "Required", REQUIRED_DESCRIPTORS);
	}
	
	protected void addContextHelp(Composite c)
	{
		PlatformUI.getWorkbench().getHelpSystem().setHelp(c, "eclipseme.ui.help_JADRequiredPropertiesEditorPage");
	}
	
	/**
	 * @see eclipseme.ui.internal.editor.jad.JADPropertiesEditorPage#doSave(org.eclipse.core.runtime.IProgressMonitor)
	 */
	public void doSave(IProgressMonitor monitor) {
		super.doSave(monitor);
		
		String currentJarUrl = getPreferenceStore().getString(IJADConstants.JAD_MIDLET_JAR_URL);
		if (!currentJarUrl.equals(loadedJarUrl)) {
			((JADEditor) getEditor()).setCleanRequired(true);
		}
	}

	/**
	 * @see eclipseme.ui.internal.editor.jad.AbstractJADEditorPage#getSectionTitle()
	 */
	protected String getSectionTitle() {
		return "Required Properties";
	}

	/**
	 * @see eclipseme.ui.internal.editor.jad.AbstractJADEditorPage#getSectionDescription()
	 */
	protected String getSectionDescription() {
		return "Required midlet suite properties must be specified on this page";
	}

	/**
	 * @see eclipseme.ui.internal.editor.jad.JADPropertiesEditorPage#setInput(org.eclipse.ui.IEditorInput)
	 */
	protected void setInput(IEditorInput input) {
		super.setInput(input);
		
		// Stash the current JAR URL setting for later save comparison
		loadedJarUrl = getPreferenceStore().getString(IJADConstants.JAD_MIDLET_JAR_URL);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -