Example #1
0
  /** Write file with position and size of the login box */
  public static void writePersistence() {

    Messages.postDebug("LoginBox", "LoginBox.writePersistence");
    // If the panel has not been created, don't try to write a file
    if (position == null) return;

    String filepath = FileUtil.savePath("USER/PERSISTENCE/LoginPanel");

    FileWriter fw;
    PrintWriter os;
    try {
      File file = new File(filepath);
      fw = new FileWriter(file);
      os = new PrintWriter(fw);
      os.println("Login Panel");

      os.println(height);
      os.println(width);
      double xd = position.getX();
      int xi = (int) xd;
      os.println(xi);
      double yd = position.getY();
      int yi = (int) yd;
      os.println(yi);

      os.close();
    } catch (Exception er) {
      Messages.postError("Problem creating  " + filepath);
      Messages.writeStackTrace(er);
    }
  }
Example #2
0
 public Point getLocation() {
   if (inEditMode) {
     tmpLoc.x = defLoc.x;
     tmpLoc.y = defLoc.y;
   } else {
     tmpLoc.x = curLoc.x;
     tmpLoc.y = curLoc.y;
   }
   return tmpLoc;
 }
Example #3
0
 public void setSizeRatio(double x, double y) {
   xRatio = x;
   yRatio = y;
   if (x > 1.0) xRatio = x - 1.0;
   if (y > 1.0) yRatio = y - 1.0;
   if (defDim.width <= 0) defDim = getPreferredSize();
   curLoc.x = (int) ((double) defLoc.x * xRatio);
   curLoc.y = (int) ((double) defLoc.y * yRatio);
   curDim.width = (int) ((double) defDim.width * xRatio);
   curDim.height = (int) ((double) defDim.height * yRatio);
   if (!inEditMode) setBounds(curLoc.x, curLoc.y, curDim.width, curDim.height);
 }
Example #4
0
 public void setEditMode(boolean s) {
   twin.setEditMode(s);
   setOpaque(s);
   if (s) {
     addMouseListener(ml);
     curLoc.x = defLoc.x;
     curLoc.y = defLoc.y;
     defDim = getPreferredSize();
     curDim.width = defDim.width;
     curDim.height = defDim.height;
   } else removeMouseListener(ml);
   inEditMode = s;
 }
Example #5
0
 public void reshape(int x, int y, int w, int h) {
   if (inEditMode) {
     defLoc.x = x;
     defLoc.y = y;
     defDim.width = w;
     defDim.height = h;
   }
   curLoc.x = x;
   curLoc.y = y;
   curDim.width = w;
   curDim.height = h;
   super.reshape(x, y, w, h);
 }
Example #6
0
 public void setSizeRatio(double x, double y) {
   double rx = x;
   double ry = y;
   if (rx > 1.0) rx = x - 1.0;
   if (ry > 1.0) ry = y - 1.0;
   if (defDim.width <= 0) defDim = getPreferredSize();
   curLoc.x = (int) ((double) defLoc.x * rx);
   curLoc.y = (int) ((double) defLoc.y * ry);
   curDim.width = (int) ((double) defDim.width * rx);
   curDim.height = (int) ((double) defDim.height * ry);
   if (!inEditMode) setBounds(curLoc.x, curLoc.y, curDim.width, curDim.height);
   twin.setSizeRatio(x, y);
 }
Example #7
0
 public void reshape(int x, int y, int w, int h) {
   if (inEditMode) {
     defLoc.x = x;
     defLoc.y = y;
     defDim.width = w;
     defDim.height = h;
   }
   curLoc.x = x;
   curLoc.y = y;
   curDim.width = w;
   curDim.height = h;
   if (!inEditMode) {
     if ((h != nHeight) || (h < rHeight)) {
       adjustFont(w, h);
     }
   }
   super.reshape(x, y, w, h);
 }
Example #8
0
 public void setEditMode(boolean s) {
   if (s) {
     addMouseListener(ml);
     setOpaque(s);
     if (font != null) {
       setFont(font);
       fontH = font.getSize();
       rHeight = fontH;
     }
     defDim = getPreferredSize();
     curLoc.x = defLoc.x;
     curLoc.y = defLoc.y;
     curDim.width = defDim.width;
     curDim.height = defDim.height;
     xRatio = 1.0;
     yRatio = 1.0;
   } else {
     removeMouseListener(ml);
     if ((bg != null) || (isActive < 1)) setOpaque(true);
     else setOpaque(false);
   }
   inEditMode = s;
 }
Example #9
0
    public void mouseClicked(MouseEvent evt) {
      int btn = evt.getButton();
      if (btn == MouseEvent.BUTTON3) {
        JPopupMenu helpMenu = new JPopupMenu();
        String helpLabel = Util.getLabel("CSHMenu");
        JMenuItem helpMenuItem = new JMenuItem(helpLabel);
        helpMenuItem.setActionCommand("help");
        helpMenu.add(helpMenuItem);

        ActionListener alMenuItem =
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                String topic = "";
                try {
                  JComponent c1 = (JComponent) tabbedPane.getSelectedComponent();
                  // This component should contain the following embedded items.
                  // We want m_helplink out of the top VGroup.
                  //   PushpinObj
                  //     XMLToolPanel
                  //       JScrollpane
                  //         JViewport
                  //           JPanel
                  //             VGroup
                  // Work down to the VGroup, checking for class type along
                  // the way.
                  if (c1 instanceof PushpinObj) {
                    Component c2[] = c1.getComponents();
                    int cnt;
                    for (cnt = 0; cnt < c2.length; cnt++) {
                      // The PushpinObj can have multiple items, find the one we want
                      if (c2[cnt] instanceof XMLToolPanel) break;
                    }
                    if (cnt < c2.length && c2[cnt] instanceof XMLToolPanel) {
                      Component c3[] = ((JComponent) c2[cnt]).getComponents();
                      if (c3[0] instanceof JScrollPane) {
                        Component c4[] = ((JComponent) c3[0]).getComponents();
                        if (c4[0] instanceof JViewport) {
                          Component c5[] = ((JComponent) c4[0]).getComponents();
                          if (c5[0] instanceof JPanel) {
                            Component c6[] = ((JComponent) c5[0]).getComponents();
                            if (c6[0] instanceof VGroup) {
                              // Get the helplink info from the VGroup
                              topic = ((VGroup) c6[0]).getAttribute(VObjDef.HELPLINK);
                            }
                          }
                        }
                      }
                    }
                  }
                  // If no helplink found, try the Tab's name
                  if (topic == null || topic.length() == 0) {
                    topic = c1.getName();
                    if (topic.equals("Locator")) topic = getLocatorName();
                    topic = topic.replace(" ", "_");
                  }
                } catch (Exception ex) {
                }
                // Get the ID and display the help content
                CSH_Util.displayCSHelp(topic);
              }
            };
        helpMenuItem.addActionListener(alMenuItem);

        Point pt = evt.getPoint();
        helpMenu.show(VTabbedToolPanel.this, (int) pt.getX(), (int) pt.getY());
      }
    }
Example #10
0
 public Point getDefLoc() {
   tmpLoc.x = defLoc.x;
   tmpLoc.y = defLoc.y;
   return tmpLoc;
 }
Example #11
0
 public void setDefLoc(int x, int y) {
   defLoc.x = x;
   defLoc.y = y;
 }