KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > model > AntPropertyNode


1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ant.internal.ui.editor.model;
13
14 import org.apache.tools.ant.BuildException;
15 import org.apache.tools.ant.Task;
16 import org.eclipse.ant.internal.ui.model.AntUIImages;
17 import org.eclipse.ant.internal.ui.model.IAntUIConstants;
18 import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
19 import org.eclipse.jface.resource.ImageDescriptor;
20 import org.xml.sax.Attributes JavaDoc;
21
22 public class AntPropertyNode extends AntTaskNode {
23     
24     private String JavaDoc fValue= null;
25     
26     public AntPropertyNode(Task task, Attributes JavaDoc attributes) {
27         super(task);
28          String JavaDoc label = attributes.getValue(IAntModelConstants.ATTR_NAME);
29          if(label == null) {
30             label = attributes.getValue(IAntModelConstants.ATTR_FILE);
31             if(label != null) {
32                 label= "file="+label; //$NON-NLS-1$
33
} else {
34                 label = attributes.getValue(IAntModelConstants.ATTR_RESOURCE);
35                 if (label != null) {
36                     label= "resource="+label; //$NON-NLS-1$
37
} else {
38                     label = attributes.getValue(IAntModelConstants.ATTR_ENVIRONMENT);
39                     if(label != null) {
40                         label= "environment=" + label; //$NON-NLS-1$
41
}
42                 }
43             }
44          } else {
45             fValue= attributes.getValue(IAntModelConstants.ATTR_VALUE);
46          }
47          setLabel(label);
48     }
49     
50     public String JavaDoc getValue() {
51         return fValue;
52     }
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.ant.internal.ui.editor.model.AntElementNode#getBaseImageDescriptor()
56      */

57     protected ImageDescriptor getBaseImageDescriptor() {
58         return AntUIImages.getImageDescriptor(IAntUIConstants.IMG_PROPERTY);
59     }
60     
61     /**
62      * Sets the property in the project.
63      */

64     public boolean configure(boolean validateFully) {
65         if (configured) {
66             return false;
67         }
68         try {
69             getTask().maybeConfigure();
70             getTask().execute();
71             configured= true;
72         } catch (BuildException be) {
73             handleBuildException(be, AntEditorPreferenceConstants.PROBLEM_PROPERTIES);
74         }
75         return false;
76     }
77 }
Popular Tags