Пример #1
0
 public void propertyChange(PropertyChangeEvent evt) {
   if (fg != null) {
     fgColor = DisplayOptions.getColor(fg);
     setForeground(fgColor);
   }
   changeFont();
 }
Пример #2
0
  public VCaretEntry(SessionShare sshare, ButtonIF vif, String typ) {
    this.type = typ;
    this.vnmrIf = vif;
    this.fg = "black";
    this.fontSize = "8";
    setText("");
    setOpaque(false);
    orgBg = VnmrRgb.getColorByName("darkGray");
    setHorizontalAlignment(JTextField.LEFT);
    setMargin(new Insets(0, 2, 0, 2));

    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);
    setEditable(true);
    caret = new VCaret();
    setCaret(caret);
    addCaretListener(this);
  }
Пример #3
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);
  }
Пример #4
0
  /**
   * constructor
   *
   * @param sshare session share
   */
  public SpotterButton(SessionShare sshare) {
    JMenuItem item;

    this.sshare = sshare;

    //	setBackground(Global.BGCOLOR);
    setContentAreaFilled(false);
    // setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    setMargin(new Insets(0, 0, 0, 0));
    setBorder(new VButtonBorder());

    setUnderline(false);
    setIcon(Util.getImageIcon("search_20.png"));
    setToolTipText(Util.getLabel("_Locator_Statements"));

    addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent evt) {
            // Save startup time by not filling this menu until
            // it is first clicked.
            fillPopupMenu();
          }
        });

    addPopListener(
        new PopListener() {
          public void popHappened(String popStr) {

            SessionShare sshare = ResultTable.getSshare();
            if (popStr.startsWith("save:")) {
              String saveName = popStr.substring(5);
              StatementHistory history = sshare.statementHistory();
              history.readNamedStatement(saveName);
            } else if (popStr.startsWith("command:")) {
              String commandName = popStr.substring(8);
              int index = commandName.indexOf('/');
              String objType = commandName.substring(0, index);
              LocatorHistory lh = sshare.getLocatorHistory();
              // Set History Active Object type to this type.
              lh.setActiveObjType(objType);

              // Now get history for this type.
              StatementHistory history = sshare.statementHistory();
              history.appendLastOfType(commandName);
            } else if (popStr.startsWith("title:")) {
              String objType = popStr.substring(6);
              LocatorHistory lh = sshare.getLocatorHistory();
              // Update locator to the most recent statement for this type
              lh.setHistoryToThisType(objType);
            }
          }
        });
    DisplayOptions.addChangeListener(this);
  } // SpotterButton()
Пример #5
0
 public void changeFont() {
   font = DisplayOptions.getFont(fontName, fontStyle, fontSize);
   setFont(font);
   fontH = font.getSize();
   rHeight = fontH;
   if (!inEditMode) {
     if ((curDim.height > 0) && (rHeight > curDim.height)) {
       adjustFont(curDim.width, curDim.height);
     }
   }
   repaint();
 }
Пример #6
0
 public void adjustFont(int w, int h) {
   if (h <= 0) return;
   int oldH = rHeight;
   if (font == null) {
     font = getFont();
     fontH = font.getSize();
     rHeight = fontH;
   }
   nHeight = h;
   if (fontH >= h) rHeight = h - 2;
   else rHeight = fontH;
   if ((rHeight < 10) && (fontH > 10)) rHeight = 10;
   if (oldH != rHeight) {
     // Font  curFont = font.deriveFont((float) rHeight);
     Font curFont = DisplayOptions.getFont(font.getName(), font.getStyle(), rHeight);
     setFont(curFont);
   }
   if (rHeight > h) rHeight = h;
 }
Пример #7
0
 /** PropertyChangeListener interface */
 public void propertyChange(PropertyChangeEvent evt) {
   if (DisplayOptions.isUpdateUIEvent(evt)) SwingUtilities.updateComponentTreeUI(this);
 }
