View | Details | Raw Unified | Return to bug 15510 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 19-24 Link Here
19
 org.eclipse.ui.navigator;bundle-version="[3.4.0,4.0.0)",
19
 org.eclipse.ui.navigator;bundle-version="[3.4.0,4.0.0)",
20
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
20
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
21
 org.eclipse.ui.views.properties.tabbed;bundle-version="[3.5.0,4.0.0)",
21
 org.eclipse.ui.views.properties.tabbed;bundle-version="[3.5.0,4.0.0)",
22
 org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)"
22
 org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)",
23
 org.eclipse.jface.text;bundle-version="[3.6.0,4.0.0)"
23
Bundle-RequiredExecutionEnvironment: J2SE-1.4
24
Bundle-RequiredExecutionEnvironment: J2SE-1.4
24
Bundle-ActivationPolicy: lazy
25
Bundle-ActivationPolicy: lazy
(-)src/org/eclipse/ui/internal/navigator/resources/actions/PrintAction.java (+88 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Oakland Software Incorporated and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Francis Upton IV, Oakland Software - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.navigator.resources.actions;
12
13
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.runtime.IAdaptable;
15
import org.eclipse.jface.text.ITextViewerExtension8;
16
import org.eclipse.jface.viewers.IStructuredSelection;
17
import org.eclipse.swt.custom.StyledTextPrintOptions;
18
import org.eclipse.ui.IEditorInput;
19
import org.eclipse.ui.IEditorPart;
20
import org.eclipse.ui.IWorkbenchCommandConstants;
21
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.actions.SelectionListenerAction;
23
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
24
import org.eclipse.ui.part.FileEditorInput;
25
import org.eclipse.ui.texteditor.AbstractTextEditor;
26
import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
27
28
/**
29
 * 
30
 */
31
/* package */class PrintAction extends SelectionListenerAction {
32
33
	private ITextViewerExtension8 textViewer;
34
	private AbstractTextEditor textEditor;
35
	
36
	/**
37
	 * @param aSite  
38
	 */
39
	public PrintAction(ICommonActionExtensionSite aSite) {
40
		// Text does not matter since this is just for the handler
41
		super(""); //$NON-NLS-1$
42
		setActionDefinitionId(IWorkbenchCommandConstants.FILE_PRINT);
43
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IAbstractTextEditorHelpContextIds.PRINT_ACTION);
44
	}
45
46
	public void run() {
47
		// FINISHME - is this right?
48
		StyledTextPrintOptions options= new StyledTextPrintOptions();
49
		options.printTextFontStyle= true;
50
		options.printTextForeground= true;
51
		options.printTextBackground= true;
52
		options.jobName= textEditor.getTitle();
53
		textViewer.print(options);
54
	}
55
56
	protected boolean updateSelection(IStructuredSelection sel) {
57
		if (!super.updateSelection(sel)) {
58
			return false;
59
		}
60
61
		Object obj = sel.getFirstElement();
62
63
		IFile file = null;
64
		if (obj instanceof IFile) {
65
			file = (IFile) obj;
66
		} else if (obj instanceof IAdaptable) {
67
			file = (IFile) ((IAdaptable) obj).getAdapter(IFile.class);
68
		}
69
70
		if (file != null) {
71
			IEditorInput fileInput = new FileEditorInput(file);
72
			IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findEditor(
73
					fileInput);
74
			if (editor == null)
75
				return false;
76
			if (editor instanceof AbstractTextEditor) {
77
				textEditor = (AbstractTextEditor) editor;
78
				// FINISHME - need to know how to get the text viewer
79
				Object sv = null;
80
				if ((sv instanceof ITextViewerExtension8))
81
					return false;
82
				textViewer = (ITextViewerExtension8) sv;
83
				return true;
84
			}
85
		}
86
		return false;
87
	}
88
}
(-)src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java (-1 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
2
 * Copyright (c) 2006, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 69-74 Link Here
69
	private CloseUnrelatedProjectsAction closeUnrelatedProjectsAction;
69
	private CloseUnrelatedProjectsAction closeUnrelatedProjectsAction;
70
70
71
	private RefreshAction refreshAction;
71
	private RefreshAction refreshAction;
72
	
73
	private PrintAction printAction;
72
74
73
	private Shell shell;
75
	private Shell shell;
74
76
Lines 91-96 Link Here
91
		actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), openProjectAction);
93
		actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), openProjectAction);
92
		actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), closeProjectAction);
94
		actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), closeProjectAction);
93
		actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), closeUnrelatedProjectsAction);
95
		actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), closeUnrelatedProjectsAction);
96
		actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), printAction);
94
		updateActionBars();
97
		updateActionBars();
95
	}
98
	}
96
99
Lines 246-251 Link Here
246
249
247
		buildAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD);
250
		buildAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD);
248
		buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT);
251
		buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT);
252
		
253
		printAction = new PrintAction(getActionSite());
249
	}
254
	}
250
255
251
	/**
256
	/**
Lines 263-268 Link Here
263
		openProjectAction.selectionChanged(selection);
268
		openProjectAction.selectionChanged(selection);
264
		closeUnrelatedProjectsAction.selectionChanged(selection);
269
		closeUnrelatedProjectsAction.selectionChanged(selection);
265
		closeProjectAction.selectionChanged(selection);
270
		closeProjectAction.selectionChanged(selection);
271
		printAction.selectionChanged(selection);
266
	}
272
	}
267
273
268
}
274
}

Return to bug 15510