customereditor.java

来自「JAVA RCP源码」· Java 代码 · 共 62 行

JAVA
62
字号
package myrcp.intro;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;


public class CustomerEditor extends EditorPart {

	public static final String ID = "myrcp.editor"; //$NON-NLS-1$
	private Customer customer;
	private Text text;
	/**
	 * Create contents of the editor part
	 * @param parent
	 */
	public void createPartControl(Composite parent) {
		//Composite container = new Composite(parent, SWT.NONE);
		text = new Text(parent,SWT.NONE);
		text.setText(customer.getName());
		//
	}

	public void setFocus() {
		// Set the focus
	}

	public void doSave(IProgressMonitor monitor) {
		// Do the Save operation
	}

	public void doSaveAs() {
		// Do the Save As operation
	}

	public void init(IEditorSite site, IEditorInput input)
			throws PartInitException {
		// Initialize the editor part
		if(input instanceof CustomerEditorInput){
			customer=((CustomerEditorInput)input).getCustomer();
			this.setSite(site);
			this.setInput(input);
		}

	}
	public boolean isDirty() {
		return false;
	}

	public boolean isSaveAsAllowed() {
		return false;
	}
//	private void initializeToolBar() {
//		IToolBarManager toolBarManager = getEditorSite().getActionBars().getToolBarManager();
//	}

}

⌨️ 快捷键说明

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