1 11 package org.eclipse.pde.internal.ui.editor.feature; 12 import java.lang.reflect.InvocationTargetException ; 13 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.jface.action.Action; 16 import org.eclipse.jface.operation.IRunnableWithProgress; 17 import org.eclipse.jface.wizard.WizardDialog; 18 import org.eclipse.pde.core.IModel; 19 import org.eclipse.pde.internal.ui.PDEPlugin; 20 import org.eclipse.pde.internal.ui.PDEUIMessages; 21 import org.eclipse.ui.PlatformUI; 22 23 public class SynchronizeVersionsAction extends Action { 24 private FeatureEditor activeEditor; 25 public SynchronizeVersionsAction() { 26 setText(PDEUIMessages.Actions_synchronizeVersions_label); 27 } 28 private void ensureContentSaved() { 29 if (activeEditor.isDirty()) { 30 try { 31 IRunnableWithProgress op = new IRunnableWithProgress() { 32 public void run(IProgressMonitor monitor) { 33 activeEditor.doSave(monitor); 34 } 35 }; 36 PlatformUI.getWorkbench().getProgressService().runInUI( 37 PDEPlugin.getActiveWorkbenchWindow(), op, 38 PDEPlugin.getWorkspace().getRoot()); 39 } catch (InvocationTargetException e) { 40 PDEPlugin.logException(e); 41 } catch (InterruptedException e) { 42 } 43 } 44 } 45 46 public void run() { 47 ensureContentSaved(); 48 SynchronizeVersionsWizard wizard = new SynchronizeVersionsWizard( 49 activeEditor); 50 WizardDialog dialog = new WizardDialog(PDEPlugin 51 .getActiveWorkbenchShell(), wizard); 52 dialog.open(); 53 } 54 public void setActiveEditor(FeatureEditor editor) { 55 this.activeEditor = editor; 56 IModel model = (IModel) editor.getAggregateModel(); 57 setEnabled(model.isEditable()); 58 } 59 } 60 | Popular Tags |