1 20 21 package org.apache.directory.ldapstudio.schemas.controller.actions; 22 23 24 import org.apache.directory.ldapstudio.schemas.Activator; 25 import org.apache.directory.ldapstudio.schemas.Messages; 26 import org.apache.directory.ldapstudio.schemas.PluginConstants; 27 import org.apache.directory.ldapstudio.schemas.model.SchemaPool; 28 import org.apache.log4j.Logger; 29 import org.eclipse.core.runtime.IStatus; 30 import org.eclipse.core.runtime.Status; 31 import org.eclipse.jface.action.Action; 32 import org.eclipse.jface.action.IAction; 33 import org.eclipse.jface.dialogs.ErrorDialog; 34 import org.eclipse.jface.viewers.ISelection; 35 import org.eclipse.ui.IViewActionDelegate; 36 import org.eclipse.ui.IViewPart; 37 import org.eclipse.ui.IWorkbenchWindow; 38 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 39 import org.eclipse.ui.PlatformUI; 40 import org.eclipse.ui.plugin.AbstractUIPlugin; 41 42 43 46 public class SaveAllAction extends Action implements IWorkbenchWindowActionDelegate, IViewActionDelegate 47 { 48 private static Logger logger = Logger.getLogger( SaveAllAction.class ); 49 50 51 56 public SaveAllAction() 57 { 58 super( Messages.getString( "SaveAllAction.Save_all_schemas" ) ); setToolTipText( getText() ); 60 setId( PluginConstants.CMD_SAVE_ALL ); 61 setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, 62 PluginConstants.IMG_SAVE_ALL ) ); 63 setEnabled( true ); 64 } 65 66 67 70 public void run() 71 { 72 SchemaPool schemaPool = SchemaPool.getInstance(); 73 try 74 { 75 schemaPool.saveAll(); 76 } 77 catch ( Exception e ) 78 { 79 ErrorDialog 80 .openError( 81 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 82 Messages.getString( "SaveAllAction.Error" ), Messages.getString( "SaveAllAction.An_error_occured_when_saving_schemas" ), new Status( IStatus.ERROR, Activator.PLUGIN_ID, 0, "Status Error Message", null ) ); logger.debug( "An error occured when saving schemas" ); } 86 } 87 88 89 public void run( IAction action ) 90 { 91 this.run(); 92 } 93 94 95 public void dispose() 96 { 97 } 98 99 100 public void init( IWorkbenchWindow window ) 101 { 102 } 103 104 105 public void selectionChanged( IAction action, ISelection selection ) 106 { 107 } 108 109 110 public void init( IViewPart view ) 111 { 112 } 113 } 114 | Popular Tags |