KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > common > actions > DeleteAllValuesAction


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.browser.common.actions;
22
23
24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
25 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
26 import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
27 import org.apache.directory.ldapstudio.browser.core.model.IValue;
28 import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaUtils;
29 import org.eclipse.jface.resource.ImageDescriptor;
30
31
32 /**
33  * This Action deletes all the values of an Attribute (a whole Attribute).
34  *
35  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
36  * @version $Rev$, $Date$
37  */

38 public class DeleteAllValuesAction extends DeleteAction
39 {
40     /**
41      * Creates a new instance of DeleteAllValuesAction.
42      */

43     public DeleteAllValuesAction()
44     {
45     }
46
47
48     /**
49      * {@inheritDoc}
50      */

51     public void run()
52     {
53         super.run();
54     }
55
56
57     /**
58      * {@inheritDoc}
59      */

60     public String JavaDoc getText()
61     {
62         if ( getSelectedValues().length == 1 )
63         {
64             return "Delete Attribute '" + getSelectedValues()[0].getAttribute().getDescription() + "'";
65         }
66         else
67         {
68             return "Delete Attribute";
69         }
70     }
71
72
73     /**
74      * {@inheritDoc}
75      */

76     public ImageDescriptor getImageDescriptor()
77     {
78         return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_DELETE_ALL );
79     }
80
81
82     /**
83      * {@inheritDoc}
84      */

85     public String JavaDoc getCommandId()
86     {
87         return null;
88     }
89
90
91     /**
92      * {@inheritDoc}
93      */

94     public boolean isEnabled()
95     {
96         return super.isEnabled();
97         // return getSelectedAttributes().length == 0 &&
98
// getSelectedValues().length == 1 &&
99
// getSelectedValues()[0].getAttribute().getValueSize() > 1 &&
100
// !getSelectedValues()[0].getAttribute().isMustAttribute() &&
101
// !getSelectedValues()[0].getAttribute().isObjectClassAttribute() &&
102
// !getSelectedValues()[0].getAttribute().isOperationalAttribute();
103
}
104
105
106     /**
107      * {@inheritDoc}
108      */

109     protected IAttribute[] getAttributes() throws Exception JavaDoc
110     {
111         if ( getSelectedAttributes().length == 0 && getSelectedValues().length == 1
112             && getSelectedValues()[0].getAttribute().getValueSize() > 1
113             && !getSelectedValues()[0].getAttribute().isMustAttribute()
114             && !getSelectedValues()[0].getAttribute().isObjectClassAttribute()
115             && SchemaUtils.isModifyable( getSelectedValues()[0].getAttribute().getAttributeTypeDescription() ) )
116         {
117
118             return new IAttribute[]
119                 { getSelectedValues()[0].getAttribute() };
120
121         }
122         else
123         {
124             return new IAttribute[0];
125         }
126     }
127
128
129     /**
130      * {@inheritDoc}
131      */

132     protected IValue[] getValues() throws Exception JavaDoc
133     {
134         return new IValue[0];
135     }
136 }
137
Popular Tags