コード例 #1
1
    protected void displayNewTxf(String strLabel, String strValue) {
      strLabel = (strLabel == null) ? "" : strLabel.trim();
      strValue = (strValue == null) ? "" : strValue.trim();

      JCheckBox chkBox1 = new JCheckBox(Util.getImageIcon("boxGray.gif"));
      DataField txf1 = new DataField(strLabel);
      DataField txf2 = new DataField(strValue);
      JPanel pnlTxf = new JPanel(m_gbl);
      m_nRow = m_nRow + 1;

      txf1.setName("label");
      txf2.setName("value");

      /* 1st line of text field*/
      m_gbc.weightx = 0;
      showComp(m_gbl, m_gbc, 0, m_nRow, 1, chkBox1);
      m_gbc.weightx = 1;
      showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf1);
      // showSpaces( gbl, gbc, 2, 6 );
      showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf2);
      m_gbc.weightx = 0;
      txf1.addFocusListener(this);
      txf2.addFocusListener(this);

      m_objTxfValue.addToLabel(txf1);
      m_objTxfValue.addToValue(txf2);
    }
コード例 #2
0
  protected void setBgColor(Color bgColor) {
    setBackgroundColor(bgColor);

    panelForBtns.setBackground(Util.getBgColor());
    addButton.setBackground(Util.getBgColor());
    removeButton.setBackground(Util.getBgColor());
  }
コード例 #3
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
 /**
  * Gets the imageicon. If the user has a predefined icon, get that, otherwise get the varian icon.
  *
  * @return the imageicon
  */
 protected ImageIcon getImageIcon() {
   ImageIcon icon = null;
   String strPath = WOperators.getDefIcon();
   if (strPath != null) {
     icon = Util.getImageIcon(strPath);
   }
   if (icon == null) icon = Util.getImageIcon(WOperators.ICON);
   return icon;
 }
コード例 #4
0
ファイル: TextPanel.java プロジェクト: dimitarp/basex
 /**
  * Performs a search.
  *
  * @param sc search context
  * @param jump jump to next hit
  */
 final void search(final SearchContext sc, final boolean jump) {
   try {
     rend.search(sc);
     if (!sc.search.isEmpty()) gui.status.setText(Util.info(Text.STRINGS_FOUND_X, sc.nr()));
     if (jump) jump(SearchDir.CURRENT, false);
   } catch (final Exception ex) {
     final String msg = Util.message(ex).replaceAll(Prop.NL + ".*", "");
     gui.status.setError(Text.REGULAR_EXPR + Text.COLS + msg);
   }
 }
