KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > schemas > controller > actions > SaveAllAction


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

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 /**
44  * This class implements the Action for saving all schemas
45  */

46 public class SaveAllAction extends Action implements IWorkbenchWindowActionDelegate, IViewActionDelegate
47 {
48     private static Logger logger = Logger.getLogger( SaveAllAction.class );
49
50
51     /**
52      * Default constructor
53      * @param window
54      * @param label
55      */

56     public SaveAllAction()
57     {
58         super( Messages.getString( "SaveAllAction.Save_all_schemas" ) ); //$NON-NLS-1$
59
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     /* (non-Javadoc)
68      * @see org.eclipse.jface.action.Action#run()
69      */

70     public void run()
71     {
72         SchemaPool schemaPool = SchemaPool.getInstance();
73         try
74         {
75             schemaPool.saveAll();
76         }
77         catch ( Exception JavaDoc 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, //$NON-NLS-1$ //$NON-NLS-2$
83
"Status Error Message", null ) ); //$NON-NLS-1$
84
logger.debug( "An error occured when saving schemas" ); //$NON-NLS-1$
85
}
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