01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.examples.templateeditor.editors;
11:
12: import org.eclipse.jface.action.IAction;
13:
14: import org.eclipse.jface.text.source.ISourceViewer;
15:
16: import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
17: import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
18: import org.eclipse.ui.texteditor.TextOperationAction;
19:
20: /**
21: * A simple xml editor with template capabilities.
22: */
23: public class TemplateEditor extends AbstractDecoratedTextEditor {
24:
25: private static final String TEMPLATE_PROPOSALS = "template_proposals_action"; //$NON-NLS-1$
26: private ColorManager colorManager;
27:
28: /**
29: * Creates a new template editor.
30: */
31: public TemplateEditor() {
32: super ();
33: colorManager = new ColorManager();
34: setSourceViewerConfiguration(new XMLConfiguration(colorManager));
35: setDocumentProvider(new XMLDocumentProvider());
36: }
37:
38: public void dispose() {
39: colorManager.dispose();
40: super .dispose();
41: }
42:
43: protected void createActions() {
44: super .createActions();
45:
46: IAction action = new TextOperationAction(TemplateMessages
47: .getResourceBundle(),
48: "Editor." + TEMPLATE_PROPOSALS + ".", //$NON-NLS-1$ //$NON-NLS-2$
49: this , ISourceViewer.CONTENTASSIST_PROPOSALS);
50: action
51: .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
52: setAction(TEMPLATE_PROPOSALS, action);
53: markAsStateDependentAction(TEMPLATE_PROPOSALS, true);
54: }
55:
56: }
|