Sync trunk and gavotte editor_api_delivery_200701191221 editor_api_update_200612151030
authoryaroslavskiy@netbeans.org
Wed, 13 Dec 2006 11:35:25 +0000
changeset 229aac0c501914
parent 21 130037ec4624
child 23 0d0eebfb6b23
Sync trunk and gavotte
bpel.editors/nbproject/project.xml
bpel.editors/src/org/netbeans/modules/bpel/properties/editors/PartnerLinkMainPanel.java
bpel.editors/src/org/netbeans/modules/bpel/properties/editors/WsdlWrapper.java
bpel.editors/src/org/netbeans/modules/bpel/properties/editors/resources/wsdl.wsdl
bpel.refactoring/nbproject/project.xml
bpel.search/nbproject/project.xml
bpel.search/src/org/netbeans/modules/bpel/search/impl/action/Bundle.properties
bpel.search/src/org/netbeans/modules/bpel/search/impl/action/SearchAction.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/core/Manager.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Bundle.properties
bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Construct.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Element.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Engine.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/model/Bundle.properties
bpel.search/src/org/netbeans/modules/bpel/search/impl/model/Element.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/model/Engine.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/resources/layer.xml
bpel.search/src/org/netbeans/modules/bpel/search/impl/resources/search.settings
bpel.search/src/org/netbeans/modules/bpel/search/impl/resources/search.wstcref
bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Bundle.properties
bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Find.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Search.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Tree.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/View.java
bpel.search/src/org/netbeans/modules/bpel/search/impl/util/Util.java
     1.1 --- a/bpel.editors/nbproject/project.xml	Thu Nov 23 12:01:23 2006 +0000
     1.2 +++ b/bpel.editors/nbproject/project.xml	Wed Dec 13 11:35:25 2006 +0000
     1.3 @@ -25,6 +25,15 @@
     1.4              <suite-component/>
     1.5              <module-dependencies>
     1.6                  <dependency>
     1.7 +                    <code-name-base>org.netbeans.modules.print.api</code-name-base>
     1.8 +                    <build-prerequisite/>
     1.9 +                    <compile-dependency/>
    1.10 +                    <run-dependency>
    1.11 +                        <release-version>1</release-version>
    1.12 +                        <specification-version>1.1</specification-version>
    1.13 +                    </run-dependency>
    1.14 +                </dependency>
    1.15 +                <dependency>
    1.16                      <code-name-base>org.jdesktop.layout</code-name-base>
    1.17                      <build-prerequisite/>
    1.18                      <compile-dependency/>
    1.19 @@ -99,7 +108,6 @@
    1.20                          <release-version>1</release-version>
    1.21                      </run-dependency>
    1.22                  </dependency>
    1.23 -<!--
    1.24                  <dependency>
    1.25                      <code-name-base>org.netbeans.modules.websvc.core</code-name-base>
    1.26                      <build-prerequisite/>
    1.27 @@ -108,7 +116,14 @@
    1.28                          <specification-version>1.6.20.1.4</specification-version>
    1.29                      </run-dependency>
    1.30                  </dependency>
    1.31 --->                
    1.32 +                <dependency>
    1.33 +                    <code-name-base>org.netbeans.modules.xml.axi</code-name-base>
    1.34 +                    <build-prerequisite/>
    1.35 +                    <compile-dependency/>
    1.36 +                    <run-dependency>
    1.37 +                        <specification-version>1.2</specification-version>
    1.38 +                    </run-dependency>
    1.39 +                </dependency>
    1.40                  <dependency>
    1.41                      <code-name-base>org.netbeans.modules.xml.refactoring</code-name-base>
    1.42                      <build-prerequisite/>
    1.43 @@ -135,14 +150,6 @@
    1.44                      </run-dependency>
    1.45                  </dependency>
    1.46                  <dependency>
    1.47 -                    <code-name-base>org.netbeans.modules.xml.schema.ui.basic</code-name-base>
    1.48 -                    <build-prerequisite/>
    1.49 -                    <compile-dependency/>
    1.50 -                    <run-dependency>
    1.51 -                        <release-version>1</release-version>
    1.52 -                    </run-dependency>
    1.53 -                </dependency>
    1.54 -                <dependency>
    1.55                      <code-name-base>org.netbeans.modules.xml.validation</code-name-base>
    1.56                      <build-prerequisite/>
    1.57                      <compile-dependency/>
    1.58 @@ -182,6 +189,14 @@
    1.59                      </run-dependency>
    1.60                  </dependency>
    1.61                  <dependency>
    1.62 +                    <code-name-base>org.netbeans.modules.xml.xpath</code-name-base>
    1.63 +                    <build-prerequisite/>
    1.64 +                    <compile-dependency/>
    1.65 +                    <run-dependency>
    1.66 +                        <specification-version>1.1</specification-version>
    1.67 +                    </run-dependency>
    1.68 +                </dependency>
    1.69 +                <dependency>
    1.70                      <code-name-base>org.netbeans.spi.navigator</code-name-base>
    1.71                      <build-prerequisite/>
    1.72                      <compile-dependency/>
    1.73 @@ -294,12 +309,26 @@
    1.74                          <specification-version>6.2</specification-version>
    1.75                      </run-dependency>
    1.76                  </dependency>
    1.77 +                <dependency>
    1.78 +                    <code-name-base>org.netbeans.modules.bpel.search.api</code-name-base>
    1.79 +                    <build-prerequisite/>
    1.80 +                    <compile-dependency/>
    1.81 +                    <run-dependency>
    1.82 +                        <release-version>1</release-version>
    1.83 +                        <specification-version>1.1</specification-version>
    1.84 +                    </run-dependency>
    1.85 +                </dependency>
    1.86              </module-dependencies>
    1.87              <friend-packages>
    1.88 -                <friend>org.netbeans.modules.bpel.debugger.ui</friend>
    1.89 -                <friend>org.netbeans.modules.bpel.xpath</friend>
    1.90 -                <friend>org.netbeans.modules.bpel.refactoring</friend>
    1.91 +                <friend>org.netbeans.modules.bpel.search</friend>
    1.92 +                <package>org.netbeans.modules.bpel.design</package>
    1.93 +                <package>org.netbeans.modules.bpel.design.decoration</package>
    1.94 +                <package>org.netbeans.modules.bpel.design.model</package>
    1.95 +                <package>org.netbeans.modules.bpel.design.model.elements</package>
    1.96                  <package>org.netbeans.modules.bpel.design.model.patterns</package>
    1.97 +                <package>org.netbeans.modules.bpel.design.nodes</package>
    1.98 +                <package>org.netbeans.modules.bpel.design.selection</package>
    1.99 +                <package>org.netbeans.modules.bpel.editors.multiview</package>
   1.100                  <package>org.netbeans.modules.bpel.nodes</package>
   1.101                  <package>org.netbeans.modules.bpel.nodes.navigator</package>
   1.102                  <package>org.netbeans.modules.bpel.nodes.refactoring</package>
     2.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/PartnerLinkMainPanel.java	Thu Nov 23 12:01:23 2006 +0000
     2.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/PartnerLinkMainPanel.java	Wed Dec 13 11:35:25 2006 +0000
     2.3 @@ -30,6 +30,7 @@
     2.4  import java.util.Collection;
     2.5  import java.util.Iterator;
     2.6  import java.util.List;
     2.7 +import java.util.StringTokenizer;
     2.8  import javax.swing.Timer;
     2.9  import javax.swing.DefaultComboBoxModel;
    2.10  import javax.swing.DefaultListCellRenderer;
    2.11 @@ -40,27 +41,27 @@
    2.12  import org.netbeans.modules.bpel.core.helper.api.BusinessProcessHelper;
    2.13  import org.netbeans.modules.bpel.design.DnDHandler;
    2.14  import org.netbeans.modules.bpel.design.model.PartnerLinkHelper;
    2.15 -import org.netbeans.modules.bpel.design.nodes.NodeType;
    2.16 +import org.netbeans.modules.bpel.editors.api.nodes.NodeType;
    2.17  import org.netbeans.modules.bpel.model.api.PartnerLink;
    2.18  import org.netbeans.modules.bpel.model.api.references.WSDLReference;
    2.19  import org.netbeans.modules.bpel.properties.ImportRegistrationHelper;
    2.20  import org.netbeans.modules.bpel.properties.Util;
    2.21 -import org.netbeans.modules.bpel.properties.editors.controls.CustomNodeEditor;
    2.22 -import org.netbeans.modules.bpel.properties.editors.controls.valid.Validator;
    2.23 +import org.netbeans.modules.bpel.editors.api.ui.CustomNodeEditor;
    2.24 +import org.netbeans.modules.bpel.editors.api.ui.valid.Validator;
    2.25  import org.netbeans.modules.xml.wsdl.model.WSDLModelFactory;
    2.26  import org.openide.ErrorManager;
    2.27  import static org.netbeans.modules.bpel.properties.PropertyType.*;
    2.28  import org.netbeans.modules.bpel.properties.editors.controls.EditorLifeCycleAdapter;
    2.29 -import org.netbeans.modules.bpel.properties.editors.controls.valid.DefaultValidator;
    2.30 -import org.netbeans.modules.bpel.properties.editors.controls.valid.ValidStateManager;
    2.31 -import org.netbeans.modules.bpel.properties.editors.controls.valid.ValidStateManager.ValidStateListener;
    2.32 -import org.netbeans.modules.bpel.nodes.BpelNode;
    2.33 -import org.netbeans.modules.bpel.nodes.PartnerLinkNode;
    2.34 +import org.netbeans.modules.bpel.editors.api.ui.valid.DefaultValidator;
    2.35 +import org.netbeans.modules.bpel.editors.api.ui.valid.ErrorMessagesBundle;
    2.36 +import org.netbeans.modules.bpel.editors.api.ui.valid.ValidStateManager;
    2.37 +import org.netbeans.modules.bpel.editors.api.ui.valid.ValidStateManager.ValidStateListener;
    2.38  import org.netbeans.modules.bpel.properties.Constants;
    2.39  import org.netbeans.modules.bpel.properties.ResolverUtility;
    2.40  import org.netbeans.modules.xml.retriever.catalog.Utilities;
    2.41  import org.netbeans.modules.xml.wsdl.model.Definitions;
    2.42  import org.netbeans.modules.xml.wsdl.model.PortType;
    2.43 +import org.netbeans.modules.xml.wsdl.model.Import;
    2.44  import org.netbeans.modules.xml.wsdl.model.WSDLModel;
    2.45  import org.netbeans.modules.xml.wsdl.model.extensions.bpel.BPELComponentFactory;
    2.46  import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType;
    2.47 @@ -73,28 +74,28 @@
    2.48  import org.openide.util.Lookup;
    2.49  
    2.50  /**
    2.51 - *
    2.52 - * @author  nk160297
    2.53 + * @author nk160297
    2.54   */
    2.55  public class PartnerLinkMainPanel extends EditorLifeCycleAdapter
    2.56          implements Validator.Provider, HelpCtx.Provider {
    2.57      
    2.58      static final long serialVersionUID = 1L;
    2.59      
    2.60 -    private CustomNodeEditor myEditor;
    2.61 +    private CustomNodeEditor<PartnerLink> myEditor;
    2.62      
    2.63      private ArrayList<Role> rolesList;
    2.64      private Role myRole;
    2.65      private Role partnerRole;
    2.66      
    2.67 -    private static String ROLE_NA = "-----"; // NOI18N
    2.68 +    private static final String ROLE_NA = "-----"; // NOI18N
    2.69 +    private static final String SLASH = "/"; // NOI18N
    2.70      
    2.71      private DefaultValidator myValidator;
    2.72      
    2.73      private Timer inputDelayTimer;
    2.74      
    2.75      /** Creates new form PartnerLinkMainPanel */
    2.76 -    public PartnerLinkMainPanel(CustomNodeEditor anEditor) {
    2.77 +    public PartnerLinkMainPanel(CustomNodeEditor<PartnerLink> anEditor) {
    2.78          myEditor = anEditor;
    2.79          createContent();
    2.80      }
    2.81 @@ -120,6 +121,11 @@
    2.82          //
    2.83          cbxWsdlFile.setRenderer(new WsdlFileRenderer());
    2.84          //
    2.85 +        // vlv
    2.86 +        if (wsdlFilesArr.length == 1) {
    2.87 +          cbxWsdlFile.setSelectedItem(wsdlFilesArr[0]);
    2.88 +        }
    2.89 +        //
    2.90          cbxProcessPortType.setRenderer(new PortTypeRenderer());
    2.91          cbxPartnerPortType.setRenderer(new PortTypeRenderer());
    2.92          //
    2.93 @@ -296,10 +302,7 @@
    2.94              // A wsdl file is usually passed when the DnD of Wsdl is performed
    2.95              boolean wsdlFileWasSpecified = false;
    2.96              //
    2.97 -            BpelNode node = myEditor.getModelNode();
    2.98 -            assert node instanceof PartnerLinkNode;
    2.99 -            PartnerLinkNode pnNode = (PartnerLinkNode)node;
   2.100 -            PartnerLink pLink = pnNode.getReference();
   2.101 +            PartnerLink pLink = myEditor.getEditedObject();
   2.102              WSDLReference<PartnerLinkType> pltRef = pLink.getPartnerLinkType();
   2.103              PartnerLinkType plType = null;
   2.104              FileObject resultWsdlFile = null;
   2.105 @@ -327,8 +330,6 @@
   2.106                  }
   2.107              }
   2.108              //
   2.109 -            cbxWsdlFile.setSelectedIndex(-1);
   2.110 -             
   2.111              if (resultWsdlFile != null) {
   2.112                  cbxWsdlFile.setSelectedItem(resultWsdlFile);
   2.113              }
   2.114 @@ -353,11 +354,10 @@
   2.115              if (!wsdlFileWasSpecified) {
   2.116    
   2.117                  // Set selection to roles combo-boxes
   2.118 -                WSDLReference<Role> myRoleRef = pnNode.getReference().getMyRole();
   2.119 +                WSDLReference<Role> myRoleRef = pLink.getMyRole();
   2.120                  setRoleByRef(true, myRoleRef);
   2.121                  //
   2.122 -                WSDLReference<Role> partnerRoleRef =
   2.123 -                        pnNode.getReference().getPartnerRole();
   2.124 +                WSDLReference<Role> partnerRoleRef = pLink.getPartnerRole();
   2.125                  setRoleByRef(false, partnerRoleRef);
   2.126              } 
   2.127              //
   2.128 @@ -547,18 +547,17 @@
   2.129          //
   2.130          getValidator().revalidate(true);
   2.131      }
   2.132 -    
   2.133 +
   2.134      public boolean applyNewValues() {
   2.135          try {
   2.136 -            BpelNode node = myEditor.getModelNode();
   2.137 -            assert node instanceof PartnerLinkNode;
   2.138 -            PartnerLinkNode pnNode = (PartnerLinkNode)node;
   2.139 -            PartnerLink pLink = pnNode.getReference();
   2.140 +            PartnerLink pLink = myEditor.getEditedObject();
   2.141              PartnerLinkType plType = null;
   2.142              //
   2.143              if (rbtnUseExistingPLT.isSelected()) {
   2.144 +//System.out.println("11");
   2.145                  plType = tuneForExistingPLT(pLink);
   2.146              } else {
   2.147 +//System.out.println("22");
   2.148                  plType = tuneFromNewPLT(pLink);
   2.149              }
   2.150              //
   2.151 @@ -572,35 +571,75 @@
   2.152          return true;
   2.153      }
   2.154      
   2.155 -    private PartnerLinkType tuneForExistingPLT(final PartnerLink pLink) {
   2.156 -        PartnerLinkType plType =
   2.157 -                (PartnerLinkType)cbxPartnerLinkType.getSelectedItem();
   2.158 -        //
   2.159 -        if(plType != null){
   2.160 -            pLink.setPartnerLinkType(
   2.161 -                    pLink.createWSDLReference(
   2.162 -                    plType, PartnerLinkType.class));
   2.163 +    // vlv
   2.164 +    private WSDLModel getCurrentWsdlModel(boolean isWsdlWrapperSet) {
   2.165 +//System.out.println("get curr model: " + isWsdlWrapperSet);
   2.166 +      FileObject currentFile = getCurrentWsdlFile();
   2.167 +      WSDLModel currentModel = getWsdlModel(currentFile);
   2.168 +      WsdlWrapper wsdlWrapper = new WsdlWrapper(currentFile.getParent(), "wrapper"); // todo m
   2.169 +
   2.170 +      if (isWsdlWrapperSet) {
   2.171 +        WSDLModel wrapperModel = wsdlWrapper.getModel();
   2.172 +        FileObject wrapperFile = wsdlWrapper.getFile();
   2.173 +        addImport(wrapperModel, wrapperFile, currentModel, currentFile);
   2.174 +        return wrapperModel;
   2.175 +//System.out.println("Model: " + model);
   2.176 +      }
   2.177 +      return currentModel;
   2.178 +    }
   2.179 +
   2.180 +    // vlv
   2.181 +    private void addImport(
   2.182 +      WSDLModel model,
   2.183 +      FileObject file,
   2.184 +      WSDLModel importedModel,
   2.185 +      FileObject importedFile)
   2.186 +    {
   2.187 +      model.startTransaction();
   2.188 +      Definitions definitions = model.getDefinitions();
   2.189 +      Import inport = model.getFactory().createImport();
   2.190 +      inport.setLocation(getRelativePath(file, importedFile));
   2.191 +      inport.setNamespace(importedModel.getDefinitions().getTargetNamespace());
   2.192 +      definitions.addImport(inport);
   2.193 +      model.endTransaction();
   2.194 +    }
   2.195 +
   2.196 +    // vlv
   2.197 +    private String getRelativePath(FileObject file1, FileObject file2) {
   2.198 +      StringTokenizer stk1 = new StringTokenizer(file1.getPath(), SLASH);
   2.199 +      StringTokenizer stk2 = new StringTokenizer(file2.getPath(), SLASH);
   2.200 +      String relative = ""; // NOI18N
   2.201 +
   2.202 +      while (stk1.hasMoreTokens() && stk2.hasMoreTokens()) {
   2.203 +        relative = stk2.nextToken();
   2.204 +
   2.205 +        if ( !stk1.nextToken().equals(relative)) {
   2.206 +          break;
   2.207          }
   2.208 -        //
   2.209 -        if (myRole == null) {
   2.210 -            pLink.removeMyRole();
   2.211 -        } else {
   2.212 -            WSDLReference<Role> roleRef =
   2.213 -                    pLink.createWSDLReference(myRole, Role.class);
   2.214 -            pLink.setMyRole(roleRef);
   2.215 -        }
   2.216 -        //
   2.217 -        if (partnerRole == null) {
   2.218 -            pLink.removePartnerRole();
   2.219 -        } else {
   2.220 -            WSDLReference<Role> roleRef =
   2.221 -                    pLink.createWSDLReference(partnerRole, Role.class);
   2.222 -            pLink.setPartnerRole(roleRef);
   2.223 -        }
   2.224 -        //
   2.225 -        return plType;
   2.226 +      }
   2.227 +      while (stk1.hasMoreTokens()) {
   2.228 +        relative = "../".concat(relative); // NOI18N
   2.229 +        stk1.nextToken();
   2.230 +      }
   2.231 +      while(stk2.hasMoreTokens()) {
   2.232 +        relative = relative.concat(SLASH); // NOI18N
   2.233 +        relative = relative.concat(stk2.nextToken());
   2.234 +      }
   2.235 +      return relative;
   2.236      }
   2.237 -    
   2.238 +
   2.239 +    /**
   2.240 +     * Returns the current WSDL model which is selected in the combo-box.
   2.241 +     * Method can return null!
   2.242 +     */
   2.243 +    private WSDLModel getCurrentWsdlModel() {
   2.244 +        return getCurrentWsdlModel(false);
   2.245 +    }
   2.246 +
   2.247 +    private FileObject getCurrentWsdlFile() {
   2.248 +        return (FileObject)cbxWsdlFile.getSelectedItem();
   2.249 +    }
   2.250 +
   2.251      private PartnerLinkType tuneFromNewPLT(final PartnerLink pLink) {
   2.252          PartnerLinkType plType = null;
   2.253          Role newMyRole = null;
   2.254 @@ -609,7 +648,8 @@
   2.255          // Create a New Partner Link Type in the WSDL model.
   2.256          // It has to be done first because of the PLT will not be
   2.257          // visible until end of WSDL transaction.
   2.258 -        WSDLModel wsdlModel = getCurrentWsdlModel();
   2.259 +        WSDLModel wsdlModel = getCurrentWsdlModel(true);
   2.260 +        //
   2.261          if (wsdlModel != null) {
   2.262              wsdlModel.startTransaction();
   2.263              try {
   2.264 @@ -692,16 +732,7 @@
   2.265          }
   2.266          return plType;
   2.267      }
   2.268 -    
   2.269 -    /**
   2.270 -     * Returns the current WSDL model which is selected in the combo-box.
   2.271 -     * Method can return null!
   2.272 -     */
   2.273 -    private WSDLModel getCurrentWsdlModel() {
   2.274 -        FileObject wsdlFile = (FileObject)cbxWsdlFile.getSelectedItem();
   2.275 -        return getWsdlModel(wsdlFile);
   2.276 -    }
   2.277 -    
   2.278 +
   2.279      private WSDLModel getWsdlModel(FileObject wsdlFile) {
   2.280          if (wsdlFile != null) {
   2.281              ModelSource modelSource = Utilities.getModelSource(wsdlFile, true);
   2.282 @@ -716,47 +747,68 @@
   2.283          //
   2.284          return null;
   2.285      }
   2.286 -    
   2.287 +
   2.288 +    private PartnerLinkType tuneForExistingPLT(final PartnerLink pLink) {
   2.289 +        PartnerLinkType plType =
   2.290 +                (PartnerLinkType)cbxPartnerLinkType.getSelectedItem();
   2.291 +        //
   2.292 +        if(plType != null){
   2.293 +            pLink.setPartnerLinkType(
   2.294 +                    pLink.createWSDLReference(
   2.295 +                    plType, PartnerLinkType.class));
   2.296 +        }
   2.297 +        //
   2.298 +        if (myRole == null) {
   2.299 +            pLink.removeMyRole();
   2.300 +        } else {
   2.301 +            WSDLReference<Role> roleRef =
   2.302 +                    pLink.createWSDLReference(myRole, Role.class);
   2.303 +            pLink.setMyRole(roleRef);
   2.304 +        }
   2.305 +        //
   2.306 +        if (partnerRole == null) {
   2.307 +            pLink.removePartnerRole();
   2.308 +        } else {
   2.309 +            WSDLReference<Role> roleRef =
   2.310 +                    pLink.createWSDLReference(partnerRole, Role.class);
   2.311 +            pLink.setPartnerRole(roleRef);
   2.312 +        }
   2.313 +        //
   2.314 +        return plType;
   2.315 +    }
   2.316 +
   2.317      public DefaultValidator getValidator() {
   2.318          if (myValidator == null) {
   2.319 -            myValidator = new DefaultValidator(myEditor) {
   2.320 +            myValidator = new DefaultValidator(myEditor, ErrorMessagesBundle.class) {
   2.321                  
   2.322                  public boolean doFastValidation() {
   2.323 -                    boolean isValid = true;
   2.324 -                    //
   2.325                      String plName = fldPartnerLinkName.getText();
   2.326                      if (plName == null || plName.length() == 0) {
   2.327                          addReasonKey("ERR_NAME_EMPTY"); //NOI18N
   2.328 -                        isValid = false;
   2.329                      }
   2.330                      //
   2.331                      if (cbxWsdlFile.getSelectedIndex() == -1) {
   2.332                          addReasonKey("ERR_WSDL_FILE_NOT_SPECIFIED"); //NOI18N
   2.333 -                        isValid = false;
   2.334                      }
   2.335                      //
   2.336                      if (rbtnUseExistingPLT.isSelected()) {
   2.337                          if (cbxPartnerLinkType.getSelectedIndex() == -1) {
   2.338                              addReasonKey("ERR_PL_TYPE_NOT_SPECIFIED"); //NOI18N
   2.339 -                            isValid = false;
   2.340                          }
   2.341                      } else {
   2.342                          String pltName = fldNewPLTName.getText();
   2.343                          if (pltName == null || pltName.length() == 0) {
   2.344                              addReasonKey("ERR_PLT_NAME_EMPTY"); //NOI18N
   2.345 -                            isValid = false;
   2.346                          } else {
   2.347                              boolean isCorrectPLTName = Util.isNCName(pltName);
   2.348                              if (!isCorrectPLTName) {
   2.349                                  addReasonKey("ERR_PLT_NAME_INVALID"); //NOI18N
   2.350 -                                isValid = false;
   2.351                              } else {
   2.352                                  WSDLModel wsdlModel = getCurrentWsdlModel();
   2.353                                  if (wsdlModel != null) {
   2.354                                      isCorrectPLTName = Util.isUniquePartnerLinkTypeName(wsdlModel, pltName);
   2.355                                      if (!isCorrectPLTName) {
   2.356                                          addReasonKey("ERR_PLT_NAME_NOT_UNIQUE"); //NOI18N
   2.357 -                                        isValid = false;
   2.358                                      }
   2.359                                  }
   2.360                              }
   2.361 @@ -765,19 +817,16 @@
   2.362                          if (!chbxProcessWillImplement.isSelected() &&
   2.363                                  !chbxPartnerWillImpement.isSelected()) {
   2.364                              addReasonKey("ERR_NEW_PLT_ROLES_NOT_SPECIFIED"); //NOI18N
   2.365 -                            isValid = false;
   2.366                          }
   2.367                          //
   2.368                          if (chbxProcessWillImplement.isSelected()) {
   2.369                              String myRoleName = fldProcessRoleName.getText();
   2.370                              if (myRoleName == null || myRoleName.length() == 0) {
   2.371                                  addReasonKey("ERR_PLT_MY_ROLE_NAME_EMPTY"); //NOI18N
   2.372 -                                isValid = false;
   2.373                              } else {
   2.374                                  boolean isCorrectMyRoleName = Util.isNCName(myRoleName);
   2.375                                  if (!isCorrectMyRoleName) {
   2.376                                      addReasonKey("ERR_PLT_MY_ROLE_NAME_INVALID"); //NOI18N
   2.377 -                                    isValid = false;
   2.378                                  }
   2.379                              }
   2.380                              //
   2.381 @@ -785,7 +834,6 @@
   2.382                                      cbxProcessPortType.getSelectedIndex();
   2.383                              if (processPortTypeIndex == -1) {
   2.384                                  addReasonKey("ERR_PLT_MY_ROLE_PORT_TYPE_EMPTY"); //NOI18N
   2.385 -                                isValid = false;
   2.386                              }
   2.387                          }
   2.388                          //
   2.389 @@ -793,12 +841,10 @@
   2.390                              String myRoleName = fldPartnerRoleName.getText();
   2.391                              if (myRoleName == null || myRoleName.length() == 0) {
   2.392                                  addReasonKey("ERR_PLT_PARTNER_ROLE_NAME_EMPTY"); //NOI18N
   2.393 -                                isValid = false;
   2.394                              } else {
   2.395                                  boolean isCorrectPartnerRoleName = Util.isNCName(myRoleName);
   2.396                                  if (!isCorrectPartnerRoleName) {
   2.397                                      addReasonKey("ERR_PLT_PARTNER_ROLE_NAME_INVALID"); //NOI18N
   2.398 -                                    isValid = false;
   2.399                                  }
   2.400                              }
   2.401                              //
   2.402 @@ -806,7 +852,6 @@
   2.403                                      cbxPartnerPortType.getSelectedIndex();
   2.404                              if (partnerPortTypeIndex == -1) {
   2.405                                  addReasonKey("ERR_PLT_PARTNER_ROLE_PORT_TYPE_EMPTY"); //NOI18N
   2.406 -                                isValid = false;
   2.407                              }
   2.408                          }
   2.409                          //
   2.410 @@ -820,13 +865,12 @@
   2.411                                      && myRoleName.equals(partnerRoleName)) 
   2.412                              {
   2.413                                  addReasonKey("ERR_PLT_ROLES_NOT_UNIQUE"); //NOI18N
   2.414 -                                isValid = false;
   2.415                              }
   2.416                          }
   2.417                      }
   2.418                      //
   2.419                      //
   2.420 -                    return isValid;
   2.421 +                    return isReasonsListEmpty();
   2.422                  }
   2.423                  
   2.424              };
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/WsdlWrapper.java	Wed Dec 13 11:35:25 2006 +0000
     3.3 @@ -0,0 +1,148 @@
     3.4 +/*
     3.5 + * The contents of this file are subject to the terms of the Common Development
     3.6 + * and Distribution License (the License). You may not use this file except in
     3.7 + * compliance with the License.
     3.8 + *
     3.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    3.10 + * or http://www.netbeans.org/cddl.txt.
    3.11 + *
    3.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
    3.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
    3.14 + * If applicable, add the following below the CDDL Header, with the fields
    3.15 + * enclosed by brackets [] replaced by your own identifying information:
    3.16 + * "Portions Copyrighted [year] [name of copyright owner]"
    3.17 + *
    3.18 + * The Original Software is NetBeans. The Initial Developer of the Original
    3.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    3.20 + * Microsystems, Inc. All Rights Reserved.
    3.21 + */
    3.22 +package org.netbeans.modules.bpel.properties.editors;
    3.23 +
    3.24 +import java.io.File;
    3.25 +import java.io.FileWriter;
    3.26 +import java.io.IOException;
    3.27 +import java.io.PrintWriter;
    3.28 +
    3.29 +import org.openide.filesystems.FileObject;
    3.30 +import org.openide.filesystems.FileUtil;
    3.31 +import org.openide.filesystems.Repository;
    3.32 +
    3.33 +import org.netbeans.modules.xml.retriever.catalog.Utilities;
    3.34 +import org.netbeans.modules.xml.xam.ModelSource;
    3.35 +
    3.36 +import org.netbeans.modules.xml.wsdl.model.Definitions;
    3.37 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
    3.38 +import org.netbeans.modules.xml.wsdl.model.WSDLModelFactory;
    3.39 +
    3.40 +/**
    3.41 + * @author Vladimir Yaroslavskiy
    3.42 + * @version 2006.12.11
    3.43 + */
    3.44 +final class WsdlWrapper {
    3.45 +
    3.46 +  WsdlWrapper(FileObject folder, String name) {
    3.47 +    myFolder = folder;
    3.48 +    myName = name;
    3.49 +  }
    3.50 +
    3.51 +  WSDLModel getModel() {
    3.52 +//out("Create in: " + folder);
    3.53 +    FileObject file = getFile();
    3.54 +
    3.55 +    if (file == null) {
    3.56 +      return null;
    3.57 +    }
    3.58 +    ModelSource source = Utilities.getModelSource(file, file.canWrite());
    3.59 +    WSDLModel model = WSDLModelFactory.getDefault().getModel(source);
    3.60 +
    3.61 +    model.startTransaction();
    3.62 +    Definitions definitions = model.getDefinitions();
    3.63 +    definitions.setName(myName);
    3.64 +    definitions.setTargetNamespace(HOST + myName);
    3.65 +    model.endTransaction();
    3.66 +
    3.67 +    return model;
    3.68 +  }
    3.69 +
    3.70 +  FileObject getFile() {
    3.71 +    FileObject file = myFolder.getFileObject(myName, EXTENSION);
    3.72 +
    3.73 +    if (file != null) { // todo m canCreate
    3.74 +//out("exists: " + name);
    3.75 +      return file;
    3.76 +//      file = folder.getFileObject(name, EXTENSION);
    3.77 +//
    3.78 +//      try {
    3.79 +//        file.delete();
    3.80 +//      }
    3.81 +//      catch (IOException e) {
    3.82 +//        e.printStackTrace(); // todo m
    3.83 +//      }
    3.84 +    }
    3.85 +/*
    3.86 +    try {
    3.87 +      file = folder.createData(name, EXTENSION);
    3.88 +
    3.89 +      File content = FileUtil.toFile(file);
    3.90 +      PrintWriter writer = new PrintWriter(content, "UTF-8"); // NOI18N
    3.91 +      StringBuffer buffer = new StringBuffer();
    3.92 +
    3.93 +      buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + LS);
    3.94 +      buffer.append("<definitions" + LS);
    3.95 +      buffer.append("    xmlns=\"http://schemas.xmlsoap.org/wsdl/\"" + LS);
    3.96 +      buffer.append("    xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\"" + LS);
    3.97 +      buffer.append("    xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\"" + LS);
    3.98 +      buffer.append("    xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + LS);
    3.99 +      buffer.append("</definitions>" + LS);
   3.100 +
   3.101 +      writer.write(buffer.toString());
   3.102 +      writer.flush();
   3.103 +      writer.close();
   3.104 +    }
   3.105 +    catch (IOException e) {
   3.106 +      e.printStackTrace(); // todo m
   3.107 +    }
   3.108 +*/
   3.109 +    return copyFile(myFolder, "wsdl/", "wsdl.wsdl", myName);
   3.110 +  }
   3.111 +
   3.112 +  private FileObject copyFile(
   3.113 +    FileObject destination,
   3.114 +    String path,
   3.115 +    String file,
   3.116 +    String name)
   3.117 +  {
   3.118 +//    int k = file.lastIndexOf ("."); // NOI18N
   3.119 +//    String name = k == -1 ? file : file.substring(0, k);
   3.120 +//out();
   3.121 +//out("file: " + file);
   3.122 +//out(" dst: " + destination);
   3.123 +//out("name: " + name);
   3.124 +//out("path: " + path);
   3.125 +//out("find: " + Repository.getDefault().getDefaultFileSystem().findResource(path + file));
   3.126 +    try {
   3.127 +      return FileUtil.copyFile(
   3.128 +        Repository.getDefault().getDefaultFileSystem().findResource(path + file),
   3.129 +        destination,
   3.130 +        name);
   3.131 +    }
   3.132 +    catch (IOException e) {
   3.133 +      e.printStackTrace();
   3.134 +    }
   3.135 +    return null;
   3.136 +  }
   3.137 +
   3.138 +  private void out() {
   3.139 +    System.out.println();
   3.140 +  }
   3.141 +
   3.142 +  private void out(Object object) {
   3.143 +    System.out.println("*** " + object); // NOI18N
   3.144 +  }
   3.145 +
   3.146 +  private String myName;
   3.147 +  private FileObject myFolder;
   3.148 +  
   3.149 +  private static final String EXTENSION = "wsdl"; // NOI18N
   3.150 +  private static final String HOST = "http://enterprise.netbeans.org/bpel/"; // NOI18N
   3.151 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/resources/wsdl.wsdl	Wed Dec 13 11:35:25 2006 +0000
     4.3 @@ -0,0 +1,8 @@
     4.4 +<?xml version="1.0" encoding="UTF-8"?>
     4.5 +
     4.6 +<definitions
     4.7 +    xmlns="http://schemas.xmlsoap.org/wsdl/"
     4.8 +    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
     4.9 +    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    4.10 +    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    4.11 +</definitions>
     5.1 --- a/bpel.refactoring/nbproject/project.xml	Thu Nov 23 12:01:23 2006 +0000
     5.2 +++ b/bpel.refactoring/nbproject/project.xml	Wed Dec 13 11:35:25 2006 +0000
     5.3 @@ -122,7 +122,7 @@
     5.4                      </run-dependency>
     5.5                  </dependency>
     5.6                  <dependency>
     5.7 -                    <code-name-base>org.netbeans.modules.bpel.editors</code-name-base>
     5.8 +                    <code-name-base>org.netbeans.modules.bpel.editors.api</code-name-base>
     5.9                      <build-prerequisite/>
    5.10                      <compile-dependency/>
    5.11                      <run-dependency>
    5.12 @@ -138,6 +138,15 @@
    5.13                          <specification-version>1.0</specification-version>
    5.14                      </run-dependency>
    5.15                  </dependency>
    5.16 +                <dependency>
    5.17 +                    <code-name-base>org.netbeans.modules.print.api</code-name-base>
    5.18 +                    <build-prerequisite/>
    5.19 +                    <compile-dependency/>
    5.20 +                    <run-dependency>
    5.21 +                        <release-version>1</release-version>
    5.22 +                        <specification-version>1.1</specification-version>
    5.23 +                    </run-dependency>
    5.24 +                </dependency>
    5.25              </module-dependencies>
    5.26              <public-packages/>
    5.27          </data>
     6.1 --- a/bpel.search/nbproject/project.xml	Thu Nov 23 12:01:23 2006 +0000
     6.2 +++ b/bpel.search/nbproject/project.xml	Wed Dec 13 11:35:25 2006 +0000
     6.3 @@ -33,6 +33,30 @@
     6.4                      </run-dependency>
     6.5                  </dependency>
     6.6                  <dependency>
     6.7 +                    <code-name-base>org.openide.dialogs</code-name-base>
     6.8 +                    <build-prerequisite/>
     6.9 +                    <compile-dependency/>
    6.10 +                    <run-dependency>
    6.11 +                        <specification-version>6.2</specification-version>
    6.12 +                    </run-dependency>
    6.13 +                </dependency>
    6.14 +                <dependency>
    6.15 +                    <code-name-base>org.openide.loaders</code-name-base>
    6.16 +                    <build-prerequisite/>
    6.17 +                    <compile-dependency/>
    6.18 +                    <run-dependency>
    6.19 +                        <specification-version>5.8.1</specification-version>
    6.20 +                    </run-dependency>
    6.21 +                </dependency>
    6.22 +                <dependency>
    6.23 +                    <code-name-base>org.openide.nodes</code-name-base>
    6.24 +                    <build-prerequisite/>
    6.25 +                    <compile-dependency/>
    6.26 +                    <run-dependency>
    6.27 +                        <specification-version>6.2</specification-version>
    6.28 +                    </run-dependency>
    6.29 +                </dependency>
    6.30 +                <dependency>
    6.31                      <code-name-base>org.openide.util</code-name-base>
    6.32                      <build-prerequisite/>
    6.33                      <compile-dependency/>
    6.34 @@ -41,6 +65,22 @@
    6.35                      </run-dependency>
    6.36                  </dependency>
    6.37                  <dependency>
    6.38 +                    <code-name-base>org.openide.windows</code-name-base>
    6.39 +                    <build-prerequisite/>
    6.40 +                    <compile-dependency/>
    6.41 +                    <run-dependency>
    6.42 +                        <specification-version>6.2</specification-version>
    6.43 +                    </run-dependency>
    6.44 +                </dependency>
    6.45 +                <dependency>
    6.46 +                    <code-name-base>org.netbeans.modules.xml.xam</code-name-base>
    6.47 +                    <build-prerequisite/>
    6.48 +                    <compile-dependency/>
    6.49 +                    <run-dependency>
    6.50 +                        <release-version>1</release-version>
    6.51 +                    </run-dependency>
    6.52 +                </dependency>
    6.53 +                <dependency>
    6.54                      <code-name-base>org.netbeans.modules.xml.xam.ui</code-name-base>
    6.55                      <build-prerequisite/>
    6.56                      <compile-dependency/>
    6.57 @@ -58,6 +98,15 @@
    6.58                      </run-dependency>
    6.59                  </dependency>
    6.60                  <dependency>
    6.61 +                    <code-name-base>org.netbeans.modules.bpel.editors.api</code-name-base>
    6.62 +                    <build-prerequisite/>
    6.63 +                    <compile-dependency/>
    6.64 +                    <run-dependency>
    6.65 +                        <release-version>1</release-version>
    6.66 +                        <specification-version>1.2</specification-version>
    6.67 +                    </run-dependency>
    6.68 +                </dependency>
    6.69 +                <dependency>
    6.70                      <code-name-base>org.netbeans.modules.bpel.editors</code-name-base>
    6.71                      <build-prerequisite/>
    6.72                      <compile-dependency/>
    6.73 @@ -75,6 +124,15 @@
    6.74                          <specification-version>1.1</specification-version>
    6.75                      </run-dependency>
    6.76                  </dependency>
    6.77 +                <dependency>
    6.78 +                    <code-name-base>org.netbeans.modules.print.api</code-name-base>
    6.79 +                    <build-prerequisite/>
    6.80 +                    <compile-dependency/>
    6.81 +                    <run-dependency>
    6.82 +                        <release-version>1</release-version>
    6.83 +                        <specification-version>1.1</specification-version>
    6.84 +                    </run-dependency>
    6.85 +                </dependency>
    6.86              </module-dependencies>
    6.87              <public-packages/>
    6.88          </data>
     7.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/action/Bundle.properties	Thu Nov 23 12:01:23 2006 +0000
     7.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/action/Bundle.properties	Wed Dec 13 11:35:25 2006 +0000
     7.3 @@ -17,4 +17,4 @@
     7.4  # Microsystems, Inc. All Rights Reserved.
     7.5  
     7.6  # SearchAction
     7.7 -CTL_Search_Action=Search ...
     7.8 +CTL_Search_Action=Advanced Search ...
     8.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/action/SearchAction.java	Thu Nov 23 12:01:23 2006 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,79 +0,0 @@
     8.4 -/*
     8.5 - * The contents of this file are subject to the terms of the Common Development
     8.6 - * and Distribution License (the License). You may not use this file except in
     8.7 - * compliance with the License.
     8.8 - *
     8.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    8.10 - * or http://www.netbeans.org/cddl.txt.
    8.11 - *
    8.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
    8.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
    8.14 - * If applicable, add the following below the CDDL Header, with the fields
    8.15 - * enclosed by brackets [] replaced by your own identifying information:
    8.16 - * "Portions Copyrighted [year] [name of copyright owner]"
    8.17 - *
    8.18 - * The Original Software is NetBeans. The Initial Developer of the Original
    8.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    8.20 - * Microsystems, Inc. All Rights Reserved.
    8.21 - */
    8.22 -package org.netbeans.modules.bpel.search.impl.action;
    8.23 -
    8.24 -import org.openide.util.HelpCtx;
    8.25 -import org.openide.util.NbBundle;
    8.26 -import org.openide.util.actions.CallableSystemAction;
    8.27 -
    8.28 -import org.netbeans.modules.bpel.search.api.SearchLog;
    8.29 -
    8.30 -/**
    8.31 - * @author Vladimir Yaroslavskiy
    8.32 - * @version 2006.11.13
    8.33 - */
    8.34 -public final class SearchAction extends CallableSystemAction {
    8.35 -
    8.36 -  /**{@inheritDoc}*/
    8.37 -  @Override
    8.38 -  public void performAction()
    8.39 -  {
    8.40 -//out();
    8.41 -//out("SEARCH");
    8.42 -//todo a
    8.43 -  }
    8.44 -
    8.45 -  /**{@inheritDoc}*/
    8.46 -  @Override
    8.47 -  public boolean isEnabled()
    8.48 -  {
    8.49 -    return true;
    8.50 -  }
    8.51 -
    8.52 -  /**{@inheritDoc}*/
    8.53 -  @Override
    8.54 -  protected boolean asynchronous()
    8.55 -  {
    8.56 -    return false;
    8.57 -  }
    8.58 -
    8.59 -  /**{@inheritDoc}*/
    8.60 -  @Override
    8.61 -  public String getName()
    8.62 -  {
    8.63 -    return NbBundle.getMessage(SearchAction.class, "CTL_Search_Action"); // NOI18N
    8.64 -  }
    8.65 -  
    8.66 -  /**{@inheritDoc}*/
    8.67 -  @Override
    8.68 -  public HelpCtx getHelpCtx()
    8.69 -  {
    8.70 -    return HelpCtx.DEFAULT_HELP;
    8.71 -  }
    8.72 -
    8.73 -  private void out() {
    8.74 -    SearchLog.out();
    8.75 -  }
    8.76 -
    8.77 -  private void out(Object object) {
    8.78 -    SearchLog.out(object);
    8.79 -  }
    8.80 -
    8.81 -  private String myName;
    8.82 -}
     9.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/core/Manager.java	Thu Nov 23 12:01:23 2006 +0000
     9.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/core/Manager.java	Wed Dec 13 11:35:25 2006 +0000
     9.3 @@ -18,24 +18,18 @@
     9.4   */
     9.5  package org.netbeans.modules.bpel.search.impl.core;
     9.6  
     9.7 -import java.awt.Event;
     9.8 -import java.awt.event.ActionEvent;
     9.9 -import java.awt.event.KeyEvent;
    9.10 +import java.awt.Component;
    9.11 +import java.util.ArrayList;
    9.12  import java.util.List;
    9.13  import javax.swing.JComponent;
    9.14  
    9.15 -import javax.swing.AbstractAction;
    9.16 -import javax.swing.Action;
    9.17 -import javax.swing.InputMap;
    9.18 -import javax.swing.KeyStroke;
    9.19 -
    9.20 -import org.openide.actions.FindAction;
    9.21 -
    9.22 +import org.netbeans.modules.print.api.PrintUtil;
    9.23  import org.netbeans.modules.bpel.search.api.SearchManager;
    9.24  import org.netbeans.modules.bpel.search.api.SearchMatch;
    9.25  import org.netbeans.modules.bpel.search.api.SearchPattern;
    9.26  import org.netbeans.modules.bpel.search.spi.SearchEngine;
    9.27  import org.netbeans.modules.bpel.search.impl.ui.Find;
    9.28 +import org.netbeans.modules.bpel.search.impl.ui.Search;
    9.29  import org.netbeans.modules.bpel.search.impl.util.Util;
    9.30  
    9.31  /**
    9.32 @@ -47,54 +41,53 @@
    9.33    /**{@inheritDoc}*/
    9.34    public Manager() {
    9.35      myEngines = Util.getInstances(SearchEngine.class);
    9.36 +    mySearch = new Search();
    9.37    }
    9.38  
    9.39    /**{@inheritDoc}*/
    9.40 -  public JComponent getUI(Object source, JComponent parent) {
    9.41 -    SearchEngine engine = getEngine(source);
    9.42 -//Log.out("Set engine: " + engine);
    9.43 -    assert engine != null : "Can't find engine for " + source; // NOI18N
    9.44 -    Find find = new Find(engine, source);
    9.45 -    find.setVisible(false);
    9.46 -    bindAction(parent, find);
    9.47 -    return find;
    9.48 +  public Component getUI(Object source, JComponent parent, boolean advanced) {
    9.49 +    List<SearchEngine> engines = getEngines(source);
    9.50 +//out("Set engines: " + engines);
    9.51 +    
    9.52 +    if (engines.isEmpty()) {
    9.53 +      return null;
    9.54 +    }
    9.55 +    if (advanced) {
    9.56 +      return mySearch.getComponent(engines, source);
    9.57 +    }
    9.58 +    else {
    9.59 +      return new Find(engines, source, parent);
    9.60 +    }
    9.61    }
    9.62  
    9.63    /**{@inheritDoc}*/
    9.64    public SearchPattern getPattern(
    9.65      String text,
    9.66 -    SearchMatch searchMatch,
    9.67 -    boolean isCaseSensitive)
    9.68 +    SearchMatch match,
    9.69 +    boolean caseSensitive)
    9.70    {
    9.71 -    return new Pattern(text, searchMatch, isCaseSensitive);
    9.72 +    return new Pattern(text, match, caseSensitive);
    9.73    }
    9.74  
    9.75 -  private void bindAction(JComponent parent, final JComponent component) {
    9.76 -    FindAction findAction = (FindAction) FindAction.get(FindAction.class);
    9.77 -    Object mapKey = findAction.getActionMapKey();
    9.78 -    parent.getActionMap().put(mapKey, new AbstractAction () {
    9.79 -      public void actionPerformed(ActionEvent event) {
    9.80 -        component.setVisible(true);
    9.81 +  private List<SearchEngine> getEngines(Object source) {
    9.82 +    List<SearchEngine> engines = new ArrayList<SearchEngine>();
    9.83 +
    9.84 +    for (SearchEngine engine : myEngines) {
    9.85 +      if (engine.accepts(source)) {
    9.86 +        engines.add(engine);
    9.87        }
    9.88 -    });
    9.89 -    InputMap keys =
    9.90 -      parent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    9.91 -    KeyStroke key = (KeyStroke) findAction.getValue(Action.ACCELERATOR_KEY);
    9.92 -
    9.93 -    if (key == null) {
    9.94 -      key = KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK);
    9.95      }
    9.96 -    keys.put(key, mapKey);
    9.97 +    return engines;
    9.98    }
    9.99  
   9.100 -  private SearchEngine getEngine(Object source) {
   9.101 -    for (SearchEngine engine : myEngines) {
   9.102 -      if (engine.accepts(source)) {
   9.103 -        return engine;
   9.104 -      }
   9.105 -    }
   9.106 -    return null;
   9.107 +  private void out() {
   9.108 +    PrintUtil.out();
   9.109    }
   9.110  
   9.111 +  private void out(Object object) {
   9.112 +    PrintUtil.out(object);
   9.113 +  }
   9.114 +
   9.115 +  private Search mySearch;
   9.116    private List<SearchEngine> myEngines;
   9.117  }
    10.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Bundle.properties	Thu Nov 23 12:01:23 2006 +0000
    10.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Bundle.properties	Wed Dec 13 11:35:25 2006 +0000
    10.3 @@ -17,5 +17,9 @@
    10.4  # Microsystems, Inc. All Rights Reserved.
    10.5  
    10.6  # Engine
    10.7 -CTL_Display_Name=Text on diagram
    10.8 -CTL_Short_Description=Searches text on diagram
    10.9 +CTL_Engine_Display_Name=Text on diagram
   10.10 +CTL_Engine_Short_Description=Searches text on diagram
   10.11 +
   10.12 +# Construct
   10.13 +CTL_Construct_Display_Name=BPEL Construct
   10.14 +CTL_Construct_Short_Description=Searches bpel elements by Component Kind, Attribute Declaration or Attribute Value
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Construct.java	Wed Dec 13 11:35:25 2006 +0000
    11.3 @@ -0,0 +1,115 @@
    11.4 +/*
    11.5 + * The contents of this file are subject to the terms of the Common Development
    11.6 + * and Distribution License (the License). You may not use this file except in
    11.7 + * compliance with the License.
    11.8 + *
    11.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   11.10 + * or http://www.netbeans.org/cddl.txt.
   11.11 + *
   11.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
   11.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
   11.14 + * If applicable, add the following below the CDDL Header, with the fields
   11.15 + * enclosed by brackets [] replaced by your own identifying information:
   11.16 + * "Portions Copyrighted [year] [name of copyright owner]"
   11.17 + *
   11.18 + * The Original Software is NetBeans. The Initial Developer of the Original
   11.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   11.20 + * Microsystems, Inc. All Rights Reserved.
   11.21 + */
   11.22 +package org.netbeans.modules.bpel.search.impl.diagram;
   11.23 +
   11.24 +import java.util.Iterator;
   11.25 +import java.util.List;
   11.26 +
   11.27 +import org.w3c.dom.NamedNodeMap;
   11.28 +import org.w3c.dom.Node;
   11.29 +import org.openide.util.NbBundle;
   11.30 +
   11.31 +import org.netbeans.modules.bpel.model.api.BpelEntity;
   11.32 +
   11.33 +import org.netbeans.modules.bpel.design.DesignView;
   11.34 +import org.netbeans.modules.bpel.design.model.DiagramModel;
   11.35 +import org.netbeans.modules.bpel.design.model.elements.VisualElement;
   11.36 +import org.netbeans.modules.bpel.design.model.patterns.Pattern;
   11.37 +
   11.38 +import org.netbeans.modules.bpel.search.api.SearchOption;
   11.39 +
   11.40 +/**
   11.41 + * @author Vladimir Yaroslavskiy
   11.42 + * @version 2006.12.05
   11.43 + */
   11.44 +public final class Construct extends Engine {
   11.45 +
   11.46 +  /**{@inheritDoc}*/
   11.47 +  public void search(SearchOption option) {
   11.48 +    DesignView view = (DesignView) option.getSource();
   11.49 +    myModel = view.getModel();
   11.50 +    Util.getDecorator(view).clearHighlighting();
   11.51 +//out();
   11.52 +    fireSearchStarted(option);
   11.53 +    search(getRoot(myModel, option.useSelection()).getOMReference(), ""); // NOI18N
   11.54 +    fireSearchFinished(option);
   11.55 +  }
   11.56 +
   11.57 +  private void search(BpelEntity element, String indent) {
   11.58 +    if (element == null) {
   11.59 +      return;
   11.60 +    }
   11.61 +    process(element, indent);
   11.62 +    List<BpelEntity> children = element.getChildren();
   11.63 +  
   11.64 +    for (BpelEntity entity : children) {
   11.65 +      search(entity, indent + "    "); // NOI18N
   11.66 +    }
   11.67 +  }
   11.68 +
   11.69 +  private void process(BpelEntity element, String indent) {
   11.70 +    Pattern pattern = myModel.getPattern(element);
   11.71 +
   11.72 +    if (pattern == null) {
   11.73 +      return;
   11.74 +    }
   11.75 +    Iterator<VisualElement> iterator = pattern.getElements().iterator();
   11.76 +
   11.77 +    if ( !iterator.hasNext()) {
   11.78 +      return;
   11.79 +    }
   11.80 +    if (acceptsAttribute(element) || acceptsComponent(element)) {
   11.81 +//out(indent + "      add.");
   11.82 +      fireSearchFound(new Element(iterator.next()));
   11.83 +    }
   11.84 +  }
   11.85 +
   11.86 +  private boolean acceptsAttribute(BpelEntity element) {
   11.87 +    NamedNodeMap attributes = element.getPeer().getAttributes();
   11.88 +
   11.89 +    for (int i=0; i < attributes.getLength(); i++) {
   11.90 +      Node attribute = attributes.item(i);
   11.91 +     
   11.92 +      if (accepts(attribute.getNodeName())) {
   11.93 +        return true;
   11.94 +      }
   11.95 +      if (accepts(attribute.getNodeValue())) {
   11.96 +        return true;
   11.97 +      }
   11.98 +    }
   11.99 +    return false;
  11.100 +  }
  11.101 +
  11.102 +  private boolean acceptsComponent(BpelEntity element) {
  11.103 +    return accepts(element.getPeer().getTagName());
  11.104 +  }
  11.105 +
  11.106 +  /**{@inheritDoc}*/
  11.107 +  public String getDisplayName() {
  11.108 +    return NbBundle.getMessage(Engine.class, "CTL_Construct_Display_Name"); // NOI18N
  11.109 +  }
  11.110 +
  11.111 +  /**{@inheritDoc}*/
  11.112 +  public String getShortDescription() {
  11.113 +    return NbBundle.getMessage(
  11.114 +      Engine.class, "CTL_Construct_Short_Description"); // NOI18N
  11.115 +  }
  11.116 +
  11.117 +  private DiagramModel myModel;
  11.118 +}
    12.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Element.java	Thu Nov 23 12:01:23 2006 +0000
    12.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Element.java	Wed Dec 13 11:35:25 2006 +0000
    12.3 @@ -18,11 +18,12 @@
    12.4   */
    12.5  package org.netbeans.modules.bpel.search.impl.diagram;
    12.6  
    12.7 +import org.netbeans.modules.bpel.model.api.BpelEntity;
    12.8 +import org.netbeans.modules.bpel.design.DesignView;
    12.9  import org.netbeans.modules.bpel.design.model.elements.VisualElement;
   12.10  import org.netbeans.modules.bpel.design.model.patterns.Pattern;
   12.11  
   12.12  import org.netbeans.modules.bpel.search.api.SearchElement;
   12.13 -import org.netbeans.modules.bpel.search.api.SearchLog;
   12.14  
   12.15  /**
   12.16   * @author Vladimir Yaroslavskiy
   12.17 @@ -33,22 +34,44 @@
   12.18    Element(VisualElement element) {
   12.19      super(element.getText(), element.getText(), null, null);
   12.20      myElement = element;
   12.21 +    highlight(true);
   12.22    }
   12.23  
   12.24 -  public void selectOnDiagram() {
   12.25 -//out("select: " + this);
   12.26 -    Pattern pattern = myElement.getPattern();
   12.27 -    pattern.getModel().getView().getSelectionModel().setSelected(pattern);
   12.28 +  @Override
   12.29 +  public void gotoSource()
   12.30 +  {
   12.31 +//out("goto source: " + this); // todo a
   12.32    }
   12.33  
   12.34 -  public void gotoSource() {}
   12.35 +  @Override
   12.36 +  public void select()
   12.37 +  {
   12.38 +//out("select: " + getText());
   12.39 +    Pattern pattern = myElement.getPattern();
   12.40 +    DesignView view = pattern.getModel().getView();
   12.41  
   12.42 -  private void out() {
   12.43 -    SearchLog.out();
   12.44 +    // select
   12.45 +    view.getSelectionModel().setSelectedPattern(pattern);
   12.46 +
   12.47 +    // glow
   12.48 +    getDecorator().select(getEntity());
   12.49 +
   12.50 +    // scroll
   12.51 +    myElement.scrollTo();
   12.52    }
   12.53  
   12.54 -  private void out(Object object) {
   12.55 -    SearchLog.out(object);
   12.56 +  @Override
   12.57 +  public void highlight(boolean highlighted)
   12.58 +  {
   12.59 +    getDecorator().highlight(getEntity(), highlighted);
   12.60 +  }
   12.61 +
   12.62 +  private BpelEntity getEntity() {
   12.63 +    return myElement.getPattern().getOMReference();
   12.64 +  }
   12.65 +
   12.66 +  private Decorator getDecorator() {
   12.67 +    return Util.getDecorator(myElement.getPattern().getModel().getView());
   12.68    }
   12.69  
   12.70    private VisualElement myElement;
    13.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Engine.java	Thu Nov 23 12:01:23 2006 +0000
    13.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/diagram/Engine.java	Wed Dec 13 11:35:25 2006 +0000
    13.3 @@ -28,45 +28,31 @@
    13.4  import org.netbeans.modules.bpel.design.model.patterns.CompositePattern;
    13.5  import org.netbeans.modules.bpel.design.model.patterns.Pattern;
    13.6  
    13.7 -import org.netbeans.modules.bpel.search.api.SearchLog;
    13.8 -import org.netbeans.modules.bpel.search.api.SearchManagerAccess;
    13.9  import org.netbeans.modules.bpel.search.api.SearchOption;
   13.10 -import org.netbeans.modules.bpel.search.api.SearchPattern;
   13.11  import org.netbeans.modules.bpel.search.spi.SearchEngine;
   13.12  
   13.13  /**
   13.14   * @author Vladimir Yaroslavskiy
   13.15   * @version 2006.11.13
   13.16   */
   13.17 -public final class Engine extends SearchEngine.Adapter {
   13.18 +public class Engine extends SearchEngine.Adapter {
   13.19  
   13.20    /**{@inheritDoc}*/
   13.21 -  public String getDisplayName() {
   13.22 -    return NbBundle.getMessage(Engine.class, "CTL_Display_Name"); // NOI18N
   13.23 +  public void search(SearchOption option) {
   13.24 +    DesignView view = (DesignView) option.getSource();
   13.25 +    DiagramModel model = view.getModel();
   13.26 +    Util.getDecorator(view).clearHighlighting();
   13.27 +//out();
   13.28 +    fireSearchStarted(option);
   13.29 +    search(getRoot(model, option.useSelection()), ""); // NOI18N
   13.30 +    fireSearchFinished(option);
   13.31    }
   13.32  
   13.33 -  /**{@inheritDoc}*/
   13.34 -  public String getShortDescription() {
   13.35 -    return NbBundle.getMessage(Engine.class, "CTL_Short_Description"); // NOI18N
   13.36 -  }
   13.37 -
   13.38 -  /**{@inheritDoc}*/
   13.39 -  public boolean accepts(Object source) {
   13.40 -    return source instanceof DesignView;
   13.41 -  }
   13.42 -
   13.43 -  /**{@inheritDoc}*/
   13.44 -  public void search(SearchOption searchOption) {
   13.45 -    DesignView designView = (DesignView) searchOption.getSource();
   13.46 -    DiagramModel model = designView.getModel();
   13.47 -    mySearchPattern = SearchManagerAccess.getManager().getPattern(
   13.48 -      searchOption.getText(),
   13.49 -      searchOption.getSearchMatch(),
   13.50 -      searchOption.isCaseSensitive());
   13.51 -//out();
   13.52 -    fireSearchStarted(searchOption);
   13.53 -    search(model.getRootPattern(), ""); // NOI18N
   13.54 -    fireSearchFinished();
   13.55 +  protected Pattern getRoot(DiagramModel model, boolean useSelection) {
   13.56 +    if (useSelection) {
   13.57 +      return model.getView().getSelectionModel().getSelectedPattern();
   13.58 +    }
   13.59 +    return model.getRootPattern();
   13.60    }
   13.61  
   13.62    private void search(Pattern pattern, String indent) {
   13.63 @@ -97,26 +83,27 @@
   13.64        return;
   13.65      }
   13.66      String text = element.getText();
   13.67 -
   13.68 -    if (text == null) {
   13.69 -      return;
   13.70 -    }
   13.71 -    text = text.trim();
   13.72  //out(indent + " see: " + text);
   13.73  
   13.74 -    if (mySearchPattern.accepts(text)) {
   13.75 +    if (accepts(text)) {
   13.76  //out(indent + "      add.");
   13.77        fireSearchFound(new Element(element));
   13.78      }
   13.79    }
   13.80  
   13.81 -  private void out() {
   13.82 -    SearchLog.out();
   13.83 +  /**{@inheritDoc}*/
   13.84 +  public boolean accepts(Object source) {
   13.85 +    return source instanceof DesignView;
   13.86    }
   13.87  
   13.88 -  private void out(Object object) {
   13.89 -    SearchLog.out(object);
   13.90 +  /**{@inheritDoc}*/
   13.91 +  public String getDisplayName() {
   13.92 +    return NbBundle.getMessage(Engine.class, "CTL_Engine_Display_Name"); // NOI18N
   13.93    }
   13.94  
   13.95 -  private SearchPattern mySearchPattern;
   13.96 +  /**{@inheritDoc}*/
   13.97 +  public String getShortDescription() {
   13.98 +    return NbBundle.getMessage(
   13.99 +      Engine.class, "CTL_Engine_Short_Description"); // NOI18N
  13.100 +  }
  13.101  }
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/model/Bundle.properties	Wed Dec 13 11:35:25 2006 +0000
    14.3 @@ -0,0 +1,21 @@
    14.4 +#
    14.5 +# The contents of this file are subject to the terms of the Common Development
    14.6 +# and Distribution License (the License). You may not use this file except in
    14.7 +# compliance with the License.
    14.8 +#
    14.9 +# You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   14.10 +# or http://www.netbeans.org/cddl.txt.
   14.11 +#
   14.12 +# When distributing Covered Code, include this CDDL Header Notice in each file
   14.13 +# and include the License file at http://www.netbeans.org/cddl.txt.
   14.14 +# If applicable, add the following below the CDDL Header, with the fields
   14.15 +# enclosed by brackets [] replaced by your own identifying information:
   14.16 +# "Portions Copyrighted [year] [name of copyright owner]"
   14.17 +#
   14.18 +# The Original Software is NetBeans. The Initial Developer of the Original
   14.19 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   14.20 +# Microsystems, Inc. All Rights Reserved.
   14.21 +
   14.22 +# Engine
   14.23 +CTL_Engine_Display_Name=Name of bpel element
   14.24 +CTL_Engine_Short_Description=Searches bpel elements by given name and type
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/model/Element.java	Wed Dec 13 11:35:25 2006 +0000
    15.3 @@ -0,0 +1,135 @@
    15.4 +/*
    15.5 + * The contents of this file are subject to the terms of the Common Development
    15.6 + * and Distribution License (the License). You may not use this file except in
    15.7 + * compliance with the License.
    15.8 + *
    15.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   15.10 + * or http://www.netbeans.org/cddl.txt.
   15.11 + *
   15.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
   15.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
   15.14 + * If applicable, add the following below the CDDL Header, with the fields
   15.15 + * enclosed by brackets [] replaced by your own identifying information:
   15.16 + * "Portions Copyrighted [year] [name of copyright owner]"
   15.17 + *
   15.18 + * The Original Software is NetBeans. The Initial Developer of the Original
   15.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   15.20 + * Microsystems, Inc. All Rights Reserved.
   15.21 + */
   15.22 +package org.netbeans.modules.bpel.search.impl.model;
   15.23 +
   15.24 +import javax.swing.Icon;
   15.25 +
   15.26 +import org.netbeans.modules.bpel.editors.api.nodes.NodeType;
   15.27 +import org.netbeans.modules.bpel.editors.api.utils.Util;
   15.28 +import org.netbeans.modules.bpel.model.api.BpelEntity;
   15.29 +import org.netbeans.modules.bpel.model.api.NamedElement;
   15.30 +
   15.31 +import org.netbeans.modules.bpel.search.api.SearchElement;
   15.32 +
   15.33 +/**
   15.34 + * @author Vladimir Yaroslavskiy
   15.35 + * @version 2006.11.17
   15.36 + */
   15.37 +final class Element extends SearchElement.Adapter {
   15.38 +
   15.39 +  Element(BpelEntity element) {
   15.40 +    super(
   15.41 +      getText(element),
   15.42 +      getToolTip(element),
   15.43 +      getIcon(element),
   15.44 +      getParent(element)); 
   15.45 +
   15.46 +    myElement = element;
   15.47 +  }
   15.48 +
   15.49 +  /**{@inheritDoc}*/
   15.50 +  @Override
   15.51 +  public void select()
   15.52 +  {
   15.53 +//out("select: " + this); // todo a
   15.54 +  }
   15.55 +
   15.56 +  /**{@inheritDoc}*/
   15.57 +  @Override
   15.58 +  public void highlight(boolean highlighted)
   15.59 +  {
   15.60 +  // todo a
   15.61 +  }
   15.62 +
   15.63 +  /**{@inheritDoc}*/
   15.64 +  @Override
   15.65 +  public void gotoSource()
   15.66 +  {
   15.67 +//out("goto source: " + this); // todo a
   15.68 +  }
   15.69 +
   15.70 +  /**{@inheritDoc}*/
   15.71 +  @Override
   15.72 +  public boolean equals(Object object)
   15.73 +  {
   15.74 +    if ( !(object instanceof Element)) {
   15.75 +      return false;
   15.76 +    }
   15.77 +    return ((Element) object).myElement.equals(myElement);
   15.78 +  }
   15.79 +
   15.80 +  /**{@inheritDoc}*/
   15.81 +  @Override
   15.82 +  public int hashCode()
   15.83 +  {
   15.84 +    return myElement.hashCode();
   15.85 +  }
   15.86 +
   15.87 +  private static String getText(BpelEntity element) {
   15.88 +    String name = getName(element);
   15.89 +
   15.90 +    if (name != null) {
   15.91 +      return name;
   15.92 +    }
   15.93 +    return getType(element);
   15.94 +  }
   15.95 +
   15.96 +  private static String getToolTip(BpelEntity element) {
   15.97 +    String name = getName(element);
   15.98 +    String type = getType(element);
   15.99 +
  15.100 +    if (name == null) {
  15.101 +      return type;
  15.102 +    }
  15.103 +    return type + " '" + name + "'"; // NOI18N
  15.104 +  }
  15.105 +
  15.106 +  private static SearchElement getParent(BpelEntity element) {
  15.107 +    BpelEntity parent = element.getParent();
  15.108 +
  15.109 +    if (parent == null) {
  15.110 +      return null;
  15.111 +    }
  15.112 +    return new Element(parent);
  15.113 +  }
  15.114 +
  15.115 +  private static String getName(BpelEntity element) {
  15.116 +    if (element instanceof NamedElement) {
  15.117 +      return ((NamedElement) element).getName();
  15.118 +    }
  15.119 +    return null;
  15.120 +  }
  15.121 +
  15.122 +  private static String getType(BpelEntity element) {
  15.123 +    String type = element.getElementType().getName();
  15.124 +    int k = type.lastIndexOf("."); // NOI18N
  15.125 +
  15.126 +    if (k == -1) {
  15.127 +      return type;
  15.128 +    }
  15.129 +    return type.substring(k + 1);
  15.130 +  }
  15.131 +
  15.132 +  private static Icon getIcon(BpelEntity element) {
  15.133 +    NodeType node = Util.getBasicNodeType(element);
  15.134 +    return node.getIcon();
  15.135 +  }
  15.136 +
  15.137 +  private BpelEntity myElement;
  15.138 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/model/Engine.java	Wed Dec 13 11:35:25 2006 +0000
    16.3 @@ -0,0 +1,87 @@
    16.4 +/*
    16.5 + * The contents of this file are subject to the terms of the Common Development
    16.6 + * and Distribution License (the License). You may not use this file except in
    16.7 + * compliance with the License.
    16.8 + *
    16.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   16.10 + * or http://www.netbeans.org/cddl.txt.
   16.11 + *
   16.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
   16.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
   16.14 + * If applicable, add the following below the CDDL Header, with the fields
   16.15 + * enclosed by brackets [] replaced by your own identifying information:
   16.16 + * "Portions Copyrighted [year] [name of copyright owner]"
   16.17 + *
   16.18 + * The Original Software is NetBeans. The Initial Developer of the Original
   16.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   16.20 + * Microsystems, Inc. All Rights Reserved.
   16.21 + */
   16.22 +package org.netbeans.modules.bpel.search.impl.model;
   16.23 +
   16.24 +import java.util.List;
   16.25 +import org.openide.util.NbBundle;
   16.26 +
   16.27 +import org.netbeans.modules.bpel.model.api.BpelEntity;
   16.28 +import org.netbeans.modules.bpel.model.api.BpelModel;
   16.29 +import org.netbeans.modules.bpel.model.api.NamedElement;
   16.30 +
   16.31 +import org.netbeans.modules.bpel.search.api.SearchOption;
   16.32 +import org.netbeans.modules.bpel.search.spi.SearchEngine;
   16.33 +
   16.34 +/**
   16.35 + * @author Vladimir Yaroslavskiy
   16.36 + * @version 2006.11.13
   16.37 + */
   16.38 +public final class Engine extends SearchEngine.Adapter {
   16.39 +
   16.40 +  /**{@inheritDoc}*/
   16.41 +  public void search(SearchOption option) {
   16.42 +    BpelModel model = (BpelModel) option.getSource();
   16.43 +//out();
   16.44 +    fireSearchStarted(option);
   16.45 +    search(model.getProcess(), ""); // NOI18N
   16.46 +    fireSearchFinished(option);
   16.47 +  }
   16.48 +
   16.49 +  private void search(BpelEntity element, String indent) {
   16.50 +    if (element == null) {
   16.51 +      return;
   16.52 +    }
   16.53 +    process(element, indent);
   16.54 +    List<BpelEntity> children = element.getChildren();
   16.55 +  
   16.56 +    for (BpelEntity entity : children) {
   16.57 +      search(entity, indent + "    "); // NOI18N
   16.58 +    }
   16.59 +  }
   16.60 +
   16.61 +  private void process(BpelEntity element, String indent) {
   16.62 +    if ( !(element instanceof NamedElement)) {
   16.63 +      return;
   16.64 +    }
   16.65 +    NamedElement named = (NamedElement) element;
   16.66 +    String text = named.getName();
   16.67 +//out(indent + " see: " + text);
   16.68 +
   16.69 +    if (accepts(text)) {
   16.70 +//out(indent + "      add.");
   16.71 +      fireSearchFound(new Element(element));
   16.72 +    }
   16.73 +  }
   16.74 +
   16.75 +  /**{@inheritDoc}*/
   16.76 +  public boolean accepts(Object source) {
   16.77 +    return source instanceof BpelModel;
   16.78 +  }
   16.79 +
   16.80 +  /**{@inheritDoc}*/
   16.81 +  public String getDisplayName() {
   16.82 +    return NbBundle.getMessage(Engine.class, "CTL_Engine_Display_Name"); // NOI18N
   16.83 +  }
   16.84 +
   16.85 +  /**{@inheritDoc}*/
   16.86 +  public String getShortDescription() {
   16.87 +    return NbBundle.getMessage(
   16.88 +      Engine.class, "CTL_Engine_Short_Description"); // NOI18N
   16.89 +  }
   16.90 +}
    17.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/resources/layer.xml	Thu Nov 23 12:01:23 2006 +0000
    17.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/resources/layer.xml	Wed Dec 13 11:35:25 2006 +0000
    17.3 @@ -22,25 +22,36 @@
    17.4  <filesystem>
    17.5      <folder name="Actions">
    17.6          <folder name="Edit">
    17.7 -            <file name="org-netbeans-modules-bpel-search-impl-action-SearchAction.instance"/>
    17.8 +            <file name="org-netbeans-modules-bpel-search-impl-action-Search.instance"/>
    17.9          </folder>
   17.10      </folder>
   17.11      
   17.12      <folder name="Menu">
   17.13          <folder name="Edit">
   17.14 -            <file name="org-netbeans-modules-bpel-search-impl-action-SearchAction.shadow">
   17.15 -                <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-bpel-search-impl-action-SearchAction.instance"/>
   17.16 +            <file name="org-netbeans-modules-bpel-search-impl-action-Search.shadow">
   17.17 +                <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-bpel-search-impl-action-Search.instance"/>
   17.18              </file>
   17.19  
   17.20              <!-- sorting -->
   17.21 -            <attr name="WhereUsedAction.instance/org-netbeans-modules-bpel-search-impl-action-SearchAction.shadow" boolvalue="true"/>
   17.22 -            <attr name="org-netbeans-modules-bpel-search-impl-action-SearchAction.shadow/org-netbeans-modules-search-project-ProjectsSearchAction.instance" boolvalue="true"/>
   17.23 +            <attr name="WhereUsedAction.instance/org-netbeans-modules-bpel-search-impl-action-Search.shadow" boolvalue="true"/>
   17.24 +            <attr name="org-netbeans-modules-bpel-search-impl-action-Search.shadow/org-netbeans-modules-search-project-ProjectsSearchAction.instance" boolvalue="true"/>
   17.25 +        </folder>
   17.26 +    </folder>
   17.27 +
   17.28 +    <folder name="Windows2">
   17.29 +        <folder name="Modes">
   17.30 +            <folder name="output">
   17.31 +                <file name="search.wstcref" url="search.wstcref"/>
   17.32 +            </folder>
   17.33 +        </folder>
   17.34 +        <folder name="Components">
   17.35 +            <file name="search.settings" url="search.settings"/>
   17.36          </folder>
   17.37      </folder>
   17.38  
   17.39      <folder name="Shortcuts">
   17.40          <file name="AS-F.shadow">
   17.41 -            <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-bpel-search-impl-action-SearchAction.instance"/>
   17.42 +            <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-bpel-search-impl-action-Search.instance"/>
   17.43          </file>
   17.44      </folder>
   17.45  </filesystem>
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/resources/search.settings	Wed Dec 13 11:35:25 2006 +0000
    18.3 @@ -0,0 +1,27 @@
    18.4 +<?xml version="1.0"?>
    18.5 +<!--
    18.6 +  The contents of this file are subject to the terms of the Common Development
    18.7 +  and Distribution License (the License). You may not use this file except in
    18.8 +  compliance with the License.
    18.9 +
   18.10 +  You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   18.11 +  or http://www.netbeans.org/cddl.txt.
   18.12 +
   18.13 +  When distributing Covered Code, include this CDDL Header Notice in each file
   18.14 +  and include the License file at http://www.netbeans.org/cddl.txt.
   18.15 +  If applicable, add the following below the CDDL Header, with the fields
   18.16 +  enclosed by brackets [] replaced by your own identifying information:
   18.17 +  "Portions Copyrighted [year] [name of copyright owner]"
   18.18 +
   18.19 +  The Original Software is NetBeans. The Initial Developer of the Original
   18.20 +  Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   18.21 +  Microsystems, Inc. All Rights Reserved.
   18.22 +-->
   18.23 +<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
   18.24 +
   18.25 +<settings version="1.0">
   18.26 +    <module name="org.netbeans.modules.bpel.search/1" spec="1.1"/>
   18.27 +    <instanceof class="org.openide.windows.TopComponent"/>
   18.28 +    <instanceof class="org.netbeans.modules.bpel.search.impl.ui.View"/>
   18.29 +    <instance class="org.netbeans.modules.bpel.search.impl.ui.View"/>
   18.30 +</settings>
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/resources/search.wstcref	Wed Dec 13 11:35:25 2006 +0000
    19.3 @@ -0,0 +1,26 @@
    19.4 +<?xml version="1.0" encoding="UTF-8"?>
    19.5 +<!--
    19.6 +  The contents of this file are subject to the terms of the Common Development
    19.7 +  and Distribution License (the License). You may not use this file except in
    19.8 +  compliance with the License.
    19.9 +
   19.10 +  You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   19.11 +  or http://www.netbeans.org/cddl.txt.
   19.12 +
   19.13 +  When distributing Covered Code, include this CDDL Header Notice in each file
   19.14 +  and include the License file at http://www.netbeans.org/cddl.txt.
   19.15 +  If applicable, add the following below the CDDL Header, with the fields
   19.16 +  enclosed by brackets [] replaced by your own identifying information:
   19.17 +  "Portions Copyrighted [year] [name of copyright owner]"
   19.18 +
   19.19 +  The Original Software is NetBeans. The Initial Developer of the Original
   19.20 +  Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   19.21 +  Microsystems, Inc. All Rights Reserved.
   19.22 +-->
   19.23 +<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd">
   19.24 +
   19.25 +<tc-ref version="2.0">
   19.26 +    <module name="org.netbeans.modules.bpel.search/1" spec="1.1"/>
   19.27 +    <tc-id id="search"/>
   19.28 +    <state opened="false"/>
   19.29 +</tc-ref>
    20.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Bundle.properties	Thu Nov 23 12:01:23 2006 +0000
    20.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Bundle.properties	Wed Dec 13 11:35:25 2006 +0000
    20.3 @@ -18,3 +18,21 @@
    20.4  
    20.5  # Provider
    20.6  CTL_Input_Description=Enter a text to be found
    20.7 +
    20.8 +# Search
    20.9 +LBL_Advanced_Search=Advanced Search
   20.10 +LBL_Search=Search
   20.11 +TLT_Search=Starts the search
   20.12 +
   20.13 +# Tree
   20.14 +# {0} - text to be find
   20.15 +# {1} - count of occurrences
   20.16 +LBL_Found_Occurrences=Found {1} occurrences of ''{0}''
   20.17 +LBL_Select_Action=Select on Diagram
   20.18 +
   20.19 +# View
   20.20 +# {0} - search result
   20.21 +CTL_Search_Results_Print=Search Results - {0}
   20.22 +CTL_Search_Results_Name=Search Results
   20.23 +CTL_Search_Results_Tooltip=Search Results
   20.24 +
    21.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Find.java	Thu Nov 23 12:01:23 2006 +0000
    21.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Find.java	Wed Dec 13 11:35:25 2006 +0000
    21.3 @@ -18,11 +18,32 @@
    21.4   */
    21.5  package org.netbeans.modules.bpel.search.impl.ui;
    21.6  
    21.7 -import java.util.Collections;
    21.8 +import java.awt.Event;
    21.9 +import java.awt.event.ActionEvent;
   21.10 +import java.awt.event.KeyEvent;
   21.11 +import java.util.ArrayList;
   21.12 +import java.util.List;
   21.13 +
   21.14 +import javax.swing.AbstractAction;
   21.15 +import javax.swing.Action;
   21.16 +import javax.swing.InputMap;
   21.17 +import javax.swing.JComponent;
   21.18 +import javax.swing.KeyStroke;
   21.19 +
   21.20 +import org.openide.actions.FindAction;
   21.21 +import org.openide.util.NbBundle;
   21.22  
   21.23  import org.netbeans.modules.xml.xam.ui.search.SearchControlPanel;
   21.24 +import org.netbeans.modules.xml.xam.ui.search.SearchProvider;
   21.25 +import org.netbeans.modules.xml.xam.ui.search.Query;
   21.26 +
   21.27 +import org.netbeans.modules.print.api.PrintUtil;
   21.28  import org.netbeans.modules.bpel.search.api.SearchElement;
   21.29 +import org.netbeans.modules.bpel.search.api.SearchEvent;
   21.30 +import org.netbeans.modules.bpel.search.api.SearchOption;
   21.31 +import org.netbeans.modules.bpel.search.api.SearchMatch;
   21.32  import org.netbeans.modules.bpel.search.spi.SearchEngine;
   21.33 +import org.netbeans.modules.bpel.search.spi.SearchListener;
   21.34  
   21.35  /**
   21.36   * @author Vladimir Yaroslavskiy
   21.37 @@ -31,16 +52,127 @@
   21.38  public final class Find extends SearchControlPanel {
   21.39  
   21.40    /**{@inheritDoc}*/
   21.41 -  public Find(SearchEngine engine, Object source) {
   21.42 +  public Find(List<SearchEngine> engines, Object source, JComponent parent) {
   21.43      super();
   21.44 -    setProviders(Collections.singleton(new Provider(engine, source)));
   21.45 +    bindAction(parent);
   21.46 +    List<Object> providers = new ArrayList<Object>();
   21.47 +
   21.48 +    for (SearchEngine engine : engines) {
   21.49 +      providers.add(new Provider(engine, source));
   21.50 +    }
   21.51 +    setProviders(providers);
   21.52    }
   21.53  
   21.54 -  protected void showSearchResult(Object object) {
   21.55 +  @Override
   21.56 +  protected void hideResults()
   21.57 +  {
   21.58 +//out("Hide selection");
   21.59 +    if (myElements == null) {
   21.60 +      return;
   21.61 +    }
   21.62 +    for (Object element : myElements) {
   21.63 +      ((SearchElement) element).highlight(false);
   21.64 +    }
   21.65 +    myElements = null;
   21.66 +  }
   21.67 +
   21.68 +  @Override
   21.69 +  protected void showSearchResult(Object object)
   21.70 +  {
   21.71 +//out("show");
   21.72      if ( !(object instanceof SearchElement)) {
   21.73        return;
   21.74      }
   21.75      SearchElement element = (SearchElement) object;
   21.76 -    element.selectOnDiagram();
   21.77 +    element.select();
   21.78    }
   21.79 +
   21.80 +  private void bindAction(JComponent parent) {
   21.81 +    FindAction findAction = (FindAction) FindAction.get(FindAction.class);
   21.82 +    Object mapKey = findAction.getActionMapKey();
   21.83 +    parent.getActionMap().put(mapKey, new AbstractAction () {
   21.84 +      public void actionPerformed(ActionEvent event) {
   21.85 +        setVisible( !isVisible());
   21.86 +      }
   21.87 +    });
   21.88 +    InputMap keys =
   21.89 +      parent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
   21.90 +    KeyStroke key = (KeyStroke) findAction.getValue(Action.ACCELERATOR_KEY);
   21.91 +
   21.92 +    if (key == null) {
   21.93 +      key = KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK);
   21.94 +    }
   21.95 +    keys.put(key, mapKey);
   21.96 +  }
   21.97 +
   21.98 +  private void out() {
   21.99 +    PrintUtil.out();
  21.100 +  }
  21.101 +
  21.102 +  private void out(Object object) {
  21.103 +    PrintUtil.out(object);
  21.104 +  }
  21.105 +
  21.106 +  // ---------------------------------------------------------------------
  21.107 +  private final class Provider implements SearchProvider, SearchListener {
  21.108 +    
  21.109 +    private Provider(SearchEngine engine, Object source) {
  21.110 +      mySearchEngine = engine;
  21.111 +      mySearchEngine.addSearchListener(this);
  21.112 +      mySource = source;
  21.113 +    }
  21.114 +
  21.115 +    public String getDisplayName() {
  21.116 +      return mySearchEngine.getDisplayName();
  21.117 +    }
  21.118 +
  21.119 +    public String getShortDescription() {
  21.120 +      return mySearchEngine.getShortDescription();
  21.121 +    }
  21.122 +
  21.123 +    public String getInputDescription() {
  21.124 +      return NbBundle.getMessage(Provider.class, "CTL_Input_Description"); // NOI18N
  21.125 +    }
  21.126 +
  21.127 +    public List<Object> search(Query query) {
  21.128 +      String text = query.getQuery();
  21.129 +
  21.130 +      SearchOption option = new SearchOption.Adapter(
  21.131 +        text,
  21.132 +        mySource,
  21.133 +        query.isRegularExpression() ?
  21.134 +          SearchMatch.REGULAR_EXPRESSION : getMatch(text),
  21.135 +        false, // case sensitive
  21.136 +        query.useSelected());
  21.137 +
  21.138 +      mySearchEngine.search(option);
  21.139 +
  21.140 +      return myElements;
  21.141 +    }
  21.142 +
  21.143 +    private SearchMatch getMatch(String text) {
  21.144 +      if (text.contains("*") || text.contains("?")) { // NOI18N
  21.145 +        return SearchMatch.PATTERN_MATCH;
  21.146 +      }
  21.147 +      return null;
  21.148 +    }
  21.149 +
  21.150 +    public void searchStarted(SearchEvent event) {
  21.151 +      myElements = new ArrayList<Object>();
  21.152 +    }
  21.153 +
  21.154 +    public void searchFound(SearchEvent event) {
  21.155 +      myElements.add(event.getSearchElement());
  21.156 +    }
  21.157 +
  21.158 +    public void searchFinished(SearchEvent event) {
  21.159 +      myCurrentIndex = 0;
  21.160 +    }
  21.161 +
  21.162 +    private Object mySource;
  21.163 +    private SearchEngine mySearchEngine;
  21.164 +  }
  21.165 +
  21.166 +  private int myCurrentIndex;
  21.167 +  private List<Object> myElements;
  21.168  }
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Search.java	Wed Dec 13 11:35:25 2006 +0000
    22.3 @@ -0,0 +1,280 @@
    22.4 +/*
    22.5 + * The contents of this file are subject to the terms of the Common Development
    22.6 + * and Distribution License (the License). You may not use this file except in
    22.7 + * compliance with the License.
    22.8 + *
    22.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   22.10 + * or http://www.netbeans.org/cddl.txt.
   22.11 + *
   22.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
   22.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
   22.14 + * If applicable, add the following below the CDDL Header, with the fields
   22.15 + * enclosed by brackets [] replaced by your own identifying information:
   22.16 + * "Portions Copyrighted [year] [name of copyright owner]"
   22.17 + *
   22.18 + * The Original Software is NetBeans. The Initial Developer of the Original
   22.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   22.20 + * Microsystems, Inc. All Rights Reserved.
   22.21 + */
   22.22 +package org.netbeans.modules.bpel.search.impl.ui;
   22.23 +
   22.24 +import java.awt.Color;
   22.25 +import java.awt.Component;
   22.26 +import java.awt.Dimension;
   22.27 +import java.awt.GridBagConstraints;
   22.28 +import java.awt.GridBagLayout;
   22.29 +import java.awt.Insets;
   22.30 +import java.awt.Point;
   22.31 +import java.awt.Toolkit;
   22.32 +import java.awt.event.ActionEvent;
   22.33 +import java.awt.event.ActionListener;
   22.34 +import java.awt.event.KeyAdapter;
   22.35 +import java.awt.event.KeyEvent;
   22.36 +import java.awt.event.MouseAdapter;
   22.37 +import java.awt.event.MouseEvent;
   22.38 +import java.awt.event.MouseWheelEvent;
   22.39 +import java.awt.event.MouseWheelListener;
   22.40 +import java.util.ArrayList;
   22.41 +import java.util.Date;
   22.42 +import java.util.List;
   22.43 +
   22.44 +import javax.swing.AbstractAction;
   22.45 +import javax.swing.JButton;
   22.46 +import javax.swing.JComponent;
   22.47 +import javax.swing.JPanel;
   22.48 +import javax.swing.JTextField;
   22.49 +import javax.swing.JToggleButton;
   22.50 +import javax.swing.JScrollPane;
   22.51 +import javax.swing.JViewport;
   22.52 +import javax.swing.ScrollPaneConstants;
   22.53 +import javax.swing.SwingUtilities;
   22.54 +
   22.55 +import org.openide.DialogDescriptor;
   22.56 +
   22.57 +import org.netbeans.modules.print.api.PrintUtil.Dialog;
   22.58 +import org.netbeans.modules.bpel.search.api.SearchOption;
   22.59 +import org.netbeans.modules.bpel.search.api.SearchMatch;
   22.60 +import org.netbeans.modules.bpel.search.spi.SearchEngine;
   22.61 +import org.netbeans.modules.bpel.search.spi.SearchListener;
   22.62 +
   22.63 +/**
   22.64 + * @author Vladimir Yaroslavskiy
   22.65 + * @version 2006.11.23
   22.66 + */
   22.67 +public final class Search extends Dialog {
   22.68 +
   22.69 +  /**{@inheritDoc}*/
   22.70 +  public Component getComponent(List<SearchEngine> engines, Object source) {
   22.71 +    mySource = source;
   22.72 +    myTree = new Tree();
   22.73 +    mySearchEngine = engines.get(0);
   22.74 +    mySearchEngine.addSearchListener(myTree);
   22.75 +    show();
   22.76 +    return getComponent();
   22.77 +  }
   22.78 +
   22.79 +  private JPanel createMainPanel() {
   22.80 +//out("Create Main panel");
   22.81 +    JPanel panel = new JPanel(new GridBagLayout());
   22.82 +    GridBagConstraints c = new GridBagConstraints();
   22.83 +    c.gridy = 1;
   22.84 +
   22.85 +    // text field
   22.86 +    myText = new JTextField("*"); // todo r
   22.87 +    // todo m
   22.88 +    int width = TEXT_WIDTH;
   22.89 +    int height = myText.getPreferredSize().height;
   22.90 +    myText.setPreferredSize(new Dimension(width, height));
   22.91 +    myText.setMinimumSize(new Dimension(width, height));
   22.92 +    panel.add(myText, c);
   22.93 +
   22.94 +//    c.gridy++;
   22.95 +
   22.96 +    return panel;
   22.97 +  }
   22.98 +
   22.99 +  private JComponent createNavigatePanel() {
  22.100 +    JPanel panel = new JPanel(new GridBagLayout());
  22.101 +    GridBagConstraints c = new GridBagConstraints();
  22.102 +
  22.103 +    // first
  22.104 +    panel = new JPanel(new GridBagLayout());
  22.105 +    c.insets = new Insets(TINY_INSET, TINY_INSET, TINY_INSET, TINY_INSET);
  22.106 +/*
  22.107 +    myFirst = (JButton) createButton(new JButton(),
  22.108 +      "TLT_First", // NOI18N
  22.109 +      new AbstractAction(null, Util.getIcon("first")) { // NOI18N
  22.110 +        public void actionPerformed(ActionEvent event) {
  22.111 +          first();
  22.112 +        }
  22.113 +      }
  22.114 +    );
  22.115 +*/
  22.116 +    panel.add(myFirst, c);
  22.117 +
  22.118 +    // previous
  22.119 +    panel.add(myPrevious, c);
  22.120 +
  22.121 +//    int width = (int)Math.round(myPrevious.getPreferredSize().width/PREVIEW_FACTOR);
  22.122 +//    int height = myPrevious.getPreferredSize().height;
  22.123 +//    myGoto.setPreferredSize(new Dimension(width, height));
  22.124 +//    myGoto.setMinimumSize(new Dimension(width, height));
  22.125 +
  22.126 +//    myGoto.setHorizontalAlignment(JTextField.CENTER);
  22.127 +//    myGoto.setToolTipText(getMessage("TLT_Goto")); // NOI18N
  22.128 +//    myGoto.addActionListener(new ActionListener() {
  22.129 +//      public void actionPerformed(ActionEvent event) {
  22.130 +//        goTo();
  22.131 +//      }
  22.132 +//    });
  22.133 +//    panel.add(myGoto, c);
  22.134 +    
  22.135 +    // next
  22.136 +    panel.add(myNext, c);
  22.137 +
  22.138 +    // last
  22.139 +    panel.add(myLast, c);
  22.140 +
  22.141 +    return panel;
  22.142 +  }
  22.143 +
  22.144 +  private JComponent createScalePanel() {
  22.145 +//out("Create scale panel");
  22.146 +    JPanel panel = new JPanel(new GridBagLayout());
  22.147 +    GridBagConstraints c = new GridBagConstraints();
  22.148 +
  22.149 +    // fit to window
  22.150 +    c.insets = new Insets(TINY_INSET, MEDIUM_INSET, TINY_INSET, TINY_INSET);
  22.151 +    panel.add(myFit, c);
  22.152 +
  22.153 +    // decrease
  22.154 +    panel.add(myDecrease, c);
  22.155 +
  22.156 +    // increase
  22.157 +    panel.add(myIncrease, c);
  22.158 +
  22.159 +    return panel;
  22.160 +  }
  22.161 +
  22.162 +  private JComponent createScrollPanel() {
  22.163 +//out("Create scroll panel");
  22.164 +    GridBagConstraints c = new GridBagConstraints();
  22.165 +
  22.166 +    // papers
  22.167 +//    myPaperPanel = new JPanel(new GridBagLayout());
  22.168 +//    myPaperPanel.setBackground(Color.lightGray);
  22.169 +    JPanel panel = new JPanel(new GridBagLayout());
  22.170 +
  22.171 +    c.gridy = 1;
  22.172 +    c.anchor = GridBagConstraints.NORTHWEST;
  22.173 +    c.weightx = 1.0;
  22.174 +    c.weighty = 1.0;
  22.175 +    c.insets = new Insets(0, 0, 0, 0);
  22.176 +    panel.setBackground(Color.lightGray);
  22.177 +//    panel.add(myPaperPanel, c);
  22.178 +    //panel.setBorder(new javax.swing.border.LineBorder(java.awt.Color.yellow));
  22.179 +    //optionPanel.setBorder(new javax.swing.border.LineBorder(java.awt.Color.green));
  22.180 +    //myPaperPanel.setBorder(new javax.swing.border.LineBorder(java.awt.Color.green));
  22.181 +
  22.182 +    // scroll
  22.183 +    c.fill = GridBagConstraints.BOTH;
  22.184 +
  22.185 +    return null;
  22.186 +  }
  22.187 +
  22.188 +  private void search() {
  22.189 +//out("text: '" + myText.getText() + "'");
  22.190 +    SearchOption option = new SearchOption.Adapter(
  22.191 +      myText.getText(),
  22.192 +      mySource,
  22.193 +      SearchMatch.PATTERN_MATCH, // todo m
  22.194 +      false, // case sensitive
  22.195 +      false); // use selection
  22.196 +
  22.197 +    mySearchEngine.search(option);
  22.198 +  }
  22.199 +
  22.200 +  private void updateButtons() {
  22.201 +/*
  22.202 +    myGoto.setText (getPaper(myPaperNumber));
  22.203 +    myFirst.setEnabled (myPaperNumber > 1);
  22.204 +    myPrevious.setEnabled (myPaperNumber > 1);
  22.205 +    myGoto.setEnabled (enabled);
  22.206 +    myToggle.setEnabled (enabled);
  22.207 +    myFit.setEnabled (enabled);
  22.208 +    myIncrease.setEnabled (enabled);
  22.209 +    myDecrease.setEnabled (enabled);
  22.210 +    myPrnBtn.setEnabled (enabled);
  22.211 +    myOptBtn.setEnabled (enabled);
  22.212 +*/
  22.213 +// disable Search button if name is empty
  22.214 +  }
  22.215 +
  22.216 +  @Override
  22.217 +  protected void closed()
  22.218 +  {
  22.219 +    mySearchEngine.removeSearchListener(myTree);
  22.220 +    mySearchEngine = null;
  22.221 +    mySource = null;
  22.222 +    myTree = null;
  22.223 +  }
  22.224 +
  22.225 +  @Override
  22.226 +  protected void opened()
  22.227 +  {
  22.228 +//    myScrollPanel.requestFocus();
  22.229 +  }
  22.230 +
  22.231 +  @Override
  22.232 +  protected DialogDescriptor getDescriptor()
  22.233 +  {
  22.234 +    Object[] buttons = getButtons();
  22.235 +    DialogDescriptor descriptor = new DialogDescriptor(
  22.236 +      createMainPanel(),
  22.237 +      getMessage("LBL_Advanced_Search"), // NOI18N
  22.238 +      true,
  22.239 +      buttons,
  22.240 +      mySearchButton,
  22.241 +      DialogDescriptor.DEFAULT_ALIGN,
  22.242 +      null,
  22.243 +      null
  22.244 +    );
  22.245 +//    descriptor.setClosingOptions(
  22.246 +//      new Object[] { myPrnBtn, DialogDescriptor.CANCEL_OPTION });
  22.247 +
  22.248 +    return descriptor;
  22.249 +  }
  22.250 +
  22.251 +  private Object[] getButtons() {
  22.252 +    mySearchButton = (JButton) createButton(new JButton(),
  22.253 +      "TLT_Search", // NOI18N
  22.254 +      new AbstractAction(getMessage("LBL_Search")) { // NOI18N
  22.255 +        public void actionPerformed(ActionEvent event) {
  22.256 +          search();
  22.257 +        }
  22.258 +      }
  22.259 +    );
  22.260 +    return new Object[] {
  22.261 +      mySearchButton,
  22.262 +      DialogDescriptor.CANCEL_OPTION,
  22.263 +    };
  22.264 +  }
  22.265 +
  22.266 +  private JButton myFirst;
  22.267 +  private JButton myPrevious;
  22.268 +  private JButton myNext;
  22.269 +  private JButton myLast;
  22.270 +
  22.271 +  private JButton myFit;
  22.272 +  private JButton myIncrease;
  22.273 +  private JButton myDecrease;
  22.274 +
  22.275 +  
  22.276 +  private Object mySource;
  22.277 +  private JTextField myText;
  22.278 +  private SearchListener myTree;
  22.279 +  private JButton mySearchButton;
  22.280 +  private SearchEngine mySearchEngine;
  22.281 +
  22.282 +  private static final int TEXT_WIDTH = 100;
  22.283 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/Tree.java	Wed Dec 13 11:35:25 2006 +0000
    23.3 @@ -0,0 +1,594 @@
    23.4 +/*
    23.5 + * The contents of this file are subject to the terms of the Common Development
    23.6 + * and Distribution License (the License). You may not use this file except in
    23.7 + * compliance with the License.
    23.8 + *
    23.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   23.10 + * or http://www.netbeans.org/cddl.txt.
   23.11 + *
   23.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
   23.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
   23.14 + * If applicable, add the following below the CDDL Header, with the fields
   23.15 + * enclosed by brackets [] replaced by your own identifying information:
   23.16 + * "Portions Copyrighted [year] [name of copyright owner]"
   23.17 + *
   23.18 + * The Original Software is NetBeans. The Initial Developer of the Original
   23.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   23.20 + * Microsystems, Inc. All Rights Reserved.
   23.21 + */
   23.22 +package org.netbeans.modules.bpel.search.impl.ui;
   23.23 +
   23.24 +import java.util.ArrayList;
   23.25 +import java.util.Enumeration;
   23.26 +import java.util.Iterator;
   23.27 +import java.util.List;
   23.28 +
   23.29 +import java.awt.Component;
   23.30 +import java.awt.Dimension;
   23.31 +import java.awt.event.ActionEvent;
   23.32 +import java.awt.event.ActionListener;
   23.33 +import java.awt.event.KeyEvent;
   23.34 +import java.awt.event.KeyAdapter;
   23.35 +import java.awt.event.MouseAdapter;
   23.36 +import java.awt.event.MouseEvent;
   23.37 +
   23.38 +import javax.swing.JMenuItem;
   23.39 +import javax.swing.JPopupMenu;
   23.40 +import javax.swing.JTree;
   23.41 +import javax.swing.SwingUtilities;
   23.42 +import javax.swing.ToolTipManager;
   23.43 +import javax.swing.event.TreeExpansionEvent;
   23.44 +import javax.swing.event.TreeExpansionListener;
   23.45 +import javax.swing.event.TreeWillExpandListener;
   23.46 +import javax.swing.tree.DefaultMutableTreeNode;
   23.47 +import javax.swing.tree.DefaultTreeCellRenderer;
   23.48 +import javax.swing.tree.DefaultTreeModel;
   23.49 +import javax.swing.tree.MutableTreeNode;
   23.50 +import javax.swing.tree.TreeNode;
   23.51 +import javax.swing.tree.TreePath;
   23.52 +import javax.swing.tree.TreeSelectionModel;
   23.53 +
   23.54 +import org.openide.util.NbBundle;
   23.55 +import org.openide.windows.WindowManager;
   23.56 +
   23.57 +import org.netbeans.modules.print.api.PrintUtil;
   23.58 +import org.netbeans.modules.bpel.search.api.SearchEvent;
   23.59 +import org.netbeans.modules.bpel.search.api.SearchElement;
   23.60 +import org.netbeans.modules.bpel.search.spi.SearchListener;
   23.61 +import org.netbeans.modules.bpel.search.impl.util.Util;
   23.62 +
   23.63 +/**
   23.64 + * @author Vladimir Yaroslavskiy
   23.65 + * @version 2006.11.24
   23.66 + */
   23.67 +final class Tree implements SearchListener {
   23.68 +/*
   23.69 +  Tree() {
   23.70 +    myConfig = new Config (key);
   23.71 +    mySeparator = I18n.get (myConfig.get ("separator", "$separator." + myKey));
   23.72 +  }
   23.73 +// todo r
   23.74 +*/
   23.75 +  public void searchStarted(SearchEvent event) {
   23.76 +//out();
   23.77 +    myRoot = new DefaultMutableTreeNode();
   23.78 +    myFoundCount = 0;
   23.79 +  }
   23.80 +
   23.81 +  public void searchFound(SearchEvent event) {
   23.82 +    SearchElement element = event.getSearchElement();
   23.83 +//out("Found: " + element);
   23.84 +//out("       " + element.getText());
   23.85 +    addElement(myRoot, element, getElements(element));
   23.86 +    myFoundCount++;
   23.87 +  }
   23.88 +
   23.89 +  public void searchFinished(SearchEvent event) {
   23.90 +    String text = event.getSearchOption().getText();
   23.91 +    String count = String.valueOf(myFoundCount);
   23.92 +    String title = NbBundle.getMessage(
   23.93 +      Tree.class, "LBL_Found_Occurrences", text, myFoundCount); // NOI18N
   23.94 +    myRoot.setUserObject(
   23.95 +      new SearchElement.Adapter(title, title, Util.getIcon("find"), null)); // NOI18N
   23.96 +// todo r
   23.97 +//  factorizeRoot(myRoot);
   23.98 +    View view = (View) WindowManager.getDefault().findTopComponent(View.NAME);
   23.99 +    view.show(createTree());
  23.100 +  }
  23.101 +
  23.102 +  private JTree createTree() {
  23.103 +    myTree = new JTree(new DefaultTreeModel(myRoot));
  23.104 +    myTree.getSelectionModel().setSelectionMode(
  23.105 +      TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  23.106 +    ToolTipManager.sharedInstance().registerComponent(myTree);
  23.107 +    myTree.setCellRenderer(new TreeRenderer());
  23.108 +    myTree.setShowsRootHandles(false);
  23.109 +    myTree.setRootVisible(true);
  23.110 +
  23.111 +    myTree.addTreeWillExpandListener(new TreeWillExpandListener() {
  23.112 +      public void treeWillExpand(TreeExpansionEvent event) {
  23.113 +      }
  23.114 +      public void treeWillCollapse(TreeExpansionEvent event) {
  23.115 +//out("Will collapse: " + getNode(event.getPath()));
  23.116 +        collapseChildren(getNode(event.getPath()));
  23.117 +      }
  23.118 +    });
  23.119 +    myTree.addTreeExpansionListener(new TreeExpansionListener() {
  23.120 +      public void treeExpanded(TreeExpansionEvent event) {
  23.121 +//out("Expanded: " + getNode(event.getPath()));
  23.122 +        expandChildren(getNode(event.getPath()));
  23.123 +        updateSize();
  23.124 +      }
  23.125 +      public void treeCollapsed(TreeExpansionEvent event) {
  23.126 +        updateSize();
  23.127 +      }
  23.128 +    });
  23.129 +    myTree.addMouseListener(new MouseAdapter() {
  23.130 +      public void mousePressed(MouseEvent event) {
  23.131 +        if (SwingUtilities.isRightMouseButton(event)) {
  23.132 +          showPopupMenu(event);
  23.133 +        }
  23.134 +      }
  23.135 +      public void mouseClicked(MouseEvent event) {
  23.136 +        // simple click
  23.137 +        if (event.getClickCount() == 1) {
  23.138 +          select(getNode(event));
  23.139 +        }
  23.140 +      }
  23.141 +    });
  23.142 +    myTree.addKeyListener(new KeyAdapter() {
  23.143 +      public void keyReleased(KeyEvent event) {
  23.144 +        if (event.getKeyCode() == event.VK_ENTER) {
  23.145 +          reform(getSelectedNodes());
  23.146 +//todo a  goto(getSelectedNodes());
  23.147 +        }
  23.148 +      }
  23.149 +    });
  23.150 +    updateSize();
  23.151 +
  23.152 +    return myTree;
  23.153 +  }
  23.154 +
  23.155 +  private void updateSize() {
  23.156 +    myTree.putClientProperty(Dimension.class.getName(), myTree.getMaximumSize());
  23.157 +  }
  23.158 +
  23.159 +  private void showPopupMenu(MouseEvent event) {
  23.160 +    DefaultMutableTreeNode node = getNode(event);
  23.161 +    JPopupMenu popup = new JPopupMenu();
  23.162 +    JMenuItem item;
  23.163 +
  23.164 +    // select
  23.165 +    item = createItem("LBL_Select_Action"); // NOI18N
  23.166 +    item.addActionListener(new ActionListener() {
  23.167 +      public void actionPerformed(ActionEvent event) {
  23.168 +        select(getSelectedNodes());
  23.169 +      }
  23.170 +    });
  23.171 +    if ( !node.isRoot()) {
  23.172 +      popup.add(item);
  23.173 +    }
  23.174 +    popup.addSeparator();
  23.175 +    // todo start here
  23.176 +
  23.177 +    if (popup.getSubElements().length != 0) {
  23.178 +      popup.show(event.getComponent(), event.getX(), event.getY());
  23.179 +    }
  23.180 +  }
  23.181 +
  23.182 +  private JMenuItem createItem(String name) {
  23.183 +    return new JMenuItem(NbBundle.getMessage(Tree.class, name));
  23.184 +  }
  23.185 +
  23.186 +  private void select(DefaultMutableTreeNode [] nodes) {
  23.187 +    if (nodes == null) {
  23.188 +      return;
  23.189 +    }
  23.190 +    for (DefaultMutableTreeNode node : nodes) {
  23.191 +      select(node);
  23.192 +    }
  23.193 +  }
  23.194 +
  23.195 +  private void select(DefaultMutableTreeNode node) {
  23.196 +    if (node == null || node.isRoot()) {
  23.197 +      return;
  23.198 +    }
  23.199 +    ((SearchElement) node.getUserObject()).select();
  23.200 +  }
  23.201 +
  23.202 +  private void reform(DefaultMutableTreeNode [] nodes) {
  23.203 +    if (nodes == null) {
  23.204 +      return;
  23.205 +    }
  23.206 +    for (DefaultMutableTreeNode node : nodes) {
  23.207 +      reform(node);
  23.208 +    }
  23.209 +  }
  23.210 +
  23.211 +  private void reform(DefaultMutableTreeNode node) {
  23.212 +    if (node == null || node.isLeaf()) {
  23.213 +      return;
  23.214 +    }
  23.215 +    myIsReformAll = true;
  23.216 +    TreePath path = new TreePath(node.getPath());
  23.217 +    boolean isExpanded = myTree.isExpanded(path);
  23.218 +
  23.219 +    // for root special check
  23.220 +    if (node.isRoot()) {
  23.221 +      Enumeration children = node.children();
  23.222 +      isExpanded = false;
  23.223 +
  23.224 +      while (children.hasMoreElements()) {
  23.225 +        DefaultMutableTreeNode child =
  23.226 +          (DefaultMutableTreeNode) children.nextElement();
  23.227 +        isExpanded = myTree.isExpanded(new TreePath(child.getPath()));
  23.228 +
  23.229 +        if (isExpanded) {
  23.230 +          break;
  23.231 +        }
  23.232 +      }
  23.233 +    }
  23.234 +    if (isExpanded) {
  23.235 +      // collapse
  23.236 +      if (node.isRoot()) {
  23.237 +        collapseChildren(node);
  23.238 +      }
  23.239 +      else {
  23.240 +        myTree.collapsePath(path);
  23.241 +      }
  23.242 +    }
  23.243 +    else {
  23.244 +      // expand
  23.245 +      myTree.expandPath(path);
  23.246 +
  23.247 +      if (myTree.isExpanded(path)) {
  23.248 +        expandChildren(node);
  23.249 +      }
  23.250 +    }
  23.251 +    myIsReformAll = false;
  23.252 +  }
  23.253 +
  23.254 +  private void expandChildren(TreeNode node) {
  23.255 +    Enumeration children = node.children();
  23.256 +    
  23.257 +    if (myIsReformAll) {
  23.258 +      while (children.hasMoreElements()) {
  23.259 +        DefaultMutableTreeNode child =
  23.260 +          (DefaultMutableTreeNode) children.nextElement();
  23.261 +        TreePath path = new TreePath(child.getPath());
  23.262 +        myTree.expandPath(path);
  23.263 +
  23.264 +        if (myTree.isExpanded(path)) {
  23.265 +          expandChildren(child);
  23.266 +        }
  23.267 +      }
  23.268 +    }
  23.269 +    else {
  23.270 +      // process node which has only one child
  23.271 +      if (children.hasMoreElements()) {
  23.272 +        DefaultMutableTreeNode child =
  23.273 +          (DefaultMutableTreeNode) children.nextElement();
  23.274 +
  23.275 +        if ( !children.hasMoreElements()) {
  23.276 +          TreePath path = new TreePath(child.getPath());
  23.277 +          myTree.expandPath(path);
  23.278 +
  23.279 +          if (myTree.isExpanded(path)) {
  23.280 +            expandChildren(child);
  23.281 +          }
  23.282 +        }
  23.283 +      }
  23.284 +    }
  23.285 +  }
  23.286 +
  23.287 +  private void collapseChildren(TreeNode node) {
  23.288 +    if (myIsReformAll) {
  23.289 +      Enumeration children = node.children();
  23.290 +    
  23.291 +      while (children.hasMoreElements()) {
  23.292 +        DefaultMutableTreeNode child =
  23.293 +          (DefaultMutableTreeNode) children.nextElement();
  23.294 +        TreePath path = new TreePath(child.getPath());
  23.295 +        myTree.collapsePath(path);
  23.296 +      }
  23.297 +    }
  23.298 +  }
  23.299 +
  23.300 +  private DefaultMutableTreeNode getNode(MouseEvent event) {
  23.301 +    return getNode(myTree.getPathForLocation(event.getX(), event.getY()));
  23.302 +  }
  23.303 +
  23.304 +  private DefaultMutableTreeNode getNode(TreePath path) {
  23.305 +    if (path == null) {
  23.306 +      return null;
  23.307 +    }
  23.308 +    return (DefaultMutableTreeNode) path.getLastPathComponent();
  23.309 +  }
  23.310 +
  23.311 +  private DefaultMutableTreeNode [] getSelectedNodes() {
  23.312 +    TreePath [] treePaths = myTree.getSelectionPaths();
  23.313 +
  23.314 +    if (treePaths == null) {
  23.315 +      return null;
  23.316 +    }
  23.317 +    DefaultMutableTreeNode [] nodes = new DefaultMutableTreeNode[treePaths.length];
  23.318 +
  23.319 +    for (int i=0; i < treePaths.length; i++) {
  23.320 +      nodes [i] = getNode(treePaths[i]);
  23.321 +    }
  23.322 +    return nodes;
  23.323 +  }
  23.324 +
  23.325 +/*todo r
  23.326 +  private void factorizeRoot(DefaultMutableTreeNode root) {
  23.327 +    int count = root.getChildCount ();
  23.328 +
  23.329 +    for (int i=0; i < count; i++) {
  23.330 +      factorize ((DefaultMutableTreeNode) root.getChildAt (i));
  23.331 +    }
  23.332 +  }
  23.333 +
  23.334 +  private void factorize (DefaultMutableTreeNode node) {
  23.335 +//System.out.println ();
  23.336 +//System.out.println ("SEE: " + node);
  23.337 +    if (node.getChildCount () != 1) {
  23.338 +//System.out.println ("    return: has more children: " + node.getChildCount ());
  23.339 +      return;
  23.340 +    }
  23.341 +    DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt (0);
  23.342 +
  23.343 +    if (child.isLeaf ()) {
  23.344 +//System.out.println ("    return: child is leaf: " + child);
  23.345 +      return;
  23.346 +    }
  23.347 +    DefaultMutableTreeNode grandChild = (DefaultMutableTreeNode) child.getChildAt (0);
  23.348 +
  23.349 +    if (grandChild.isLeaf ()) {
  23.350 +//System.out.println ("    return: grandchild is leaf: " + grandchild);
  23.351 +      return;
  23.352 +    }
  23.353 +    // union node with child
  23.354 +//System.out.println ("==== see  node: " + node  + " " + ((SearchElement) node.getUserObject ()));
  23.355 +//System.out.println ("==== see child: " + child + " " + ((SearchElement) child.getUserObject ()));
  23.356 +    SearchElement searchElement = (SearchElement) child.getUserObject ();
  23.357 +    String text = "" + node + mySeparator + child;
  23.358 +    node.setUserObject (searchElement.clone (text));
  23.359 +//System.out.println ("==== set text: " + text);
  23.360 +
  23.361 +    node.remove (child);
  23.362 +//System.out.println ("      remove child: " + child);
  23.363 +
  23.364 +    Vector grandchildren = new Vector ();
  23.365 +    Enumeration children = child.children ();
  23.366 +
  23.367 +    while (children.hasMoreElements ()) {
  23.368 +      DefaultMutableTreeNode next = (DefaultMutableTreeNode) children.nextElement ();
  23.369 +      grandchildren.add (next);
  23.370 +//System.out.println ("        grandchild: " + next);
  23.371 +    }
  23.372 +//System.out.println ("        --------------------");
  23.373 +
  23.374 +    for (int i=0; i < grandchildren.size (); i++) {
  23.375 +      DefaultMutableTreeNode next = (DefaultMutableTreeNode) grandchildren.get (i);
  23.376 +      node.add (next); 
  23.377 +//System.out.println ("    add grandchild: " + next);
  23.378 +    }
  23.379 +//System.out.println ("           updated: " + node);
  23.380 +    factorize (node);
  23.381 +  }
  23.382 +
  23.383 +  public void copy () {
  23.384 +    DefaultMutableTreeNode [] nodes = getSelectedNodes();
  23.385 +
  23.386 +    if (nodes == null) {
  23.387 +      return;
  23.388 +    }
  23.389 +    StringBuffer buffer = new StringBuffer ();
  23.390 +
  23.391 +    for (int i=0; i < nodes.length; i++) {
  23.392 +      copy (nodes [i], buffer, "");
  23.393 +      buffer.append ("\n");
  23.394 +    }
  23.395 +    StringSelection stringSelection = new StringSelection (buffer.toString ());
  23.396 +    Toolkit.getDefaultToolkit ().getSystemClipboard ().setContents (stringSelection, stringSelection);
  23.397 +  }
  23.398 +
  23.399 +  private void copy (DefaultMutableTreeNode node, StringBuffer buffer, String indent) {
  23.400 +    buffer.append (indent + node + "\n");
  23.401 +    Enumeration children = node.children ();
  23.402 +
  23.403 +    while (children.hasMoreElements ()) {
  23.404 +      DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement ();
  23.405 +      copy (child, buffer, indent + "   ");
  23.406 +    }
  23.407 +  }
  23.408 +
  23.409 +  public void remove () {
  23.410 +    DefaultMutableTreeNode [] nodes = getSelectedNodes();
  23.411 +
  23.412 +    if (nodes == null) {
  23.413 +      return;
  23.414 +    }
  23.415 +    for (int i=0; i < nodes.length; i++) {
  23.416 +      DefaultMutableTreeNode parent = (DefaultMutableTreeNode) nodes [i].getParent ();
  23.417 +
  23.418 +      if (parent == null) {
  23.419 +        continue;
  23.420 +      }
  23.421 +      parent.remove (nodes [i]);
  23.422 +    }
  23.423 +//todo r    myTree.updateUI ();
  23.424 +myTree.revalidate();
  23.425 +myTree.repaint();
  23.426 +  }
  23.427 +
  23.428 +  public void removeAll () {
  23.429 +    DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTree.getModel ().getRoot ();
  23.430 +    root.removeAllChildren ();
  23.431 +//todo r    myTree.updateUI ();
  23.432 +myTree.revalidate();
  23.433 +myTree.repaint();
  23.434 +  }
  23.435 +
  23.436 +  public void export () { // todo rename save
  23.437 +    DefaultMutableTreeNode [] nodes = getSelectedNodes();
  23.438 +
  23.439 +    if (nodes == null) {
  23.440 +      return;
  23.441 +    }
  23.442 +    Vector descriptions = new Vector ();
  23.443 +
  23.444 +    for (int i=0; i < nodes.length; i++) {
  23.445 +      export (nodes [i], descriptions);
  23.446 +      descriptions.add (null);
  23.447 +    }
  23.448 +    if (myExport == null) {
  23.449 +      myExport = new Export ();
  23.450 +    }
  23.451 +    myExport.show (descriptions, myTitle);
  23.452 +  }
  23.453 +
  23.454 +  private void export (DefaultMutableTreeNode node, Vector descriptions) {
  23.455 +    if (node.isLeaf ()) {
  23.456 +      Vector description = new Vector ();
  23.457 +      description.add (getDescription (node));
  23.458 +      description.add ("" + node);
  23.459 +      descriptions.add (description);
  23.460 +    }
  23.461 +    Enumeration children = node.children ();
  23.462 +
  23.463 +    while (children.hasMoreElements ()) {
  23.464 +      DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement ();
  23.465 +      export (child, descriptions);
  23.466 +    }
  23.467 +  }
  23.468 +
  23.469 +  private String getDescription (DefaultMutableTreeNode node) {
  23.470 +    if (isRoot (node)) {
  23.471 +      return "";
  23.472 +    }
  23.473 +    String description = getDescription ((DefaultMutableTreeNode) node.getParent ());
  23.474 +
  23.475 +    if ( !node.isLeaf () ) {
  23.476 +      if ( !isRoot ((DefaultMutableTreeNode) node.getParent ())) {
  23.477 +        description += mySeparator;
  23.478 +      }
  23.479 +      description += node;
  23.480 +    }
  23.481 +    return description;
  23.482 +  }
  23.483 +
  23.484 +  private boolean isRoot (DefaultMutableTreeNode node) {
  23.485 +    if (node == null) {
  23.486 +      return true;
  23.487 +    }
  23.488 +    if (node.getParent () == null) {
  23.489 +      return true;
  23.490 +    }
  23.491 +    if (node.getParent ().getParent () == null) {
  23.492 +      return true;
  23.493 +    }
  23.494 +    return false;
  23.495 +  }
  23.496 +
  23.497 +  private String myId;
  23.498 +  private String myTitle;
  23.499 +  private String mySeparator;
  23.500 +  private Export myExport = null;
  23.501 +//todo r  private JPanel myPanel = new JPanel (new GridBagLayout ());
  23.502 +*/
  23.503 +  private void addElement(
  23.504 +    MutableTreeNode root,
  23.505 +    SearchElement element,
  23.506 +    Iterator<SearchElement> elements)
  23.507 +  {
  23.508 +    if (root == null) {
  23.509 +      return;
  23.510 +    }
  23.511 +    SearchElement next = null;
  23.512 +
  23.513 +    if (elements.hasNext()) {
  23.514 +      next = elements.next();
  23.515 +    }
  23.516 +    if (next == null) { // it is leaf
  23.517 +//out("add leaf: " + element);
  23.518 +      root.insert(new DefaultMutableTreeNode(element), 0);
  23.519 +      return;
  23.520 +    }
  23.521 +    // try to find node among children
  23.522 +    Enumeration children = root.children();
  23.523 +
  23.524 +//out("try to add child: " + next);
  23.525 +    while (children.hasMoreElements()) {
  23.526 +      DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
  23.527 +
  23.528 +      if (child.isLeaf()) {
  23.529 +//out("skip leaf: " + child);
  23.530 +        continue;
  23.531 +      }
  23.532 +//todo r      String text = ((SearchElement) child.getUserObject()).getText();
  23.533 +//out("see child: " + text);
  23.534 +//out("see next: " + next.toString());
  23.535 +
  23.536 +//todo r?      if (next.getText().equals(text)) {
  23.537 +//      if (next.toString().equals(child.toString())) {
  23.538 +      if (child.getUserObject().equals(next)) {
  23.539 +        // go to the next level
  23.540 +//out("next level");
  23.541 +        addElement(child, element, elements);
  23.542 +        return;
  23.543 +      }
  23.544 +    }
  23.545 +    // cannot find the same node, add new node
  23.546 +    MutableTreeNode node = new DefaultMutableTreeNode(next);
  23.547 +//out("add internal: " + next);
  23.548 +    root.insert(node, 0);
  23.549 +    addElement(node, element, elements);
  23.550 +  }
  23.551 +
  23.552 +  private Iterator<SearchElement> getElements(SearchElement element) {
  23.553 +    List<SearchElement> elements = new ArrayList<SearchElement>();
  23.554 +    SearchElement parent = element.getParent();
  23.555 +
  23.556 +    while (parent != null) {
  23.557 +      elements.add(0, parent);
  23.558 +      parent = parent.getParent();
  23.559 +    }
  23.560 +    return elements.iterator();
  23.561 +  }
  23.562 +
  23.563 +  private void out() {
  23.564 +    PrintUtil.out();
  23.565 +  }
  23.566 +
  23.567 +  private void out(Object object) {
  23.568 +    PrintUtil.out(object);
  23.569 +  }
  23.570 +
  23.571 +  // ----------------------------------------------------------------
  23.572 +  private static class TreeRenderer extends DefaultTreeCellRenderer {
  23.573 +
  23.574 +    public Component getTreeCellRendererComponent (
  23.575 +      JTree tree, Object value, boolean select, boolean expanded,
  23.576 +      boolean leaf, int row, boolean focus)
  23.577 +    {
  23.578 +      super.getTreeCellRendererComponent(
  23.579 +        tree, value, select, expanded, leaf, row, focus);
  23.580 +      SearchElement element =
  23.581 +        (SearchElement) ((DefaultMutableTreeNode) value).getUserObject();
  23.582 +      setText(element.getText());
  23.583 +      setToolTipText(element.getToolTip());
  23.584 +      setIcon(element.getIcon());
  23.585 +      return this;
  23.586 +    }
  23.587 +  }
  23.588 +
  23.589 +// todo r
  23.590 +//  private String myKey;
  23.591 +//  private Config myConfig;
  23.592 +//  private String mySeparator;
  23.593 +  private JTree myTree;
  23.594 +  private int myFoundCount;
  23.595 +  private boolean myIsReformAll;
  23.596 +  private MutableTreeNode myRoot;
  23.597 +}
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/ui/View.java	Wed Dec 13 11:35:25 2006 +0000
    24.3 @@ -0,0 +1,142 @@
    24.4 +/*
    24.5 + * The contents of this file are subject to the terms of the Common Development
    24.6 + * and Distribution License (the License). You may not use this file except in
    24.7 + * compliance with the License.
    24.8 + *
    24.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   24.10 + * or http://www.netbeans.org/cddl.txt.
   24.11 + *
   24.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
   24.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
   24.14 + * If applicable, add the following below the CDDL Header, with the fields
   24.15 + * enclosed by brackets [] replaced by your own identifying information:
   24.16 + * "Portions Copyrighted [year] [name of copyright owner]"
   24.17 + *
   24.18 + * The Original Software is NetBeans. The Initial Developer of the Original
   24.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   24.20 + * Microsystems, Inc. All Rights Reserved.
   24.21 + */
   24.22 +package org.netbeans.modules.bpel.search.impl.ui;
   24.23 +
   24.24 +import java.awt.Dimension;
   24.25 +import java.awt.GridBagConstraints;
   24.26 +import java.awt.GridBagLayout;
   24.27 +import java.awt.event.FocusEvent;
   24.28 +import java.awt.event.FocusListener;
   24.29 +import java.util.Date;
   24.30 +
   24.31 +import javax.swing.JScrollPane;
   24.32 +import javax.swing.JTree;
   24.33 +
   24.34 +import org.openide.util.HelpCtx;
   24.35 +import org.openide.util.NbBundle;
   24.36 +import org.openide.windows.TopComponent;
   24.37 +
   24.38 +import org.netbeans.modules.bpel.search.impl.util.Util;
   24.39 +
   24.40 +/**
   24.41 + * @author Vladimir Yaroslavskiy
   24.42 + * @version 2006.11.24
   24.43 + */
   24.44 +public final class View extends TopComponent implements FocusListener {
   24.45 +
   24.46 +  /**{@inheritDoc}*/
   24.47 +  public View() {
   24.48 +    setIcon(Util.getIcon("find").getImage()); // NOI18N
   24.49 +    setLayout(new GridBagLayout());
   24.50 +  }
   24.51 +
   24.52 +  void show(JTree tree) {
   24.53 +    myTree = tree;
   24.54 +    myModifiedDate = new Date(System.currentTimeMillis());
   24.55 +    myTree.addFocusListener(this);
   24.56 +    createPanel();
   24.57 +    open();
   24.58 +    requestActive();
   24.59 +    setActivatedNode();
   24.60 +  }
   24.61 +
   24.62 +  /**{@inheritDoc}*/
   24.63 +  public void focusGained(FocusEvent event) {
   24.64 +    setActivatedNode();
   24.65 +  }
   24.66 +
   24.67 +  /**{@inheritDoc}*/
   24.68 +  public void focusLost(FocusEvent event) {
   24.69 +    setActivatedNodes(null);
   24.70 +  }
   24.71 +
   24.72 +  private void setActivatedNode() {
   24.73 +    String root = myTree.getModel().getRoot().toString();
   24.74 +    String name = NbBundle.getMessage(
   24.75 +      View.class, "CTL_Search_Results_Print", root); // NOI18N
   24.76 +    setActivatedNodes(new Node [] { new Node(myTree, name, myModifiedDate) });
   24.77 +  }
   24.78 +
   24.79 +  private void createPanel() {
   24.80 +    removeAll();
   24.81 +    JScrollPane scrollPanel = new JScrollPane(myTree);
   24.82 +    GridBagConstraints c = new GridBagConstraints();
   24.83 +    c.anchor = GridBagConstraints.NORTH;
   24.84 +    c.fill = GridBagConstraints.BOTH;
   24.85 +    c.weightx = 1.0;
   24.86 +    c.weighty = 1.0;
   24.87 +    add(scrollPanel, c);
   24.88 +
   24.89 +    revalidate();
   24.90 +    repaint();
   24.91 +  }
   24.92 +  
   24.93 +  /**{@inheritDoc}*/
   24.94 +  @Override
   24.95 +  public HelpCtx getHelpCtx()
   24.96 +  {
   24.97 +    return HelpCtx.DEFAULT_HELP;
   24.98 +  }
   24.99 +
  24.100 +  /**{@inheritDoc}*/
  24.101 +  @Override
  24.102 +  public int getPersistenceType()
  24.103 +  {
  24.104 +    return PERSISTENCE_ALWAYS;
  24.105 +  }
  24.106 +      
  24.107 +  /**{@inheritDoc}*/
  24.108 +  @Override
  24.109 +  public String getName()
  24.110 +  {
  24.111 +    return NAME;
  24.112 +  }
  24.113 +  
  24.114 +  /**{@inheritDoc}*/
  24.115 +  @Override
  24.116 +  public String getDisplayName()
  24.117 +  {
  24.118 +    return NbBundle.getMessage(View.class, "CTL_Search_Results_Name"); // NOI18N
  24.119 +  }
  24.120 +
  24.121 +  /**{@inheritDoc}*/
  24.122 +  @Override
  24.123 +  public String getToolTipText()
  24.124 +  {
  24.125 +    return NbBundle.getMessage(View.class, "CTL_Search_Results_Tooltip"); // NOI18N
  24.126 +  }
  24.127 +
  24.128 +  @Override
  24.129 +  protected void componentClosed()
  24.130 +  {
  24.131 +    super.componentClosed();
  24.132 +    myTree = null;
  24.133 +    myModifiedDate = null;
  24.134 +  }
  24.135 +
  24.136 +  @Override
  24.137 +  protected String preferredID()
  24.138 +  {
  24.139 +    return NAME;
  24.140 +  }
  24.141 +
  24.142 +  public static final String NAME = "search"; // NOI18N
  24.143 +  private JTree myTree;
  24.144 +  private Date myModifiedDate;
  24.145 +}
    25.1 --- a/bpel.search/src/org/netbeans/modules/bpel/search/impl/util/Util.java	Thu Nov 23 12:01:23 2006 +0000
    25.2 +++ b/bpel.search/src/org/netbeans/modules/bpel/search/impl/util/Util.java	Wed Dec 13 11:35:25 2006 +0000
    25.3 @@ -21,7 +21,11 @@
    25.4  import java.util.ArrayList;
    25.5  import java.util.Collection;
    25.6  import java.util.List;
    25.7 +
    25.8 +import javax.swing.ImageIcon;
    25.9 +
   25.10  import org.openide.util.Lookup;
   25.11 +import org.netbeans.modules.print.api.PrintUtil;
   25.12  
   25.13  /**
   25.14   * @author Vladimir Yaroslavskiy
   25.15 @@ -44,4 +48,13 @@
   25.16      }
   25.17      return list;
   25.18    }
   25.19 +
   25.20 +  /**
   25.21 +   * Returns icon for given name.
   25.22 +   * @param name given name
   25.23 +   * @return icon for given name
   25.24 +   */
   25.25 +  public static ImageIcon getIcon(String name) {
   25.26 +    return PrintUtil.getIcon(Util.class, name);
   25.27 +  }
   25.28  }