Example #1
0
  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);
  }
Example #2
0
  private int getCorrectionOffset(FilePanel fp) {
    JTextComponent editor;
    int offset;
    Rectangle rect;
    Point p;
    JViewport viewport;

    editor = fp.getEditor();
    viewport = fp.getScrollPane().getViewport();
    p = viewport.getViewPosition();
    offset = editor.viewToModel(p);

    try {
      // This happens when you scroll to the bottom. The upper line won't
      //   start at the right position (You can see half of the line)
      // Correct this offset with the pane next to it to keep in sync.
      rect = editor.modelToView(offset);
      if (rect != null) {
        return p.y - rect.getLocation().y;
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return 0;
  }
  //
  //  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 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);
  }
  /*
   *  This method is called every time:
   *  - to make sure the viewport is returned to its default position
   *  - to remove the horizontal scrollbar when it is not wanted
   */
  private void checkHorizontalScrollBar(BasicComboPopup popup) {
    //  Reset the viewport to the left

    JViewport viewport = scrollPane.getViewport();
    Point p = viewport.getViewPosition();
    p.x = 0;
    viewport.setViewPosition(p);

    //  Remove the scrollbar so it is never painted

    if (!scrollBarRequired) {
      scrollPane.setHorizontalScrollBar(null);
      return;
    }

    //	Make sure a horizontal scrollbar exists in the scrollpane

    JScrollBar horizontal = scrollPane.getHorizontalScrollBar();

    if (horizontal == null) {
      horizontal = new JScrollBar(JScrollBar.HORIZONTAL);
      scrollPane.setHorizontalScrollBar(horizontal);
      scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }

    //	Potentially increase height of scroll pane to display the scrollbar

    if (horizontalScrollBarWillBeVisible(popup, scrollPane)) {
      Dimension scrollPaneSize = scrollPane.getPreferredSize();
      scrollPaneSize.height += horizontal.getPreferredSize().height;
      scrollPane.setPreferredSize(scrollPaneSize);
      scrollPane.setMaximumSize(scrollPaneSize);
      scrollPane.revalidate();
    }
  }
Example #6
0
  private int getCurrentLineCenter(FilePanel fp) {
    JScrollPane scrollPane;
    BufferDocumentIF bd;
    JTextComponent editor;
    JViewport viewport;
    int line;
    Rectangle rect;
    int offset;
    Point p;

    editor = fp.getEditor();
    scrollPane = fp.getScrollPane();
    viewport = scrollPane.getViewport();
    p = viewport.getViewPosition();
    offset = editor.viewToModel(p);

    // Scroll around the center of the editpane
    p.y += getHeightOffset(fp);

    offset = editor.viewToModel(p);
    bd = fp.getBufferDocument();
    if (bd == null) {
      return -1;
    }
    line = bd.getLineForOffset(offset);

    return line;
  }
 private JScrollPane getScrollPane() {
   if (desktop.getParent() instanceof JViewport) {
     JViewport viewPort = (JViewport) desktop.getParent();
     if (viewPort.getParent() instanceof JScrollPane) return (JScrollPane) viewPort.getParent();
   }
   return null;
 }
Example #8
0
  public void scrollToLine(FilePanel fp, int line) {
    JScrollPane scrollPane;
    FilePanel fp2;
    BufferDocumentIF bd;
    JTextComponent editor;
    JViewport viewport;
    Rectangle rect;
    int offset;
    Point p;
    Rectangle viewRect;
    Dimension viewSize;
    Dimension extentSize;
    int x;

    fp2 = fp == filePanelLeft ? filePanelRight : filePanelLeft;

    bd = fp.getBufferDocument();
    if (bd == null) {
      return;
    }

    offset = bd.getOffsetForLine(line);
    if (offset < 0) {
      return;
    }

    viewport = fp.getScrollPane().getViewport();
    editor = fp.getEditor();

    try {
      rect = editor.modelToView(offset);
      if (rect == null) {
        return;
      }

      p = rect.getLocation();
      p.y -= getHeightOffset(fp);
      p.y += getCorrectionOffset(fp2);

      // Do not allow scrolling before the begin.
      if (p.y < 0) {
        p.y = 0;
      }

      // Do not allow scrolling after the end.
      viewSize = viewport.getViewSize();
      viewRect = viewport.getViewRect();
      extentSize = viewport.getExtentSize();
      if (p.y > viewSize.height - extentSize.height) {
        p.y = viewSize.height - extentSize.height;
      }

      p.x = viewRect.x;

      viewport.setViewPosition(p);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #9
0
  /** {@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);
    }
  }
    private void updateColor(Component c) {
      if (!(c instanceof JScrollPane)) return;

      JViewport vp = ((JScrollPane) c).getViewport();
      if (vp == null) return;

      Component view = vp.getView();
      if (view == null) return;

      lineColor = view.getBackground();
    }
Example #11
0
  public void scrollToCellLocation(int rowIndex, int colIndex) {

    if (!(getParent() instanceof JViewport)) {
      return;
    }

    JViewport scrollPane = (JViewport) getParent();
    Rectangle rect = getCellRect(rowIndex, colIndex, true);
    Point p = scrollPane.getViewPosition();
    rect.setLocation(rect.x - p.x, rect.y - p.y);
    scrollPane.scrollRectToVisible(rect);
  }
Example #12
0
 /** {@inheritDoc} */
 @Override
 protected void uninstallListeners(JComponent c) {
   super.uninstallListeners(c);
   c.removePropertyChangeListener(this);
   if (viewportViewFocusHandler != null) {
     JViewport viewport = ((JScrollPane) c).getViewport();
     viewport.removeContainerListener(viewportViewFocusHandler);
     if (viewport.getView() != null) {
       viewport.getView().removeFocusListener(viewportViewFocusHandler);
     }
     viewportViewFocusHandler = null;
   }
 }
  @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);
    }
  }
