1*34dd1e25SAndrew Rist /**************************************************************
2*34dd1e25SAndrew Rist  *
3*34dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*34dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*34dd1e25SAndrew Rist  * distributed with this work for additional information
6*34dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*34dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*34dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
9*34dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*34dd1e25SAndrew Rist  *
11*34dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*34dd1e25SAndrew Rist  *
13*34dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*34dd1e25SAndrew Rist  * software distributed under the License is distributed on an
15*34dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*34dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
17*34dd1e25SAndrew Rist  * specific language governing permissions and limitations
18*34dd1e25SAndrew Rist  * under the License.
19*34dd1e25SAndrew Rist  *
20*34dd1e25SAndrew Rist  *************************************************************/
21*34dd1e25SAndrew Rist 
22*34dd1e25SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir import com.sun.star.uno.XComponentContext;
25cdf0e10cSrcweir import java.awt.Component;
26cdf0e10cSrcweir import java.awt.Container;
27cdf0e10cSrcweir import java.awt.Dimension;
28cdf0e10cSrcweir import java.awt.event.ActionListener;
29cdf0e10cSrcweir import java.awt.event.ComponentAdapter;
30cdf0e10cSrcweir import java.awt.event.ComponentEvent;
31cdf0e10cSrcweir import java.awt.event.KeyEvent;
32cdf0e10cSrcweir import java.awt.event.WindowAdapter;
33cdf0e10cSrcweir import java.awt.event.WindowEvent;
34cdf0e10cSrcweir import javax.swing.ButtonGroup;
35cdf0e10cSrcweir import javax.swing.JCheckBoxMenuItem;
36cdf0e10cSrcweir import javax.swing.JDialog;
37cdf0e10cSrcweir import javax.swing.JEditorPane;
38cdf0e10cSrcweir import javax.swing.JMenu;
39cdf0e10cSrcweir import javax.swing.JMenuBar;
40cdf0e10cSrcweir import javax.swing.JMenuItem;
41cdf0e10cSrcweir import javax.swing.JPanel;
42cdf0e10cSrcweir import javax.swing.JPopupMenu;
43cdf0e10cSrcweir import javax.swing.JRadioButtonMenuItem;
44cdf0e10cSrcweir import javax.swing.JTabbedPane;
45cdf0e10cSrcweir import javax.swing.KeyStroke;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 
49cdf0e10cSrcweir public class SwingDialogProvider implements XDialogProvider{
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     private JPopupMenu m_jPopupMenu = new JPopupMenu();
52cdf0e10cSrcweir     private XComponentContext m_xComponentContext;
53cdf0e10cSrcweir     private Inspector._Inspector m_oInspector;
54cdf0e10cSrcweir     private JDialog m_jInspectorDialog = new JDialog();
55cdf0e10cSrcweir     private JTabbedPane m_jTabbedPane1 = new JTabbedPane();
56cdf0e10cSrcweir     private Container cp;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     private JMenu jMnuOptions = new JMenu("Options");
59cdf0e10cSrcweir     private JRadioButtonMenuItem jJavaMenuItem = null;
60cdf0e10cSrcweir     private JRadioButtonMenuItem jCPlusPlusMenuItem = null;
61cdf0e10cSrcweir     private JRadioButtonMenuItem jBasicMenuItem = null;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     /** Creates a new instance of SwingPopupMentuProvider */
SwingDialogProvider(Inspector._Inspector _oInspector, String _sTitle)64cdf0e10cSrcweir     public SwingDialogProvider(Inspector._Inspector _oInspector, String _sTitle) {
65cdf0e10cSrcweir         m_oInspector = _oInspector;
66cdf0e10cSrcweir         m_xComponentContext = _oInspector.getXComponentContext();
67cdf0e10cSrcweir         insertMenus();
68cdf0e10cSrcweir         initializePopupMenu();
69cdf0e10cSrcweir         cp = m_jInspectorDialog.getContentPane();
70cdf0e10cSrcweir         cp.setLayout(new java.awt.BorderLayout(0, 10));
71cdf0e10cSrcweir         m_jTabbedPane1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
72cdf0e10cSrcweir         m_jInspectorDialog.addWindowListener(new InspectorWindowAdapter());
73cdf0e10cSrcweir         m_jInspectorDialog.addComponentListener(new InspectorComponentAdapter());
74cdf0e10cSrcweir         m_jInspectorDialog.setTitle(_sTitle);
75cdf0e10cSrcweir         m_jInspectorDialog.setLocation(100, 50);
76cdf0e10cSrcweir         m_jInspectorDialog.getContentPane().add(m_jTabbedPane1);
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
getDialog()81cdf0e10cSrcweir         public JDialog getDialog(){
82cdf0e10cSrcweir             return m_jInspectorDialog;
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
addMenuBar(JMenuBar _jMenuBar)86cdf0e10cSrcweir         public void addMenuBar(JMenuBar _jMenuBar){
87cdf0e10cSrcweir             getDialog().setJMenuBar(_jMenuBar);
88cdf0e10cSrcweir         }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
removeTabPaneByIndex(int _nIndex)91cdf0e10cSrcweir         public void  removeTabPaneByIndex(int _nIndex){
92cdf0e10cSrcweir             if (_nIndex > -1){
93cdf0e10cSrcweir                 String sSelInspectorPanelTitle = m_jTabbedPane1.getTitleAt(_nIndex);
94cdf0e10cSrcweir                 m_jTabbedPane1.remove(_nIndex);
95cdf0e10cSrcweir                 m_oInspector.getInspectorPages().remove(sSelInspectorPanelTitle);
96cdf0e10cSrcweir             }
97cdf0e10cSrcweir         }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
selectInspectorPageByIndex(int nTabIndex)100cdf0e10cSrcweir         public void selectInspectorPageByIndex(int nTabIndex){
101cdf0e10cSrcweir             m_jTabbedPane1.setSelectedIndex(nTabIndex);
102cdf0e10cSrcweir         }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
getInspectorPageCount()105cdf0e10cSrcweir         public int getInspectorPageCount(){
106cdf0e10cSrcweir             return  m_jTabbedPane1.getTabCount();
107cdf0e10cSrcweir         }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
getTabbedPane()110cdf0e10cSrcweir         public JTabbedPane getTabbedPane(){
111cdf0e10cSrcweir             return m_jTabbedPane1;
112cdf0e10cSrcweir         }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
getSelectedInspectorPage()115cdf0e10cSrcweir         public InspectorPane getSelectedInspectorPage(){
116cdf0e10cSrcweir             int nIndex = m_jTabbedPane1.getSelectedIndex();
117cdf0e10cSrcweir             return getInspectorPage(nIndex);
118cdf0e10cSrcweir         }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
getInspectorPage(int _nIndex)121cdf0e10cSrcweir         public InspectorPane getInspectorPage(int _nIndex){
122cdf0e10cSrcweir             InspectorPane oInspectorPane = null;
123cdf0e10cSrcweir             if (_nIndex > -1){
124cdf0e10cSrcweir                 JPanel jPnlContainerInspectorPanel = (JPanel) m_jTabbedPane1.getComponentAt(_nIndex);
125cdf0e10cSrcweir                 String sInspectorPanelTitle = m_jTabbedPane1.getTitleAt(_nIndex);
126cdf0e10cSrcweir                 oInspectorPane = (InspectorPane) m_oInspector.getInspectorPages().get(sInspectorPanelTitle);
127cdf0e10cSrcweir             }
128cdf0e10cSrcweir             return oInspectorPane;
129cdf0e10cSrcweir         }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
removeTabPanes()132cdf0e10cSrcweir         public void removeTabPanes(){
133cdf0e10cSrcweir             int nCount = m_jTabbedPane1.getTabCount();
134cdf0e10cSrcweir             if (nCount > 0){
135cdf0e10cSrcweir                 for (int i = nCount-1; i >= 0; i--){
136cdf0e10cSrcweir                     removeTabPaneByIndex(i);
137cdf0e10cSrcweir                 }
138cdf0e10cSrcweir             }
139cdf0e10cSrcweir         }
140cdf0e10cSrcweir 
removeSelectedTabPane()141cdf0e10cSrcweir         public void removeSelectedTabPane(){
142cdf0e10cSrcweir             int nIndex = getTabbedPane().getSelectedIndex();
143cdf0e10cSrcweir             removeTabPaneByIndex(nIndex);
144cdf0e10cSrcweir         }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         private class InspectorComponentAdapter extends ComponentAdapter{
componentHidden(ComponentEvent e)148cdf0e10cSrcweir             public void componentHidden(ComponentEvent e){
149cdf0e10cSrcweir                 m_jInspectorDialog.pack();
150cdf0e10cSrcweir                 m_jInspectorDialog.invalidate();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir             }
153cdf0e10cSrcweir 
componentShown(ComponentEvent e)154cdf0e10cSrcweir             public void componentShown(ComponentEvent e){
155cdf0e10cSrcweir                 m_jInspectorDialog.pack();
156cdf0e10cSrcweir                 m_jInspectorDialog.invalidate();
157cdf0e10cSrcweir             }
158cdf0e10cSrcweir         }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         private class InspectorWindowAdapter extends WindowAdapter{
windowClosed(WindowEvent e)161cdf0e10cSrcweir             public void windowClosed(WindowEvent e){
162cdf0e10cSrcweir                 removeTabPanes();
163cdf0e10cSrcweir                 m_oInspector.disposeHiddenDocuments();
164cdf0e10cSrcweir             }
165cdf0e10cSrcweir 
windowClosing(WindowEvent e)166cdf0e10cSrcweir             public void windowClosing(WindowEvent e){
167cdf0e10cSrcweir                 removeTabPanes();
168cdf0e10cSrcweir                 m_oInspector.disposeHiddenDocuments();
169cdf0e10cSrcweir             }
170cdf0e10cSrcweir         }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 
initializePopupMenu()174cdf0e10cSrcweir         private void initializePopupMenu(){
175cdf0e10cSrcweir             m_jPopupMenu.add(getInspectMenuItem("Inspect"));
176cdf0e10cSrcweir             m_jPopupMenu.add(getSourceCodeMenuItem(SADDTOSOURCECODE));
177cdf0e10cSrcweir             m_jPopupMenu.add(getInvokeMenuItem(SINVOKE));
178cdf0e10cSrcweir             m_jPopupMenu.addSeparator();
179cdf0e10cSrcweir             m_jPopupMenu.add(getHelpMenuItem("Help"));
180cdf0e10cSrcweir         }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 
addOpenDocumentMenu(JMenu _jMnuRoot)183cdf0e10cSrcweir         private void addOpenDocumentMenu(JMenu _jMnuRoot){
184cdf0e10cSrcweir             ActionListener oActionListener = new ActionListener(){
185cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
186cdf0e10cSrcweir                     String sTDocUrl = evt.getActionCommand();
187cdf0e10cSrcweir                     m_oInspector.inspectOpenDocument(sTDocUrl);
188cdf0e10cSrcweir                 }
189cdf0e10cSrcweir             };
190cdf0e10cSrcweir             String[] sTDocUrls = m_oInspector.getTDocUrls();
191cdf0e10cSrcweir             String[] sTDocTitles = m_oInspector.getTDocTitles(sTDocUrls);
192cdf0e10cSrcweir             for (int i = 0; i < sTDocUrls.length; i++){
193cdf0e10cSrcweir                 addSingleMenuItem(_jMnuRoot, sTDocTitles[i], sTDocUrls[i], oActionListener);
194cdf0e10cSrcweir             }
195cdf0e10cSrcweir         }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
addApplicationDocumentMenu(JMenu _jMnuRoot)198cdf0e10cSrcweir         private void addApplicationDocumentMenu(JMenu _jMnuRoot){
199cdf0e10cSrcweir             ActionListener oActionListener = new ActionListener(){
200cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
201cdf0e10cSrcweir                     String sApplicationDocUrl = evt.getActionCommand();
202cdf0e10cSrcweir                     m_oInspector.inspectOpenEmptyDocument(sApplicationDocUrl);
203cdf0e10cSrcweir                 }
204cdf0e10cSrcweir             };
205cdf0e10cSrcweir             String[][] sApplUrls = m_oInspector.getApplicationUrls();
206cdf0e10cSrcweir             for (int i = 0; i < sApplUrls.length; i++){
207cdf0e10cSrcweir                 addSingleMenuItem(_jMnuRoot, sApplUrls[i][1], sApplUrls[i][0], oActionListener);
208cdf0e10cSrcweir             }
209cdf0e10cSrcweir         }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 
addSingleMenuItem(JMenu _jMnuOpenDocs, String _sTitle, String _sActionCommand, ActionListener _oActionListener)212cdf0e10cSrcweir         private void addSingleMenuItem(JMenu _jMnuOpenDocs, String _sTitle, String _sActionCommand, ActionListener _oActionListener){
213cdf0e10cSrcweir             javax.swing.JMenuItem jMnuItemOpenDoc = new javax.swing.JMenuItem(_sTitle);
214cdf0e10cSrcweir             jMnuItemOpenDoc.setActionCommand(_sActionCommand);
215cdf0e10cSrcweir             jMnuItemOpenDoc.addActionListener(_oActionListener);
216cdf0e10cSrcweir             _jMnuOpenDocs.add(jMnuItemOpenDoc);
217cdf0e10cSrcweir         }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
addHelpMenu(JMenuBar _jInspectMenuBar)220cdf0e10cSrcweir         private void addHelpMenu(JMenuBar _jInspectMenuBar){
221cdf0e10cSrcweir             JMenu jMnuHelp = new JMenu("Help");
222cdf0e10cSrcweir             jMnuHelp.add(getHelpMenuItem("Idl-Help"));
223cdf0e10cSrcweir             _jInspectMenuBar.add(jMnuHelp);
224cdf0e10cSrcweir         }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 
getHelpMenuItem(String _sMenuTitle)227cdf0e10cSrcweir         private JMenuItem getHelpMenuItem(String _sMenuTitle){
228cdf0e10cSrcweir             JMenuItem jMnuHelpItem = new JMenuItem(_sMenuTitle);
229cdf0e10cSrcweir             jMnuHelpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
230cdf0e10cSrcweir             jMnuHelpItem.setMnemonic('H');
231cdf0e10cSrcweir             jMnuHelpItem.addActionListener(new ActionListener(){
232cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
233cdf0e10cSrcweir                     m_oInspector.openIdlFileforSelectedNode();
234cdf0e10cSrcweir                 }
235cdf0e10cSrcweir             });
236cdf0e10cSrcweir             return jMnuHelpItem;
237cdf0e10cSrcweir         }
238cdf0e10cSrcweir 
addFileMenu(JMenuBar _jInspectMenuBar)239cdf0e10cSrcweir         private void addFileMenu(JMenuBar _jInspectMenuBar){
240cdf0e10cSrcweir             JMenu jMnuFile = new JMenu("File");
241cdf0e10cSrcweir             JMenuItem jMnuItemRemoveInspector = new JMenuItem("Remove");
242cdf0e10cSrcweir             jMnuItemRemoveInspector.addActionListener(new ActionListener(){
243cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
244cdf0e10cSrcweir                     removeSelectedTabPane();
245cdf0e10cSrcweir                 }
246cdf0e10cSrcweir             });
247cdf0e10cSrcweir             jMnuFile.add(jMnuItemRemoveInspector);
248cdf0e10cSrcweir             JMenuItem jMnuItemExit = new JMenuItem("Exit");
249cdf0e10cSrcweir             jMnuItemExit.addActionListener(new ActionListener(){
250cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
251cdf0e10cSrcweir                     getDialog().dispose();
252cdf0e10cSrcweir                 }
253cdf0e10cSrcweir             });
254cdf0e10cSrcweir             jMnuFile.add(jMnuItemExit);
255cdf0e10cSrcweir             _jInspectMenuBar.add(jMnuFile);
256cdf0e10cSrcweir         }
257cdf0e10cSrcweir 
getInspectMenuItem(String _sLabel)258cdf0e10cSrcweir         private JMenuItem getInspectMenuItem(String _sLabel){
259cdf0e10cSrcweir             JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel);
260cdf0e10cSrcweir             jMnuSelectedObject.addActionListener(new ActionListener(){
261cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
262cdf0e10cSrcweir                     m_oInspector.inspectSelectedNode();
263cdf0e10cSrcweir                 }
264cdf0e10cSrcweir             });
265cdf0e10cSrcweir             return jMnuSelectedObject;
266cdf0e10cSrcweir         }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 
getSourceCodeMenuItem(String _sLabel)269cdf0e10cSrcweir         private JMenuItem getSourceCodeMenuItem(String _sLabel){
270cdf0e10cSrcweir             JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel);
271cdf0e10cSrcweir             jMnuSelectedObject.addActionListener(new ActionListener(){
272cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
273cdf0e10cSrcweir                     m_oInspector.addSourceCodeOfSelectedNode();
274cdf0e10cSrcweir                 }
275cdf0e10cSrcweir             });
276cdf0e10cSrcweir             return jMnuSelectedObject;
277cdf0e10cSrcweir         }
278cdf0e10cSrcweir 
getInvokeMenuItem(String _sLabel)279cdf0e10cSrcweir         private JMenuItem getInvokeMenuItem(String _sLabel){
280cdf0e10cSrcweir             JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel);
281cdf0e10cSrcweir             jMnuSelectedObject.addActionListener(new ActionListener(){
282cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
283cdf0e10cSrcweir                     m_oInspector.invokeSelectedMethod();
284cdf0e10cSrcweir                 }
285cdf0e10cSrcweir             });
286cdf0e10cSrcweir             return jMnuSelectedObject;
287cdf0e10cSrcweir         }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 
addInspectMenu(JMenuBar _jInspectMenuBar)290cdf0e10cSrcweir         private void addInspectMenu(JMenuBar _jInspectMenuBar){
291cdf0e10cSrcweir             JMenu jMnuInspect = new JMenu("Inspect");
292cdf0e10cSrcweir             addApplicationDocumentMenu(jMnuInspect);
293cdf0e10cSrcweir             jMnuInspect.addSeparator();
294cdf0e10cSrcweir             addGlobalServiceManagerMenu(jMnuInspect);
295cdf0e10cSrcweir             jMnuInspect.addSeparator();
296cdf0e10cSrcweir             jMnuInspect.add(getInspectMenuItem("Selected Object"));
297cdf0e10cSrcweir             jMnuInspect.addSeparator();
298cdf0e10cSrcweir             addOpenDocumentMenu(jMnuInspect);
299cdf0e10cSrcweir             _jInspectMenuBar.add(jMnuInspect);
300cdf0e10cSrcweir         }
301cdf0e10cSrcweir 
getLanguage()302cdf0e10cSrcweir         public int getLanguage(){
303cdf0e10cSrcweir             return XLanguageSourceCodeGenerator.nJAVA;
304cdf0e10cSrcweir         }
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 
selectSourceCodeLanguage(int _nLanguage)307cdf0e10cSrcweir         public void selectSourceCodeLanguage(int _nLanguage){
308cdf0e10cSrcweir             switch (_nLanguage){
309cdf0e10cSrcweir                 case XLanguageSourceCodeGenerator.nJAVA:
310cdf0e10cSrcweir                     jJavaMenuItem.setSelected(true);
311cdf0e10cSrcweir                     break;
312cdf0e10cSrcweir                 case XLanguageSourceCodeGenerator.nCPLUSPLUS:
313cdf0e10cSrcweir                     jCPlusPlusMenuItem.setSelected(true);
314cdf0e10cSrcweir                     break;
315cdf0e10cSrcweir                 case XLanguageSourceCodeGenerator.nBASIC:
316cdf0e10cSrcweir                     jBasicMenuItem.setSelected(true);
317cdf0e10cSrcweir                     break;
318cdf0e10cSrcweir                 default:
319cdf0e10cSrcweir                     System.out.println("Warning: Sourcecode language is not defined!");
320cdf0e10cSrcweir             }
321cdf0e10cSrcweir         }
322cdf0e10cSrcweir 
addLanguageMenuItem(ButtonGroup _group, String _sLanguageTitle, boolean _bSelect, char _sMnemonic, final int _nLanguage)323cdf0e10cSrcweir         private JRadioButtonMenuItem addLanguageMenuItem(ButtonGroup _group, String _sLanguageTitle, boolean _bSelect, char _sMnemonic, final int _nLanguage){
324cdf0e10cSrcweir             JRadioButtonMenuItem jMenuItem = new JRadioButtonMenuItem(_sLanguageTitle, _bSelect);
325cdf0e10cSrcweir             jMenuItem.setMnemonic(_sMnemonic);
326cdf0e10cSrcweir             _group.add(jMenuItem);
327cdf0e10cSrcweir             jMenuItem.addActionListener(new ActionListener(){
328cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
329cdf0e10cSrcweir                     m_oInspector.setSourceCodeLanguage(_nLanguage);
330cdf0e10cSrcweir                 }
331cdf0e10cSrcweir             });
332cdf0e10cSrcweir             return jMenuItem;
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 
getIDLPath()336cdf0e10cSrcweir         public String getIDLPath(){
337cdf0e10cSrcweir             return this.m_oInspector.getIDLPath();
338cdf0e10cSrcweir         }
339cdf0e10cSrcweir 
addOptionsMenu(JMenuBar _jInspectMenuBar)340cdf0e10cSrcweir         private void addOptionsMenu(JMenuBar _jInspectMenuBar){
341cdf0e10cSrcweir             ButtonGroup oButtonGroup = new ButtonGroup();
342cdf0e10cSrcweir             jJavaMenuItem = addLanguageMenuItem(oButtonGroup, "Generate Java Sourcecode", true, 'J', XLanguageSourceCodeGenerator.nJAVA);
343cdf0e10cSrcweir             jMnuOptions.add(jJavaMenuItem);
344cdf0e10cSrcweir             jCPlusPlusMenuItem = addLanguageMenuItem(oButtonGroup, "Generate C++ Sourcecode", false, 'C', XLanguageSourceCodeGenerator.nCPLUSPLUS);
345cdf0e10cSrcweir             jMnuOptions.add(jCPlusPlusMenuItem);
346cdf0e10cSrcweir             jBasicMenuItem = addLanguageMenuItem(oButtonGroup, "Generate OpenOffice.org Basic Sourcecode", false, 'B', XLanguageSourceCodeGenerator.nBASIC);
347cdf0e10cSrcweir             jMnuOptions.add(jBasicMenuItem);
348cdf0e10cSrcweir             jMnuOptions.addSeparator();
349cdf0e10cSrcweir             JMenuItem jMenuItem = new JMenuItem("Path to SDK-Installation");
350cdf0e10cSrcweir             jMenuItem.setMnemonic('I');
351cdf0e10cSrcweir             jMenuItem.addActionListener(new ActionListener(){
352cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
353cdf0e10cSrcweir                     m_oInspector.assignSDKPath();
354cdf0e10cSrcweir                 }
355cdf0e10cSrcweir             });
356cdf0e10cSrcweir 
357cdf0e10cSrcweir             jMnuOptions.add(jMenuItem);
358cdf0e10cSrcweir             _jInspectMenuBar.add(jMnuOptions);
359cdf0e10cSrcweir         }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 
insertMenus()362cdf0e10cSrcweir         private void insertMenus(){
363cdf0e10cSrcweir             JMenuBar jMenuBar1 = new javax.swing.JMenuBar();
364cdf0e10cSrcweir             addFileMenu(jMenuBar1);
365cdf0e10cSrcweir             addInspectMenu(jMenuBar1);
366cdf0e10cSrcweir             JMenu jMnuEdit = new JMenu("Edit");
367cdf0e10cSrcweir             JMenu jMnuView = new JMenu("View");
368cdf0e10cSrcweir             addOptionsMenu(jMenuBar1);
369cdf0e10cSrcweir             jMenuBar1.setFont(new java.awt.Font("Dialog", 0, 12));
370cdf0e10cSrcweir             jMenuBar1.add(jMnuEdit);
371cdf0e10cSrcweir             jMenuBar1.add(jMnuView);
372cdf0e10cSrcweir             addHelpMenu(jMenuBar1);
373cdf0e10cSrcweir             addMenuBar(jMenuBar1);
374cdf0e10cSrcweir         }
375cdf0e10cSrcweir 
addGlobalServiceManagerMenu(JMenu _jMnuRoot)376cdf0e10cSrcweir         private void addGlobalServiceManagerMenu(JMenu _jMnuRoot){
377cdf0e10cSrcweir             JMenuItem jMnuGlobalServiceManager = new JMenuItem("Global Service Manager");
378cdf0e10cSrcweir             jMnuGlobalServiceManager.addActionListener(new ActionListener(){
379cdf0e10cSrcweir                 public void actionPerformed(java.awt.event.ActionEvent evt) {
380cdf0e10cSrcweir                     m_oInspector.inspect(m_xComponentContext.getServiceManager(), "Global ServiceManager");
381cdf0e10cSrcweir                 }
382cdf0e10cSrcweir             });
383cdf0e10cSrcweir             _jMnuRoot.add(jMnuGlobalServiceManager);
384cdf0e10cSrcweir         }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 
enablePopupMenuItem(String _sMenuTitle, boolean _bdoEnable)388cdf0e10cSrcweir         public void enablePopupMenuItem(String _sMenuTitle, boolean _bdoEnable){
389cdf0e10cSrcweir             Component[] oComponents = m_jPopupMenu.getComponents();
390cdf0e10cSrcweir             for (int i = 0; i < oComponents.length; i++){
391cdf0e10cSrcweir                 if (oComponents[i] instanceof JMenuItem){
392cdf0e10cSrcweir                     JMenuItem jMenuItem = (JMenuItem) oComponents[i];
393cdf0e10cSrcweir                     if (jMenuItem.getText().equals(_sMenuTitle)){
394cdf0e10cSrcweir                         jMenuItem.setEnabled(_bdoEnable);
395cdf0e10cSrcweir                     }
396cdf0e10cSrcweir                 }
397cdf0e10cSrcweir             }
398cdf0e10cSrcweir         }
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 
showPopUpMenu(Object _invoker, int x, int y)401cdf0e10cSrcweir         public void showPopUpMenu(Object _invoker, int x, int y) throws ClassCastException{
402cdf0e10cSrcweir             if (_invoker instanceof Component){
403cdf0e10cSrcweir                 m_jPopupMenu.show((Component) _invoker, x, y);
404cdf0e10cSrcweir             }
405cdf0e10cSrcweir         }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 
show(int _nPageIndex)408cdf0e10cSrcweir     public void show(int _nPageIndex){
409cdf0e10cSrcweir         Dimension aDimension = m_jInspectorDialog.getSize();
410cdf0e10cSrcweir         selectInspectorPageByIndex(_nPageIndex);
411cdf0e10cSrcweir         if (_nPageIndex > 0){
412cdf0e10cSrcweir             m_jInspectorDialog.setSize(aDimension);
413cdf0e10cSrcweir         }
414cdf0e10cSrcweir         else{
415cdf0e10cSrcweir             m_jInspectorDialog.pack();
416cdf0e10cSrcweir         }
417cdf0e10cSrcweir //            m_jInspectorDialog.paint(m_jInspectorDialog.getGraphics());
418cdf0e10cSrcweir         m_jInspectorDialog.setVisible(true);
419cdf0e10cSrcweir     }
420cdf0e10cSrcweir 
paint()421cdf0e10cSrcweir         public void paint(){
422cdf0e10cSrcweir             m_jTabbedPane1.paintImmediately(m_jTabbedPane1.getBounds());
423cdf0e10cSrcweir         }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 
addInspectorPage(String _sTitle, Object _oContainer)426cdf0e10cSrcweir         public void addInspectorPage(String _sTitle, Object _oContainer) throws ClassCastException{
427cdf0e10cSrcweir             if (_oContainer instanceof Component){
428cdf0e10cSrcweir                 m_jTabbedPane1.addTab(_sTitle, (Component) _oContainer);
429cdf0e10cSrcweir             }
430cdf0e10cSrcweir         }
431cdf0e10cSrcweir }
432