コード例 #5
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()
コード例 #6
0
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      JLabel label = null;

      // i18n
      // label = new JLabel( "File names can be constructed from a template. The LABEL field is " );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_"));
      label.setForeground(Color.black);
      // m_gbc.weightx = 0.5;
      showInstruction(m_gbl, m_gbc, 0, 0, 7, label);

      // i18n
      // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up."));
      showInstruction(m_gbl, m_gbc, 0, 1, 7, label);
      showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel(""));

      label = new JLabel(Util.getAdmLabel("_adm_LABEL"));
      label.setForeground(Color.black);
      m_gbc.gridx = 1;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 10;
      m_gbl.setConstraints(label, m_gbc);
      m_pnlDisplay.add(label);

      label = new JLabel("     ");
      m_gbc.gridx = 2;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 0; // reset to default
      m_gbc.gridwidth = 5;
      m_gbl.setConstraints(label, m_gbc);
      // add( label );

      showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE")));

      m_nRow = 3;
      m_bDefaultFile = bDefaultFile;
      m_objTxfValue.clearArrays();
      displayNewTxf(strPath);

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
コード例 #7
0
    public DisplayUserDirectory() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      hmlabel.setForeground(Color.black);
      add(hmlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(hmdir, gbc);
      add(Box.createVerticalStrut(15), gbc);

      gbc.gridwidth = 1;
      vjlabel.setForeground(Color.black);
      add(vjlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(vjdir, gbc);
      add(Box.createVerticalStrut(0), gbc);

      gbc.gridwidth = 1;
      vjlabel2.setForeground(Color.black);
      add(vjlabel2, gbc);
      setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder(" User_Directories "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
コード例 #8
0
ファイル: VText.java プロジェクト: timburrow/OpenVnmrJ
  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);
  }
コード例 #9
0
ファイル: EditorView.java プロジェクト: rostam/basex
 /**
  * Shows a quit dialog for the specified editor.
  *
  * @param edit editor to be saved
  * @return {@code false} if confirmation was canceled
  */
 private boolean confirm(final EditorArea edit) {
   if (edit.modified && (edit.opened() || edit.getText().length != 0)) {
     final Boolean ok = BaseXDialog.yesNoCancel(gui, Util.info(CLOSE_FILE_X, edit.file.name()));
     if (ok == null || ok && !save()) return false;
   }
   return true;
 }
コード例 #10
0
    /** Returns the tool bar for the panel. */
    protected JComponent getToolBar() {
      JToolBar tbarDir = new JToolBar();
      JButton btnNew = new JButton();
      // m_btnSave = new JButton("Save File");
      // i118n
      // btnNew.setText("New Label");
      btnNew.setText(Util.getAdmLabel("_adm_New_Label"));
      btnNew.setActionCommand("new");
      // m_btnSave.setActionCommand("save");

      ActionListener alTool =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              doAction(e);
            }
          };

      btnNew.addActionListener(alTool);
      // m_btnSave.addActionListener(alTool);

      tbarDir.setFloatable(false);
      tbarDir.add(btnNew);
      /*tbarDir.add(new JLabel("        "));
      tbarDir.add(m_btnSave);*/

      return tbarDir;
    }
コード例 #11
0
ファイル: JavaPanel.java プロジェクト: CTMM-TraIT/trait_ctp
 private void clearLogsDir() {
   if (clearLogs.cb.isSelected()) {
     File logs = new File("logs");
     Util.deleteAll(logs);
     IOPanel.out.clear();
   }
 }
コード例 #12
0
  /** When a new set of saved statements come in, refresh the menu of saved statements. */
  private void refreshSaveMenu() {
    ArrayList list;
    // first, delete what's already there
    for (; ; ) {
      Component comp = popup.getComponent(1);
      if (!(comp instanceof JMenuItem)) break;

      JMenuItem item = (JMenuItem) comp;
      if (item.getActionCommand().startsWith("save:")) popup.remove(1);
      else break;
    }
    StatementHistory history;
    history = sshare.statementHistory();
    // now insert the new list of saved statements
    list = history.getNamedStatementList();
    Color bgColor = Util.getBgColor();
    for (int i = 0; i < list.size(); i++) {
      ArrayList nameNlabel = (ArrayList) list.get(i);
      JMenuItem item = new JMenuItem("  " + (String) nameNlabel.get(1));
      item.setActionCommand("save:" + (String) nameNlabel.get(0));
      popup.add(item, 1);
      //	    item.setBackground(bgColor);
      item.addActionListener(popActionListener);
    }
  } // refreshSaveMenu()
コード例 #13
0
ファイル: TextView.java プロジェクト: dirkk/basex
  /** Saves the displayed text. */
  private void save() {
    final BaseXFileChooser fc =
        new BaseXFileChooser(SAVE_AS, gui.gopts.get(GUIOptions.WORKPATH), gui).suffix(IO.XMLSUFFIX);

    final IO file = fc.select(Mode.FSAVE);
    if (file == null) return;
    gui.gopts.set(GUIOptions.WORKPATH, file.path());

    gui.cursor(CURSORWAIT, true);
    final MainOptions opts = gui.context.options;
    final int mh = opts.get(MainOptions.MAXHITS);
    opts.set(MainOptions.MAXHITS, -1);
    opts.set(MainOptions.CACHEQUERY, false);

    try (final PrintOutput out = new PrintOutput(file.toString())) {
      if (cmd != null) {
        cmd.execute(gui.context, out);
      } else if (ns != null) {
        ns.serialize(Serializer.get(out));
      } else {
        final byte[] txt = text.getText();
        for (final byte t : txt) if (t < 0 || t > ' ' || ws(t)) out.write(t);
      }
    } catch (final IOException ex) {
      BaseXDialog.error(gui, Util.info(FILE_NOT_SAVED_X, file));
    } finally {
      opts.set(MainOptions.MAXHITS, mh);
      opts.set(MainOptions.CACHEQUERY, true);
      gui.cursor(CURSORARROW, true);
    }
  }