Example #14
0
 public HtmlPane() {
   try {
     URL url = getClass().getResource("/resources/HelpFiles/toc.html");
     html = new JEditorPane(url);
     html.setEditable(false);
     html.addHyperlinkListener(this);
     html.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
     JViewport vp = getViewport();
     vp.add(html);
   } catch (MalformedURLException e) {
     System.out.println("Malformed URL: " + e);
   } catch (IOException e) {
     System.out.println("IOException: " + e);
   }
 }
Example #15
0
  private int getHeightOffset(FilePanel fp) {
    JScrollPane scrollPane;
    JViewport viewport;
    int offset;
    int unitIncrement;

    scrollPane = fp.getScrollPane();
    viewport = scrollPane.getViewport();

    offset = viewport.getSize().height / 2;
    unitIncrement = scrollPane.getHorizontalScrollBar().getUnitIncrement();
    offset = offset - (offset % unitIncrement);

    return offset;
  }
Example #16
0
 @Override
 protected void paintChildren(Graphics g) {
   super.paintChildren(g);
   if (isBellVisible) {
     paintBell(g);
   }
 }
Example #17
0
  public void paintViewport(Graphics g, JViewport c) {
    if (!browser.isPreviewColumnFilled()) {
      Dimension vs = c.getSize();
      Dimension bs = browser.getSize();

      JScrollBar vb = getVerticalBar();

      g.setColor(Color.black);
      Dimension ss = vb.getPreferredSize();

      // Paint scroll bar tracks at the right to fill the viewport
      if (bs.width < vs.width) {
        int fixedCellWidth = browser.getFixedCellWidth();

        // FIXME - Apparently we have to do layout manually, because
        //         invoking cellRendererPane.paneComponent with
        //         "shouldValidate" set to true does not appear to have
        //         the desired effect.
        try {
          vb.setSize(ss.width, vs.height);
          vb.doLayout();
        } catch (NullPointerException e) {
          // We get NPE here in JDK 1.3. We ignore it.
        }

        for (int x = browser.getWidth() + fixedCellWidth;
            x < vs.width;
            x += fixedCellWidth + ss.width) {
          getCellRendererPane().paintComponent(g, vb, c, x, 0, ss.width, vs.height, false);
        }
      }
    }
  }
Example #18
0
  @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());
  }
  @Override
  protected int getMaxAvailablePageWidth(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Insets insets = list.getInsets(); // OWLFrameList.ITEM_BORDER.getBorderInsets();
    int componentWidth = list.getWidth();
    JViewport vp = (JViewport) SwingUtilities.getAncestorOfClass(JViewport.class, list);
    if (vp != null) {
      componentWidth = vp.getViewRect().width;
    }

    return componentWidth
        - list.getInsets().left
        - list.getInsets().right
        - insets.left
        + insets.right
        - 20;
  }
  public HtmlPane(String helpFileName) {
    try {
      File f = new File(helpFileName);
      String s = f.getAbsolutePath();
      s = "file:" + s;
      URL url = new URL(s);
      html = new JEditorPane(s);
      html.setEditable(false);
      html.addHyperlinkListener(this);

      JViewport vp = getViewport();
      vp.add(html);
    } catch (MalformedURLException e) {
      System.out.println("Malformed URL: " + e);
    } catch (IOException e) {
      System.out.println("IOException: " + e);
    }
  }