Пример #8
0
  private void initUi() {
    String history;
    String undo;
    String close;
    String abandon;
    String help;
    String string;
    char helpMnemonic;
    char historyMnemonic;
    char undoMnemonic;
    char closeMnemonic;
    char abandonMnemonic;

    DisplayOptions.addChangeListener(this);

    // setAlwaysOnTop(true);

    // Get text for buttons from properties/resource file
    history = Util.getLabel("blHistory", "Edit...");
    undo = Util.getLabel("blUndo", "Undo");
    close = Util.getLabel("blClose", "Close");
    abandon = Util.getLabel("blAbandon", "Abandon");
    help = Util.getLabel("blHelp", "Help");

    // buttons
    undoButton = new JButton(undo);
    closeButton = new JButton(close);
    abandonButton = new JButton(abandon);
    helpButton = new JButton(help);

    // Create an ArrayList of menu items from properties file

    ArrayList<String> historyList = new ArrayList<String>();
    historyList.add(Util.getLabel("mlHistReturnInitState", "Return to initial state"));
    historyList.add(Util.getLabel("mlHistMakeSnapshot", "Make a snapshot"));
    historyList.add(Util.getLabel("mlHistReturnToSnapshot", "Return to snapshot"));
    historyList.add(Util.getLabel("mlHistReturnToDefault", "Return to system defaults"));

    // Pop Button for history menu
    historyButton = new MPopButton(historyList);
    historyButton.setText(history);

    // Only set mnemonics if found.

    if (Util.labelExists("blmHelp")) {
      string = Util.getLabel("blmHelp");
      helpMnemonic = string.charAt(0);
      helpButton.setMnemonic(helpMnemonic);
    }

    if (Util.labelExists("blmUndo")) {
      string = Util.getLabel("blmUndo");
      undoMnemonic = string.charAt(0);
      undoButton.setMnemonic(undoMnemonic);
    }

    if (Util.labelExists("blmAbandon")) {
      string = Util.getLabel("blmAbandon");
      abandonMnemonic = string.charAt(0);
      abandonButton.setMnemonic(abandonMnemonic);
    }

    if (Util.labelExists("blmClose")) {
      string = Util.getLabel("blmClose");
      closeMnemonic = string.charAt(0);
      closeButton.setMnemonic(closeMnemonic);
    }

    if (Util.labelExists("blmHistory")) {
      string = Util.getLabel("blmHistory");
      historyMnemonic = string.charAt(0);
      historyButton.setMnemonic(historyMnemonic);
    }

    helpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            // Display Help if help file exists
            CSH_Util.displayCSHelp(dialogTitle);
          }
        });

    // Make a panel to hold the buttons
    buttonPane = new JPanel();

    // Put an empty border around the inside of the panel.
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 5));
    buttonPane.setLayout(new SimpleH2Layout(SimpleH2Layout.CENTER));

    // Add the buttons to the panel with space between buttons.
    buttonPane.add(historyButton);
    // buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(undoButton);
    // buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(closeButton);
    // buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(abandonButton);
    // buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(helpButton);

    // Put everything together, using the content pane's BorderLayout.
    Container contentPane = getContentPane();
    contentPane.add(buttonPane, BorderLayout.SOUTH);

    setHistoryEnabled(false);
    // setCloseEnabled(false);
    setAbandonEnabled(false);
    setUndoEnabled(false);

    if (!CSH_Util.haveTopic(dialogTitle)) setHelpEnabled(false);

    // buttonPane.setVisible(false);
    // Add key listener to the whole dialog
    addKeyListener(this);
    // Make the frame fit its contents.
    // pack(); // nothing to pack.
  }
Пример #9
0
 public void destroy() {
   DisplayOptions.removeChangeListener(this);
 }
Пример #10
0
 public void setAttribute(int attr, String c) {
   switch (attr) {
     case TYPE:
       type = c;
       break;
     case FGCOLOR:
       fg = c;
       fgColor = DisplayOptions.getColor(fg);
       setForeground(fgColor);
       repaint();
       break;
     case BGCOLOR:
       if (!DisplayOptions.isOption(DisplayOptions.COLOR, c)) c = null;
       bg = c;
       if (c != null) {
         bgColor = DisplayOptions.getColor(c);
         setOpaque(true);
       } else {
         bgColor = Util.getBgColor();
         if (isActive < 1) setOpaque(true);
         else setOpaque(inEditMode);
       }
       setBackground(bgColor);
       repaint();
       break;
     case COLOR2:
       caretColor = c;
       if (DisplayOptions.isOption(DisplayOptions.COLOR, c)) {
         Color col = DisplayOptions.getColor(c);
         setCaretColor(col);
         setSelectionColor(col);
       }
       break;
     case SHOW:
       showVal = c;
       setBorder(isEnabled);
       break;
     case FONT_NAME:
       fontName = c;
       break;
     case FONT_STYLE:
       fontStyle = c;
       break;
     case FONT_SIZE:
       fontSize = c;
       break;
     case SETVAL:
       setVal = c;
       break;
     case SETVAL2:
       caretQuery = c;
       break;
     case VARIABLE:
       vnmrVar = c;
       break;
     case CMD:
       vnmrCmd = c;
       break;
     case CMD2:
       caretCmd = c;
       break;
     case NUMDIGIT:
       precision = c;
       break;
     case LABEL:
       label = c;
       break;
     case VALUE:
       value = c;
       setText(c);
       break;
     case KEYSTR:
       keyStr = c;
       break;
     case KEYVAL:
       setText(c);
       break;
     case DISABLE:
       m_strDisAbl = c;
       break;
   }
 }