コード例 #14
0
ファイル: BaseXLayout.java プロジェクト: adrianber/basex
  /**
   * Draws the specified string.
   *
   * @param g graphics reference
   * @param s text
   * @param x x coordinate
   * @param y y coordinate
   * @param w width
   * @param fs font size
   */
  public static void chopString(
      final Graphics g, final byte[] s, final int x, final int y, final int w, final int fs) {

    if (w < 12) return;
    final int[] cw = fontWidths(g.getFont());

    int j = s.length;
    try {
      int l = 0;
      int fw = 0;
      for (int k = 0; k < j; k += l) {
        final int ww = width(g, cw, cp(s, k));
        if (fw + ww >= w - 4) {
          j = Math.max(1, k - l);
          if (k > 1) fw -= width(g, cw, cp(s, k - 1));
          g.drawString("..", x + fw, y + fs);
          break;
        }
        fw += ww;
        l = cl(s, k);
      }
    } catch (final Exception ex) {
      Util.debug(ex);
    }
    g.drawString(string(s, 0, j), x, y + fs);
  }
コード例 #15
0
ファイル: BaseXLayout.java プロジェクト: adrianber/basex
  /**
   * Returns a keystroke for the specified string.
   *
   * @param cmd command
   * @return keystroke
   */
  public static KeyStroke keyStroke(final GUICommand cmd) {
    final Object sc = cmd.shortcuts();
    if (sc == null) return null;

    final String scut;
    if (sc instanceof BaseXKeys[]) {
      final BaseXKeys[] scs = (BaseXKeys[]) sc;
      if (scs.length == 0) return null;
      scut = scs[0].shortCut();
    } else {
      scut = Util.info(sc, META);
    }
    final KeyStroke ks = KeyStroke.getKeyStroke(scut);
    if (ks == null) Util.errln("Could not assign shortcut: " + sc + " / " + scut);
    return ks;
  }
コード例 #16
0
ファイル: JavaPanel.java プロジェクト: CTMM-TraIT/trait_ctp
 public void start() {
   running = Util.isRunning();
   if (!running) {
     clearLogsDir();
     run();
   }
 }
コード例 #17
0
ファイル: JavaPanel.java プロジェクト: CTMM-TraIT/trait_ctp
 public void actionPerformed(ActionEvent event) {
   if (event.getSource().equals(launchBrowser)) {
     Configuration config = Configuration.getInstance();
     String ip = Util.getIPAddress();
     String protocol = "http" + (config.ssl ? "s" : "");
     String url = protocol + "://" + ip + ":" + config.port;
     Util.openURL(url);
   } else if (event.getSource().equals(stop)) {
     Util.shutdown();
     running = Util.isRunning();
     setStatus();
   } else if (event.getSource().equals(start)) {
     clearLogsDir();
     run();
     launchBrowser.requestFocusInWindow();
   }
 }
