KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > EjbGenInterfaces


1 /*
2  * Created on 11 févr. 2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package com.bull.eclipse.jonas;
8
9 import java.lang.reflect.Array JavaDoc;
10 import java.lang.reflect.InvocationTargetException JavaDoc;
11 import java.util.ArrayList JavaDoc;
12 import java.util.HashMap JavaDoc;
13 import java.util.Iterator JavaDoc;
14 import java.util.Vector JavaDoc;
15
16 import org.eclipse.core.resources.IProject;
17 import org.eclipse.core.resources.ResourcesPlugin;
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.jdt.core.Flags;
20 import org.eclipse.jdt.core.ICompilationUnit;
21 import org.eclipse.jdt.core.IMethod;
22 import org.eclipse.jdt.core.IPackageFragment;
23 import org.eclipse.jdt.core.IType;
24 import org.eclipse.jdt.core.JavaCore;
25 import org.eclipse.jdt.core.Signature;
26 import org.eclipse.jdt.core.ToolFactory;
27 import org.eclipse.jdt.core.formatter.CodeFormatter;
28 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
29 import org.eclipse.jface.operation.IRunnableWithProgress;
30 import org.eclipse.jface.text.Document;
31 import org.eclipse.jface.text.IDocument;
32 import org.eclipse.jface.text.Region;
33 import org.eclipse.jface.text.formatter.ContentFormatter;
34 import org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy;
35 import org.eclipse.jface.text.formatter.FormattingContextProperties;
36 import org.eclipse.jface.text.formatter.IFormattingStrategy;
37 import org.eclipse.jface.text.source.SourceViewerConfiguration;
38 import org.eclipse.jface.viewers.IStructuredContentProvider;
39 import org.eclipse.jface.viewers.LabelProvider;
40 import org.eclipse.jface.viewers.Viewer;
41 import org.eclipse.text.edits.TextEdit;
42 import org.eclipse.ui.IWorkbenchWindow;
43 import org.eclipse.ui.PlatformUI;
44 import org.eclipse.ui.dialogs.ListSelectionDialog;
45
46 import com.bull.eclipse.jonas.utils.UtilServicesClass;
47
48 /**
49  */