Example #21
0
  /**
   * @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);
    }
  }
Example #22
0
 private void configureEnclosingScrollPaneUI() {
   final Container p = getParent();
   if (p instanceof JViewport) {
     final Container gp = p.getParent();
     if (gp instanceof JScrollPane) {
       final JScrollPane scrollPane = (JScrollPane) gp;
       // Make certain we are the viewPort's view and not, for
       // example, the rowHeaderView of the scrollPane -
       // an implementor of fixed columns might do this.
       final JViewport viewport = scrollPane.getViewport();
       if (viewport == null || viewport.getView() != this) {
         return;
       }
       //  scrollPane.getViewport().setBackingStoreEnabled(true);
       //                Border border = scrollPane.getBorder ();
       //                if ( border == null || border instanceof UIResource )
       //                {
       //                    Border scrollPaneBorder = UIManager.getBorder (
       // "Table.scrollPaneBorder" );
       //                    if ( scrollPaneBorder != null )
       //                    {
       //                        scrollPane.setBorder ( scrollPaneBorder );
       //                    }
       //                }
       // add JScrollBar corner component if available from LAF and not already set by the user
       Component corner = scrollPane.getCorner(JScrollPane.UPPER_TRAILING_CORNER);
       if (corner == null || corner instanceof UIResource) {
         corner = null;
         final Object componentClass = UIManager.get("Table.scrollPaneCornerComponent");
         if (componentClass instanceof Class) {
           try {
             corner = (Component) ((Class) componentClass).newInstance();
           } catch (final Exception e) {
             // just ignore and don't set corner
           }
         }
         scrollPane.setCorner(JScrollPane.UPPER_TRAILING_CORNER, corner);
       }
     }
   }
 }
Example #23
0
 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();
   }
 }
  public void scrollToColumnLocation(int colIndex) {
    JTable scrollTable = transposedSpreadsheetSubform.getScrollTable();
    scrollTable.setColumnSelectionInterval(colIndex, colIndex);

    JViewport scrollPane = transposedSpreadsheetSubform.getFrozenTable().getViewport();
    Rectangle rect = scrollTable.getCellRect(1, colIndex, true);
    Point p = scrollPane.getViewPosition();
    rect.setLocation(rect.x - p.x, rect.y - p.y);

    scrollPane.scrollRectToVisible(rect);

    Map<Integer, Color> columnToColor = new HashMap<Integer, Color>();
    columnToColor.put(colIndex, new Color(28, 117, 188, 70));

    transposedSpreadsheetSubform.changeTableRenderer(
        transposedSpreadsheetSubform.getScrollTable(),
        new SubFormCellRenderer(
            UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, null, columnToColor));

    transposedSpreadsheetSubform.validate();
    transposedSpreadsheetSubform.repaint();
  }
  /**
   * 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 viewportSet(JViewport viewport) {
   viewport.addChangeListener(
       new ChangeListener() {
         @Override
         public void stateChanged(ChangeEvent e) {
           TableModel model = getModel();
           if (model instanceof AbstractTableModel) {
             Couple<Integer> visibleRows = ScrollingUtil.getVisibleRows(VcsLogGraphTable.this);
             ((AbstractTableModel) model)
                 .fireTableChanged(
                     new TableModelEvent(
                         model,
                         visibleRows.first - 1,
                         visibleRows.second,
                         GraphTableModel.ROOT_COLUMN));
           }
         }
       });
 }
Example #27
0
 public void propertyChange(PropertyChangeEvent evt) {
   JViewport vp = getViewport();
   if (vp != null) vp.setBackground(Util.getBgColor());
 }
Example #28
0
  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 FixedColumnExample() {
    super("Fixed Column Example");
    setSize(400, 150);
    data =
        new Object[][] {
          {"1", "11", "A", "", "", "", "", ""},
          {"2", "22", "", "B", "", "", "", ""},
          {"3", "33", "", "", "C", "", "", ""},
          {"4", "44", "", "", "", "D", "", ""},
          {"5", "55", "", "", "", "", "E", ""},
          {"6", "66", "", "", "", "", "", "F"}
        };
    column = new Object[] {"fixed 1", "fixed 2", "a", "b", "c", "d", "e", "f"};
    AbstractTableModel fixedModel =
        new AbstractTableModel() {
          public int getColumnCount() {
            return 2;
          }

          public int getRowCount() {
            return data.length;
          }

          public String getColumnName(int col) {
            return (String) column[col];
          }

          public Object getValueAt(int row, int col) {
            return data[row][col];
          }
        };
    AbstractTableModel model =
        new AbstractTableModel() {
          public int getColumnCount() {
            return column.length - 2;
          }

          public int getRowCount() {
            return data.length;
          }

          public String getColumnName(int col) {
            return (String) column[col + 2];
          }

          public Object getValueAt(int row, int col) {
            return data[row][col + 2];
          }

          public void setValueAt(Object obj, int row, int col) {
            data[row][col + 2] = obj;
          }

          public boolean CellEditable(int row, int col) {
            return true;
          }
        };
    fixedTable =
        new JTable(fixedModel) {
          public void valueChanged(ListSelectionEvent e) {
            super.valueChanged(e);
            checkSelection(true);
          }
        };
    table =
        new JTable(model) {
          public void valueChanged(ListSelectionEvent e) {
            super.valueChanged(e);
            checkSelection(false);
          }
        };
    fixedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fixedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scroll = new JScrollPane(table);
    JViewport viewport = new JViewport();
    viewport.setView(fixedTable);
    viewport.setPreferredSize(fixedTable.getPreferredSize());
    scroll.setRowHeaderView(viewport);
    scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTable.getTableHeader());
    getContentPane().add(scroll, BorderLayout.CENTER);
  }
  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);
  }