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

📄 abstractjadeditorpage.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.resources.IMarker;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

import eclipseme.ui.EclipseMEUIStrings;
import eclipseme.ui.internal.utils.ManifestPreferenceStore;

/**
 * Abstract superclass of the multipage editor pages.
 * <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.8 $
 * <br>
 * $Date: 2005/10/30 21:16:27 $
 * <br>
 * @author Craig Setera
 */
public abstract class AbstractJADEditorPage extends FormPage
{
	/**
	 * Get a string value from the resource bundle
	 * @param key
	 * @return
	 */
	protected static String getResourceString(String key) {
		return EclipseMEUIStrings.getString(key);
	}

	// The editor we are operating within
	private JADEditor editor;
	private Section section;

	// Whether the page contents are currently dirty
	private boolean dirty;
	
	/**
	 * Constructor
	 */
	public AbstractJADEditorPage(JADEditor editor, String id, String title) {
		super(editor, id, title);
		this.editor = editor;
	}

	/**
	 * @see org.eclipse.ui.IWorkbenchPart#dispose()
	 */
	public void dispose() {
		super.dispose();
	}

	/**
	 * @see org.eclipse.ui.ISaveablePart#doSaveAs()
	 */
	public void doSaveAs() {
		// Not allowed...
	}

	/**
	 * @see org.eclipse.ui.IEditorPart#gotoMarker(org.eclipse.core.resources.IMarker)
	 */
	public void gotoMarker(IMarker marker) {
		// Nothing to do here
	}

	/**
	 * @see org.eclipse.ui.ISaveablePart#isDirty()
	 */
	public boolean isDirty() {
		return dirty || getPreferenceStore().needsSaving() || super.isDirty();
	}

	/**
	 * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
	 */
	public boolean isSaveAsAllowed() {
		return false;
	}

    /**
     * Let the editor know that the dirty state has changed.
     */
	public void editorDirtyStateChanged() {
		editor.editorDirtyStateChanged();
	}

	/**
	 * An indication to this page that the editor input has been
	 * updated external to Eclipse and the page should be updated.
	 */
	abstract void editorInputChanged();
	
	/**
	 * Return a boolean indicating whether the specified property 
	 * is managed by this page.
	 * 
	 * @param property
	 * @return
	 */
	boolean isManagingProperty(String property) {
		return false;
	}
	
	/**
	 * Get the preference store being editted.
	 */
	protected ManifestPreferenceStore getPreferenceStore() {
		return editor.getPreferenceStore();
	}
	
	/**
	 * Create the top-level composite placed within a section.
	 * 
	 * @param managedForm
	 * @return
	 */
	protected Composite createSectionComposite(IManagedForm managedForm) {
		FormToolkit toolkit = managedForm.getToolkit();
		
		Composite formBody = managedForm.getForm().getBody();
		formBody.setLayoutData(new GridData(GridData.FILL_BOTH));
		formBody.setLayout(new GridLayout(1, false));
		
		int style = 
			Section.TITLE_BAR | Section.CLIENT_INDENT | 
			Section.EXPANDED | Section.DESCRIPTION;
		section = toolkit.createSection(formBody, style);
		section.setLayoutData(new GridData(GridData.FILL_BOTH));
		section.setLayout(new GridLayout(1, false));

		section.setText(getSectionTitle());
		section.setDescription(getSectionDescription());
		toolkit.createCompositeSeparator(section);
		
		Composite composite = toolkit.createComposite(section); 
		section.setClient(composite);
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));

		return composite;
	}
	
	/**
	 * Return the title for the section heading.
	 * 
	 * @return
	 */
	protected abstract String getSectionTitle();

	/**
	 * Return the description for the section heading.
	 * 
	 * @return
	 */
	protected abstract String getSectionDescription();

	/**
	 * Set the dirty flag and let the editor know the state has changed.
	 * @param dirty
	 */
	protected void setDirty(boolean dirty) {
		this.dirty = dirty;
		editorDirtyStateChanged();
	}
}

⌨️ 快捷键说明

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