コード例 #18
0
    protected JPanel createForm() {
      JPanel panel = new JPanel();
      panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
      // Time
      JPanel pT = new JPanel(new FlowLayout());
      pT.setBorder(BorderFactory.createTitledBorder("Start Time"));
      hh = new JSpinner(new SpinnerNumberModel(Util.getHours(myrow.getTime()), 0, 99, 1));
      hh.setEditor(new JSpinner.NumberEditor(hh, "00"));
      pT.add(hh);
      pT.add(new JLabel("h "));
      mm = new JSpinner(new SpinnerNumberModel(Util.getMinutes(myrow.getTime()), 0, 59, 1));
      mm.setEditor(new JSpinner.NumberEditor(mm, "00"));
      pT.add(mm);
      pT.add(new JLabel("m "));
      ss = new JSpinner(new SpinnerNumberModel(Util.getSeconds(myrow.getTime()), 0, 59, 1));
      ss.setEditor(new JSpinner.NumberEditor(ss, "00"));
      pT.add(ss);
      pT.add(new JLabel("s"));
      panel.add(pT);
      // Green
      JPanel pG = new JPanel(new BorderLayout());
      pG.setBorder(BorderFactory.createTitledBorder("Green (sec.)"));
      green = new JSpinner(new SpinnerNumberModel(myrow.getGreen() * conversion, 0.0, 99999.99, 1));
      green.setEditor(new JSpinner.NumberEditor(green, "####0.##"));
      pG.add(green);
      panel.add(pG);
      // Red
      JPanel pR = new JPanel(new BorderLayout());
      pR.setBorder(BorderFactory.createTitledBorder("Red (sec.)"));
      red = new JSpinner(new SpinnerNumberModel(myrow.getRed() * conversion, 0.0, 99999.99, 1));
      red.setEditor(new JSpinner.NumberEditor(red, "####0.##"));
      pR.add(red);
      panel.add(pR);

      JPanel bp = new JPanel(new FlowLayout());
      JButton bOK = new JButton("    OK    ");
      bOK.setActionCommand(cmdOK);
      bOK.addActionListener(new ButtonEventsListener());
      JButton bCancel = new JButton("Cancel");
      bCancel.setActionCommand(cmdCancel);
      bCancel.addActionListener(new ButtonEventsListener());
      bp.add(bOK);
      bp.add(bCancel);
      panel.add(bp);
      return panel;
    }
