Esempio n. 1
0
  /** Creates new form FormatFrame */
  public FormatProgressDialog(Window parent, SavantFileFormatter sff, boolean toLoad) {
    super(parent, ModalityType.APPLICATION_MODAL);
    initComponents();
    formatter = sff;
    toLoadTrack = toLoad;
    setIconImage(
        SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.LOGO).getImage());

    srcLabel.setText(shorten(formatter.getInputFile().getPath()));
    destLabel.setText(shorten(formatter.getOutputFile().getPath()));
  }
Esempio n. 2
0
  public BookmarkSheet(Container c) {

    // set the layout of the data sheet
    c.setLayout(new BorderLayout());
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    /** Create a toolbar. */
    JMenuBar toolbar = new JMenuBar();
    toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
    c.add(toolbar, BorderLayout.NORTH);

    JButton previousButton = new JButton();
    previousButton.setIcon(
        SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UP));
    previousButton.setToolTipText("Go to previous bookmark [ Ctrl+( ]");
    previousButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    previousButton.putClientProperty("JButton.segmentPosition", "first");
    previousButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            goToPreviousBookmark();
          }
        });
    toolbar.add(previousButton);

    JButton nextButton = new JButton();
    nextButton.setIcon(
        SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.DOWN));
    nextButton.setToolTipText("Go to next bookmark [ Ctrl+) ]");
    nextButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    nextButton.putClientProperty("JButton.segmentPosition", "last");
    nextButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            goToNextBookmark();
          }
        });
    toolbar.add(nextButton);

    JButton goButton = new JButton("Go");
    goButton.setToolTipText("Go to selected bookmark");
    goButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    goButton.putClientProperty("JButton.segmentPosition", "only");
    goButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            goToSelectedBookmark();
          }
        });
    toolbar.add(goButton);

    toolbar.add(Box.createGlue());

    addButton = new JButton();
    addButton.setIcon(
        SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_ADD));
    addButton.setToolTipText("Add bookmark for current range");
    addButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    addButton.putClientProperty("JButton.segmentPosition", "first");
    addButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            BookmarkController fc = BookmarkController.getInstance();
            fc.addCurrentRangeToBookmarks();
          }
        });
    toolbar.add(addButton);

    JButton deleteButton = new JButton();
    deleteButton.setIcon(
        SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_RM));
    deleteButton.setToolTipText("Delete selected bookmarks");
    deleteButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    deleteButton.putClientProperty("JButton.segmentPosition", "last");
    deleteButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            BookmarkController fc = BookmarkController.getInstance();
            int[] selectedRows = table.getSelectedRows();
            Arrays.sort(selectedRows);
            boolean delete = false;

            if (selectedRows.length > 0 && confirmDelete) {
              Object[] options = {"Yes", "No", "Yes, don't ask again"};
              JLabel message =
                  new JLabel(
                      "Are you sure you want to delete " + selectedRows.length + " item(s)?");
              message.setPreferredSize(new Dimension(300, 20));
              int confirmDeleteDialog =
                  JOptionPane.showOptionDialog(
                      DialogUtils.getMainWindow(),
                      message,
                      "Confirm Delete",
                      JOptionPane.YES_NO_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE,
                      null,
                      options,
                      options[0]);

              if (confirmDeleteDialog == 0) {
                delete = true;
              } else if (confirmDeleteDialog == 2) {
                delete = true;
                confirmDelete = false;
              }
            } else if (selectedRows.length > 0 && !confirmDelete) {
              delete = true;
            }

            if (delete) {
              for (int i = selectedRows.length - 1; i >= 0; i--) {
                fc.removeBookmark(selectedRows[i]);
              }
            }
          }
        });
    toolbar.add(deleteButton);

    toolbar.add(Box.createGlue());

    JButton loadButton = new JButton();
    loadButton.setIcon(
        SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.OPEN));
    loadButton.setToolTipText("Load bookmarks from file");
    loadButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    loadButton.putClientProperty("JButton.segmentPosition", "first");
    loadButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            loadBookmarks(table);
          }
        });
    toolbar.add(loadButton);

    JButton saveButton = new JButton();
    saveButton.setIcon(
        SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SAVE));
    saveButton.setToolTipText("Save bookmarks to file");
    saveButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    saveButton.putClientProperty("JButton.segmentPosition", "last");
    saveButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            saveBookmarks(table);
          }
        });
    toolbar.add(saveButton);

    // create a table (the most important component)
    table = new JTable(new BookmarksTableModel());
    table.setAutoCreateRowSorter(true);
    table.setFillsViewportHeight(true);
    table.setShowGrid(true);
    table.setGridColor(Color.gray);
    // table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

    // add the table and its header to the subpanel
    c.add(table.getTableHeader());

    add(table);

    final JScrollPane sp =
        new JScrollPane(
            table,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    sp.setWheelScrollingEnabled(false);
    sp.addMouseWheelListener(
        new MouseWheelListener() {
          @Override
          public void mouseWheelMoved(MouseWheelEvent e) {
            sp.getVerticalScrollBar()
                .setValue(sp.getVerticalScrollBar().getValue() + e.getUnitsToScroll() * 2);
          }
        });

    c.add(sp);

    // add glue to fill the remaining space
    add(Box.createGlue());
  }