50 public class EjbGenInterfaces {
51     private ICompilationUnit cu;
52     private String JavaDoc[] szMethode_ =
53         {
54             "ejbCreate",
55             "ejbPostCreate",
56             "ejbRemove",
57             "ejbLoad",
58             "ejbStore",
59             "ejbActivate",
60             "ejbPassivate",
61             "ejbPassivate",
62             "setEntityContext",
63             "unsetEntityContext",
64             "setSessionContext",
65             "unsetSessionContext",
66             "afterBegin",
67             "afterCompletion",
68             "beforeCompletion",
69             "ejbFind" };
70
71     public void run(ICompilationUnit cu) throws Exception JavaDoc {
72         // gen remote
73
this.cu = cu;
74
75         // mettre à jour le BeanLocal
76
final String JavaDoc s = cu.getElementName().replaceAll("EJB.java", "");
77         final String JavaDoc sEJB = cu.getElementName().replaceAll(".java", "");
78
79         // Refresh
80
IPackageFragment pkg = (IPackageFragment) cu.getParent();
81         String JavaDoc jonasprojName = cu.getParent().getJavaProject().getElementName();
82
83         // get the corresponding JonasProject object
84
final IProject proj =
85             ResourcesPlugin.getWorkspace().getRoot().getProject(jonasprojName);
86
87         UtilServicesClass.saveFiles();
88         
89         final IMethod[] sel = getMethodesDialog(sEJB);
90         if (sel == null)
91             return;
92
93         /***
94          * Create worker thread
95          */

96
97         IRunnableWithProgress worker = new IRunnableWithProgress() {
98             public void run(IProgressMonitor monitor)
99                 throws InvocationTargetException JavaDoc {
100                 try {
101
102                     monitor.setTaskName(
103                         JonasPluginResources.GEN_INTERFACES_TITLE);
104
105                     // local/remote
106
monitor.beginTask(
107                         JonasPluginResources.GEN_INTERFACES_MSG_LOCAL,
108                         5);
109                     updEjbLocalFile(s + "Local", sel);
110                     monitor.worked(1);
111
112                     monitor.setTaskName(
113                         JonasPluginResources.GEN_INTERFACES_MSG_REMOTE);
114                     updEjbLocalFile(s, sel);
115                     monitor.worked(2);
116
117                     // createn interface home/localHome
118
monitor.setTaskName(
119                         JonasPluginResources.GEN_INTERFACES_MSG_HOME);
120                     updEjbHomeFile(s + "Home");
121                     monitor.worked(3);
122
123                     monitor.setTaskName(
124                         JonasPluginResources.GEN_INTERFACES_MSG_LOCALH);
125                     updEjbHomeFile(s + "LocalHome");
126                     monitor.worked(4);
127
128                     monitor.setTaskName(
129                         JonasPluginResources.GEN_INTERFACES_MSG_LOCALH);
130                     updEjbBeanFile(sEJB);
131                     monitor.worked(5);
132
133                 } catch (Exception JavaDoc e) {
134                     System.out.println("Excepion : " + e.getMessage());
135                 } finally {
136                     monitor.done();
137                 }
138             }
139         };
140
141         /***
142          * Run worker thread
143          */

144         try {
145             new ProgressMonitorDialog(
146                 PlatformUI
147                     .getWorkbench()
148                     .getActiveWorkbenchWindow()
149                     .getShell())
150                     .run(
151                 false,
152                 false,
153                 worker);
154         } catch (InterruptedException JavaDoc e) {
155             e.printStackTrace();
156         } catch (InvocationTargetException JavaDoc e) {
157             e.printStackTrace();
158         }
159
160     }
161
162     private void updEjbBeanFile(String JavaDoc sUnit) throws Exception JavaDoc {
163         boolean bFound = false;
164
165         IPackageFragment pkg = (IPackageFragment) cu.getParent();
166         //
167
ICompilationUnit unitA = null;
168         try {
169             unitA = pkg.getCompilationUnit(sUnit + ".java");
170             if (!unitA.getResource().exists())
171                 return;
172
173         } catch (Exception JavaDoc ex) {
174             // return if unknown ..
175
return;
176         }
177
178         IType itCible = unitA.getType(sUnit);
179         // delete all ejbPostCreate methods
180
IMethod[] ime = itCible.getMethods();
181
182         int iCount = 0;
183         for (int j = 0; j < ime.length; j++) {
184             if (ime[j].getElementName().equals("ejbPostCreate"))
185                 iCount++;
186         }
187         
188         int crCount = 0;
189         for (int j = 0; j < ime.length; j++) {
190             if (ime[j].getElementName().equals("ejbCreate"))
191                 crCount++;
192         }
193
194         //
195
// si pas de méthode ejbPostCreate --> les créer
196
//
197
if (iCount == 0) {
198             // for each ejbCreate Method, create an ejbPostCreate method
199
for (int j = 0; j < ime.length; j++) {
200                 if (ime[j].getElementName().equals("ejbCreate")) {
201                     // ime[j].delete(true, null);
202
itCible.createMethod(
203                         MakeEJBPostCreateMethode(ime[j]),
204                         null,
205                         true,
206                         null);
207
208                 }
209             }
210         }
211
212 // // for each ejbCreate Method, create an ejbPostCreate method
213
// for (int j = 0; j < ime.length; j++) {
214
// if (ime[j].getElementName().equals("ejbCreate")) {
215
//
216
// // ime[j].delete(true, null);
217
// itCible.createMethod(
218
// MakeEJBPostCreateMethode(ime[j]),
219
// null,
220
// true,
221
// null);
222
//
223
// }
224
// }
225

226         // reformat code ..
227
CodeFormat(unitA);
228
229     }
230
231     private void updEjbLocalFile(String JavaDoc sUnit, IMethod[] imeSelected)
232         throws Exception JavaDoc {
233
234         boolean bFound = false;
235
236         IPackageFragment pkg = (IPackageFragment) cu.getParent();
237         //
238
ICompilationUnit unitA = null;
239         try {
240             unitA = pkg.getCompilationUnit(sUnit + ".java");
241             if (!unitA.getResource().exists())
242                 return;
243
244         } catch (Exception JavaDoc ex) {
245             // return if unknown ..
246
return;
247         }
248
249         IType itCible = unitA.getType(sUnit);
250         IMethod[] ime = itCible.getMethods();
251         int nbMethodesInFacade = ime.length;
252         int nbMethodesInBean = imeSelected.length;
253         ArrayList JavaDoc candidateMeth = new ArrayList JavaDoc();
254         int h = 0;
255         
256         for (int j = 0; j < nbMethodesInBean; j++) {
257             for (h = 0; h < nbMethodesInFacade; h++) {
258                     if ((ime[h].getElementName().equals(imeSelected[j]
259                             .getElementName()))
260                             && (ime[h].getSignature().equals(imeSelected[j]
261                                     .getSignature()))) {
262                         System.out.println("Méthode déjà dans la façade = "
263                                 + imeSelected[j].getElementName());
264                         break;
265                     }
266             }
267             if ((h == nbMethodesInFacade) && (imeSelected[j] != null))
268                 candidateMeth.add(imeSelected[j]);
269         }
270
271         for (int j = 0; j < nbMethodesInFacade; j++) {
272             for (h = 0; h < nbMethodesInBean; h++) {
273                     if ((ime[j].getElementName().equals(imeSelected[h]
274                             .getElementName())
275                             && (ime[j].getSignature().equals(imeSelected[h]
276                                     .getSignature())))) {
277                         System.out.println("Méthode déjà dans la façade = "
278                                 + imeSelected[j].getElementName());
279                         break;
280                     }
281             }
282             if ((h == nbMethodesInBean) && (ime[j] != null))
283                 ime[j].delete(true,null);
284         }
285
286         System.out.println("Liste des mèthodes publiques");
287         IType[] it = cu.getAllTypes();
288
289         // for (int i = 0; i < it.length; i++) {
290
// ime = it[i].getMethods();
291
//
292
// for (int j = 0; j < ime.length; j++) {
293

294         // // méthode publique ?
295
// if (ime[j].getFlags() != Flags.AccPublic)
296
// continue;
297
//
298
// // méthode abstraite ?
299
// if (ime[j].getFlags() == Flags.AccAbstract)
300
// continue;
301
//
302
// // méthode EJBxxx ?
303
// if (MethodeToIgnore(ime[j].getElementName()))
304
// continue;
305

306         // Ne retenir que les méthodes qui sont sélectionnées
307
//if ()
308
for (int i = 0; i < candidateMeth.size(); i++) {
309             System.out.println(
310                 "liste des methodes retenues : "
311                     + ((IMethod)candidateMeth.get(i)).getElementName());
312         }
313
314         for (int i = 0; i < candidateMeth.size(); i++) {
315             // if (ime[j].getElementName().equals(imeSelected[u].getElementName())) {
316
// ajouter éthode ...
317
String JavaDoc s = MakeMethode(((IMethod)candidateMeth.get(i)), false, sUnit);
318             System.out.println("ajout meth : " + s);
319             itCible.createMethod(s, null, true, null);
320
321             // }
322
}
323         // }
324
// }
325
//CodeFormat(unitA);
326
}
327
328     private void updEjbHomeFile(String JavaDoc sUnit) throws Exception JavaDoc {
329
330         IPackageFragment pkg = (IPackageFragment) cu.getParent();
331
332         //
333
ICompilationUnit unitA = null;
334         try {
335             unitA = pkg.getCompilationUnit(sUnit + ".java");
336             if (!unitA.getResource().exists())
337                 return;
338
339         } catch (Exception JavaDoc ex) {
340             // return if unknown ..
341
return;
342         }
343
344         IType itCible = unitA.getType(sUnit);
345
346         // supprimer méthodes déjà inscrites
347
IMethod[] ime = itCible.getMethods();
348         for (int j = 0; j < ime.length; j++) {
349             if (ime[j].getElementName().startsWith("Find"))
350                 continue;
351             if (ime[j].getElementName().startsWith("create"))
352                 ime[j].delete(true, null);
353         }
354
355         System.out.println("Liste des mèthodes publiques");
356         String JavaDoc beanName = cu.getElementName();
357         Vector JavaDoc listeMethodes = getMethodes(beanName.substring(0,beanName.length()-5),true);
358         for (int j = 0; j < listeMethodes.size(); j++) {
359
360                 // méthode publique ?
361
if (((IMethod)listeMethodes.get(j)).getFlags() != Flags.AccPublic)
362                     continue;
363
364                 // méthode abstraite ?
365
if (((IMethod)listeMethodes.get(j)).getFlags() == Flags.AccAbstract)
366                     continue;
367
368                 String JavaDoc szMethode = ((IMethod)listeMethodes.get(j)).getElementName();
369
370                 //if (!szMethode.startsWith("ejb"))
371
// continue;
372

373                 if (!szMethode.startsWith("ejbCreate"))
374                     continue;
375
376                 // ajouter éthode ...
377
String JavaDoc s = MakeMethode(((IMethod)listeMethodes.get(j)), true, sUnit);
378                 System.out.println("ajout meth : " + s);
379                 itCible.createMethod(s, null, true, null);
380
381         }
382         // reformat code
383
CodeFormat(unitA);
384     }
385
386     private String JavaDoc MakeMethode(IMethod ime, boolean bHome, String JavaDoc EJBName)
387         throws Exception JavaDoc {
388
389         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("public ");
390         String JavaDoc sig = ime.getReturnType();
391         // force method = 'EJBname' + 'Local'
392
if (bHome)
393             sig = EJBName.replaceAll("Home", "");
394
395         String JavaDoc sName = ime.getElementName();
396
397         if (sName.startsWith("ejbCreate"))
398             sName = "create";
399         else if (sName.startsWith("ejbFind"))
400             sName = sName.replaceAll("ejbFind", "Find");
401
402         sb.append(getType(sig) + " ");
403         sb.append(sName + "(");
404         String JavaDoc[] spars = ime.getParameterNames();
405         String JavaDoc[] sparstype = ime.getParameterTypes();
406         for (int k = 0; k < ime.getNumberOfParameters(); k++) {
407             if (k != 0)
408                 sb.append(", ");
409             sb.append(getType(sparstype[k]));
410             sb.append(" ");
411             sb.append(spars[k]);
412         }
413         sb.append(")");
414         //
415
// Build excpetion depending on the type of interface
416
//
417
HashMap JavaDoc hMap = new HashMap JavaDoc(10);
418         String JavaDoc[] exc = ime.getExceptionTypes();
419
420         for (int u = 0; u < exc.length; u++) {
421             String JavaDoc s = getType(exc[u]);
422             hMap.put(s, s);
423         }
424         String JavaDoc szRemote = "java.rmi.RemoteException";
425         String JavaDoc szRemote_ = "RemoteException";
426
427         // If local object and remoteExceptio is present then remove it
428
if (EJBName.indexOf("Local") != -1 && hMap.get(szRemote) != null)
429             hMap.remove(szRemote);
430
431         if (EJBName.indexOf("Local") != -1 && hMap.get(szRemote_) != null)
432             hMap.remove(szRemote_);
433
434         // If not local object and not remoteException is present then add it
435
if (EJBName.indexOf("Local") == -1) {
436             if ((hMap.get(szRemote) == null) && (hMap.get(szRemote_) == null))
437                 hMap.put(szRemote, szRemote);
438         }
439         //
440
if (hMap.size() != 0) {
441             sb.append(" throws ");
442             Iterator JavaDoc it = hMap.values().iterator();
443             while (it.hasNext()) {
444                 sb.append((String JavaDoc) it.next());
445                 if (it.hasNext())
446                     sb.append(", ");
447             }
448         }
449
450         sb.append(";\n\n");
451
452         return sb.toString();
453     }
454
455     private String JavaDoc MakeEJBPostCreateMethode(IMethod ime) throws Exception JavaDoc {
456
457         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("public void ejbPostCreate (");
458         String JavaDoc[] spars = ime.getParameterNames();
459         String JavaDoc[] sparstype = ime.getParameterTypes();
460         for (int k = 0; k < ime.getNumberOfParameters(); k++) {
461             if (k != 0)
462                 sb.append(", ");
463             sb.append(getType(sparstype[k]));
464             sb.append(" ");
465             sb.append(spars[k]);
466         }
467         String JavaDoc[] exc = ime.getExceptionTypes();
468         sb.append(")");
469         if (exc.length != 0) {
470             sb.append(" throws ");
471             for (int u = 0; u < exc.length; u++) {
472                 if (u != 0)
473                     sb.append(", ");
474                 sb.append(getType(exc[u]));
475             }
476         }
477
478         sb.append(" {}\n\n");
479         return sb.toString();
480
481     }
482
483     private void CodeFormat(ICompilationUnit unit) throws Exception JavaDoc {
484         // reformat code
485
// ContentFormatter cf = new ContentFormatter();
486
// cf.enablePartitionAwareFormatting(true);
487
// SourceViewerConfiguration svc = new SourceViewerConfiguration();
488
// CodeFormatter ic = ToolFactory.createCodeFormatter(JavaCore.getOptions());
489
// String srcCode = unit.getBuffer().getContents();
490
// System.out.println("in : " + srcCode);
491
// Document doc = new Document(srcCode);
492
// cf.setDocumentPartitioning(doc.get());
493
// IFormattingStrategy fs = cf.getFormattingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
494
// srcCode = doc.get();
495
// cf.format(doc,new Region(0,srcCode.length()));
496
// srcCode = doc.get();
497
// TextEdit te = ic.format(CodeFormatter.K_COMPILATION_UNIT, srcCode,1 ,srcCode.length() ,0 , null).apply(doc);
498
// TextEdit[] e = te.getChildren();
499
// TextEdit parent = te.getParent();
500
// srcCode = ic.format(CodeFormatter.K_COMPILATION_UNIT, srcCode,1 ,srcCode.length() ,0 , null).toString();
501
// System.out.println("out : " + srcCode);
502
// unit.getBuffer().setContents(srcCode);
503
// unit.getBuffer().save(null, false);
504
}
505
506     private boolean MethodeToIgnore(String JavaDoc szMethode) {
507         for (int m_ = 0; m_ < szMethode_.length; m_++) {
508             if (szMethode.equalsIgnoreCase(szMethode_[m_]))
509                 return true;
510             if (szMethode.startsWith("ejbFind"))
511                 return true;
512
513         }
514         return false;
515     }
516
517     private String JavaDoc getType(String JavaDoc s) {
518
519         if (s.equalsIgnoreCase("v"))
520             return "void";
521
522         if (s.equalsIgnoreCase("b"))
523             return "byte";
524         if (s.equalsIgnoreCase("[b"))
525             return "byte []";
526
527         if (s.equalsIgnoreCase("c"))
528             return "char";
529         if (s.equalsIgnoreCase("[c"))
530             return "char []";
531
532         if (s.equalsIgnoreCase("d"))
533             return "double";
534         if (s.equalsIgnoreCase("[d"))
535             return "double []";
536
537         if (s.equalsIgnoreCase("f"))
538             return "float";
539         if (s.equalsIgnoreCase("[f"))
540             return "float []";
541
542         if (s.equalsIgnoreCase("i"))
543             return "int";
544         if (s.equalsIgnoreCase("[i"))
545             return "int []";
546
547         if (s.equalsIgnoreCase("j"))
548             return "long";
549         if (s.equalsIgnoreCase("[j"))
550             return "long []";
551
552         if (s.equalsIgnoreCase("s"))
553             return "short";
554         if (s.equalsIgnoreCase("[s"))
555             return "short []";
556
557         if (s.equalsIgnoreCase("z"))
558             return "boolean";
559         if (s.equalsIgnoreCase("[z"))
560             return "boolean []";
561
562         if (s.startsWith("Q")) {
563             return s.substring(1, s.length() - 1);
564         }
565
566         if (s.startsWith("[Q")) {
567             return s.substring(2, s.length() - 1) + " []";
568         }
569
570         return s;
571
572     }
573
574     private Vector JavaDoc getMethodes(String JavaDoc sUnit, boolean withejbMethods) throws Exception JavaDoc {
575
576             IWorkbenchWindow[] wk = PlatformUI.getWorkbench().getWorkbenchWindows();
577             IPackageFragment pkg = (IPackageFragment) cu.getParent();
578             //
579
ICompilationUnit unitA = null;
580             ICompilationUnit unitB = null;
581             IType itCibleA = null;
582             IType itCibleB = null;
583             try {
584                 unitA = pkg.getCompilationUnit(sUnit + ".java");
585                 itCibleA = unitA.getType(sUnit);
586                 String JavaDoc superclass = itCibleA.getSuperclassName();
587                 if ((!"java.lang.Object".equals(superclass)) && (superclass != null) ) {
588                     unitB = pkg.getCompilationUnit(superclass + ".java");
589                     itCibleB = unitB.getType(superclass);
590                 }
591                 if (!unitA.getResource().exists())
592                     return null;
593
594             } catch (Exception JavaDoc ex) {
595                 // return if unknown ..
596
System.out.println("Exception : " + ex.getMessage());
597                 return null;
598             }
599
600             // delete all ejbPostCreate methods
601
IMethod[] imeA = itCibleA.getMethods();
602             IMethod[] imeB = null;
603             if (itCibleB != null)
604                 imeB = itCibleB.getMethods();
605             
606             Vector JavaDoc vmet = new Vector JavaDoc(10);
607
608             //
609
// get methods candidate to go to the remote/local interface
610
// must be public
611
// and # ejbXXX
612
//
613
for (int i = 0; i < imeA.length; i++) {
614                 System.out.println(" method : " + imeA[i].getElementName());
615
616                 // méthode publique ?
617
if ((imeA[i].getFlags() & Flags.AccPublic) == 0)
618                     continue;
619                 // méthode abstraite ?
620
if ((imeA[i].getFlags() & Flags.AccAbstract) != 0)
621                     continue;
622
623                 // méthode EJBxxx ?
624
if (MethodeToIgnore(imeA[i].getElementName()) && !withejbMethods)
625                     continue;
626                 System.out.println(
627                     " candidate method : " + imeA[i].getElementName());
628
629                 String JavaDoc szSign = MakeMethode(imeA[i], false, "");
630
631                 vmet.add(imeA[i]);
632             }
633
634             if (imeB != null)
635                 for (int i = 0; i < imeB.length; i++) {
636                     System.out.println(" method : " + imeB[i].getElementName());
637
638                     // méthode publique ?
639
if ((imeB[i].getFlags() & Flags.AccPublic) == 0)
640                         continue;
641                     // méthode abstraite ?
642
if ((imeB[i].getFlags() & Flags.AccAbstract) != 0)
643                         continue;
644
645                     // méthode EJBxxx ?
646
if (MethodeToIgnore(imeB[i].getElementName()) && !withejbMethods)
647                         continue;
648                     System.out.println(" candidate method : "
649                             + imeB[i].getElementName());
650
651                     String JavaDoc szSign = MakeMethode(imeB[i], false, "");
652
653                     vmet.add(imeB[i]);
654                 }
655             return vmet;
656     }
657     
658     
659     //
660
// get Methods to pace on the remote interface
661
// ask user to select then
662
private IMethod[] getMethodesDialog(String JavaDoc sUnit) throws Exception JavaDoc {
663
664         Vector JavaDoc vmet = getMethodes(sUnit,false);
665         // any method candidate ?
666
if (vmet.size() == 0)
667             return null;
668
669         final Object JavaDoc[] szMethfull = vmet.toArray();
670         //final String[] szMeth = (String[]) vmet.toArray(new String[0]);
671

672         ListSelectionDialog dlg =
673             new ListSelectionDialog(
674                 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
675                 new Object JavaDoc(),
676                 new IStructuredContentProvider() {
677
678             public void dispose() {
679             }
680
681             public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
682
683                 return szMethfull;
684             }
685
686             public void inputChanged(Viewer viewer1, Object JavaDoc obj, Object JavaDoc obj1) {
687                 int i = 0;
688             }
689
690         }, new LabelProvider(), "Select methods from BEAN");
691
692         dlg.setTitle("Preselect Methods for Remote/Local Interfaces");
693         dlg.open();
694
695         final Object JavaDoc[] results_upd = (Object JavaDoc[]) dlg.getResult();
696         int ret = dlg.getReturnCode();
697         // return null ( list of methods) , if user press cancel or nothing is selected
698
if (ret == 1)
699             return null;
700         if (results_upd == null)
701             return null;
702         if (results_upd.length == 0)
703             return null;
704
705         Vector JavaDoc imeRet = new Vector JavaDoc(10);
706         
707         for (int i = 0; i < results_upd.length; i++) {
708 // for (int v = 0; v < vmet.size(); v++) {
709
//
710
// myMeth my = (myMeth) vmet.get(v);
711
// if (!results_upd[i].equals(my.getMethode()))
712
// continue;
713
//
714
// imeRet.add(imeA[my.getOrder()]);
715
imeRet.add(results_upd[i]);
716         }
717
718         return (IMethod[]) imeRet.toArray(new IMethod[0]);
719
720     }
721
722     // private class to stock all methods
723
class myMeth {
724         private String JavaDoc szSign = null;
725         private int iOrder = 0;
726         myMeth(String JavaDoc szSign, int iOrder) {
727             this.szSign = szSign;
728             this.iOrder = iOrder;
729         }
730         public int getOrder() {
731             return this.iOrder;
732         }
733         public String JavaDoc getMethode() {
734             return this.szSign;
735         }
736     }
737 }
738
Popular Tags