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.nls;
11:
12: import java.lang.reflect.InvocationTargetException;
13:
14: import org.eclipse.jface.action.IAction;
15: import org.eclipse.jface.dialogs.MessageDialog;
16: import org.eclipse.jface.viewers.ISelection;
17: import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
18: import org.eclipse.pde.internal.ui.PDEPlugin;
19: import org.eclipse.pde.internal.ui.PDEUIMessages;
20: import org.eclipse.pde.internal.ui.refactoring.PDERefactor;
21: import org.eclipse.ui.IWorkbenchWindow;
22: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
23: import org.eclipse.ui.PlatformUI;
24:
25: public class GetNonExternalizedStringsAction implements
26: IWorkbenchWindowActionDelegate {
27:
28: private ISelection fSelection;
29:
30: public GetNonExternalizedStringsAction() {
31: }
32:
33: public void run(IAction action) {
34: GetNonExternalizedStringsOperation runnable = new GetNonExternalizedStringsOperation(
35: fSelection);
36: try {
37: PlatformUI.getWorkbench().getProgressService()
38: .busyCursorWhile(runnable);
39: } catch (InvocationTargetException e) {
40: } catch (InterruptedException e) {
41: } finally {
42: if (runnable.wasCanceled())
43: return;
44: ModelChangeTable changeTable = runnable.getChangeTable();
45: if (!changeTable.isEmpty()) {
46: ExternalizeStringsProcessor processor = new ExternalizeStringsProcessor();
47: PDERefactor refactor = new PDERefactor(processor);
48: ExternalizeStringsWizard wizard = new ExternalizeStringsWizard(
49: changeTable, refactor);
50: RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(
51: wizard);
52:
53: try {
54: op.run(PDEPlugin.getActiveWorkbenchShell(), ""); //$NON-NLS-1$
55: } catch (final InterruptedException irex) {
56: }
57: } else
58: MessageDialog
59: .openInformation(
60: PlatformUI.getWorkbench()
61: .getActiveWorkbenchWindow()
62: .getShell(),
63: PDEUIMessages.GetNonExternalizedStringsAction_allExternalizedTitle,
64: PDEUIMessages.GetNonExternalizedStringsAction_allExternalizedMessage);
65: }
66: }
67:
68: public void selectionChanged(IAction action, ISelection selection) {
69: fSelection = selection;
70: }
71:
72: public void dispose() {
73: }
74:
75: public void init(IWorkbenchWindow window) {
76: }
77: }
|