/** Second part of debugger start procedure. */ private void startDebugger() { threadManager = new ThreadManager(this); setBreakpoints(); updateWatches(); println(bundle.getString("CTL_Debugger_running"), STL_OUT); setDebuggerState(DEBUGGER_RUNNING); virtualMachine.resume(); // start refresh thread ................................................. if (debuggerThread != null) debuggerThread.stop(); debuggerThread = new Thread( new Runnable() { public void run() { for (; ; ) { try { Thread.sleep(5000); } catch (InterruptedException ex) { } if (getState() == DEBUGGER_RUNNING) threadGroup.refresh(); } } }, "Debugger refresh thread"); // NOI18N debuggerThread.setPriority(Thread.MIN_PRIORITY); debuggerThread.start(); }
/** Returns version of this debugger. */ public String getVersion() { return bundle.getString("CTL_Debugger_version"); /* if (virtualMachine != null) return virtualMachine.versionDescription () + " (" + virtualMachine.majorVersion () + "/" + virtualMachine.minorVersion () + ")"; else return bundle.getString ("CTL_Debugger_version");*/ }
protected String getResourceString(String nm) { String str; try { str = resources.getString(nm); } catch (MissingResourceException mre) { str = null; } return str; }
private VirtualMachine connect(String bndlPrefix, AttachingConnector connector, Map args) throws DebuggerException { if (bndlPrefix != null) { if (connector.transport().name().equals("dt_shmem")) { Argument a = (Argument) args.get("name"); if (a == null) println(bundle.getString(bndlPrefix + "_shmem_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_shmem")) .format(new Object[] {a.value()}), ERR_OUT); } else if (connector.transport().name().equals("dt_socket")) { Argument name = (Argument) args.get("hostname"); Argument port = (Argument) args.get("port"); if ((name == null) || (port == null)) println(bundle.getString(bndlPrefix + "_socket_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_socket")) .format(new Object[] {name.value(), port.value()}), ERR_OUT); } else println(bundle.getString(bndlPrefix), ERR_OUT); } // launch VM try { // S ystem.out.println ("attach to:" + ac + " : " + password); // NOI18N return connector.attach(args); } catch (Exception e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_connecting_to_debuggee")) .format(new Object[] {e.toString()}), e); } }
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Open Source Project license - unknown ResourceBundle bundle = ResourceBundle.getBundle("InformationDialog"); JPanel dialogPane = new JPanel(); JPanel contentPanel = new JPanel(); iconLabel = new JLabel(); pathLabel = new JLabel(); JLabel labelFrom = new JLabel(); fieldFrom = new JTextField(); JLabel labelSize = new JLabel(); fieldSize = new JTextField(); JLabel labelDescription = new JLabel(); JScrollPane scrollPane1 = new JScrollPane(); descriptionArea = ComponentFactory.getTextArea(); JPanel optionsPanel = new JPanel(); JLabel saveToLabel = new JLabel(); comboPath = new JComboBox(); btnSelectPath = new JButton(); progressBar = new JProgressBar(); JLabel labelRemaining = new JLabel(); remainingLabel = new JLabel(); JLabel labelEstimateTime = new JLabel(); estTimeLabel = new JLabel(); JLabel labelCurrentSpeed = new JLabel(); currentSpeedLabel = new JLabel(); JLabel labelAverageSpeed = new JLabel(); avgSpeedLabel = new JLabel(); JXButtonPanel buttonBar = new JXButtonPanel(); okButton = new JButton(); cancelButton = new JButton(); CellConstraints cc = new CellConstraints(); // ======== this ======== Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); // ======== dialogPane ======== { dialogPane.setBorder(Borders.DIALOG); dialogPane.setLayout(new BorderLayout()); // ======== contentPanel ======== { // ---- iconLabel ---- iconLabel.setText(bundle.getString("iconLabel.text")); // ---- pathLabel ---- pathLabel.setText(bundle.getString("pathLabel.text")); pathLabel.setFont(new Font("Tahoma", Font.BOLD, 12)); // ---- labelFrom ---- labelFrom.setText(bundle.getString("labelFrom.text")); // ---- fieldFrom ---- fieldFrom.setBorder(null); fieldFrom.setOpaque(false); fieldFrom.setText(bundle.getString("fieldFrom.text")); // ---- labelSize ---- labelSize.setText(bundle.getString("labelSize.text")); // ---- fieldSize ---- fieldSize.setBorder(null); fieldSize.setOpaque(false); // ---- labelDescription ---- labelDescription.setText(bundle.getString("labelDescription.text")); // ======== scrollPane1 ======== { scrollPane1.setViewportView(descriptionArea); } // ======== optionsPanel ======== { // ---- saveToLabel ---- saveToLabel.setText(bundle.getString("saveToLabel.text")); saveToLabel.setLabelFor(comboPath); // ---- comboPath ---- comboPath.setEditable(true); // ---- btnSelectPath ---- btnSelectPath.setText(bundle.getString("btnSelectPath.text")); PanelBuilder optionsPanelBuilder = new PanelBuilder( new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC }, RowSpec.decodeSpecs("default")), optionsPanel); optionsPanelBuilder.add(saveToLabel, cc.xy(1, 1)); optionsPanelBuilder.add(comboPath, cc.xy(3, 1)); optionsPanelBuilder.add(btnSelectPath, cc.xy(5, 1)); } // ---- progressBar ---- progressBar.setFont(new Font("Tahoma", Font.BOLD, 16)); // ---- labelRemaining ---- labelRemaining.setText(bundle.getString("labelRemaining.text")); // ---- remainingLabel ---- remainingLabel.setText(bundle.getString("remainingLabel.text")); remainingLabel.setFont(new Font("Tahoma", Font.BOLD, 12)); // ---- labelEstimateTime ---- labelEstimateTime.setText(bundle.getString("labelEstimateTime.text")); // ---- estTimeLabel ---- estTimeLabel.setText(bundle.getString("estTimeLabel.text")); estTimeLabel.setFont(new Font("Tahoma", Font.BOLD, 12)); // ---- labelCurrentSpeed ---- labelCurrentSpeed.setText(bundle.getString("labelCurrentSpeed.text")); // ---- currentSpeedLabel ---- currentSpeedLabel.setText(bundle.getString("currentSpeedLabel.text")); currentSpeedLabel.setFont(new Font("Tahoma", Font.BOLD, 12)); // ---- labelAverageSpeed ---- labelAverageSpeed.setText(bundle.getString("labelAverageSpeed.text")); // ---- avgSpeedLabel ---- avgSpeedLabel.setText(bundle.getString("avgSpeedLabel.text")); avgSpeedLabel.setFont(new Font("Tahoma", Font.BOLD, 12)); PanelBuilder contentPanelBuilder = new PanelBuilder( new FormLayout( new ColumnSpec[] { new ColumnSpec(Sizes.dluX(49)), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("max(min;70dlu)") }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, new RowSpec( RowSpec.FILL, Sizes.bounded(Sizes.PREFERRED, Sizes.dluY(40), Sizes.dluY(50)), FormSpec.DEFAULT_GROW), FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, RowSpec.decode("fill:max(pref;20dlu)"), FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC }), contentPanel); contentPanelBuilder.add(iconLabel, cc.xywh(1, 1, 1, 5)); contentPanelBuilder.add(pathLabel, cc.xywh(3, 1, 7, 1)); contentPanelBuilder.add(labelFrom, cc.xy(3, 3)); contentPanelBuilder.add(fieldFrom, cc.xywh(5, 3, 5, 1)); contentPanelBuilder.add(labelSize, cc.xy(3, 5)); contentPanelBuilder.add(fieldSize, cc.xywh(5, 5, 3, 1)); contentPanelBuilder.add(labelDescription, cc.xy(1, 7)); contentPanelBuilder.add(scrollPane1, cc.xywh(1, 9, 9, 1)); contentPanelBuilder.add(optionsPanel, cc.xywh(1, 11, 9, 1)); contentPanelBuilder.add(progressBar, cc.xywh(1, 13, 9, 1)); contentPanelBuilder.add(labelRemaining, cc.xy(1, 15)); contentPanelBuilder.add(remainingLabel, cc.xywh(3, 15, 3, 1)); contentPanelBuilder.add(labelEstimateTime, cc.xy(7, 15)); contentPanelBuilder.add(estTimeLabel, cc.xy(9, 15)); contentPanelBuilder.add(labelCurrentSpeed, cc.xy(1, 17)); contentPanelBuilder.add(currentSpeedLabel, cc.xywh(3, 17, 3, 1)); contentPanelBuilder.add(labelAverageSpeed, cc.xy(7, 17)); contentPanelBuilder.add(avgSpeedLabel, cc.xy(9, 17)); } dialogPane.add(contentPanel, BorderLayout.CENTER); // ======== buttonBar ======== { buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); // ---- okButton ---- okButton.setText(bundle.getString("okButton.text")); // ---- cancelButton ---- cancelButton.setText(bundle.getString("cancelButton.text")); PanelBuilder buttonBarBuilder = new PanelBuilder( new FormLayout( new ColumnSpec[] { new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormSpecs.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("max(pref;55dlu)"), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC }, RowSpec.decodeSpecs("fill:pref")), buttonBar); ((FormLayout) buttonBar.getLayout()).setColumnGroups(new int[][] {{3, 5}}); buttonBarBuilder.add(okButton, cc.xy(3, 1)); buttonBarBuilder.add(cancelButton, cc.xy(5, 1)); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } contentPane.add(dialogPane, BorderLayout.CENTER); pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents }
private VirtualMachine launch(DebuggerInfo info) throws DebuggerException { // create process & read password for local debugging // create main class & arguments ............................................... StringBuffer sb = new StringBuffer(); sb.append(mainClassName); String[] infoArgs = info.getArguments(); int i, k = infoArgs.length; for (i = 0; i < k; i++) sb.append(" \"").append(infoArgs[i]).append('"'); // NOI18N String main = new String(sb); // create connector .............................................................. VirtualMachineManager vmm = Bootstrap.virtualMachineManager(); java.util.List lcs = vmm.launchingConnectors(); k = lcs.size(); for (i = 0; i < k; i++) if (((LaunchingConnector) lcs.get(i)).name().indexOf("RawCommandLineLaunch") >= 0) // NOI18N break; if (i == k) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Cannot_find_launcher")) .format( new Object[] { "RawCommandLineLaunch" // NOI18N })); } LaunchingConnector lc = (LaunchingConnector) lcs.get(i); String transport = lc.transport().name(); // create commandLine & NbProcessDescriptor .............................. NbProcessDescriptor debugerProcess; if (info instanceof ProcessDebuggerInfo) debugerProcess = ((ProcessDebuggerInfo) info).getDebuggerProcess(); else debugerProcess = ProcessDebuggerType.DEFAULT_DEBUGGER_PROCESS; // generate password String password; if (transport.equals("dt_shmem")) { // NOI18N connector = getAttachingConnectorFor("dt_shmem"); password = generatePassword(); args = connector.defaultArguments(); ((Argument) args.get("name")).setValue(password); } else { try { java.net.ServerSocket ss = new java.net.ServerSocket(0); password = "" + ss.getLocalPort(); // NOI18N ss.close(); } catch (java.io.IOException e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Cannot_find_empty_local_port")) .format(new Object[] {e.toString()})); } connector = getAttachingConnectorFor("dt_socket"); args = connector.defaultArguments(); ((Argument) args.get("port")).setValue(password); } HashMap map = Utils.processDebuggerInfo( info, "-Xdebug -Xnoagent -Xrunjdwp:transport=" + // NOI18N transport + ",address=" + // NOI18N password + ",suspend=y ", // NOI18N main); MapFormat format = new MapFormat(map); String commandLine = format.format( debugerProcess.getProcessName() + " " + // NOI18N debugerProcess.getArguments()); println(commandLine, ERR_OUT); /* We mus wait on process start to connect... try { process = debugerProcess.exec (format); } catch (java.io.IOException exc) { finishDebugger (); throw new DebuggerException ( new MessageFormat (bundle.getString ("EXC_While_create_debuggee")). format (new Object[] { debugerProcess.getProcessName (), exc.toString () }), exc ); } return connect ( null, connector, args );*/ /* S ystem.out.println ("attaching: "); Utils.showConnectors (vmm.attachingConnectors ()); S ystem.out.println ("launching: "); Utils.showConnectors (vmm.launchingConnectors ()); S ystem.out.println ("listening: "); Utils.showConnectors (vmm.listeningConnectors ());*/ // set debugger-start arguments Map params = lc.defaultArguments(); ((Argument) params.get("command")) .setValue( // NOI18N commandLine); ((Argument) params.get("address")) .setValue( // NOI18N password); // launch VM try { return lc.launch(params); } catch (VMStartException exc) { showOutput(process = exc.process(), ERR_OUT, ERR_OUT); finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_create_debuggee")) .format( new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}), exc); } catch (Exception exc) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_create_debuggee")) .format( new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}), exc); } }
/** * Starts the debugger. The method stops the current debugging (if any) and takes information from * the provided info (containing the class to start and arguments to pass it and name of class to * stop debugging in) and starts new debugging session. * * @param info debugger info about class to start * @exception DebuggerException if an error occures during the start of the debugger */ public void startDebugger(DebuggerInfo info) throws DebuggerException { debuggerInfo = info; if (virtualMachine != null) finishDebugger(); stopOnMain = info.getStopClassName() != null; mainClassName = info .getClassName(); // S ystem.out.println ("JPDADebugger stop on " + info.getStopClassName // ()); // NOI18N // open output window ... super.startDebugger(info); // stop on main if (stopOnMain) { try { String stopClassName = debuggerInfo.getStopClassName(); AbstractDebugger d = (AbstractDebugger) TopManager.getDefault().getDebugger(); breakpointMain = new CoreBreakpoint[stopMethodNames.length]; for (int x = 0; x < breakpointMain.length; x++) { breakpointMain[x] = (CoreBreakpoint) d.createBreakpoint(true); breakpointMain[x].setClassName(""); // NOI18N breakpointMain[x].setMethodName(stopMethodNames[x]); // NOI18N CoreBreakpoint.Action[] a = breakpointMain[x].getActions(); int i, ii = a.length; for (i = 0; i < ii; i++) if (a[i] instanceof PrintAction) { ((PrintAction) a[i]).setPrintText(bundle.getString("CTL_Stop_On_Main_print_text")); } breakpointMain[x].setClassName(stopClassName); } addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent ev) { if (ev.getPropertyName().equals(PROP_STATE)) { if ((((Integer) ev.getNewValue()).intValue() == DEBUGGER_STOPPED) || (((Integer) ev.getNewValue()).intValue() == DEBUGGER_NOT_RUNNING)) { if (breakpointMain != null) { for (int x = 0; x < breakpointMain.length; x++) breakpointMain[x].remove(); breakpointMain = null; } removePropertyChangeListener(this); } } } }); } catch (DebuggerException e) { e.printStackTrace(); } } // start & init remote debugger ............................................ boolean launch = false; if (info instanceof ReconnectDebuggerInfo) { virtualMachine = reconnect((ReconnectDebuggerInfo) info); } else if (info instanceof RemoteDebuggerInfo) { virtualMachine = connect((RemoteDebuggerInfo) info); } else { virtualMachine = launch(info); process = virtualMachine.process(); showOutput(process, STD_OUT, STD_OUT); connectInput(process); launch = true; } requestManager = virtualMachine.eventRequestManager(); operator = new Operator( virtualMachine, launch ? new Runnable() { public void run() { startDebugger(); } } : null, new Runnable() { public void run() { try { finishDebugger(); } catch (DebuggerException e) { } } }); operator.start(); if (!launch) startDebugger(); }
// ------------------------------------------------------------------------ TextViewer(JFrame inParentFrame) { // super(true); //is double buffered - only for panels textViewerFrame = this; parentFrame = inParentFrame; lastViewedDirStr = ""; lastViewedFileStr = ""; setTitle(resources.getString("Title")); addWindowListener(new AppCloser()); pack(); setSize(500, 600); warningPopup = new WarningDialog(this); okCancelPopup = new WarningDialogOkCancel(this); messagePopup = new MessageDialog(this); okCancelMessagePopup = new MessageDialogOkCancel(this); // Force SwingSet to come up in the Cross Platform L&F try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); // If you want the System L&F instead, comment out the above line and // uncomment the following: // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception exc) { String errstr = "TextViewer:Error loading L&F: " + exc; warningPopup.display(errstr); } Container cf = getContentPane(); cf.setBackground(Color.lightGray); // Border etched=BorderFactory.createEtchedBorder(); // Border title=BorderFactory.createTitledBorder(etched,"TextViewer"); // cf.setBorder(title); cf.setLayout(new BorderLayout()); // create the embedded JTextComponent editor1 = createEditor(); editor1.setFont(new Font("monospaced", Font.PLAIN, 12)); // aa -added next line setPlainDocument((PlainDocument) editor1.getDocument()); // sets doc1 // install the command table commands = new Hashtable(); Action[] actions = getActions(); for (int i = 0; i < actions.length; i++) { Action a = actions[i]; commands.put(a.getValue(Action.NAME), a); // System.out.println("Debug:TextViewer: actionName:"+a.getValue(Action.NAME)); } // editor1.setPreferredSize(new Dimension(,)); // get setting from user preferences if (UserPref.keymapType.equals("Word")) { editor1 = updateKeymapForWord(editor1); } else { editor1 = updateKeymapForEmacs(editor1); } scroller1 = new JScrollPane(); viewport1 = scroller1.getViewport(); viewport1.add(editor1); scroller1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scroller1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); try { String vpFlag = resources.getString("ViewportBackingStore"); Boolean bs = new Boolean(vpFlag); viewport1.setBackingStoreEnabled(bs.booleanValue()); } catch (MissingResourceException mre) { System.err.println("TextViewer:missing resource:" + mre.getMessage()); // just use the viewport1 default } menuItems = new Hashtable(); menubar = createMenubar(); lowerPanel = new JPanel(true); // moved double buffering to here lowerPanel.setLayout(new BorderLayout()); lowerPanel.add("North", createToolbar()); lowerPanel.add("Center", scroller1); cf.add("North", menubar); cf.add("Center", lowerPanel); cf.add("South", createStatusbar()); // for the find/search utilities mySearchDialog = new SearchDialog(this); // System.out.println("Debug:TextViewer: end of TextViewer constructor"); }
public void init() { symbolData = new Icon[] { new ImageIcon(getClass().getResource("images/sym_square.gif")), new ImageIcon(getClass().getResource("images/sym_squarefilled.gif")), new ImageIcon(getClass().getResource("images/sym_circle.gif")), new ImageIcon(getClass().getResource("images/sym_circlefilled.gif")), new ImageIcon(getClass().getResource("images/sym_diamond.gif")), new ImageIcon(getClass().getResource("images/sym_diamondfilled.gif")), new ImageIcon(getClass().getResource("images/sym_triangle.gif")), new ImageIcon(getClass().getResource("images/sym_trianglefilled.gif")), new ImageIcon(getClass().getResource("images/sym_cross1.gif")), new ImageIcon(getClass().getResource("images/sym_cross2.gif")) }; mSymbolPopup = new JOAJComboBox(); for (int i = 0; i < symbolData.length; i++) { mSymbolPopup.addItem(symbolData[i]); } mSymbolPopup.setSelectedIndex(mCurrSymbol - 1); JPanel everyThingPanel = new JPanel(new BorderLayout(5, 5)); // create the two parameter chooser lists Container contents = this.getContentPane(); this.getContentPane().setLayout(new BorderLayout(5, 5)); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout(5, 5)); JPanel paramPanel = new JPanel(new GridLayout(1, 2, 5, 5)); JPanel upperPanel = new JPanel(new BorderLayout(5, 5)); mYParamList = new StnParameterChooser(mFileViewer, new String("Stations Parameters:"), this, 5, "SALT"); OffsetPanel ofp = new OffsetPanel(this); mYParamList.init(); paramPanel.add(mYParamList); paramPanel.add(ofp); upperPanel.add("Center", paramPanel); everyThingPanel.add(BorderLayout.NORTH, upperPanel); // Options JPanel middlePanel = new JPanel(); middlePanel.setLayout(new ColumnLayout(Orientation.CENTER, Orientation.TOP, 3)); TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOptions")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } middlePanel.setBorder(tb); // containers for the non-advanced options JPanel nonAdvOptions = new JPanel(); nonAdvOptions.setLayout(new BorderLayout(5, 0)); JPanel ctrNonAdvOptions = new JPanel(); ctrNonAdvOptions.setLayout(new GridLayout(1, 2, 2, 2)); // plot axes goes in ctrNonAdvOptions JPanel axesOptions = new JPanel(); axesOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); tb = BorderFactory.createTitledBorder(b.getString("kAxes")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } axesOptions.setBorder(tb); JPanel line0 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line33 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); mConnectObs = new JOAJCheckBox(b.getString("kConnectObservations"), true); mReverseY = new JOAJCheckBox(b.getString("kReverseYAxis"), false); mReverseY.addItemListener(this); mPlotYGrid = new JOAJCheckBox(b.getString("kYGrid")); mPlotXGrid = new JOAJCheckBox(b.getString("kXGrid")); line0.add(mConnectObs); line1.add(mReverseY); line3.add(mPlotYGrid); line33.add(mPlotXGrid); axesOptions.add(line1); axesOptions.add(line3); axesOptions.add(line33); // other options JPanel otherOptions = new JPanel(); otherOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); tb = BorderFactory.createTitledBorder(b.getString("kOther")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } otherOptions.setBorder(tb); // plot symbols JPanel line4 = new JPanel(); line4.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); mEnableSymbols = new JOAJLabel(b.getString("kSymbol")); line4.add(mEnableSymbols); line4.add(mSymbolPopup); mSymbolPopup.addItemListener(this); mSizeLabel = new JOAJLabel(b.getString("kSize")); line4.add(mSizeLabel); SpinnerNumberModel model = new SpinnerNumberModel(4, 1, 100, 1); mSizeField = new JSpinner(model); line4.add(mSizeField); otherOptions.add(line0); otherOptions.add(line4); // add the axes and other panels to the gridlayout ctrNonAdvOptions.add(axesOptions); ctrNonAdvOptions.add(otherOptions); // add this panel to the north of the borderlayout nonAdvOptions.add("Center", ctrNonAdvOptions); JPanel colorNameContPanel = new JPanel(); colorNameContPanel.setLayout(new BorderLayout(0, 0)); JPanel colorNamePanel = new JPanel(); colorNamePanel.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); // swatches JPanel lineLCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); lineLCS.add(new JOAJLabel(b.getString("kLineColor"))); mLineColorSwatch = new Swatch(Color.black, 12, 12); lineLCS.add(new JOAJLabel(" ")); lineLCS.add(mLineColorSwatch); JPanel lineSCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); lineSCS.add(new JOAJLabel(b.getString("kSymbolColor"))); mSymbolColorSwatch = new Swatch(Color.black, 12, 12); lineSCS.add(new JOAJLabel(" ")); lineSCS.add(mSymbolColorSwatch); JPanel line7 = new JPanel(); line7.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0)); line7.add(new JOAJLabel(b.getString("kBackgroundColor"))); plotBg = new Swatch(JOAConstants.DEFAULT_CONTENTS_COLOR, 12, 12); line7.add(new JOAJLabel(" ")); line7.add(plotBg); JPanel line8 = new JPanel(); line8.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0)); line8.add(new JOAJLabel(b.getString("kGridColor"))); axesColor = new Swatch(Color.black, 12, 12); line8.add(new JOAJLabel(" ")); line8.add(axesColor); JPanel line9 = new JPanel(); line9.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); line9.add(new JOAJLabel(b.getString("kColorSchemes"))); Vector<String> presetSchemes = new Vector<String>(); presetSchemes.addElement(b.getString("kDefault")); presetSchemes.addElement(b.getString("kWhiteBackground")); presetSchemes.addElement(b.getString("kBlackBackground")); presetColorSchemes = new JOAJComboBox(presetSchemes); presetColorSchemes.setSelectedItem(b.getString("kDefault")); presetColorSchemes.addItemListener(this); line9.add(presetColorSchemes); JPanel swatchCont = new JPanel(); swatchCont.setLayout(new GridLayout(4, 1, 0, 5)); swatchCont.add(lineLCS); swatchCont.add(lineSCS); swatchCont.add(line7); swatchCont.add(line8); JPanel swatchContCont = new JPanel(); swatchContCont.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); swatchContCont.add(swatchCont); swatchContCont.add(line9); tb = BorderFactory.createTitledBorder(b.getString("kColors")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } swatchContCont.setBorder(tb); // window name JPanel namePanel = new JPanel(); namePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 5)); namePanel.add(new JOAJLabel(b.getString("kWindowName"))); mNameField = new JOAJTextField(30); mNameField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); namePanel.add(mNameField); // add the color panel colorNameContPanel.add("North", swatchContCont); colorNamePanel.add(colorNameContPanel); // add the name panel colorNamePanel.add(namePanel); // add these to the south of the borderlayout nonAdvOptions.add("South", colorNamePanel); // add all of this to the middle panel middlePanel.add(nonAdvOptions); // advanced options panel // axis container // y axis detail // container for the axes stuff plotScaleCont = new JPanel(new GridLayout(1, 2, 5, 5)); // y axis container JPanel yAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2)); tb = BorderFactory.createTitledBorder(b.getString("kYAxis")); yAxis.setBorder(tb); StnPlotSpecification mPlotSpec = new StnPlotSpecification(); JPanel line5y = new JPanel(); line5y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line5y.add(new JOAJLabel(b.getString("kMinimum"))); yMin = new JOAJTextField(6); yMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMin()), 3, false)); yMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line5y.add(yMin); JPanel line6y = new JPanel(); line6y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line6y.add(new JOAJLabel(b.getString("kMaximum"))); yMax = new JOAJTextField(6); yMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMax()), 3, false)); yMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line6y.add(yMax); JPanel line7y = new JPanel(); line7y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line7y.add(new JOAJLabel(b.getString("kIncrement"))); yInc = new JOAJTextField(6); yInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getYInc()), 3, false)); yInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line7y.add(yInc); JPanel line8y = new JPanel(); line8y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line8y.add(new JOAJLabel(b.getString("kNoMinorTicks"))); SpinnerNumberModel model3 = new SpinnerNumberModel(mPlotSpec.getYTics(), 0, 100, 1); yTics = new JSpinner(model3); line8y.add(yTics); yAxis.add(line5y); yAxis.add(line6y); yAxis.add(line7y); yAxis.add(line8y); yAxis.add(new JLabel(" ")); yAxis.add(new JLabel(" ")); yAxis.add(new JLabel(" ")); plotScaleCont.add(yAxis); // x axis container JPanel xAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2)); tb = BorderFactory.createTitledBorder(b.getString("kXAxis")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } xAxis.setBorder(tb); JPanel line5x = new JPanel(); line5x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line5x.add(mMinXLabel); xMin = new JOAJTextField(6); xMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMin()), 3, false)); xMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line5x.add(xMin); JPanel minTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1)); minTime.add(mMinXTLabel); JPanel maxTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1)); maxTime.add(mMaxXTLabel); GeoDate minDate = new GeoDate(mFileViewer.getMinDate()); minDate.decrement(1.0, GeoDate.YEARS); GeoDate maxDate = new GeoDate(mFileViewer.getMaxDate()); maxDate.increment(1.0, GeoDate.YEARS); // value, start,end SpinnerDateModel mStartDateModel = new SpinnerDateModel( new GeoDate(mFileViewer.getMinDate()), minDate, maxDate, Calendar.HOUR); mStartSpinner = new JSpinner(mStartDateModel); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(mStartSpinner, "yyyy-MM-dd HH:mm"); mStartSpinner.setEditor(dateEditor); SpinnerDateModel mEndDateModel = new SpinnerDateModel( new GeoDate(mFileViewer.getMaxDate()), minDate, maxDate, Calendar.HOUR); mEndSpinner = new JSpinner(mEndDateModel); JSpinner.DateEditor dateEditor2 = new JSpinner.DateEditor(mEndSpinner, "yyyy-MM-dd HH:mm"); minTime.add(mStartSpinner); maxTime.add(mEndSpinner); mEndSpinner.setEditor(dateEditor2); JPanel line6x = new JPanel(); line6x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line6x.add(mMaxXLabel); xMax = new JOAJTextField(6); xMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMax()), 3, false)); xMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line6x.add(xMax); JPanel line7x = new JPanel(); line7x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line7x.add(mIncLabel); xInc = new JOAJTextField(6); xInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getXInc()), 3, false)); xInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line7x.add(xInc); JPanel line8x = new JPanel(); line8x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line8x.add(mXIncLabel); SpinnerNumberModel model2 = new SpinnerNumberModel(mPlotSpec.getXTics(), 0, 100, 1); xTics = new JSpinner(model2); line8x.add(xTics); xAxis.add(minTime); xAxis.add(maxTime); xAxis.add(line5x); xAxis.add(line6x); xAxis.add(line7x); xAxis.add(line8x); plotScaleCont.add(xAxis); everyThingPanel.add(BorderLayout.CENTER, plotScaleCont); everyThingPanel.add(BorderLayout.SOUTH, middlePanel); mainPanel.add(BorderLayout.CENTER, new TenPixelBorder(everyThingPanel, 10, 10, 10, 10)); // lower panel mOKBtn = new JOAJButton(b.getString("kPlot")); mOKBtn.setActionCommand("ok"); this.getRootPane().setDefaultButton(mOKBtn); mCancelButton = new JOAJButton(b.getString("kCancel")); mCancelButton.setActionCommand("cancel"); JPanel dlgBtnsInset = new JPanel(); JPanel dlgBtnsPanel = new JPanel(); dlgBtnsInset.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 1)); dlgBtnsPanel.setLayout(new GridLayout(1, 4, 15, 1)); if (JOAConstants.ISMAC) { dlgBtnsPanel.add(mCancelButton); dlgBtnsPanel.add(mOKBtn); } else { dlgBtnsPanel.add(mOKBtn); dlgBtnsPanel.add(mCancelButton); } dlgBtnsInset.add(dlgBtnsPanel); mOKBtn.addActionListener(this); mCancelButton.addActionListener(this); mainPanel.add(new TenPixelBorder(dlgBtnsInset, 5, 5, 5, 5), "South"); contents.add("Center", mainPanel); this.pack(); runTimer(); setXRangeToDistance(); // show dialog at center of screen Rectangle dBounds = this.getBounds(); Dimension sd = Toolkit.getDefaultToolkit().getScreenSize(); int x = sd.width / 2 - dBounds.width / 2; int y = sd.height / 2 - dBounds.height / 2; this.setLocation(x, y); }
@SuppressWarnings("serial") public class ConfigureStationValuePlot extends JOAJDialog implements ListSelectionListener, ActionListener, ButtonMaintainer, ItemListener { ResourceBundle b = ResourceBundle.getBundle("javaoceanatlas.resources.JOAResources"); protected FileViewer mFileViewer; protected String mTitle; protected Component mComp; protected StnParameterChooser mYParamList; protected int mSelYParam = -1; protected JOAJButton mOKBtn = null; protected JOAJButton mCancelButton = null; protected JOAJTextField mNameField = null; protected JOAJRadioButton b1 = null; protected JOAJRadioButton b2 = null; protected JOAJRadioButton b3 = null; protected int mOffset = JOAConstants.PROFDISTANCE; protected Swatch plotBg = null; protected Swatch axesColor = null; protected Swatch mLineColorSwatch = null; protected Swatch mSymbolColorSwatch = null; protected JOAJComboBox presetColorSchemes = null; protected JOAJCheckBox mReverseY = null; protected JOAJCheckBox mPlotYGrid = null; protected JOAJCheckBox mPlotXGrid = null; protected JOAJComboBox mSymbolPopup = null; protected int mCurrSymbol = JOAConstants.SYMBOL_CROSS1; protected Icon[] symbolData = null; protected JSpinner mSizeField = null; protected JOAJLabel mEnableSymbols = null; protected JOAJLabel mSizeLabel = null; private Timer timer = new Timer(); protected JOAJTextField yMin, yMax, yInc; protected JSpinner yTics, xTics; protected JOAJTextField xMin, xMax, xInc; protected JPanel plotScaleCont = null; protected int pPos = -1; protected int yTicsVal = 1; protected int xTicsVal = 1; private JOAJLabel mMinXLabel = new JOAJLabel(b.getString("kMinimum")); private JOAJLabel mMaxXLabel = new JOAJLabel(b.getString("kMaximum")); private JOAJLabel mIncLabel = new JOAJLabel(b.getString("kIncrement")); private JOAJLabel mMinXTLabel = new JOAJLabel(b.getString("kMinimum")); private JOAJLabel mMaxXTLabel = new JOAJLabel(b.getString("kMaximum")); private JOAJLabel mXIncLabel = new JOAJLabel(b.getString("kNoMinorTicks")); private JSpinner mStartSpinner; private JSpinner mEndSpinner; private JCheckBox mConnectObs; public ConfigureStationValuePlot(JFrame par, FileViewer fv) { super(par, "Station Value Plot", false); mFileViewer = fv; this.init(); } public void init() { symbolData = new Icon[] { new ImageIcon(getClass().getResource("images/sym_square.gif")), new ImageIcon(getClass().getResource("images/sym_squarefilled.gif")), new ImageIcon(getClass().getResource("images/sym_circle.gif")), new ImageIcon(getClass().getResource("images/sym_circlefilled.gif")), new ImageIcon(getClass().getResource("images/sym_diamond.gif")), new ImageIcon(getClass().getResource("images/sym_diamondfilled.gif")), new ImageIcon(getClass().getResource("images/sym_triangle.gif")), new ImageIcon(getClass().getResource("images/sym_trianglefilled.gif")), new ImageIcon(getClass().getResource("images/sym_cross1.gif")), new ImageIcon(getClass().getResource("images/sym_cross2.gif")) }; mSymbolPopup = new JOAJComboBox(); for (int i = 0; i < symbolData.length; i++) { mSymbolPopup.addItem(symbolData[i]); } mSymbolPopup.setSelectedIndex(mCurrSymbol - 1); JPanel everyThingPanel = new JPanel(new BorderLayout(5, 5)); // create the two parameter chooser lists Container contents = this.getContentPane(); this.getContentPane().setLayout(new BorderLayout(5, 5)); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout(5, 5)); JPanel paramPanel = new JPanel(new GridLayout(1, 2, 5, 5)); JPanel upperPanel = new JPanel(new BorderLayout(5, 5)); mYParamList = new StnParameterChooser(mFileViewer, new String("Stations Parameters:"), this, 5, "SALT"); OffsetPanel ofp = new OffsetPanel(this); mYParamList.init(); paramPanel.add(mYParamList); paramPanel.add(ofp); upperPanel.add("Center", paramPanel); everyThingPanel.add(BorderLayout.NORTH, upperPanel); // Options JPanel middlePanel = new JPanel(); middlePanel.setLayout(new ColumnLayout(Orientation.CENTER, Orientation.TOP, 3)); TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOptions")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } middlePanel.setBorder(tb); // containers for the non-advanced options JPanel nonAdvOptions = new JPanel(); nonAdvOptions.setLayout(new BorderLayout(5, 0)); JPanel ctrNonAdvOptions = new JPanel(); ctrNonAdvOptions.setLayout(new GridLayout(1, 2, 2, 2)); // plot axes goes in ctrNonAdvOptions JPanel axesOptions = new JPanel(); axesOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); tb = BorderFactory.createTitledBorder(b.getString("kAxes")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } axesOptions.setBorder(tb); JPanel line0 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line33 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); mConnectObs = new JOAJCheckBox(b.getString("kConnectObservations"), true); mReverseY = new JOAJCheckBox(b.getString("kReverseYAxis"), false); mReverseY.addItemListener(this); mPlotYGrid = new JOAJCheckBox(b.getString("kYGrid")); mPlotXGrid = new JOAJCheckBox(b.getString("kXGrid")); line0.add(mConnectObs); line1.add(mReverseY); line3.add(mPlotYGrid); line33.add(mPlotXGrid); axesOptions.add(line1); axesOptions.add(line3); axesOptions.add(line33); // other options JPanel otherOptions = new JPanel(); otherOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); tb = BorderFactory.createTitledBorder(b.getString("kOther")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } otherOptions.setBorder(tb); // plot symbols JPanel line4 = new JPanel(); line4.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); mEnableSymbols = new JOAJLabel(b.getString("kSymbol")); line4.add(mEnableSymbols); line4.add(mSymbolPopup); mSymbolPopup.addItemListener(this); mSizeLabel = new JOAJLabel(b.getString("kSize")); line4.add(mSizeLabel); SpinnerNumberModel model = new SpinnerNumberModel(4, 1, 100, 1); mSizeField = new JSpinner(model); line4.add(mSizeField); otherOptions.add(line0); otherOptions.add(line4); // add the axes and other panels to the gridlayout ctrNonAdvOptions.add(axesOptions); ctrNonAdvOptions.add(otherOptions); // add this panel to the north of the borderlayout nonAdvOptions.add("Center", ctrNonAdvOptions); JPanel colorNameContPanel = new JPanel(); colorNameContPanel.setLayout(new BorderLayout(0, 0)); JPanel colorNamePanel = new JPanel(); colorNamePanel.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); // swatches JPanel lineLCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); lineLCS.add(new JOAJLabel(b.getString("kLineColor"))); mLineColorSwatch = new Swatch(Color.black, 12, 12); lineLCS.add(new JOAJLabel(" ")); lineLCS.add(mLineColorSwatch); JPanel lineSCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); lineSCS.add(new JOAJLabel(b.getString("kSymbolColor"))); mSymbolColorSwatch = new Swatch(Color.black, 12, 12); lineSCS.add(new JOAJLabel(" ")); lineSCS.add(mSymbolColorSwatch); JPanel line7 = new JPanel(); line7.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0)); line7.add(new JOAJLabel(b.getString("kBackgroundColor"))); plotBg = new Swatch(JOAConstants.DEFAULT_CONTENTS_COLOR, 12, 12); line7.add(new JOAJLabel(" ")); line7.add(plotBg); JPanel line8 = new JPanel(); line8.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0)); line8.add(new JOAJLabel(b.getString("kGridColor"))); axesColor = new Swatch(Color.black, 12, 12); line8.add(new JOAJLabel(" ")); line8.add(axesColor); JPanel line9 = new JPanel(); line9.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); line9.add(new JOAJLabel(b.getString("kColorSchemes"))); Vector<String> presetSchemes = new Vector<String>(); presetSchemes.addElement(b.getString("kDefault")); presetSchemes.addElement(b.getString("kWhiteBackground")); presetSchemes.addElement(b.getString("kBlackBackground")); presetColorSchemes = new JOAJComboBox(presetSchemes); presetColorSchemes.setSelectedItem(b.getString("kDefault")); presetColorSchemes.addItemListener(this); line9.add(presetColorSchemes); JPanel swatchCont = new JPanel(); swatchCont.setLayout(new GridLayout(4, 1, 0, 5)); swatchCont.add(lineLCS); swatchCont.add(lineSCS); swatchCont.add(line7); swatchCont.add(line8); JPanel swatchContCont = new JPanel(); swatchContCont.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); swatchContCont.add(swatchCont); swatchContCont.add(line9); tb = BorderFactory.createTitledBorder(b.getString("kColors")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } swatchContCont.setBorder(tb); // window name JPanel namePanel = new JPanel(); namePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 5)); namePanel.add(new JOAJLabel(b.getString("kWindowName"))); mNameField = new JOAJTextField(30); mNameField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); namePanel.add(mNameField); // add the color panel colorNameContPanel.add("North", swatchContCont); colorNamePanel.add(colorNameContPanel); // add the name panel colorNamePanel.add(namePanel); // add these to the south of the borderlayout nonAdvOptions.add("South", colorNamePanel); // add all of this to the middle panel middlePanel.add(nonAdvOptions); // advanced options panel // axis container // y axis detail // container for the axes stuff plotScaleCont = new JPanel(new GridLayout(1, 2, 5, 5)); // y axis container JPanel yAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2)); tb = BorderFactory.createTitledBorder(b.getString("kYAxis")); yAxis.setBorder(tb); StnPlotSpecification mPlotSpec = new StnPlotSpecification(); JPanel line5y = new JPanel(); line5y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line5y.add(new JOAJLabel(b.getString("kMinimum"))); yMin = new JOAJTextField(6); yMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMin()), 3, false)); yMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line5y.add(yMin); JPanel line6y = new JPanel(); line6y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line6y.add(new JOAJLabel(b.getString("kMaximum"))); yMax = new JOAJTextField(6); yMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMax()), 3, false)); yMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line6y.add(yMax); JPanel line7y = new JPanel(); line7y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line7y.add(new JOAJLabel(b.getString("kIncrement"))); yInc = new JOAJTextField(6); yInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getYInc()), 3, false)); yInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line7y.add(yInc); JPanel line8y = new JPanel(); line8y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line8y.add(new JOAJLabel(b.getString("kNoMinorTicks"))); SpinnerNumberModel model3 = new SpinnerNumberModel(mPlotSpec.getYTics(), 0, 100, 1); yTics = new JSpinner(model3); line8y.add(yTics); yAxis.add(line5y); yAxis.add(line6y); yAxis.add(line7y); yAxis.add(line8y); yAxis.add(new JLabel(" ")); yAxis.add(new JLabel(" ")); yAxis.add(new JLabel(" ")); plotScaleCont.add(yAxis); // x axis container JPanel xAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2)); tb = BorderFactory.createTitledBorder(b.getString("kXAxis")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } xAxis.setBorder(tb); JPanel line5x = new JPanel(); line5x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line5x.add(mMinXLabel); xMin = new JOAJTextField(6); xMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMin()), 3, false)); xMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line5x.add(xMin); JPanel minTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1)); minTime.add(mMinXTLabel); JPanel maxTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1)); maxTime.add(mMaxXTLabel); GeoDate minDate = new GeoDate(mFileViewer.getMinDate()); minDate.decrement(1.0, GeoDate.YEARS); GeoDate maxDate = new GeoDate(mFileViewer.getMaxDate()); maxDate.increment(1.0, GeoDate.YEARS); // value, start,end SpinnerDateModel mStartDateModel = new SpinnerDateModel( new GeoDate(mFileViewer.getMinDate()), minDate, maxDate, Calendar.HOUR); mStartSpinner = new JSpinner(mStartDateModel); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(mStartSpinner, "yyyy-MM-dd HH:mm"); mStartSpinner.setEditor(dateEditor); SpinnerDateModel mEndDateModel = new SpinnerDateModel( new GeoDate(mFileViewer.getMaxDate()), minDate, maxDate, Calendar.HOUR); mEndSpinner = new JSpinner(mEndDateModel); JSpinner.DateEditor dateEditor2 = new JSpinner.DateEditor(mEndSpinner, "yyyy-MM-dd HH:mm"); minTime.add(mStartSpinner); maxTime.add(mEndSpinner); mEndSpinner.setEditor(dateEditor2); JPanel line6x = new JPanel(); line6x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line6x.add(mMaxXLabel); xMax = new JOAJTextField(6); xMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMax()), 3, false)); xMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line6x.add(xMax); JPanel line7x = new JPanel(); line7x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line7x.add(mIncLabel); xInc = new JOAJTextField(6); xInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getXInc()), 3, false)); xInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line7x.add(xInc); JPanel line8x = new JPanel(); line8x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line8x.add(mXIncLabel); SpinnerNumberModel model2 = new SpinnerNumberModel(mPlotSpec.getXTics(), 0, 100, 1); xTics = new JSpinner(model2); line8x.add(xTics); xAxis.add(minTime); xAxis.add(maxTime); xAxis.add(line5x); xAxis.add(line6x); xAxis.add(line7x); xAxis.add(line8x); plotScaleCont.add(xAxis); everyThingPanel.add(BorderLayout.CENTER, plotScaleCont); everyThingPanel.add(BorderLayout.SOUTH, middlePanel); mainPanel.add(BorderLayout.CENTER, new TenPixelBorder(everyThingPanel, 10, 10, 10, 10)); // lower panel mOKBtn = new JOAJButton(b.getString("kPlot")); mOKBtn.setActionCommand("ok"); this.getRootPane().setDefaultButton(mOKBtn); mCancelButton = new JOAJButton(b.getString("kCancel")); mCancelButton.setActionCommand("cancel"); JPanel dlgBtnsInset = new JPanel(); JPanel dlgBtnsPanel = new JPanel(); dlgBtnsInset.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 1)); dlgBtnsPanel.setLayout(new GridLayout(1, 4, 15, 1)); if (JOAConstants.ISMAC) { dlgBtnsPanel.add(mCancelButton); dlgBtnsPanel.add(mOKBtn); } else { dlgBtnsPanel.add(mOKBtn); dlgBtnsPanel.add(mCancelButton); } dlgBtnsInset.add(dlgBtnsPanel); mOKBtn.addActionListener(this); mCancelButton.addActionListener(this); mainPanel.add(new TenPixelBorder(dlgBtnsInset, 5, 5, 5, 5), "South"); contents.add("Center", mainPanel); this.pack(); runTimer(); setXRangeToDistance(); // show dialog at center of screen Rectangle dBounds = this.getBounds(); Dimension sd = Toolkit.getDefaultToolkit().getScreenSize(); int x = sd.width / 2 - dBounds.width / 2; int y = sd.height / 2 - dBounds.height / 2; this.setLocation(x, y); } public void runTimer() { TimerTask task = new TimerTask() { public void run() { maintainButtons(); } }; timer.schedule(task, 0, 1000); } private class OffsetPanel extends JPanel { private OffsetPanel(Component comp) { this.setLayout(new BorderLayout(0, 0)); TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOffsetBy")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } this.setBorder(tb); JPanel controls = new JPanel(); controls.setLayout(new GridLayout(3, 1, 5, 0)); b1 = new JOAJRadioButton(b.getString("kSequence")); b2 = new JOAJRadioButton(b.getString("kDistance"), true); b3 = new JOAJRadioButton(b.getString("kTime")); controls.add(b2); controls.add(b1); controls.add(b3); controls.add(new JOAJLabel(" ")); ButtonGroup bg = new ButtonGroup(); bg.add(b1); bg.add(b2); bg.add(b3); this.add("Center", controls); b1.addItemListener((ItemListener) comp); b2.addItemListener((ItemListener) comp); b3.addItemListener((ItemListener) comp); } } public void valueChanged(ListSelectionEvent evt) { if (evt.getSource() == mYParamList.getJList()) { mSelYParam = mYParamList.getJList().getSelectedIndex(); setAdvancedValues(); } generatePlotName(); } public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("cancel")) { this.dispose(); timer.cancel(); } else if (cmd.equals("ok")) { StnPlotSpecification spec = createPlotSpec(); try { spec.writeToLog("New Station Value Plot (" + mFileViewer.getTitle() + "):"); } catch (Exception ex) { } JOAStnValPlotWindow plotWind = new JOAStnValPlotWindow(spec, mFileViewer); plotWind.pack(); plotWind.setVisible(true); mFileViewer.addOpenWindow(plotWind); timer.cancel(); this.dispose(); } } public void itemStateChanged(ItemEvent evt) { if (evt.getSource() instanceof JOAJRadioButton) { JOAJRadioButton rb = (JOAJRadioButton) evt.getSource(); if (rb == b1 && evt.getStateChange() == ItemEvent.SELECTED) { mOffset = JOAConstants.PROFSEQUENCE; setXRangeToSequence(); } else if (rb == b2 && evt.getStateChange() == ItemEvent.SELECTED) { mOffset = JOAConstants.PROFDISTANCE; setXRangeToDistance(); } else if (rb == b3 && evt.getStateChange() == ItemEvent.SELECTED) { mOffset = JOAConstants.PROFTIME; setXRangeToTime(); } } else if (evt.getSource() instanceof JOAJCheckBox) { } else if (evt.getSource() instanceof JOAJComboBox) { JOAJComboBox cb = (JOAJComboBox) evt.getSource(); if (cb == presetColorSchemes) { int colorScheme = cb.getSelectedIndex(); if (colorScheme == 0) { // default bg plotBg.setColor(JOAConstants.DEFAULT_CONTENTS_COLOR); axesColor.setColor(Color.black); } else if (colorScheme == 1) { // white bg plotBg.setColor(Color.white); axesColor.setColor(Color.black); } else { // color bg plotBg.setColor(Color.black); axesColor.setColor(Color.white); } } else if (cb == mSymbolPopup) { mCurrSymbol = cb.getSelectedIndex() + 1; } } generatePlotName(); } public void maintainButtons() { if (mSelYParam >= 0) { mOKBtn.setEnabled(true); } else { mOKBtn.setEnabled(false); } } public StnPlotSpecification createPlotSpec() { StnPlotSpecification ps = new StnPlotSpecification(); // get the colors ps.setFGColor(axesColor.getColor()); ps.setBGColor(plotBg.getColor()); ps.setSectionType(mOffset); ps.setFileViewer(mFileViewer); ps.setXStnVarCode(mSelYParam); ps.setYStnVarName(new String((String) mYParamList.getJList().getSelectedValue())); ps.setWinTitle(mNameField.getText()); ps.setYGrid(mPlotYGrid.isSelected()); ps.setXGrid(mPlotXGrid.isSelected()); ps.setReverseY(mReverseY.isSelected()); ps.setSymbol(mCurrSymbol); ps.setSymbolSize(((Integer) mSizeField.getValue()).intValue()); ps.setConnectObs(mConnectObs.isSelected()); ps.setLineColor(mLineColorSwatch.getColor()); ps.setSymbolColor(mSymbolColorSwatch.getColor()); boolean error = false; try { ps.setWinYPlotMin(Double.valueOf(yMin.getText()).doubleValue()); } catch (NumberFormatException ex) { error = true; } try { ps.setWinYPlotMax(Double.valueOf(yMax.getText()).doubleValue()); } catch (NumberFormatException ex) { error = true; } try { ps.setYInc(Double.valueOf(yInc.getText()).doubleValue()); } catch (NumberFormatException ex) { error = true; } ps.setYTics(((Integer) yTics.getValue()).intValue()); if (mOffset == JOAConstants.PROFSEQUENCE || mOffset == JOAConstants.PROFDISTANCE) { try { ps.setWinXPlotMin(Double.valueOf(xMin.getText()).doubleValue()); } catch (NumberFormatException ex) { error = true; } try { ps.setWinXPlotMax(Double.valueOf(xMax.getText()).doubleValue()); } catch (NumberFormatException ex) { error = true; } try { ps.setXInc(Double.valueOf(xInc.getText()).doubleValue()); } catch (NumberFormatException ex) { error = true; } } else { long startTime = ((Date) mStartSpinner.getValue()).getTime(); long endTime = ((Date) mEndSpinner.getValue()).getTime(); ps.setWinXPlotMin(startTime); ps.setWinXPlotMax(endTime); } ps.setXTics(((Integer) xTics.getValue()).intValue()); if (error) { // post alert } return ps; } public void setAdvancedValues() { // get pretty ranges for the current parameters // get the range for the station value double min = 10000; double max = 0; for (int fc = 0; fc < mFileViewer.mNumOpenFiles; fc++) { OpenDataFile of = (OpenDataFile) mFileViewer.mOpenFiles.elementAt(fc); for (int sec = 0; sec < of.mNumSections; sec++) { Section sech = (Section) of.mSections.elementAt(sec); if (sech.mNumCasts == 0) { continue; } for (int stc = 0; stc < sech.mStations.size(); stc++) { Station sh = (Station) sech.mStations.elementAt(stc); if (!sh.mUseStn) { continue; } // get the station value double y = sh.getStnValue(mSelYParam); if (y == JOAConstants.MISSINGVALUE || y >= JOAConstants.EPICMISSINGVALUE) { continue; } else { min = y < min ? y : min; max = y > max ? y : max; } } } } Triplet newRange = JOAFormulas.GetPrettyRange(min, max); double yMinv = newRange.getVal1(); double yMaxv = newRange.getVal2(); double yIncv = newRange.getVal3(); yMin.setText(JOAFormulas.formatDouble(String.valueOf(yMinv), 3, false)); yMax.setText(JOAFormulas.formatDouble(String.valueOf(yMaxv), 3, false)); yInc.setText(JOAFormulas.formatDouble(String.valueOf(yIncv), 3, false)); yTics.setValue(new Integer(yTicsVal)); if (b1.isSelected()) { mOffset = JOAConstants.PROFSEQUENCE; setXRangeToSequence(); } else if (b2.isSelected()) { mOffset = JOAConstants.PROFDISTANCE; setXRangeToDistance(); } else if (b3.isSelected()) { mOffset = JOAConstants.PROFTIME; setXRangeToTime(); } } public void setXRangeToDistance() { hideTime(); // set the x axis from the total mercator distance double tempXMin = 0; double tempXMax = mFileViewer.mTotMercDist * 1.852; Triplet newRange = JOAFormulas.GetPrettyRange(tempXMin, tempXMax); double xMinv = newRange.getVal1(); double xMaxv = newRange.getVal2(); double xIncv = newRange.getVal3(); xMin.setText(JOAFormulas.formatDouble(String.valueOf(xMinv), 3, false)); xMax.setText(JOAFormulas.formatDouble(String.valueOf(xMaxv), 3, false)); xInc.setText(JOAFormulas.formatDouble(String.valueOf(xIncv), 3, false)); xTics.setValue(new Integer(xTicsVal)); } public void setXRangeToTime() { showTime(); // set the x axis from the time range of the data GeoDate minDate = mFileViewer.getMinDate(); GeoDate maxDate = mFileViewer.getMaxDate(); xTics.setValue(new Integer(xTicsVal)); } public void setXRangeToSequence() { hideTime(); // set the x axis from the total mercator distance double tempXMin = 0; double tempXMax = mFileViewer.mTotalStations; Triplet newRange = JOAFormulas.GetPrettyRange(tempXMin, tempXMax); double xMinv = newRange.getVal1(); double xMaxv = newRange.getVal2(); double xIncv = newRange.getVal3(); xMin.setText(String.valueOf((int) xMinv)); xMax.setText(String.valueOf((int) xMaxv)); xInc.setText(String.valueOf((int) xIncv)); xTics.setValue(new Integer(xTicsVal)); } public void hideTime() { mMaxXTLabel.setEnabled(false); mMinXTLabel.setEnabled(false); mMaxXLabel.setEnabled(true); mMinXLabel.setEnabled(true); mIncLabel.setEnabled(true); xMin.setEnabled(true); xMax.setEnabled(true); xInc.setEnabled(true); mStartSpinner.setEnabled(false); mEndSpinner.setEnabled(false); xTics.setEnabled(true); mPlotXGrid.setEnabled(true); mXIncLabel.setEnabled(true); } public void showTime() { mMaxXTLabel.setEnabled(true); mMinXTLabel.setEnabled(true); mMaxXLabel.setEnabled(false); mMinXLabel.setEnabled(false); mIncLabel.setEnabled(false); xMin.setText(""); xMax.setText(""); xInc.setText(""); xMin.setEnabled(false); xMax.setEnabled(false); xInc.setEnabled(false); mStartSpinner.setEnabled(true); mEndSpinner.setEnabled(true); xTics.setEnabled(false); mPlotXGrid.setEnabled(false); mXIncLabel.setEnabled(false); } public void generatePlotName() { String yVarText = (String) mYParamList.getJList().getSelectedValue(); if (yVarText == null || yVarText.length() == 0) { yVarText = "?"; } String offsetStr = null; if (b1.isSelected()) { offsetStr = "Seq"; } else if (b2.isSelected()) { offsetStr = "Dist"; } else { offsetStr = "Time"; } String nameString = new String(yVarText + "-" + offsetStr + " (" + mFileViewer.mFileViewerName + ")"); mNameField.setText(nameString); } }
/** Returns version of this debugger. */ public String getVersion() { return bundle.getString("CTL_Debugger_version"); }
/** * Starts the debugger. The method stops the current debugging (if any) and takes information from * the provided info (containing the class to start and arguments to pass it and name of class to * stop debugging in) and starts new debugging session. * * @param info debugger info about class to start * @exception DebuggerException if an error occures during the start of the debugger */ public void startDebugger(DebuggerInfo info) throws DebuggerException { debuggerInfo = info; if (remoteDebugger != null) finishDebugger(); // S ystem.out.println("startDebugger " + info); // NOI18N // RemoteDebugging support hostName = null; password = null; boolean local = true; if (info instanceof ReconnectDebuggerInfo) { ReconnectDebuggerInfo rdi = (ReconnectDebuggerInfo) info; hostName = rdi.getHostName(); password = rdi.getPassword(); local = false; } else if (info instanceof RemoteDebuggerInfo) { hostName = ((RemoteDebuggerInfo) info).getHostName(); password = ((RemoteDebuggerInfo) info).getPassword(); local = false; } boolean stopOnMain = info.getStopClassName() != null; stopOnMainFlag = stopOnMain; // S ystem.out.println ("ToolsDebugger.startDebugger " + info.getStopClassName ()); // NOI18N // T hread.dumpStack (); synchronizer = new RequestSynchronizer(); // open output window ... super.startDebugger(info); // start & init remote debugger ................................................ // process = null; if (local) { // create process & read password for local debugging // create starting string & NbProcessDescriptor NbProcessDescriptor debugerProcess; if (info instanceof ProcessDebuggerInfo) debugerProcess = ((ProcessDebuggerInfo) info).getDebuggerProcess(); else debugerProcess = ProcessDebuggerType.DEFAULT_DEBUGGER_PROCESS; HashMap map; if (info instanceof ToolsDebugger10Info) { map = Utils.processDebuggerInfo( info, "-debug", // NOI18N "sun.tools.debug.EmptyApp" // NOI18N ); map.put(ToolsDebugger10Type.JAVA_HOME_SWITCH, ((ToolsDebugger10Info) info).getJavaHome()); } else { if (info instanceof ToolsDebugger11Info) { String javaHome11 = ((ToolsDebugger11Info) info).getJavaHome(); if ((javaHome11 == null) || (javaHome11.trim().length() == 0)) { finishDebugger(); throw new DebuggerException(bundle.getString("EXC_JDK11_home_is_not_set")); } map = Utils.processDebuggerInfo( info, "-debug -nojit", // NOI18N "sun.tools.debug.EmptyApp" // NOI18N ); map.put(ToolsDebugger11Type.JAVA_HOME_SWITCH, javaHome11); } else { map = Utils.processDebuggerInfo( info, "-Xdebug", // NOI18N "sun.tools.agent.EmptyApp" // NOI18N ); } } MapFormat format = new MapFormat(map); String s = format.format( debugerProcess.getProcessName() + " " + debugerProcess.getArguments() // NOI18N ); println(s, ERR_OUT); // start process & read password ...................................... try { process = debugerProcess.exec(format); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(process.getInputStream())); password = bufferedreader.readLine(); showOutput(process, ERR_OUT, ERR_OUT); connectInput(process); } catch (java.lang.Exception e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_create_debuggee")) .format( new Object[] {format.format(debugerProcess.getProcessName()), e.toString()}), e); } if (password == null) { // no reply finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_connect_to_debuggee")) .format(new Object[] {format.format(debugerProcess.getProcessName())})); } if (password.indexOf("=") < 0) { // NOI18N // unexpected reply println(bundle.getString("CTL_Unexpected_reply") + ": " + password, ERR_OUT); showOutput(process, ERR_OUT + STD_OUT, ERR_OUT); finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Unecpected_debugger_reply")) .format(new Object[] {password})); } password = password.substring(password.indexOf("=") + 1); // NOI18N println(bundle.getString("CTL_Password") + ": " + password, ERR_OUT); hostName = "127.0.0.1"; // NOI18N } // end of local debugging specific else if (info instanceof ReconnectDebuggerInfo) { println(bundle.getString("CTL_Reconnecting"), ERR_OUT | STD_OUT); } else println(bundle.getString("CTL_Connecting_to") + ": " + hostName + ":" + password, ERR_OUT); // start RemoteDebugger ................................................... try { remoteDebugger = new RemoteDebugger( hostName, password.length() < 1 ? null : password, new ToolsCallback(this), isShowMessages()); } catch (java.net.ConnectException e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Cannot_connect_to_debuggee")) .format(new Object[] {e.toString()}), e); } catch (Throwable e) { if (e instanceof ThreadDeath) throw (ThreadDeath) e; // e.printStackTrace (); finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Cannot_connect_to_debuggee")) .format(new Object[] {e.toString()}), e); } // create arguments for main class ............................................... mainClassName = info.getClassName(); RemoteClass cls; String[] args = null; if ((mainClassName != null) && (mainClassName.length() > 0)) { String[] infoArgs = info.getArguments(); args = new String[infoArgs.length + 1]; args[0] = mainClassName; System.arraycopy(infoArgs, 0, args, 1, infoArgs.length); // args[0] = name of class // args[...] = parameters // find main class ......................................................... try { cls = remoteDebugger.findClass(mainClassName); } catch (Throwable e) { if (e instanceof ThreadDeath) throw (ThreadDeath) e; finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Cannot_find_class")) .format(new Object[] {mainClassName, e.toString()}), e); } if (cls == null) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Cannot_find_class")) .format(new Object[] {mainClassName, new ClassNotFoundException().toString()})); } } // set breakpoint on stop class method ............................................... if (stopOnMain) { RemoteClass stopClass = null; try { stopClass = remoteDebugger.findClass(stopClassName = info.getStopClassName()); } catch (Throwable e) { if (e instanceof ThreadDeath) throw (ThreadDeath) e; println( bundle.getString("MSG_Exc_while_finding_class") + stopClassName + '\n' + e, ERR_OUT); } if (stopClass == null) { println(bundle.getString("CTL_No_such_class") + ": " + stopClassName, ERR_OUT); } else { try { RemoteField[] rf = stopClass.getMethods(); int i, k = rf.length; Type t = Type.tMethod(Type.tVoid, new Type[] {Type.tArray(Type.tString)}); Type startT = Type.tMethod(Type.tVoid); RemoteField startM = null; RemoteField initM = null; RemoteField constM = null; for (i = 0; i < k; i++) { if (rf[i].getName().equals("main") && // NOI18N rf[i].getType().equals(t)) break; else if (rf[i].getName().equals("start") && // NOI18N rf[i].getType().equals(startT)) startM = rf[i]; else if (rf[i].getName().equals("init") && // NOI18N rf[i].getType().equals(startT)) initM = rf[i]; else if (rf[i].getName().equals("<init>") && // NOI18N rf[i].getType().equals(startT)) constM = rf[i]; } if (i < k) // [PENDING] stop on non main too !!!!!!!!!!!!!!!!!!!!! stopClass.setBreakpointMethod(rf[i]); // have main else if (initM != null) stopClass.setBreakpointMethod(initM); else if (startM != null) stopClass.setBreakpointMethod(startM); else if (constM != null) stopClass.setBreakpointMethod(constM); // S ystem.out.println ("Stop: " + (i <k) + " " + initM +" " + startM +" " + constM); // // NOI18N /* pendingBreakpoints = new RemoteField [1]; pendingBreakpoints [0] = rf[i]; pendingBreakpointsClass = stopClass;*/ } catch (Throwable e) { if (e instanceof ThreadDeath) throw (ThreadDeath) e; println(bundle.getString("MSG_Exc_while_setting_breakpoint") + '\n' + e, ERR_OUT); } } } // stopOnMain setBreakpoints(); updateWatches(); println(bundle.getString("CTL_Debugger_running"), STL_OUT); setDebuggerState(DEBUGGER_RUNNING); // run debugged class ............................................... if (args != null) { RemoteThreadGroup rtg = null; try { rtg = remoteDebugger.run(args.length, args); // threadGroup.setRemoteThreadGroup (rtg); } catch (Throwable e) { if (e instanceof ThreadDeath) throw (ThreadDeath) e; finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_calling_run")) .format(new Object[] {mainClassName, e.toString()}), e); } if (rtg == null) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_calling_run")) .format( new Object[] { mainClassName, "" // NOI18N })); } } // start refresh thread ................................................. if (debuggerThread != null) debuggerThread.stop(); debuggerThread = new Thread( new Runnable() { public void run() { for (; ; ) { try { Thread.sleep(5000); } catch (InterruptedException ex) { } if (getState() == DEBUGGER_RUNNING) try { threadGroup.threadChanged(); } catch (Throwable e) { if (e instanceof ThreadDeath) throw (ThreadDeath) e; if (e instanceof java.net.SocketException) { debuggerThread = null; try { finishDebugger(); } catch (Throwable ee) { if (ee instanceof ThreadDeath) throw (ThreadDeath) ee; } Thread.currentThread().stop(); } } } } }, "Debugger refresh thread"); // NOI18N debuggerThread.setPriority(Thread.MIN_PRIORITY); debuggerThread.start(); }