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

📄 codegenpreferencepage.java.svn-base

📁 Eclipse代码生成器,支持Eclipse3.3 WTP版本,该项目实现了Spring + hibernate + webService + struts 框架文件的自动生成,有这方面需求的个人公司
💻 SVN-BASE
字号:
package com.newegg.eclipse.soaw.facet.codegen.ui.preferences;

import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

import com.newegg.eclipse.soaw.facet.codegen.ui.CodeGenUIMessages;
import com.newegg.eclipse.soaw.facet.codegen.ui.plugin.CodeGenPlugin;
import com.newegg.eclipse.soaw.facet.codegen.ui.util.Utils;

/**
 * This class represents a preference page that is contributed to the Preferences dialog. By
 * subclassing <samp>FieldEditorPreferencePage</samp>, we can use the field support built into
 * JFace that allows us to create a page that is small and knows how to save, restore and apply
 * itself.
 * <p>
 * This page is used to modify preferences only. They are stored in the preference store that
 * belongs to the main plug-in class. That way, preferences can be accessed directly via the
 * preference store.
 */
public class CodeGenPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
{
	private ComboFieldEditor controllerComboEditor = null;
	private ComboFieldEditor contextComboEditor = null;
	private ComboFieldEditor persistentComboEditor = null;
	private ComboFieldEditor dataBaseTypeComboEditor = null;

	private String[][] controller_comboItems;
	private String[][] context_comboItems;
	private String[][] persistent_comboItems;
	private String[][] database_comboItems;

	public CodeGenPreferencePage ()
	{
		super(GRID);
		setPreferenceStore(CodeGenPlugin.getInstance().getPreferenceStore());
		setDescription(CodeGenUIMessages.DESCRIPTION_SELECT_PORTFOLIO_FRAMEWORK);
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
	 */
	public void init(IWorkbench workbench)
	{
		controller_comboItems = assembleArray(Utils
				.getFrameworkVesions(CodeGenUIMessages.NEWEGG_THIRDPART_CONTROLLER_LIB_FOLDER));
		context_comboItems = assembleArray(Utils
				.getFrameworkVesions(CodeGenUIMessages.NEWEGG_THIRDPART_CONTEXT_LIB_FOLDER));
		persistent_comboItems = assembleArray(Utils
				.getFrameworkVesions(CodeGenUIMessages.NEWEGG_THIRDPART_PERSISTENT_LIB_FOLDER));
		database_comboItems = assembleArray(Utils.getDataBaseTypes());
	}

	/**
	 * 
	 * @param srcArray
	 * @return
	 */
	private String[][] assembleArray(String[] srcArray)
	{
		int length = srcArray.length;
		int secondLength = 2;
		String[][] targetArray = new String[length][secondLength];
		for (int i = 0; i < length; i++)
		{
			String curVersion = srcArray[i];
			for (int j = 0; j < secondLength; j++)
			{
				targetArray[i][j] = curVersion;
			}
		}
		return targetArray;
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
	 */
	@Override
	protected void createFieldEditors()
	{
		controllerComboEditor = new ComboFieldEditor(PreferenceConstants.NEWEGG_SOAW_FACET_CONTROLLER,
				CodeGenUIMessages.LABEL_CONTROLLER_SELECT, controller_comboItems, getFieldEditorParent());
		addField(controllerComboEditor);

		contextComboEditor = new ComboFieldEditor(PreferenceConstants.NEWEGG_SOAW_FACET_CONTEXT,
				CodeGenUIMessages.LABEL_SPRING_SELECT, context_comboItems, getFieldEditorParent());
		addField(contextComboEditor);

		persistentComboEditor = new ComboFieldEditor(PreferenceConstants.NEWEGG_SOAW_FACET_PERSISTENT,
				CodeGenUIMessages.LABEL_PRESISTENT_SELECT, persistent_comboItems, getFieldEditorParent());
		addField(persistentComboEditor);

		dataBaseTypeComboEditor = new ComboFieldEditor(PreferenceConstants.NEWEGG_SOAW_FACET_DATABASETYPE,
				CodeGenUIMessages.LABEL_DATABASE_SELECT, database_comboItems, getFieldEditorParent());
		addField(dataBaseTypeComboEditor);
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#checkState()
	 */
	protected void checkState()
	{
		super.checkState();
		if (!isValid())
			return;
		setErrorMessage(null);
		setValid(true);

	}
}

⌨️ 快捷键说明

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