01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 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.pde.internal.ui.editor.actions;
11:
12: import java.lang.reflect.InvocationTargetException;
13:
14: import org.eclipse.jface.action.Action;
15: import org.eclipse.pde.internal.ui.PDEPlugin;
16: import org.eclipse.pde.internal.ui.PDEUIMessages;
17: import org.eclipse.pde.internal.ui.editor.plugin.BundleSourcePage;
18: import org.eclipse.swt.widgets.Event;
19: import org.eclipse.ui.PlatformUI;
20: import org.eclipse.ui.texteditor.ITextEditor;
21:
22: public class FormatAction extends Action {
23:
24: protected ITextEditor fTextEditor;
25:
26: public FormatAction() {
27: setText(PDEUIMessages.FormatManifestAction_actionText);
28: }
29:
30: public void runWithEvent(Event event) {
31: run();
32: }
33:
34: public void run() {
35: if (fTextEditor == null || fTextEditor.getEditorInput() == null)
36: return;
37:
38: try {
39: PlatformUI.getWorkbench().getProgressService()
40: .busyCursorWhile(
41: new FormatOperation(
42: new Object[] { fTextEditor
43: .getEditorInput() }));
44: } catch (InvocationTargetException e) {
45: PDEPlugin.log(e);
46: } catch (InterruptedException e) {
47: PDEPlugin.log(e);
48: }
49: }
50:
51: public void setTextEditor(ITextEditor textEditor) {
52: // TODO Temporary: Until plug-in manifest XML source page format
53: // functionality is completed
54: setEnabled(textEditor instanceof BundleSourcePage);
55: fTextEditor = textEditor;
56: }
57:
58: }
|