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

📄 abstractdeviceeditorpage.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2006 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.device.editor;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
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 eclipseme.core.model.device.IDevice;
import eclipseme.core.model.impl.AbstractDevice;

/**
 * Abstract superclass for all of the device editor pages.
 * <p />
 * Copyright (c) 2003-2006 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.3 $
 * <br>
 * $Date: 2006/03/03 01:37:07 $
 * <br>
 * @author Craig Setera
 */
public abstract class AbstractDeviceEditorPage extends Composite {
	protected DeviceEditorDialog dialog;
	protected AbstractDevice editDevice;
	protected String errorMessage;
	protected boolean valid;
	
	/**
	 * Construct a new editor page.
	 * 
	 * @param parent
	 * @param style
	 */
	public AbstractDeviceEditorPage(Composite parent, int style) {
		super(parent, style);

		// Assume we start valid...
		valid = true;
		
		setLayoutData(new GridData(GridData.FILL_BOTH));
		setLayout(new GridLayout(1, true));
		
		Composite topComposite = new Composite(this, SWT.NONE);
		topComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
		topComposite.setLayout(new GridLayout(1, true));

		Label label = new Label(topComposite, SWT.NONE);
		label.setText(getDescription());
		label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		Composite controlsComposite = new Composite(topComposite, SWT.NONE);
		controlsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
		
		addPageControls(controlsComposite);
	}

	/**
	 * Commit all of the changes on this page to the device.
	 * 
	 * @throws CoreException
	 */
	public abstract void commitDeviceChanges() throws CoreException;

	/**
	 * Return a description of what is being specified on this page.
	 * 
	 * @return
	 */
	public abstract String getDescription();
	
	/**
	 * Return the title for this page.
	 * 
	 * @return
	 */
	public abstract String getTitle();

	/**
	 * Return a boolean indicating whether the values on the
	 * page are valid.
	 * 
	 * @return
	 */
	public boolean isValid() {
		return valid;
	}

	/**
	 * Set the device to be edited.
	 * 
	 * @param device
	 */
	public void setDevice(IDevice device) {
		editDevice = (AbstractDevice) device;
	}
	
	/**
	 * Set the dialog in which this page resides.
	 * 
	 * @param dialog
	 */
	void setDialog(DeviceEditorDialog dialog) {
		this.dialog = dialog;
	}
	
	/**
	 * Create the controls specific to this page.
	 * 
	 * @param parent
	 */
	protected abstract void addPageControls(Composite parent);
	
	/**
	 * Set the error message to be displayed to the user.
	 * 
	 * @param message
	 */
	protected void setErrorMessage(String message) {
		this.errorMessage = message;
		if ((dialog != null) && isVisible()) {
			dialog.setErrorMessage(message);
		}
	}
	
	/**
	 * Update the validity status of this page.
	 * 
	 * @param isValid
	 */
	protected void setValid(boolean isValid) {
		valid = isValid;
		
		if (dialog != null) {
			dialog.updateCompletionState();
		}
	}
}

⌨️ 快捷键说明

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