01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the
09: * Free Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15: * for more details.
16: *
17: * You should have received a copy of the GNU General Public License along with
18: * this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: *
21: *
22: * $Id: Message.java 3512 2006-12-08 05:52:03Z yling $
23: */
24:
25: package com.bostechcorp.cbesb.ui.util.ucm;
26:
27: import java.util.List;
28:
29: import org.eclipse.core.internal.resources.Project;
30: import org.eclipse.swt.widgets.Text;
31:
32: import com.bostechcorp.cbesb.common.i18n.Message;
33: import com.bostechcorp.cbesb.common.i18n.Messages;
34: import com.bostechcorp.cbesb.ui.util.MsgUtil;
35: import com.bostechcorp.cbesb.ui.util.ProjectUtil;
36:
37: public class UcmMethodSelection {
38: private String projectName = "";
39:
40: private String projectLocation = "";
41:
42: public UcmMethodSelection(String projectName, String projectLocation) {
43: super ();
44: this .projectLocation = projectLocation;
45: this .projectName = projectName;
46: }
47:
48: public void selectMethod(String className, Text methodText) {
49: List methodList = null;
50: try {
51: UcmClassLoader classLocader = new UcmClassLoader(
52: UcmClassURLHelper.getURL(projectName,
53: projectLocation), this .getClass()
54: .getClassLoader(), projectName,
55: projectLocation);
56:
57: methodList = classLocader.getMethodList(className);
58: if (methodList.size() == 0) {
59: List list = ProjectUtil.getRelatedProject(projectName);
60: for (int i = 0; i < list.size(); i++) {
61: Project eproject = (Project) list.get(i);
62: if (eproject.getName().equals(projectName))
63: continue;
64: UcmClassLoader esbClassLocader = new UcmClassLoader(
65: UcmClassURLHelper
66: .getURL(eproject.getName(),
67: eproject.getLocation()
68: .toOSString()),
69: this .getClass().getClassLoader(), eproject
70: .getName(), eproject.getLocation()
71: .toOSString());
72:
73: methodList = esbClassLocader
74: .getMethodList(className);
75:
76: break;
77: }
78: }
79: // should release the sa url
80: UcmClassURLHelper.clearSaPath(projectName);
81:
82: } catch (Exception ex) {
83: MsgUtil.warningMsg(ex.getMessage());
84: return;
85:
86: }
87: if (methodList == null || methodList.isEmpty()) {
88: MsgUtil.warningMsg(new Message(
89: Messages.TRANSFORMER_ERROR_NO_METHOD).getMessage());
90: return;
91: } else {
92: UcmSelectionDialog dialog = new UcmSelectionDialog(
93: methodText.getShell(), methodList, "Method",
94: methodText);
95: dialog.open();
96: }
97: }
98:
99: }
|