Пример #11
0
  public void fillPopupMenu() {
    JMenuItem item;
    TextImageIcon textIcon;
    StatementHistory history;
    int rowCount = 0;
    int numRows = 0;
    Insets margin = new Insets(0, 0, 0, 0);

    // Get the font defined in the displayOptions panel for menus
    Font ft = DisplayOptions.getFont("Menu1");
    // We need a fairly small font, so make it 2 smaller.
    int size = ft.getSize();
    // If larger than 12, subtract 2
    if (size > 12) size -= 2;
    Font font = DisplayOptions.getFont(ft.getName(), ft.getStyle(), size);

    // This flag is used so that we only fill the menu when needed
    if (menuAlreadyFilled) return;

    menuAlreadyFilled = true;

    history = sshare.statementHistory();

    ArrayList list = history.getNamedStatementList();
    Color bgColor = Util.getBgColor();
    // Only show the Saved Statements section if there are some.
    if (list != null && list.size() != 0) {
      item = popup.add("Saved Statements");
      rowCount++;
      //	    item.setForeground(Color.blue);
      //	    item.setBackground(bgColor);
      item.setFont(font);
      item.setMargin(margin);
      popup.add(item);

      for (int i = 0; i < list.size(); i++) {
        ArrayList nameNlabel = (ArrayList) list.get(i);
        // first item in nameNlabel is name and second is label
        item = popup.add("  " + (String) nameNlabel.get(1));
        rowCount++;
        item.setActionCommand("save:" + (String) nameNlabel.get(0));
        //		item.setBackground(bgColor);
        item.addActionListener(popActionListener);
        item.setFont(font);
        item.setMargin(margin);
      }
    }
    // the rest of menu (return object types, statement types, etc.)
    ShufflerService shufflerService = sshare.shufflerService();
    ArrayList objTypes = shufflerService.getAllMenuObjectTypes();

    for (int i = 0; i < objTypes.size(); i++) {
      String objType = (String) objTypes.get(i);

      // Do not display menu for DB_AVAIL_SUB_TYPES
      if (objType.equals(Shuf.DB_AVAIL_SUB_TYPES)) continue;

      // addSeparator looks bad using GridLayout because it creates rows
      // and columns which are all equal in size.  It cannot have a row
      // with a separator which is a different height than the other
      // rectangles it creates. So just use dashes.
      item = popup.add(separator);
      item.setFont(font);
      item.setMargin(margin);
      rowCount++;
      item = popup.add(shufflerService.getCategoryLabel(objType));
      rowCount++;
      //	    item.setForeground(Color.blue);
      item.setActionCommand("title:" + objType);
      //	    item.setBackground(bgColor);
      item.addActionListener(popActionListener);
      item.setFont(font);
      item.setMargin(margin);

      ArrayList menuStrings = shufflerService.getmenuStringsThisObj(objType);

      // If current rowCount plus the next section size is too big,
      // specify the numRows to the current value of rowCount -1.
      // That is, put this next section in a new column.
      // 47 is emperical number of rows to fit 90% full screen.
      if (numRows == 0 && rowCount - 1 + menuStrings.size() > 44) {

        numRows = rowCount - 2;
      }

      for (int j = 0; j < menuStrings.size(); j++) {
        String menuString = (String) menuStrings.get(j);
        item = popup.add("  " + menuString);
        rowCount++;
        item.setActionCommand("command:" + objType + "/" + menuString);
        //		item.setBackground(bgColor);
        item.addActionListener(popActionListener);
        item.setFont(font);
        item.setMargin(margin);
      }
      // The spotter menu changes dynamically when
      // the list of saved statements changes.
      history.addStatementListener(
          new StatementAdapter() {
            public void saveListChanged() {
              refreshSaveMenu();
            }
          });
    }

    if (numRows == 0) numRows = rowCount;

    GridLayoutCol lm = new GridLayoutCol(numRows, 0);
    popup.setLayout(lm);
  }