home *** CD-ROM | disk | FTP | other *** search
Wrap
package com.ibm.ivj.testpilot.view.swing; import com.ibm.ivj.testpilot.control.MemberControlEvent; import com.ibm.ivj.testpilot.control.MemberController; import com.ibm.ivj.testpilot.model.FactoryModel; import com.ibm.ivj.testpilot.model.MemberModel; import com.ibm.ivj.testpilot.model.TypeConstructorModel; import com.ibm.ivj.testpilot.utils.ClassUtils; import com.ibm.ivj.testpilot.view.MembersViewEventListener; import com.ibm.ivj.testpilot.view.swing.list.ObjectListEventListener; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Frame; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; public class ObjectConstructorPanel extends MembersPanel { private static String copyright = "Licensed Material - Property of IBM IBM(R) VisualAge(R) for Java(TM), Version 3.5 (C) Copyright IBM Corp. 1997, 2000- All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp."; private Class targetType = null; private JSplitPane splitPane = null; private JTabbedPane tabbedPane = null; private JPanel constructorsPanel = null; private JPanel staticsPanel = null; private TreeSplitPanel constructorsSplitPanel = null; private TreeSplitPanel staticsSplitPanel = null; private ObjectListPanel objectListPanel = null; private JPanel constructorsHeaderPanel = null; private JPanel staticsHeaderPanel = null; private JLabel constructorsInLabel = null; private JLabel staticsInLabel = null; private JButton constructorsInChangeButton = null; private JButton staticsInChangeButton = null; private static final String constructorsText = ResourceHandler.getHandler().getMessage("CONSTRUCTORS"); private static final String staticsText = ResourceHandler.getHandler().getMessage("FACTORY_METHODS"); private static final String argumentsText = ResourceHandler.getHandler().getMessage("ARGUMENTS"); private static final String inText = ResourceHandler.getHandler().getMessage("IN"); private static final String changeText = ResourceHandler.getHandler().getMessage("CHANGE"); private static final String classInputTitle = ResourceHandler.getHandler().getMessage("CLASS_INPUT_TITLE"); private static final String constructorChangeMsg = ResourceHandler.getHandler().getMessage("CONSTRUCTOR_CHANGE_MSG"); private static final String factoryChangeMsg = ResourceHandler.getHandler().getMessage("FACTORY_CHANGE_MSG"); private static final String changeClassErrorTitle = ResourceHandler.getHandler().getMessage("CLASS_INPUT_ERROR_TITLE"); // $FF: synthetic field static Class class$0; public ObjectConstructorPanel(Class var1) { this.initializeType(var1); this.initialize(); } public ObjectConstructorPanel(Class var1, Frame var2) { ((MembersPanel)this).setRootFrame(var2); this.initializeType(var1); this.initialize(); } public void addMembersViewEventListener(MembersViewEventListener var1) { this.getConstructorsSplitPanel().addMembersViewEventListener(var1); this.getStaticsSplitPanel().addMembersViewEventListener(var1); } public void addObjectListEventListener(ObjectListEventListener var1) { this.getObjectListPanel().addObjectListEventListener(var1); } public void cleanup() { } private Class defaultPromptForType(String var1, String var2, Class var3) { Frame var4 = ((MembersPanel)this).getRootFrame(); Class var5 = null; String var6 = var2; if (var2 == null) { var6 = ""; } Class var7 = var3; if (var3 == null) { Class var10000 = class$0; if (var10000 == null) { try { var10000 = Class.forName("java.lang.Object"); } catch (ClassNotFoundException var14) { throw new NoClassDefFoundError(((Throwable)var14).getMessage()); } class$0 = var10000; } var7 = var10000; } boolean var8 = false; Object var9 = null; String var10 = ""; Object var11 = null; while(!var8) { var9 = JOptionPane.showInputDialog(var4, var1, classInputTitle, 3, (Icon)null, (Object[])null, var6); if (var9 == null) { var8 = true; } else { var10 = "" + var9.toString(); Class var17 = null; var6 = var10; try { var17 = Class.forName(var10); } catch (Throwable var13) { JOptionPane.showMessageDialog(var4, "" + var13, changeClassErrorTitle, 0); } if (var17 != null) { if (var7.isAssignableFrom(var17)) { var5 = var17; var8 = true; } else { JOptionPane.showMessageDialog(var4, ResourceHandler.getHandler().getMessage("CLASS_ASSIGN_ERROR", var10, var3.getName()), changeClassErrorTitle, 0); } } } } return var5; } private Class getClassFromUser(String var1, String var2, Class var3) { return !MemberController.getVmAllowsClassPrompting() ? this.defaultPromptForType(var1, var2, var3) : this.defaultPromptForType(var1, var2, var3); } private JPanel getConstructorsHeaderPanel() { if (this.constructorsHeaderPanel == null) { this.constructorsHeaderPanel = new JPanel(new BorderLayout()); this.constructorsHeaderPanel.add(this.getConstructorsInLabel(), "Center"); this.constructorsHeaderPanel.add(this.getConstructorsInChangeButton(), "East"); this.constructorsHeaderPanel.setBorder(BorderFactory.createEtchedBorder()); } return this.constructorsHeaderPanel; } private JButton getConstructorsInChangeButton() { if (this.constructorsInChangeButton == null) { this.constructorsInChangeButton = new JButton(changeText); this.constructorsInChangeButton.addActionListener(new 1(this)); } return this.constructorsInChangeButton; } private JLabel getConstructorsInLabel() { if (this.constructorsInLabel == null) { String var1 = ClassUtils.getLongNameFor(this.getTargetType()); this.constructorsInLabel = new JLabel(constructorsText + " " + inText + " " + var1); this.constructorsInLabel.setHorizontalAlignment(0); } return this.constructorsInLabel; } private JPanel getConstructorsPanel() { if (this.constructorsPanel == null) { this.constructorsPanel = new JPanel(new BorderLayout()); this.constructorsPanel.add(this.getConstructorsHeaderPanel(), "North"); this.constructorsPanel.add(this.getConstructorsSplitPanel(), "Center"); } return this.constructorsPanel; } private TreeSplitPanel getConstructorsSplitPanel() { if (this.constructorsSplitPanel == null) { this.constructorsSplitPanel = new TreeSplitPanel(new TypeConstructorModel(this.getTargetType()), constructorsText, argumentsText); this.constructorsSplitPanel.addMemberControlEventListener(new 2(this)); } return this.constructorsSplitPanel; } public MemberController getInvokeTarget() { switch (this.getTabbedPane().getSelectedIndex()) { case 0: return this.getConstructorsSplitPanel().getInvokeTarget(); case 1: return this.getStaticsSplitPanel().getInvokeTarget(); default: return null; } } public Object getNewObject() { return this.getObjectListPanel().getSelectedObject(); } private ObjectListPanel getObjectListPanel() { if (this.objectListPanel == null) { this.objectListPanel = new ObjectListPanel(); } return this.objectListPanel; } public MemberController getSelectedController() { switch (this.getTabbedPane().getSelectedIndex()) { case 0: return this.getConstructorsSplitPanel().getSelectedController(); case 1: return this.getStaticsSplitPanel().getSelectedController(); default: return null; } } private JSplitPane getSplitPane() { if (this.splitPane == null) { this.splitPane = new MySplitPane(0); this.splitPane.setTopComponent(this.getTabbedPane()); this.splitPane.setBottomComponent(this.getObjectListPanel()); this.splitPane.setDividerLocation((double)0.75F); } return this.splitPane; } private JPanel getStaticsHeaderPanel() { if (this.staticsHeaderPanel == null) { this.staticsHeaderPanel = new JPanel(new BorderLayout()); this.staticsHeaderPanel.add(this.getStaticsInLabel(), "Center"); this.staticsHeaderPanel.add(this.getStaticsInChangeButton(), "East"); this.staticsHeaderPanel.setBorder(BorderFactory.createEtchedBorder()); } return this.staticsHeaderPanel; } private JButton getStaticsInChangeButton() { if (this.staticsInChangeButton == null) { this.staticsInChangeButton = new JButton(changeText); this.staticsInChangeButton.addActionListener(new 3(this)); } return this.staticsInChangeButton; } private JLabel getStaticsInLabel() { if (this.staticsInLabel == null) { String var1 = ClassUtils.getLongNameFor(this.getTargetType()); this.staticsInLabel = new JLabel(staticsText + " " + inText + " " + var1); this.staticsInLabel.setHorizontalAlignment(0); } return this.staticsInLabel; } private JPanel getStaticsPanel() { if (this.staticsPanel == null) { this.staticsPanel = new JPanel(new BorderLayout()); this.staticsPanel.add(this.getStaticsHeaderPanel(), "North"); this.staticsPanel.add(this.getStaticsSplitPanel(), "Center"); } return this.staticsPanel; } private TreeSplitPanel getStaticsSplitPanel() { if (this.staticsSplitPanel == null) { this.staticsSplitPanel = new TreeSplitPanel(new FactoryModel(this.getTargetType()), staticsText, argumentsText); this.staticsSplitPanel.addMemberControlEventListener(new 4(this)); } return this.staticsSplitPanel; } private JTabbedPane getTabbedPane() { if (this.tabbedPane == null) { this.tabbedPane = new JTabbedPane(); this.tabbedPane.add(constructorsText, this.getConstructorsPanel()); this.tabbedPane.add(staticsText, this.getStaticsPanel()); } return this.tabbedPane; } public Class getTargetType() { if (this.targetType == null) { Class var10001 = class$0; if (var10001 == null) { try { var10001 = Class.forName("java.lang.Object"); } catch (ClassNotFoundException var1) { throw new NoClassDefFoundError(((Throwable)var1).getMessage()); } class$0 = var10001; } this.targetType = var10001; } return this.targetType; } private void handleConstructorClassChange() { Class var1 = this.getTargetType(); Class var2 = this.getClassFromUser(constructorChangeMsg, var1.getName(), var1); if (var2 != null && !var2.equals(var1)) { this.getConstructorsSplitPanel().replaceModel(new TypeConstructorModel(var2)); this.getConstructorsSplitPanel().getTree().setSelectionRow(1); this.getConstructorsInLabel().setText(constructorsText + " " + inText + " " + ClassUtils.getLongNameFor(var2)); } } private void handleNewInstanceEvent(MemberControlEvent var1) { if (var1 != null) { Object var2 = var1.getResultObject(); if (var2 != null) { this.getObjectListPanel().addObject(var2); } } } private void handleStaticsClassChange() { Class var1 = this.getTargetType(); Class var2 = this.getStaticsSplitPanel().getRootController().getModel().getActualType(); Class var3 = this.getClassFromUser(factoryChangeMsg, var2.getName(), (Class)null); if (var3 != null && !var3.equals(var2)) { this.getStaticsSplitPanel().replaceModel(new FactoryModel(var3, var1)); this.getStaticsSplitPanel().getTree().setSelectionRow(1); this.getStaticsInLabel().setText(staticsText + " " + inText + " " + ClassUtils.getLongNameFor(var3)); } } private void initialize() { ((Container)this).setLayout(new BorderLayout()); ((Container)this).add(this.getSplitPane(), "Center"); } private void initializeType(Class var1) { this.targetType = var1; } public void removeObjectListEventListener(ObjectListEventListener var1) { this.getObjectListPanel().removeObjectListEventListener(var1); } public void replaceModel(MemberModel var1) { this.getConstructorsSplitPanel().replaceModel(var1); } private Class vajPromptForType(String var1, String var2, Class var3) { return null; } // $FF: synthetic method static void access$0(ObjectConstructorPanel var0) { var0.handleConstructorClassChange(); } // $FF: synthetic method static void access$1(ObjectConstructorPanel var0, MemberControlEvent var1) { var0.handleNewInstanceEvent(var1); } // $FF: synthetic method static void access$2(ObjectConstructorPanel var0) { var0.handleStaticsClassChange(); } }