コード例 #19
0
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      // gbc.weightx = 0.5;

      showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1);
      showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2);
      showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3);
      /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 );
      showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/
      showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel(""));

      // i18n
      // label = new JLabel( "LABEL" );
      label = new JLabel(Util.getAdmLabel("_adm_LABEL"));
      label.setForeground(Color.black);
      m_gbc.gridx = 1;
      m_gbc.gridy = 5;
      // gbc.ipadx = 10;
      m_gbl.setConstraints(label, m_gbc);
      m_pnlDisplay.add(label);

      label = new JLabel("     ");
      m_gbc.gridx = 2;
      m_gbc.gridy = 5;
      m_gbc.ipadx = 0;
      m_gbc.gridwidth = 5;
      m_gbc.weightx = 0;
      m_gbl.setConstraints(label, m_gbc);
      // add( label );

      // i18n
      // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" ));
      showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY")));

      m_nRow = 5;

      m_bDefaultFile = bDefaultFile;
      m_objTxfValue.clearArrays();
      displayNewTxf(strPath);

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder( "  Parent Directories  "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
コード例 #20
0
ファイル: ProjectList.java プロジェクト: LukasK/basex
 /** Open all selected files externally. */
 private void openExternal() {
   for (final IOFile file : selectedValues()) {
     try {
       file.open();
     } catch (final IOException ex) {
       BaseXDialog.error(project.gui, Util.info(FILE_NOT_OPENED_X, file));
     }
   }
 }
コード例 #21
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
 public void setVisible(boolean bShow, String title) {
   if (bShow) {
     String strDir = "";
     String strFreq = "";
     String strTraynum = "";
     m_strHelpFile = getHelpFile(title);
     String strSampleName = getSampleName(title);
     String frameBounds = getFrameBounds(title);
     StringTokenizer tok = new QuotedStringTokenizer(title);
     if (tok.hasMoreTokens()) strDir = tok.nextToken();
     if (tok.hasMoreTokens()) strFreq = tok.nextToken();
     if (tok.hasMoreTokens()) strTraynum = tok.nextToken();
     else {
       try {
         Integer.parseInt(strDir);
         // if strdir is number, then strdir is empty, and the
         // strfreq is the number
         strTraynum = strFreq;
         strFreq = strDir;
         strDir = "";
       } catch (Exception e) {
       }
     }
     try {
       setTitle(gettitle(strFreq));
       m_lblSampleName.setText("3");
       boolean bVast = isVast(strTraynum);
       CardLayout layout = (CardLayout) m_pnlSampleName.getLayout();
       if (!bVast) {
         if (strSampleName == null) {
           strSampleName = getSampleName(strDir, strTraynum);
         }
         m_lblSampleName.setText(strSampleName);
         layout.show(m_pnlSampleName, OTHER);
       } else {
         m_strDir = strDir;
         setTrays();
         layout.show(m_pnlSampleName, VAST);
         m_trayTimer.start();
       }
       boolean bSample = bVast || !strSampleName.trim().equals("");
       m_pnlSampleName.setVisible(bSample);
       m_lblLogin.setForeground(getBackground());
       m_lblLogin.setVisible(false);
       m_passwordField.setText("");
       m_passwordField.setCaretPosition(0);
     } catch (Exception e) {
       Messages.writeStackTrace(e);
     }
     setBounds(frameBounds);
     ExpPanel exp = Util.getActiveView();
     if (exp != null) exp.waitLogin(true);
   }
   writePersistence();
   setVisible(bShow);
 }
コード例 #22
0
 public Object getValueAt(int row, int column) {
   if ((row < 0) || (row > cycledata.size() - 1) || (column < 0) || (column > 2)) return null;
   NumberFormat form = NumberFormat.getInstance();
   form.setMaximumFractionDigits(2);
   String s;
   if (column == 0) s = Util.time2string(cycledata.get(row).getTime());
   else if (column == 1) s = form.format(cycledata.get(row).getGreen() * conversion);
   else s = form.format(cycledata.get(row).getRed() * conversion);
   return s;
 }
コード例 #23
0
 @Override
 @EventHandler
 public void onChatReceived(ChatReceivedEvent event) {
   super.onChatReceived(event);
   String message = Util.stripColors(event.getMessage());
   if (message.startsWith("Please register with \"/register")) {
     String password = Util.generateRandomString(10 + random.nextInt(6));
     bot.say("/register " + password + " " + password);
   } else if (message.contains("You are not member of any faction.")
       && spamMessage != null
       && createFaction) {
     String msg = "/f create " + Util.generateRandomString(7 + random.nextInt(4));
     bot.say(msg);
   }
   for (String s : captchaList) {
     Matcher captchaMatcher = Pattern.compile(s).matcher(message);
     if (captchaMatcher.matches()) bot.say(captchaMatcher.group(1));
   }
 }
コード例 #24
0
ファイル: BaseXLayout.java プロジェクト: adrianber/basex
 /**
  * Set desktop hints (not supported by all platforms).
  *
  * @param g graphics reference
  */
 public static void hints(final Graphics g) {
   if (HINTS != null && hints) {
     try {
       ((Graphics2D) g).addRenderingHints(HINTS);
     } catch (final Exception ex) {
       Util.stack(ex);
       hints = false;
     }
   }
 }
コード例 #25
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  public LoginBox() {
    super("VnmrJ Login");

    dolayout("", "", "");
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    // setVast();
    DisplayOptions.addChangeListener(this);

    try {
      InetAddress inetAddress = InetAddress.getLocalHost();
      m_strHostname = inetAddress.getHostName();
    } catch (Exception e) {
      m_strHostname = "localhost";
    }

    VNMRFrame vnmrFrame = VNMRFrame.getVNMRFrame();
    Dimension size = vnmrFrame.getSize();
    position = vnmrFrame.getLocationOnScreen();
    AppIF appIF = Util.getAppIF();
    int h = appIF.statusBar.getSize().height;
    width = size.width;
    height = size.height - h;

    // Allow resizing and use the previous size and position
    // To stop resizing, use setResizable(false);
    readPersistence();

    //        setSize(width, height);
    //        setLocation(position);
    //        setResizable(false);

    setBackgroundColor(Util.getBgColor());

    m_trayTimer =
        new javax.swing.Timer(
            6000,
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                setTrays();
              }
            });
  }
