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

📄 entryeditorcontributor.java

📁 基于Eclipse RCP开发的管理工具
💻 JAVA
字号:
 /*    * Copyright 2006 Marcel Schoffelmeer   *   * Licensed under the Apache License, Version 2.0 (the "License");   * you may not use this file except in compliance with the License.   * You may obtain a copy of the License at   *   *    http://www.apache.org/licenses/LICENSE-2.0   *      * Unless required by applicable law or agreed to in writing, software  * distributed under the License is distributed on an "AS IS" BASIS,   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  * See the License for the specific language governing permissions and  * limitations under the License.  */package com.s10r.manager;import java.util.HashMap;import java.util.Map;import org.eclipse.jface.action.IStatusLineManager;import org.eclipse.jface.action.IToolBarManager;import org.eclipse.jface.action.StatusLineManager;import org.eclipse.ui.IEditorPart;import org.eclipse.ui.part.EditorActionBarContributor;import com.s10r.manager.actions.SearchFieldAction;/** * Example: org.eclipse.ui.texteditor.BasicTextEditorActionContributor *  * @author mms *  */public class EntryEditorContributor extends EditorActionBarContributor{	private Map<String, StatusLineContribution> statusFields = null;	private IEditorPart activeEditorPart;	private SearchFieldAction searchFieldAction;	private static final String INPUT_MODE = "inputmode";	private static final String INPUT_POSITION = "inputposition";	public EntryEditorContributor()	{		statusFields = new HashMap<String, StatusLineContribution>();		statusFields				.put(INPUT_MODE, new StatusLineContribution(INPUT_MODE, 16));		statusFields.put(INPUT_POSITION, new StatusLineContribution(				INPUT_POSITION, 16));	}	/**	 * Called when the editor is first opened (such as creation a new file)	 * 	 * @param statusLineManager	 */	public void contributeToStatusLine(IStatusLineManager statusLineManager)	{		super.contributeToStatusLine(statusLineManager);		for (String category : statusFields.keySet())		{			statusLineManager.appendToGroup(StatusLineManager.END_GROUP,					statusFields.get(category));		}	}	/**	 * Called when the editor is selected by the user. Provides the status	 * fields to the editor for use.	 * 	 * @param targetEditor	 */	public void setActiveEditor(IEditorPart targetEditor)	{		super.setActiveEditor(targetEditor);		if (!editorChanged(targetEditor))		{			return;		}		searchFieldAction.setActiveEditorPart(targetEditor);		if (activeEditorPart instanceof EntryEditor)		{			EntryEditor extension = (EntryEditor) activeEditorPart;			for (String category : statusFields.keySet())			{				extension.setStatusField(category, null);			}		}		activeEditorPart = targetEditor;		if (activeEditorPart instanceof EntryEditor)		{			EntryEditor extension = (EntryEditor) activeEditorPart;			for (String category : statusFields.keySet())			{				extension.setStatusField(category, statusFields.get(category));			}		}	}	private boolean editorChanged(IEditorPart targetEditor)	{		return activeEditorPart != targetEditor;	}	@Override	public void contributeToToolBar(IToolBarManager toolBarManager)	{		super.contributeToToolBar(toolBarManager);		searchFieldAction = new SearchFieldAction("searchfieldId");		searchFieldAction.setActiveEditorPart(activeEditorPart);		toolBarManager.add(searchFieldAction);	}}

⌨️ 快捷键说明

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