public void scrollToAttribute(Attribute a) { if (!a.getDescriptor().getConfig().equals(getConfig())) { logger.fine("Cannot scroll to attribute that isn't attached to this type of descriptor"); return; } int rowIndex = getCurrentModel().getRowForDescriptor(a.getDescriptor()); int colIndex = getCurrentModel().getColumnForAttribute(a); JScrollPane scrollPane = (JScrollPane) this.getComponent(0); JViewport viewport = (JViewport) scrollPane.getViewport(); EnhancedTable table = (EnhancedTable) viewport.getView(); // This rectangle is relative to the table where the // northwest corner of cell (0,0) is always (0,0). Rectangle rect = table.getCellRect(rowIndex, colIndex, true); // The location of the viewport relative to the table Point pt = viewport.getViewPosition(); // Translate the cell location so that it is relative // to the view, assuming the northwest corner of the // view is (0,0) rect.setLocation(rect.x - pt.x, rect.y - pt.y); // Scroll the area into view viewport.scrollRectToVisible(rect); }
// // Implement the ChangeListener // public void stateChanged(ChangeEvent e) { // Keep the scrolling of the row table in sync with main table JViewport viewport = (JViewport) e.getSource(); JScrollPane scrollPane = (JScrollPane) viewport.getParent(); scrollPane.getVerticalScrollBar().setValue(viewport.getViewPosition().y); }
public VText(SessionShare sshare, ButtonIF vif, String typ) { this.vnmrIf = vif; setOpaque(false); setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); twin = new VTextWin(this, sshare, vif, typ); setViewportView(twin); JViewport vp = getViewport(); vp.setBackground(Util.getBgColor()); orgBg = getBackground(); ml = new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int clicks = evt.getClickCount(); int modifier = evt.getModifiers(); if ((modifier & (1 << 4)) != 0) { if (clicks >= 2) { ParamEditUtil.setEditObj((VObjIF) evt.getSource()); } } } }; new DropTarget(this, this); DisplayOptions.addChangeListener(this); }
/** {@inheritDoc} */ @Override public void mouseDragged(final MouseEvent aEvent) { final MouseEvent event = convertEvent(aEvent); final Point point = event.getPoint(); // Update the selected channel while dragging... this.controller.setSelectedChannel(point); if (getModel().isCursorMode() && (this.movingCursor >= 0)) { this.controller.moveCursor(this.movingCursor, getCursorDropPoint(point)); aEvent.consume(); } else { if ((this.lastClickPosition == null) && ((aEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)) { this.lastClickPosition = new Point(point); } final JScrollPane scrollPane = getAncestorOfClass(JScrollPane.class, (Component) aEvent.getSource()); if ((scrollPane != null) && (this.lastClickPosition != null)) { final JViewport viewPort = scrollPane.getViewport(); final Component signalView = this.controller.getSignalDiagram().getSignalView(); boolean horizontalOnly = (aEvent.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0; boolean verticalOnly = horizontalOnly && ((aEvent.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0); int dx = aEvent.getX() - this.lastClickPosition.x; int dy = aEvent.getY() - this.lastClickPosition.y; Point scrollPosition = viewPort.getViewPosition(); int newX = scrollPosition.x; if (!verticalOnly) { newX -= dx; } int newY = scrollPosition.y; if (verticalOnly || !horizontalOnly) { newY -= dy; } int diagramWidth = signalView.getWidth(); int viewportWidth = viewPort.getWidth(); int maxX = diagramWidth - viewportWidth - 1; scrollPosition.x = Math.max(0, Math.min(maxX, newX)); int diagramHeight = signalView.getHeight(); int viewportHeight = viewPort.getHeight(); int maxY = diagramHeight - viewportHeight; scrollPosition.y = Math.max(0, Math.min(maxY, newY)); viewPort.setViewPosition(scrollPosition); } // Use UNCONVERTED/ORIGINAL mouse event! handleZoomRegion(aEvent, this.lastClickPosition); } }
@Override public void addNotify() { super.addNotify(); Component c = getParent(); // Keep scrolling of the row table in sync with the main table. if (c instanceof JViewport) { JViewport viewport = (JViewport) c; viewport.addChangeListener(this); } }
@Override protected void paintChildren(Graphics g) { super.paintChildren(g); if (isBellVisible) { paintBell(g); } }
@SuppressWarnings("OverridableMethodCallInConstructor") Notepad() { super(true); // Trying to set Nimbus look and feel try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ignored) { } setBorder(BorderFactory.createEtchedBorder()); setLayout(new BorderLayout()); // create the embedded JTextComponent editor = createEditor(); // Add this as a listener for undoable edits. editor.getDocument().addUndoableEditListener(undoHandler); // install the command table commands = new HashMap<Object, Action>(); Action[] actions = getActions(); for (Action a : actions) { commands.put(a.getValue(Action.NAME), a); } JScrollPane scroller = new JScrollPane(); JViewport port = scroller.getViewport(); port.add(editor); String vpFlag = getProperty("ViewportBackingStore"); if (vpFlag != null) { Boolean bs = Boolean.valueOf(vpFlag); port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE); } JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add("North", createToolbar()); panel.add("Center", scroller); add("Center", panel); add("South", createStatusbar()); }
/** * @param aEvent * @param aStartPoint */ protected void handleZoomRegion(final MouseEvent aEvent, final Point aStartPoint) { // For now, disabled by default as it isn't 100% working yet... if (Boolean.FALSE.equals(Boolean.valueOf(System.getProperty("zoomregionenabled", "false")))) { return; } final JComponent source = (JComponent) aEvent.getComponent(); final boolean dragging = (aEvent.getID() == MouseEvent.MOUSE_DRAGGED); final GhostGlassPane glassPane = (GhostGlassPane) SwingUtilities.getRootPane(source).getGlassPane(); Rectangle viewRect; final JScrollPane scrollPane = SwingComponentUtils.getAncestorOfClass(JScrollPane.class, source); if (scrollPane != null) { final JViewport viewport = scrollPane.getViewport(); viewRect = SwingUtilities.convertRectangle(viewport, viewport.getVisibleRect(), glassPane); } else { viewRect = SwingUtilities.convertRectangle(source, source.getVisibleRect(), glassPane); } final Point start = SwingUtilities.convertPoint(source, aStartPoint, glassPane); final Point current = SwingUtilities.convertPoint(source, aEvent.getPoint(), glassPane); if (dragging) { if (!glassPane.isVisible()) { glassPane.setVisible(true); glassPane.setRenderer(new RubberBandRenderer(), start, current, viewRect); } else { glassPane.updateRenderer(start, current, viewRect); } glassPane.repaintPartially(); } else /* if ( !dragging ) */ { // Fire off a signal to the zoom controller to do its job... this.controller.getZoomController().zoomRegion(aStartPoint, aEvent.getPoint()); glassPane.setVisible(false); } }
public void actionPerformed(ActionEvent e) { PrintJob pjob = getToolkit().getPrintJob(textViewerFrame, "Printing Nslm", null); if (pjob != null) { Graphics pg = pjob.getGraphics(); if (pg != null) { // todo: this should print from // the file not from the screen. // if (editor1!=null) { // editor1.print(pg); //print crashes, must use printAll // } // if (scroller1!=null) { // scroller1.printAll(pg); //is clipping on left // } if (scroller1 != null) { JViewport jvp = scroller1.getViewport(); jvp.printAll(pg); } pg.dispose(); } pjob.end(); } }
/** * Method to check that the current position is in the viewing area and if not scroll to center * the current position if possible */ public void checkScroll() { // get the x and y position in pixels int xPos = (int) (colIndex * zoomFactor); int yPos = (int) (rowIndex * zoomFactor); // only do this if the image is larger than normal if (zoomFactor > 1) { // get the rectangle that defines the current view JViewport viewport = scrollPane.getViewport(); Rectangle rect = viewport.getViewRect(); int rectMinX = (int) rect.getX(); int rectWidth = (int) rect.getWidth(); int rectMaxX = rectMinX + rectWidth - 1; int rectMinY = (int) rect.getY(); int rectHeight = (int) rect.getHeight(); int rectMaxY = rectMinY + rectHeight - 1; // get the maximum possible x and y index int macolIndexX = (int) (picture.getWidth() * zoomFactor) - rectWidth - 1; int macolIndexY = (int) (picture.getHeight() * zoomFactor) - rectHeight - 1; // calculate how to position the current position in the middle of the viewing // area int viewX = xPos - (int) (rectWidth / 2); int viewY = yPos - (int) (rectHeight / 2); // reposition the viewX and viewY if outside allowed values if (viewX < 0) viewX = 0; else if (viewX > macolIndexX) viewX = macolIndexX; if (viewY < 0) viewY = 0; else if (viewY > macolIndexY) viewY = macolIndexY; // move the viewport upper left point viewport.scrollRectToVisible(new Rectangle(viewX, viewY, rectWidth, rectHeight)); } }
public void init() { // <Begin_init> if (getParameter("RESOURCE_PROPERTIES") != null) { localePropertiesFileName = getParameter("RESOURCE_PROPERTIES"); } resourceBundle = com.adventnet.apiutils.Utility.getBundle( localePropertiesFileName, getParameter("RESOURCE_LOCALE"), applet); if (initialized) return; this.setSize(getPreferredSize().width + 495, getPreferredSize().height + 480); setTitle(resourceBundle.getString("ViewConfig")); Container container = getContentPane(); container.setLayout(new BorderLayout()); try { initVariables(); setUpGUI(container); setUpProperties(); setUpConnections(); } catch (Exception ex) { showStatus(resourceBundle.getString("Error in init method"), ex); } // let us set the initialized variable to true so // we dont initialize again even if init is called initialized = true; // <End_init> setTitle(resourceBundle.getString("View Configuration")); setIconImage(AuthMain.getBuilderUiIfInstance().getFrameIcon()); JLabel1.setIcon(AuthMain.getBuilderUiIfInstance().getImage("viewconfig.png")); com.adventnet.security.ui.ViewListCellRenderer ViewListCellRenderer1 = new com.adventnet.security.ui.ViewListCellRenderer(); JTable1.setDefaultRenderer(JTable1.getColumnClass(0), ViewListCellRenderer1); JLabel2.setIcon(AuthMain.getBuilderUiIfInstance().getImage("addview1.png")); JTable1.getCellEditor(0, 0) .getTableCellEditorComponent(JTable1, null, true, 0, 0) .setEnabled(false); DefaultCellEditor te = (DefaultCellEditor) JTable1.getCellEditor(0, 0); te.setClickCountToStart(10); JTable1.setCellEditor(te); JViewport vp = new JViewport(); JLabel lab = new JLabel(resourceBundle.getString("List of available views")); lab.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT); lab.setForeground(Color.black); vp.setView(lab); AuthMain.getBuilderUiIfInstance().centerWindow(this); setData(); viewc = this; addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent we) { close(); } }); /* TableColumn col2 = JTable1.getColumnModel().getColumn(1); DefaultTableCellRenderer ren = new DefaultTableCellRenderer(); ren.setIcon(AuthMain.getBuilderUiIfInstance().getImage("task1.png")); col2.setCellRenderer(ren); col2.setMaxWidth(30); */ DefaultListSelectionModel selModel = new DefaultListSelectionModel(); selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JTable1.setSelectionModel(selModel); }
public ODEWizardScalaSci() { editingClassName = "Lorenz"; systemOrder = 3; // the order of ODE system copyTemplateButton = new JButton("1. Copy and Edit Template", new ImageIcon("/scalaLab.jar/yellow-ball.gif")); generateEditingButton = new JButton("2. Generate Java Class", new ImageIcon("./blue-ball.gif")); saveJavaClassButton = new JButton("3. Save Java Class", new ImageIcon("scalaLab.jar/red-ball.gif")); compileJavaClassButton = new JButton("4.a. Java Compile - External Compiler", new ImageIcon("blue-ball.gif")); compileJavaInternalCompilerButton = new JButton("4.b. Java Compile - Internal Compiler", new ImageIcon("blue-ball.gif")); generateScriptCodeButton = new JButton("Generate scalaSci Script", new ImageIcon("red-ball.gif")); ODEWizardFrame = new JFrame("ODE Wizard for scalaSci with Java implementation of. ODEs"); editPanel = new JPanel(); editPanel.setLayout(new GridLayout(1, 2)); paramPanel = new JPanel(new GridLayout(1, 4)); availODEMethods.add("ODErke"); availODEMethods.add("ODEmultistep"); availODEMethods.add("ODEdiffsys"); ODEselectMethodLabel = new JLabel("ODE method: "); ODEselectMethodComboBox = new JComboBox(availODEMethods); ODEselectMethodComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ODESolveMethod = ODEselectMethodComboBox.getSelectedIndex(); updateTemplateText(); templateTextArea.setText(templateText); currentlySelectedLabel.setText( "Selected Method: " + (String) availODEMethods.get(ODESolveMethod)); } }); JLabel javaFileTextLabel = new JLabel("Java File Name: "); javaFileTextBox = new JTextField(editingClassName); javaFileTextBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { editingClassName = javaFileTextBox.getText(); String updatedStatusText = prepareStatusText(); statusAreaTop.setText(updatedStatusText); } }); JLabel systemOrderLabel = new JLabel("System order: "); systemOrderText = new JTextField(String.valueOf(systemOrder)); systemOrderText.addActionListener(new editSystemOrder()); JPanel javaFilePanel = new JPanel(); javaFilePanel.add(javaFileTextLabel); javaFilePanel.add(javaFileTextBox); JPanel systemOrderPanel = new JPanel(); systemOrderPanel.add(systemOrderLabel); systemOrderPanel.add(systemOrderText); paramMethodPanel = new JPanel(); paramMethodPanel.add(ODEselectMethodLabel); paramMethodPanel.add(ODEselectMethodComboBox); paramPanel.add(paramMethodPanel); paramPanel.add(javaFilePanel); paramPanel.add(systemOrderPanel); currentlySelectedLabel = new JLabel("Selected Method: " + (String) availODEMethods.get(ODESolveMethod)); paramPanel.add(currentlySelectedLabel); statusPanel = new JPanel(new GridLayout(2, 1)); statusAreaTop = new JTextArea(); statusAreaTop.setFont(new Font("Arial", Font.BOLD, 16)); String statusText = prepareStatusText(); statusAreaTop.setText(statusText); statusAreaBottom = new JTextArea(); statusAreaBottom.setText( "Step1: Copy and edit the template ODE (implements the famous Lorenz chaotic system),\n" + "Then set the name of your Java Class (instead of \"Lorenz\"), without the extension .java\n" + "Also set the proper order (i.e. number of equations and variables) of your system. "); statusPanel.add(statusAreaTop); statusPanel.add(statusAreaBottom); templateTextArea = new JTextArea(); updateTemplateText(); templateTextArea.setFont(new Font("Arial", Font.ITALIC, 12)); templateTextArea.setText(templateText); templateScrollPane = new JScrollPane(); templateViewPort = templateScrollPane.getViewport(); templateViewPort.add(templateTextArea); ODEWizardTextArea = new JTextArea(); ODEWizardText = ""; ODEWizardTextArea.setText(ODEWizardText); ODEWizardTextArea.setFont(new Font("Arial", Font.BOLD, 12)); ODEWizardScrollPane = new JScrollPane(); wizardViewPort = ODEWizardScrollPane.getViewport(); wizardViewPort.add(ODEWizardTextArea); editPanel.add(ODEWizardScrollPane); editPanel.add(templateScrollPane); // Step 1: copy template of ODE implementation from the // templateTextArea to ODEWizardTextArea copyTemplateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ODEWizardTextArea.setText(templateTextArea.getText()); generateEditingButton.setEnabled(true); statusAreaBottom.setText( "Step2: If you have implemented correctly your ODE, the wizard completes the ready to compile Java class"); } }); // Step 2: generate Java Class from template JPanel buttonPanel = new JPanel(); generateEditingButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String editingODE = ODEWizardTextArea.getText(); String classImplementationString = // "package javaPluggins; \n"+ "import numal.*; \n\n" + "public class " + editingClassName + " extends Object \n implements " + implementingInterfaces[ODESolveMethod] + " \n \n " + "{ \n"; classImplementationString += (editingODE + "}\n"); ODEWizardTextArea.setText(classImplementationString); saveJavaClassButton.setEnabled(true); statusAreaBottom.setText( "Step3: The generated Java source is ready, you can check it, and then proceed to save."); } }); // Step 3: save generated Java Class on disk saveJavaClassButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String currentWorkingDirectory = Directory.Current().get().path(); JFileChooser chooser = new JFileChooser(currentWorkingDirectory); chooser.setSelectedFile(new File(editingClassName + ".java")); int ret = chooser.showSaveDialog(ODEWizardFrame); if (ret != JFileChooser.APPROVE_OPTION) { return; } File f = chooser.getSelectedFile(); try { PrintWriter out = new PrintWriter(f); String javaCodeText = ODEWizardTextArea.getText(); out.write(javaCodeText); out.close(); // update the notion of the working directory String fullPathOfSavedFile = f.getAbsolutePath(); GlobalValues.workingDir = fullPathOfSavedFile.substring( 0, fullPathOfSavedFile.lastIndexOf(File.separatorChar) + 1); compileJavaClassButton.setEnabled(true); compileJavaInternalCompilerButton.setEnabled(true); statusAreaBottom.setText( "Step4: The Java source file was saved to disk, \n " + "you can proceed to compile and load the corresponding class file"); } catch (java.io.FileNotFoundException enf) { System.out.println("File " + f.getName() + " not found"); enf.printStackTrace(); } catch (Exception eOther) { System.out.println("Exception trying to create PrintWriter"); eOther.printStackTrace(); } } }); // Step 4: Compile the generated Java class compileJavaClassButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String currentWorkingDirectory = GlobalValues.workingDir; JFileChooser chooser = new JFileChooser(currentWorkingDirectory); int ret = chooser.showOpenDialog(ODEWizardFrame); if (ret != JFileChooser.APPROVE_OPTION) { return; } File f = chooser.getSelectedFile(); String javaFile = null; try { javaFile = f.getCanonicalPath(); } catch (IOException ex) { System.out.println("I/O Exception in getCanonicalPath"); ex.printStackTrace(); } // extract the path specification of the generated Java class that implements the ODE // solution method, // in order to update the ScalaSci class path String SelectedFileWithPath = f.getAbsolutePath(); String SelectedFilePathOnly = SelectedFileWithPath.substring( 0, SelectedFileWithPath.lastIndexOf(File.separatorChar)); if (GlobalValues.ScalaSciClassPath.length() == 0) GlobalValues.ScalaSciClassPath = "."; if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly) == -1) { GlobalValues.ScalaSciClassPathComponents.add(0, SelectedFilePathOnly); GlobalValues.ScalaSciClassPath = GlobalValues.ScalaSciClassPath + File.pathSeparator + SelectedFilePathOnly; } // update also the ScalaSciClassPath property StringBuilder fileStr = new StringBuilder(); Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements(); while (enumDirs.hasMoreElements()) { Object ce = enumDirs.nextElement(); fileStr.append(File.pathSeparator + (String) ce); } GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString()); ClassLoader parentClassLoader = getClass().getClassLoader(); GlobalValues.extensionClassLoader = new ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader); // update GUI components to account for the updated ScalaSci classpath scalaExec.scalaLab.scalaLab.updateTree(); boolean compilationSucccess = true; String tempFileName = ""; tempFileName = javaFile + ".java"; // public classes and Java files should have the same name String[] command = new String[6]; command[0] = "javac"; command[1] = "-cp"; command[2] = GlobalValues.jarFilePath + File.pathSeparator + GlobalValues.homeDir; command[3] = "-d"; // where to place output class files command[4] = SelectedFilePathOnly; // the path to save the compiled class files command[5] = javaFile; // full filename to compile String compileCommandString = command[0] + " " + command[1] + " " + command[2] + " " + command[3] + " " + command[4] + " " + command[5]; System.out.println("compileCommand Java= " + compileCommandString); try { Runtime rt = Runtime.getRuntime(); Process javaProcess = rt.exec(command); // an error message? StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR"); // any output? StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT"); // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? javaProcess.waitFor(); int rv = javaProcess.exitValue(); String commandString = command[0] + " " + command[1] + " " + command[2]; if (rv == 0) { System.out.println("Process: " + commandString + " exited successfully "); generateScriptCodeButton.setEnabled(true); statusAreaBottom.setText( "Step5: You can proceed now to create a draft script that utilizes your Java-based ODE integrator"); } else System.out.println( "Process: " + commandString + " exited with error, error value = " + rv); } catch (IOException exio) { System.out.println("IOException trying to executing " + command); exio.printStackTrace(); } catch (InterruptedException ie) { System.out.println("Interrupted Exception trying to executing " + command); ie.printStackTrace(); } } }); // Compile with the internal compiler compileJavaInternalCompilerButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String currentWorkingDirectory = GlobalValues.workingDir; JFileChooser chooser = new JFileChooser(currentWorkingDirectory); int ret = chooser.showOpenDialog(ODEWizardFrame); if (ret != JFileChooser.APPROVE_OPTION) { return; } File f = chooser.getSelectedFile(); String javaFile = null; try { javaFile = f.getCanonicalPath(); } catch (IOException ex) { System.out.println("I/O Exception in getCanonicalPath"); ex.printStackTrace(); } // extract the path specification of the generated Java class that implements the ODE // solution method, // in order to update the ScalaSci class path String SelectedFileWithPath = f.getAbsolutePath(); String SelectedFilePathOnly = SelectedFileWithPath.substring( 0, SelectedFileWithPath.lastIndexOf(File.separatorChar)); if (GlobalValues.ScalaSciClassPath.length() == 0) GlobalValues.ScalaSciClassPath = "."; if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly) == -1) { GlobalValues.ScalaSciClassPathComponents.add(0, SelectedFilePathOnly); GlobalValues.ScalaSciClassPath = GlobalValues.ScalaSciClassPath + File.pathSeparator + SelectedFilePathOnly; } // update also the ScalaSciClassPath property StringBuilder fileStr = new StringBuilder(); Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements(); while (enumDirs.hasMoreElements()) { Object ce = enumDirs.nextElement(); fileStr.append(File.pathSeparator + (String) ce); } GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString()); ClassLoader parentClassLoader = getClass().getClassLoader(); GlobalValues.extensionClassLoader = new ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader); // update GUI components to account for the updated ScalaSci classpath scalaExec.scalaLab.scalaLab.updateTree(); String[] command = new String[11]; String toolboxes = ""; for (int k = 0; k < GlobalValues.ScalaSciClassPathComponents.size(); k++) toolboxes = toolboxes + File.pathSeparator + GlobalValues.ScalaSciClassPathComponents.elementAt(k); // compile the temporary file command[0] = "java"; command[1] = "-classpath"; command[2] = "." + File.pathSeparator + GlobalValues.jarFilePath + File.pathSeparator + toolboxes + File.pathSeparator + SelectedFilePathOnly; command[3] = "com.sun.tools.javac.Main"; // the name of the Java compiler class command[4] = "-classpath"; command[5] = command[2]; command[6] = "-sourcepath"; command[7] = command[2]; command[8] = "-d"; // where to place output class files command[9] = SelectedFilePathOnly; command[10] = SelectedFileWithPath; String compileCommandString = command[0] + " " + command[1] + " " + command[2] + " " + command[3] + " " + command[4] + " " + command[5] + " " + command[6] + " " + command[7] + " " + command[8] + " " + command[9] + " " + command[10]; System.out.println("compileCommand Java= " + compileCommandString); try { Runtime rt = Runtime.getRuntime(); Process javaProcess = rt.exec(command); // an error message? StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR"); // any output? StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT"); // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? javaProcess.waitFor(); int rv = javaProcess.exitValue(); if (rv == 0) { System.out.println("Process: exited successfully "); JavaCompile javaCompileObj = null; try { javaCompileObj = new JavaCompile(); } catch (Exception ex) { JOptionPane.showMessageDialog( null, "Unable to compile. Please check if your system's PATH variable includes the path to your javac compiler", "Cannot compile - Check PATH", JOptionPane.INFORMATION_MESSAGE); ex.printStackTrace(); } generateScriptCodeButton.setEnabled(true); statusAreaBottom.setText( "Step5: You can proceed now to create a draft ScalaSci-Script that utilizes your Java-based ODE integrator"); } else System.out.println("Process: exited with error, error value = " + rv); } catch (IOException exio) { System.out.println("IOException trying to executing " + command); exio.printStackTrace(); } catch (InterruptedException ie) { System.out.println("Interrupted Exception trying to executing " + command); ie.printStackTrace(); } } }); // Step 5: Generate Script Code generateScriptCodeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new scriptCodeGenerationFrame("ODE Script code", editingClassName, systemOrder); } }); buttonPanel.add(copyTemplateButton); // Step 1 buttonPanel.setEnabled(true); buttonPanel.add(generateEditingButton); // Step 2 generateEditingButton.setEnabled(false); buttonPanel.add(saveJavaClassButton); // Step 3 saveJavaClassButton.setEnabled(false); buttonPanel.add(compileJavaClassButton); // Step 4 buttonPanel.add(compileJavaInternalCompilerButton); compileJavaClassButton.setEnabled(false); compileJavaInternalCompilerButton.setEnabled(false); buttonPanel.add(generateScriptCodeButton); // Step 5 generateScriptCodeButton.setEnabled(false); ODEWizardFrame.add(buttonPanel, BorderLayout.NORTH); ODEWizardFrame.add(editPanel, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(new GridLayout(2, 1)); bottomPanel.add(paramPanel); bottomPanel.add(statusPanel); ODEWizardFrame.add(bottomPanel, BorderLayout.SOUTH); ODEWizardFrame.setLocation(100, 100); ODEWizardFrame.setSize(1400, 800); ODEWizardFrame.setVisible(true); }
public void propertyChange(PropertyChangeEvent evt) { JViewport vp = getViewport(); if (vp != null) vp.setBackground(Util.getBgColor()); }