コード例 #26
0
ファイル: DialogExport.java プロジェクト: fpapai/basex
  @Override
  public void close() {
    try {
      gui.set(MainOptions.EXPORTER, options(SerialMethod.valueOf(method.getSelectedItem())));
    } catch (final BaseXException ex) {
      throw Util.notExpected(ex);
    }
    if (!ok) return;

    super.close();
    path.store();
  }
コード例 #27
0
ファイル: BaseXLayout.java プロジェクト: adrianber/basex
 /**
  * Returns the width of the specified text. Cached font widths are used to speed up calculation.
  *
  * @param g graphics reference
  * @param s string to be evaluated
  * @return string width
  */
 public static int width(final Graphics g, final byte[] s) {
   final int[] cw = fontWidths(g.getFont());
   final int l = s.length;
   int fw = 0;
   try {
     // ignore faulty character sets
     for (int k = 0; k < l; k += cl(s, k)) fw += width(g, cw, cp(s, k));
   } catch (final Exception ex) {
     Util.debug(ex);
   }
   return fw;
 }
コード例 #28
0
ファイル: TextPanel.java プロジェクト: dimitarp/basex
 /**
  * Returns the clipboard text.
  *
  * @return text
  */
 private static String clip() {
   // copy selection to clipboard
   final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
   final Transferable tr = clip.getContents(null);
   if (tr != null) {
     final ArrayList<Object> contents = BaseXLayout.contents(tr);
     if (!contents.isEmpty()) return contents.get(0).toString();
   } else {
     Util.debug("Clipboard has no contents.");
   }
   return null;
 }
コード例 #29
0
  /**
   * ************************************************
   *
   * <pre>
   * Summary: Constructor, Add buttons to dialog box
   *
   * </pre>
   *
   * *************************************************
   */
  public TagAddRemoveDialog() {
    super(Util.getLabel("_Locator_Add_Remove"));

    // Make a panel for the buttons
    panelForBtns = new JPanel();
    // It looks better with a border
    panelForBtns.setBorder(BorderFactory.createEmptyBorder(20, 35, 20, 35));

    // Create the two items.
    addButton = new JButton("Add to Group");
    removeButton = new JButton("Remove From Group");

    // Add items to panel
    panelForBtns.add(addButton);
    panelForBtns.add(removeButton);

    // Add the panel top of the dialog.
    getContentPane().add(panelForBtns, BorderLayout.NORTH);

    // Set the buttons and the text item up with Listeners
    cancelButton.setActionCommand("cancel");
    cancelButton.addActionListener(this);
    helpButton.setActionCommand("help");
    helpButton.addActionListener(this);
    addButton.setActionCommand("add");
    addButton.addActionListener(this);
    addButton.setMnemonic('a');
    removeButton.setActionCommand("remove");
    removeButton.addActionListener(this);
    removeButton.setMnemonic('r');

    // OK disabled.
    okButton.setEnabled(false);

    setBgColor(Util.getBgColor());
    DisplayOptions.addChangeListener(this);

    // Make the frame fit its contents.
    pack();
  }
コード例 #30
0
ファイル: TextPanel.java プロジェクト: dimitarp/basex
 /** Reads in the property file. */
 static {
   try {
     final String file = "/completions.properties";
     final InputStream is = TextPanel.class.getResourceAsStream(file);
     if (is == null) {
       Util.errln(file + " not found.");
     } else {
       try (final NewlineInput nli = new NewlineInput(is)) {
         for (String line; (line = nli.readLine()) != null; ) {
           final int i = line.indexOf('=');
           if (i == -1 || line.startsWith("#")) continue;
           final String key = line.substring(0, i), value = line.substring(i + 1);
           if (REPLACE.put(key, value.replace("\\n", "\n")) != null) {
             Util.errln(file + ": " + key + " was assigned twice");
           }
         }
       }
     }
   } catch (final IOException ex) {
     Util.errln(ex);
   }
 }