private void init() {
    agents = new JComboBox(model);
    agents.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            stateChanged(event);
          }
        });
    agents.addActionListener(TextChangesListener.getInstance());
    ctm = new CreationTableModel();
    datatable = new JTable(ctm);
    datatable.setShowGrid(false);
    datatable.setEnabled(false);
    datatable.setTableHeader(null);
    datatable.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3));
    JPanel apanel = new JPanel(new BorderLayout());
    apanel.add(new JLabel("Who took the photo: "), BorderLayout.WEST);
    apanel.add(agents, BorderLayout.CENTER);
    JPanel tablePanel = new JPanel(new BorderLayout());
    tablePanel.add(new JScrollPane(datatable), BorderLayout.CENTER);

    datatable.getColumnModel().getColumn(0).setMaxWidth(120);
    datatable.getColumnModel().getColumn(0).setMinWidth(80);

    datatable.addKeyListener(TextChangesListener.getInstance());

    this.add(
        ComponentFactory.createTitledPanel("Creator of the image:", apanel), BorderLayout.NORTH);
    this.add(
        ComponentFactory.createTitledPanel("Creation, EXIF & technical information:", tablePanel),
        BorderLayout.CENTER);
    this.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.WEST);
  }
  @Override
  protected void configureTable(JTable table) {
    super.configureTable(table);

    // replace default action on enter
    table
        .getActionMap()
        .put(
            "selectNextRowCell",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent ae) {}
            });
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent ke) {
            switch (ke.getKeyCode()) {
                // press enter
              case 10:
                getOpenDialogExecutor().execute();
                break;
                // press delete
              case 127:
                deleteSelected();
                refresh();
                break;
            }
          }
        });
  }
Example #3
0
    public JLabelPosition(JTable table) {
      this.table = table;
      setFont(getFont().deriveFont(Font.PLAIN));

      table.addKeyListener(this);
      table.addMouseListener(this);
    }
Example #4
0
  public void open(DefaultListModel listModel) {
    final DefaultTableModel tableModel = createTableModel(listModel);
    final JTable table = new JTable(tableModel);
    table.setToolTipText("Move: PgUp/PgDown; Edit: Double-Click or Insert/Delete");

    table.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            int[] selRows = table.getSelectedRows();
            if (selRows.length == 0) {
              return;
            }
            int firstSelectedRow = selRows[0];
            int key = e.getKeyCode();
            ListSelectionModel selectionModel = table.getSelectionModel();
            switch (key) {
              case KeyEvent.VK_DELETE:
                for (int i = selRows.length - 1; i >= 0; i--) {
                  tableModel.removeRow(selRows[i]);
                }
                if (firstSelectedRow >= 0 && firstSelectedRow < tableModel.getRowCount()) {
                  selectionModel.addSelectionInterval(firstSelectedRow, firstSelectedRow);
                }
                e.consume(); // avoid beep
                break;
              case KeyEvent.VK_INSERT:
                tableModel.insertRow(firstSelectedRow + 1, new String[] {""});
                e.consume(); // Dont edit cell
                break;
              case KeyEvent.VK_PAGE_UP:
              case KeyEvent.VK_PAGE_DOWN:
                boolean isUp = key == KeyEvent.VK_PAGE_UP;
                int direction = isUp ? -1 : 1;
                int min = selectionModel.getMinSelectionIndex() + direction;
                int max = selectionModel.getMaxSelectionIndex() + direction;
                if (min < 0 || max >= tableModel.getRowCount()) {
                  return; // avoid ArrayIndexOutOfBoundsException
                }
                for (int i = 0; i < selRows.length; i++) {
                  int row = selRows[isUp ? i : (selRows.length - 1 - i)];
                  int to = row + direction;
                  selectionModel.removeSelectionInterval(row, row);
                  selectionModel.addSelectionInterval(to, to);
                  tableModel.moveRow(row, row, to);
                }
                break;
            }
          }
        });
    int result =
        JOptionPane.showConfirmDialog(
            null,
            table,
            "Change " + jEdit.getProperty("history.caption"),
            JOptionPane.OK_CANCEL_OPTION);
    if (result == JOptionPane.OK_OPTION) {
      updatelistModel(listModel, tableModel);
    }
  }
Example #5
0
  public void addListeners(final JTable table) {
    // updates card detail, listens to any key strokes

    table.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent ev) {}

          @Override
          public void keyTyped(KeyEvent ev) {}

          @Override
          public void keyReleased(KeyEvent ev) {
            int row = table.getSelectedRow();
            if (row != -1) {
              showImage(row);
            }
          }
        });

    // updates card detail, listens to any mouse clicks
    table.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            int row = table.getSelectedRow();
            if (row != -1) {
              showImage(row);
            }
          }
        });

    // sorts
    MouseListener mouse =
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            TableColumnModel columnModel = table.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = table.convertColumnIndexToModel(viewColumn);

            if (column != -1) {
              // sort ascending
              boolean asc = true;
              if (recentSortedColumn == column) {
                asc = !recentAscending;
              }
              sortSetting.setSortIndex(column);
              sortSetting.setAscending(asc);
              sort(column, asc);
              fireTableDataChanged();
            }
          }
        };
    table.getTableHeader().addMouseListener(mouse);
  }
Example #6
0
  public TableFeedBody() {
    this.setOrientation(JSplitPane.VERTICAL_SPLIT);
    this.setOneTouchExpandable(false);
    this.setContinuousLayout(true);
    // the top component (the list) takes the extra space
    this.setResizeWeight(1);

    JScrollPane scroll = new JScrollPane();
    feedTable = new JTable();
    feedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    feedTable.setRowSelectionAllowed(true);
    feedTable.changeSelection(0, 0, false, false);
    feedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    feedTable.addMouseListener(this);
    feedTable.setRowHeight(25);
    feedTable.addKeyListener(this);
    scroll.setViewportView(feedTable);

    this.setTopComponent(scroll);

    feedItemDetail = new JEditorPane();
    feedItemDetail.setContentType("text/html");
    feedItemDetail.addHyperlinkListener(this);
    feedItemDetail.setBackground(Color.WHITE);
    feedItemDetail.setEditable(false);
    HTMLEditorKit kit = (HTMLEditorKit) feedItemDetail.getEditorKit();
    StyleSheet sheet = kit.getStyleSheet();
    Font font = UIManager.getFont("Label.font");
    sheet.addRule(
        "body {font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt;}");

    JScrollPane detailScroll = new JScrollPane();
    Dimension minDetailSize = detailScroll.getMinimumSize();
    minDetailSize.height = 100;
    detailScroll.setMinimumSize(minDetailSize);
    Dimension prefDetailSize = detailScroll.getPreferredSize();
    prefDetailSize.height = 200;
    detailScroll.setPreferredSize(prefDetailSize);
    detailScroll.setViewportView(feedItemDetail);

    this.setBottomComponent(detailScroll);

    this.setDividerSize(2);
    this.setDividerLocation(-1);
  }
Example #7
0
  public PanelPeliculas() {
    super(new BorderLayout());

    peliculaDAO = new PeliculaDAO();
    iconos = new Iconos();

    add(panelCentral(), BorderLayout.CENTER);
    add(panelPortada(), BorderLayout.WEST);

    ControladorEventos controladorEventos = new ControladorEventos();

    jtbl_peliculas.addKeyListener(controladorEventos);
    jtbl_peliculas.addMouseListener(controladorEventos);
    jtbl_peliculas.addMouseListener(new JButtonTableClick(jtbl_peliculas));
    jbtn_buscar.addActionListener(controladorEventos);
    jbtn_buscar.addKeyListener(controladorEventos);
    jbtn_agregar.addActionListener(controladorEventos);
    jtf_buscar.addKeyListener(controladorEventos);

    peliculaDAO.agregarObservador(controladorEventos);

    dialogoPelicula = null;
  }
Example #8
0
  public CharTable(Font font, FontEditor parent) {
    this.font = font;
    this.parent = parent;

    popup = new CharTablePopupMenu(this);

    columnModel = new DefaultTableColumnModel();

    TableColumn num = new TableColumn(0, 30);
    num.setHeaderValue("Dec");
    columnModel.addColumn(num);
    TableColumn hex = new TableColumn(1, 35);
    hex.setHeaderValue("Hex");
    columnModel.addColumn(hex);
    TableColumn ascii = new TableColumn(2, 37);
    ascii.setHeaderValue("ASCII");
    columnModel.addColumn(ascii);
    TableColumn width = new TableColumn(3, 37);
    width.setHeaderValue("Width");
    columnModel.addColumn(width);
    TableColumn desc = new TableColumn(4, 93);
    desc.setHeaderValue("Comment");
    columnModel.addColumn(desc);

    tableModel = new CharTableModel();
    tableModel.setColumnCount(5);

    charTable = new JTable(tableModel, columnModel);
    charTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    charTable.setMinimumSize(new Dimension(225, 100));
    charTable.addKeyListener(this);
    charTable.addMouseListener(this);
    charTable.addPropertyChangeListener(this);

    doRowData();
  }
Example #9
0
  public JipViewer(String title, JipRun run) {
    super(title);

    addKeyListener(this);
    mMethodModel.addChangeListener(this);

    // build the call tree
    mCallTreeRoot = new TreeNode(title);
    buildTree(run, mCallTreeRoot);

    mCallTree = new JTree(mCallTreeRoot);
    mCallTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    mCallTree.addTreeSelectionListener(this);
    mCallTree.addKeyListener(this);

    // build the allMethods table
    Collection<JipRun.PerMethodInfo> perMethodInfos = run.perMethodsInTotalTimeOrder();
    long totalTimeForAllThreads = run.getTotalTimeForAllThreads();
    for (JipRun.PerMethodInfo perMethod : perMethodInfos) {
      MethodRow row = new MethodRow(perMethod.getMethod());
      for (JipFrame frame : perMethod.allFrames()) {
        if (!frame.isReentrant()) {
          row.addFrame(frame);
        }
        row.setTimeDenominator(totalTimeForAllThreads);
      }
      mAllMethodsModel.add(row);
    }
    mMethods = MethodViewer.makeTableForMethodRows(mAllMethodsModel);
    mMethods.getSelectionModel().addListSelectionListener(this);
    mMethods.addKeyListener(this);
    mAllMethodsSorterModel = (TableSorter) mMethods.getModel();

    // make the ByPackageViewer
    mPkgViewer = new ByPackageViewer(run);
    mPkgViewer.addKeyListener(this);

    // make the RemoteController
    mRemoteController = new RemoteController();
    mRemoteController.addKeyListener(this);

    // make the methodViewer
    MethodViewer methodViewer = new MethodViewer(run, mMethodModel);

    // combine all the views
    JTabbedPane tabPane = new JTabbedPane();
    tabPane.addTab("call tree", new JScrollPane(mCallTree));
    tabPane.addTab("methods", new JScrollPane(mMethods));
    tabPane.addTab("by package", new JScrollPane(mPkgViewer));
    tabPane.addTab("remote control", mRemoteController);
    tabPane.addTab("help", new HelpViewer());
    tabPane.addKeyListener(this);
    tabPane.setMinimumSize(new Dimension(100, 200));

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tabPane, methodViewer);
    setContentPane(split);

    pack();
    setSize(new Dimension(1024, 768));
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  public AddEditFormFrame(LexiconList list) {

    this.lexList = list;

    setTitle("Forms");
    setSize(200, 400);
    setResizable(false);
    setLayout(null);
    setLocationRelativeTo(null);
    setVisible(true);
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(1, 1, 200, 300);
    formTable = new JTable();
    formTable.setPreferredSize(new Dimension(200, 320));
    model = (DefaultTableModel) formTable.getModel();
    model.setColumnIdentifiers(new String[] {"Forms"});
    for (String form : lexList.getPossibleForms()) model.addRow(new String[] {form});
    scrollPane.setViewportView(formTable);
    add(scrollPane);

    JButton addForm = new JButton("Add Form");
    addForm.setBounds(50, 320, 80, 30);
    add(addForm);

    addForm.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            model.addRow(new String[] {""});
          }
        });

    formTable.addKeyListener(
        new KeyListener() {

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
              if (formTable.getSelectedRowCount() > 0) {
                int n =
                    JOptionPane.showConfirmDialog(
                        null,
                        "Are you sure you want to delete all selected forms?",
                        "An Inane Question",
                        JOptionPane.YES_NO_OPTION);
                if (n == JOptionPane.YES_OPTION) {
                  for (int i = formTable.getSelectedRows().length - 1; i >= 0; i--) {
                    lexList.deletePossibleForm(
                        (String) model.getValueAt(formTable.getSelectedRows()[i], 0));
                    model.removeRow(formTable.getSelectedRows()[i]);
                  }
                }
              }
            }
          }

          public void keyReleased(KeyEvent e) {}

          public void keyTyped(KeyEvent e) {}
        });

    model.addTableModelListener(
        new TableModelListener() {
          public void tableChanged(TableModelEvent arg0) {
            int row = arg0.getFirstRow();
            int column = arg0.getColumn();
            if (column >= 0 && row >= 0) {
              if (row >= lexList.getPossibleForms().size()) {
                lexList.addNewPossibleForm((String) model.getValueAt(row, column));
              } else {
                lexList.renamePossibleForm(
                    lexList.getPossibleForms().get(row), (String) model.getValueAt(row, column));
              }
            }
          }
        });
  }
Example #11
0
  public JipViewer(String title, JipRun run) {
    super(title);

    addKeyListener(this);
    mMethodModel.addChangeListener(this);

    // build the call tree
    mCallTreeRoot = new TreeNode(title);
    buildTree(run, mCallTreeRoot);

    mCallTree = new JTree(mCallTreeRoot);
    mCallTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    mCallTree.addTreeSelectionListener(this);
    mCallTree.addKeyListener(this);

    // build the allMethods table
    Collection<JipRun.PerMethodInfo> perMethodInfos = run.perMethodsInTotalTimeOrder();
    long totalTimeForAllThreads = run.getTotalTimeForAllThreads();
    for (JipRun.PerMethodInfo perMethod : perMethodInfos) {
      MethodRow row = new MethodRow(perMethod.getMethod());
      for (JipFrame frame : perMethod.allFrames()) {
        if (!frame.isReentrant()) {
          row.addFrame(frame);
        }
        row.setTimeDenominator(totalTimeForAllThreads);
      }
      mAllMethodsModel.add(row);
    }
    mAllMethodsModel.sort();
    mMethods = MethodViewer.makeTableForMethodRows(mAllMethodsModel);
    mMethods.getSelectionModel().addListSelectionListener(this);
    mMethods.addKeyListener(this);
    mAllMethodsSorterModel = (TableSorter) mMethods.getModel();

    // make the ByPackageViewer
    mPkgViewer = new ByPackageViewer(run);
    mPkgViewer.addKeyListener(this);

    // Make the classs count viewer

    mClassAllocationViewer = new ClassAllocationViewer(run);
    mClassAllocationViewer.addKeyListener(this);

    if (instanceNumero == 0) {
      // make the RemoteController only if root
      mRemoteController = new RemoteController();
      mRemoteController.addKeyListener(this);
    }

    // make the methodViewer
    MethodViewer methodViewerMethods = new MethodViewer(run, mMethodModel);
    MethodViewer methodViewerCallTree = new MethodViewer(run, mMethodModel);

    // combine all the views
    JTabbedPane tabPane = new JTabbedPane();
    if (instanceNumero != 0 || FIRST_HAS_DATA) {
      JSplitPane splitPane =
          new JSplitPane(
              JSplitPane.VERTICAL_SPLIT, new JScrollPane(mCallTree), methodViewerCallTree);
      splitPane.setLayout(new BoxLayout(splitPane, BoxLayout.Y_AXIS));
      tabPane.addTab("call tree", splitPane);
      splitPane =
          new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(mMethods), methodViewerMethods);
      splitPane.setLayout(new BoxLayout(splitPane, BoxLayout.Y_AXIS));
      tabPane.addTab("methods", splitPane);
      tabPane.addTab("by package", new JScrollPane(mPkgViewer));
      tabPane.addTab("class allocation", mClassAllocationViewer);
    }

    if (instanceNumero == 0) {
      tabPane.addTab("remote control", mRemoteController);
    }

    tabPane.addTab("help", new HelpViewer());
    tabPane.addKeyListener(this);
    setContentPane(tabPane);
    pack();
    setSize(new Dimension(1024, 768));
    setVisible(true);

    if (instanceNumero == 0) {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } else {
      setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    instanceNumero++;
  }
Example #12
0
  private void setNodeFilterPanel() {
    lWMap = tufts.vue.VUE.getActiveMap();
    addButton.setToolTipText(VueResources.getString("nodefilter.addfilter.tooltip"));
    deleteButton.setToolTipText(VueResources.getString("nodefilter.deletefilter.tooltip"));
    elementsModel = new ElementComboBoxModel();
    elementsModel.setElements(lWMap.getMapFilterModel().getKeyVector());
    elements = new JComboBox(elementsModel);
    Font f = elements.getFont();
    Font menuFont = new Font(f.getFontName(), f.getStyle(), f.getSize() - 2);
    elements.setFont(menuFont);
    // elements.setPreferredSize(new Dimension(150,20));
    /// this is not user friendly may want to fix later.
    /**
     * elements.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) {
     * if(e.getStateChange() == ItemEvent.SELECTED) { if(e.getItem().toString() == ADD_ELEMENT) { }
     * else if(e.getItem() instanceof Key) { Statement stmt = new Statement();
     * stmt.setKey((Key)e.getItem()); nodeFilter.addStatement(stmt);
     * nodeFilter.fireTableDataChanged(); } else { System.out.println("Not Supported"); } } } });
     */
    nodeFilterTable = new JTable(nodeFilter);
    nodeFilterTable.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent e) {
            if (nodeFilterTable.isEditing()) {
              nodeFilterTable
                  .getCellEditor(
                      nodeFilterTable.getEditingRow(), nodeFilterTable.getEditingColumn())
                  .stopCellEditing();
            }
            nodeFilterTable.removeEditor();
          }

          public void focusGained(FocusEvent e) {}
        });
    nodeFilterTable.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (nodeFilterTable.getSelectedRow() == (nodeFilterTable.getRowCount() - 1)
                && e.getKeyCode() == e.VK_ENTER) {
              addButtonListener.addStatement();
            }
          }
        });

    nodeFilterTable.setPreferredScrollableViewportSize(new Dimension(240, 100));
    JScrollPane nodeFilterScrollPane = new JScrollPane(nodeFilterTable);
    nodeFilterScrollPane.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JPanel nodeFilterPanel = new JPanel();
    nodeFilterPanel.setLayout(new BorderLayout());
    nodeFilterPanel.add(nodeFilterScrollPane, BorderLayout.CENTER);
    addButtonListener = new AddButtonListener(nodeFilter);
    addButton.addActionListener(addButtonListener);
    deleteButton.setEnabled(false);
    sListener = new NodeFilterSelectionListener(deleteButton, -1);
    nodeFilterTable.getSelectionModel().addListSelectionListener(sListener);
    deleteButtonListener = new DeleteButtonListener(nodeFilterTable, sListener);
    deleteButton.addActionListener(deleteButtonListener);

    // keyEditor = new KeyCellEditor();
    // nodeFilterTable.getColumnModel().getColumn(NodeFilter.KEY_COL).setCellEditor(keyEditor);
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS));
    JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 0));
    // bottomPanel.setBorder(BorderFactory.createEmptyBorder(3,6,3,6));
    bottomPanel.add(elementLabel);
    bottomPanel.add(elements);
    bottomPanel.add(addButton);
    bottomPanel.add(deleteButton);
    bottomPanel.add(questionLabel);
    // innerPanel.add(labelPanel);
    innerPanel.add(bottomPanel);
    innerPanel.add(nodeFilterPanel);
    setLayout(new BorderLayout());
    add(innerPanel, BorderLayout.CENTER);

    validate();
  }
  // {{{ InstallPanel constructor
  InstallPanel(PluginManager window, boolean updates) {
    super(new BorderLayout(12, 12));

    this.window = window;
    this.updates = updates;

    setBorder(new EmptyBorder(12, 12, 12, 12));

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.75);
    /* Setup the table */
    table = new JTable(pluginModel = new PluginTableModel());
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setRowHeight(table.getRowHeight() + 2);
    table.setPreferredScrollableViewportSize(new Dimension(500, 200));
    table.setDefaultRenderer(
        Object.class,
        new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class)));
    table.addFocusListener(new TableFocusHandler());
    InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap tableActionMap = table.getActionMap();
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward");
    tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack");
    tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin");
    tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager");
    tableActionMap.put(
        "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER));

    TableColumn col1 = table.getColumnModel().getColumn(0);
    TableColumn col2 = table.getColumnModel().getColumn(1);
    TableColumn col3 = table.getColumnModel().getColumn(2);
    TableColumn col4 = table.getColumnModel().getColumn(3);
    TableColumn col5 = table.getColumnModel().getColumn(4);

    col1.setPreferredWidth(30);
    col1.setMinWidth(30);
    col1.setMaxWidth(30);
    col1.setResizable(false);

    col2.setPreferredWidth(180);
    col3.setPreferredWidth(130);
    col4.setPreferredWidth(70);
    col5.setPreferredWidth(70);

    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.addMouseListener(new HeaderMouseHandler());
    header.setDefaultRenderer(
        new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer()));

    scrollpane = new JScrollPane(table);
    scrollpane.getViewport().setBackground(table.getBackground());
    split.setTopComponent(scrollpane);

    /* Create description */
    JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox());
    infoPane.setPreferredSize(new Dimension(500, 100));
    split.setBottomComponent(infoPane);

    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            split.setDividerLocation(0.75);
          }
        });

    final JTextField searchField = new JTextField();
    searchField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
              table.dispatchEvent(e);
              table.requestFocus();
            }
          }
        });
    searchField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              void update() {
                pluginModel.setFilterString(searchField.getText());
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update();
              }
            });
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            int i = table.getSelectedRow(), n = table.getModel().getRowCount();
            if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1)
                || e.getKeyCode() == KeyEvent.VK_UP && i == 0) {
              searchField.requestFocus();
              searchField.selectAll();
            }
          }
        });
    Box filterBox = Box.createHorizontalBox();
    filterBox.add(new JLabel("Filter : "));
    filterBox.add(searchField);
    add(BorderLayout.NORTH, filterBox);
    add(BorderLayout.CENTER, split);

    /* Create buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    buttons.add(new InstallButton());
    buttons.add(Box.createHorizontalStrut(12));
    buttons.add(new SelectallButton());
    buttons.add(chooseButton = new ChoosePluginSet());
    buttons.add(new ClearPluginSet());
    buttons.add(Box.createGlue());
    buttons.add(new SizeLabel());

    add(BorderLayout.SOUTH, buttons);
    String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, "");
    if (!path.isEmpty()) {
      loadPluginSet(path);
    }
  } // }}}
Example #14
0
    public PopupFilter(TextPopup txtSearch, DefaultTableModelCommon defaultTableModelCommon) {
      this.textField = txtSearch;
      table = new JTable();
      table.setModel(defaultTableModelCommon);
      add(table);
      table.setRowHeight(23);
      // table.getColumnModel().getColumn(0).setMaxWidth(200);
      table.setFont(new Font("Tahoma", Font.PLAIN, 14));

      if (table.getRowCount() >= 0) {
        table.changeSelection(0, 0, true, false);
      }

      table.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
              JTable table = (JTable) e.getSource();
              switch (e.getKeyCode()) {
                case KeyEvent.VK_ESCAPE:
                  setVisible(false);
                  return;
                case KeyEvent.VK_ENTER:
                  // textField.setText(" ");
                  try {
                    object = table.getValueAt(table.getSelectedRow(), value);
                  } catch (Exception e1) {
                    textField.setText("");
                    setVisible(false);
                    return;
                  }
                  if (object != null) {
                    if (clearText) {
                      textField.setText("");
                      object = null;
                    } else {
                      if (viewCode) {
                        textField.setText(table.getValueAt(table.getSelectedRow(), 0).toString());
                        object = null;
                      } else {
                        textField.setText(object.toString());
                        object = null;
                      }
                    }
                    setVisible(false);
                    if (component instanceof JTextField) {
                      if (((JTextField) component).getText().trim().isEmpty()
                          && !(component instanceof TextPopup)) {
                        ((JTextField) component).setText("1");
                      }
                      ((JTextField) component).setSelectionStart(0);
                      component.requestFocus();
                    }
                    table.clearSelection();
                    return;
                  }
              }
            }
          });

      table.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              JTable table = (JTable) e.getSource();
              if (e.getClickCount() >= 2) {
                try {
                  object = table.getValueAt(table.getSelectedRow(), value);
                  try {
                    profile = AccountModelManager.getInstance().getProfileConfigAdmin();
                    if (profile.get(DialogConfig.Keyboard) != null
                        && profile.get(DialogConfig.Keyboard).toString().equals("true")) {
                      clearText1 = true;
                    } else {
                      clearText1 = false;
                    }
                  } catch (Exception e1) {
                  }
                } catch (Exception e1) {
                  setVisible(false);
                  return;
                }
                // textField.setText("  ");
                if (object != null) {
                  if (clearText) {
                    textField.setText("");
                    object = null;
                  } else {
                    if (viewCode) {
                      textField.setText(table.getValueAt(table.getSelectedRow(), 0).toString());
                      object = null;
                    } else {
                      textField.setText(object.toString());
                      object = null;
                    }
                  }
                  setVisible(false);
                  if (profile.get(DialogConfig.Keyboard) != null
                      && profile.get(DialogConfig.Keyboard).toString().equals("true")) {
                    table.clearSelection();
                    return;
                  }
                  if (component instanceof JTextField) {
                    if (((JTextField) component).getText().trim().isEmpty()
                        && !(component instanceof TextPopup)) {
                      ((JTextField) component).setText("1");
                      ((JTextField) component).setSelectionStart(0);
                    }
                    component.requestFocus();
                  }
                  table.clearSelection();
                  return;
                }
              }
            }
          });
      if (textField.getKeyListeners().length > 0) {
        textField.removeKeyListener(textField.getKeyListeners()[0]);
      }

      textField.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
              switch (e.getKeyCode()) {
                case KeyEvent.VK_DOWN:
                  table.clearSelection();
                  table.changeSelection(1, 1, true, false);
                  table.requestFocus();
                  return;
                case KeyEvent.VK_ENTER:
                  if (table.getSelectedRow() >= 0) {
                    try {
                      object = table.getValueAt(table.getSelectedRow(), value);
                    } catch (Exception e1) {
                      setVisible(false);
                      return;
                    }
                    // textField.setText("  ");
                    if (object != null) {
                      if (clearText) {
                        textField.setText("");
                        object = null;
                        setVisible(false);
                      } else {
                        if (viewCode) {
                          textField.setText(table.getValueAt(table.getSelectedRow(), 0).toString());
                          object = null;
                          setVisible(false);
                        } else {
                          textField.setText(object.toString());
                          object = null;
                          setVisible(false);
                        }
                      }

                      if (component instanceof JTextField) {
                        if (((JTextField) component).getText().trim().isEmpty()
                            && !(component instanceof TextPopup)) {
                          ((JTextField) component).setText("1");
                          ((JTextField) component).setSelectionStart(0);
                        }
                        component.requestFocus();
                      }
                      table.clearSelection();
                      return;
                    }
                  }
              }
            }
          });
    }
Example #15
0
  private void initializeComponent() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    getRootPane().setLayout(new BorderLayout());
    getRootPane().add(panel, BorderLayout.CENTER);

    JButton createButton = new JButton("New...");
    createButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            create();
          }
        });
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.WEST;
    panel.add(createButton, c);

    contexts = new JComboBox(new DefaultComboBoxModel());
    contexts.setPreferredSize(new Dimension(80, 24));
    contexts.setSize(new Dimension(80, 24));
    c = new GridBagConstraints();
    c.weightx = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(contexts, c);
    contexts.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            refresh();
          }
        });

    JButton refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            refresh();
          }
        });
    c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(refreshButton, c);

    itemTable = new JTable(1, 6);
    itemTable.setRowHeight(35);
    itemTable.setShowHorizontalLines(false);
    itemTable.setShowVerticalLines(false);
    itemTable.addKeyListener(
        new KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            ctrl = false;
          }

          public void keyPressed(KeyEvent e) {
            if (e.isControlDown()) {
              ctrl = true;
            }
          }
        });
    itemTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                int index = e.getFirstIndex();
                if (index >= 0 && index < items.size()) {
                  ChecklistItem item = items.get(index);
                  if (item.getStatus() == Status.Created) {
                    String actorId = getActorId();
                    try {
                      checklistManager.claimTask(actorId, item.getTaskId());
                      if (ctrl) {
                        checklistManager.abortTask(actorId, item.getTaskId());
                      } else {
                        checklistManager.completeTask(actorId, item.getTaskId());
                      }
                    } catch (Throwable t) {
                      // Do nothing
                    }
                    refresh();
                  } else if (item.getStatus() == Status.Reserved) {
                    String actorId = getActorId();
                    if (item.getActors().equals(actorId)) {
                      try {
                        if (ctrl) {
                          checklistManager.abortTask(actorId, item.getTaskId());
                        } else {
                          checklistManager.completeTask(actorId, item.getTaskId());
                        }
                      } catch (Throwable t) {
                        // Do nothing
                      }
                      refresh();
                    }
                  } else if (item.getStatus() == Status.Optional) {
                    try {
                      checklistManager.selectOptionalTask(
                          item.getName(), Long.valueOf((String) contexts.getSelectedItem()));
                    } catch (Throwable t) {
                      // Do nothing
                      t.printStackTrace();
                    }
                    refresh();
                  }
                }
              }
            });
    // TODO:
    // default width of columns
    // icons for state
    // not-editable
    // no selection
    // (scratch for aborted?)
    // replace refresh, create, etc. by icon
    c = new GridBagConstraints();
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(itemTable, c);

    JLabel nameLabel = new JLabel("Logged in as:");
    c = new GridBagConstraints();
    c.gridy = 2;
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.WEST;
    panel.add(nameLabel, c);

    userNameTextField = new JTextField("krisv");
    userNameTextField.setPreferredSize(new Dimension(80, 20));
    userNameTextField.setSize(new Dimension(80, 20));
    c = new GridBagConstraints();
    c.gridy = 2;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.WEST;
    panel.add(userNameTextField, c);

    JButton createItemButton = new JButton("+");
    createItemButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            createNewItem();
          }
        });
    c = new GridBagConstraints();
    c.gridy = 2;
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.EAST;
    panel.add(createItemButton, c);

    panel.doLayout();
  }
  public ConstructionProtocolViewD(final AppD app) {
    // cpPanel = new JPanel(new BorderLayout());

    this.app = app;
    kernel = app.getKernel();
    data = new ConstructionTableData(this);
    useColors = true;
    addIcons = false;

    table = new JTable();
    table.setAutoCreateColumnsFromModel(false);
    table.setModel(((GAbstractTableModelD) data.getImpl()).getImpl());
    table.setRowSelectionAllowed(true);
    table.setGridColor(Color.lightGray);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);

    // header
    JTableHeader header = table.getTableHeader();
    // header.setUpdateTableInRealTime(true);
    header.setReorderingAllowed(false);

    // init model
    ConstructionTableCellRenderer renderer;
    HeaderRenderer headerRend = new HeaderRenderer();
    tableColumns = new TableColumn[data.columns.length];

    for (int k = 0; k < data.columns.length; k++) {
      renderer = new ConstructionTableCellRenderer();
      renderer.setHorizontalAlignment(data.columns[k].getAlignment());
      tableColumns[k] = new TableColumn(k, data.columns[k].getPreferredWidth(), renderer, null);
      tableColumns[k].setMinWidth(data.columns[k].getMinWidth());
      tableColumns[k].setHeaderRenderer(headerRend);
      if (data.columns[k].getInitShow()) table.addColumn(tableColumns[k]);
      if (data.columns[k].getTitle() == "Caption") {
        tableColumns[k].setCellEditor(new ConstructionTableCellEditor());
      }
    }
    // first column "No." should have fixed width
    tableColumns[0].setMaxWidth(tableColumns[0].getMinWidth());

    table
        .getColumnModel()
        .addColumnModelListener(((ConstructionTableData) data).new ColumnMovementListener());

    scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setBackground(Color.white);
    // cpPanel.add(scrollPane, BorderLayout.CENTER);

    // clicking
    ConstructionMouseListener ml = new ConstructionMouseListener();
    table.addMouseListener(ml);
    table.addMouseMotionListener(ml);
    header.addMouseListener(ml); // double clicking, right-click menu
    scrollPane.addMouseListener(ml); // right-click menu

    // keys
    ConstructionKeyListener keyListener = new ConstructionKeyListener();
    table.addKeyListener(keyListener);

    app.getGuiManager().registerConstructionProtocolView(this);

    // navigation bar
    // protNavBar = new ConstructionProtocolNavigationD(app);
    // protNavBar.register(this);
    // protNavBar.setPlayButtonVisible(false);
    // protNavBar.setConsProtButtonVisible(false);
    // this.cpPanel.add(protNavBar.getImpl(), BorderLayout.SOUTH);
    // org.geogebra.desktop.util.Util.addKeyListenerToAll(protNavBar.getImpl(),
    // keyListener);

    initGUI();
    initActions();

    ConstructionProtocolSettings cps = app.getSettings().getConstructionProtocol();
    settingsChanged(cps);
    cps.addListener(this);
  }
  /** Create the frame. */
  public ServiceForm() {
    this.setClosable(true);
    this.setMaximizable(true);
    this.setVisible(true);
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setResizable(true);

    setBounds(100, 100, 450, 407);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblNewLabel = new JLabel("ID");
    lblNewLabel.setBounds(10, 53, 46, 14);
    contentPane.add(lblNewLabel);

    txt_ID = new JTextField();
    txt_ID.setEditable(false);
    txt_ID.setBounds(112, 50, 86, 20);
    contentPane.add(txt_ID);
    txt_ID.setColumns(10);

    JLabel lblName = new JLabel("Name");
    lblName.setBounds(10, 97, 46, 14);
    contentPane.add(lblName);

    txt_Name = new JTextField();
    txt_Name.setBounds(112, 91, 211, 20);
    contentPane.add(txt_Name);
    txt_Name.setColumns(10);

    JLabel lblAmount = new JLabel("Amount");
    lblAmount.setBounds(10, 142, 46, 14);
    contentPane.add(lblAmount);

    txt_Amount = new JTextField();
    txt_Amount.setBounds(112, 139, 86, 20);
    contentPane.add(txt_Amount);
    txt_Amount.setColumns(10);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 184, 422, 127);
    contentPane.add(scrollPane);

    table = new JTable();
    scrollPane.setViewportView(table);
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent arg0) {
            updateField();
          }
        });
    table.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            updateField();
          }
        });

    JButton button = new JButton("New");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            txt_ID.setText("");
            txt_Name.setText("");
            txt_Amount.setText("");
          }
        });
    button.setBounds(10, 339, 89, 23);
    contentPane.add(button);

    JButton button_1 = new JButton("Add");
    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            addRecord();
            showTable();
          }
        });
    button_1.setBounds(118, 339, 89, 23);
    contentPane.add(button_1);

    JButton button_2 = new JButton("Update");
    button_2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateRecord();
            showTable();
            updateField();
          }
        });
    button_2.setBounds(234, 339, 89, 23);
    contentPane.add(button_2);

    JButton button_3 = new JButton("Delete");
    button_3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deleteRecord();
            showTable();
            updateField();
          }
        });
    button_3.setBounds(343, 339, 89, 23);
    contentPane.add(button_3);

    JLabel lblServiceManagement = new JLabel("SERVICE MANAGEMENT");
    lblServiceManagement.setFont(new Font("Tahoma", Font.BOLD, 16));
    lblServiceManagement.setBounds(120, 11, 249, 28);
    contentPane.add(lblServiceManagement);

    showTable();
    table.selectAll();
    updateField();
  }
Example #18
0
  private void init() {
    tm = new RhTableModel();
    lookUp =
        new JButton("Ver", new ImageIcon(RhTable.class.getResource("/icons/Preview_24x24.png")));
    delete =
        new JButton(
            "Eliminar", new ImageIcon(RhTable.class.getResource("/icons/Delete_24x24.png")));
    filter = new JTextField(35);
    filterLab = new JLabel("Filtrar: ");
    filterBackUp = null;

    table = new JTable(tm);
    table.setFont(TABLE_FONT);
    table.getTableHeader().setFont(TABLE_FONT.deriveFont(java.awt.Font.BOLD).deriveFont(12f));
    table.setAutoCreateRowSorter(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    filter.setBackground(Color.LIGHT_GRAY);
    filter.setHorizontalAlignment(JTextField.CENTER);
    filter.setFont(TABLE_FONT);
    filterLab.setFont(TABLE_FONT.deriveFont(Font.BOLD));

    lookUp.setFont(TABLE_FONT);
    delete.setFont(TABLE_FONT);

    // removing ENTER behavior
    table
        .getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent arg0) {}
            });

    table.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            if (e.getClickCount() > 1) {
              lookUpSelected();
            }
          }
        });

    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);

            switch (e.getKeyCode()) {
              case KeyEvent.VK_DELETE:
                removeSelected();
                break;
              case KeyEvent.VK_ENTER:
                lookUpSelected();
                break;
              case KeyEvent.VK_F5:
                filter.setText("");
                updateTableData();
                break;
              case KeyEvent.VK_P:
                if (e.getModifiers() == KeyEvent.CTRL_MASK) openPrintableView();
                break;
              case KeyEvent.VK_F:
                if (e.getModifiers() == KeyEvent.CTRL_MASK) {
                  filter.getParent().setVisible(true);
                  filter.requestFocus();
                }
                break;

              default:
            }
          }
        });

    lookUp.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            lookUpSelected();
          }
        });

    delete.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            removeSelected();
          }
        });

    filter.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);

            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
              filter.getParent().setVisible(false);
              filter.setText("");
            }

            if (filterBackUp != null) {
              applyFilter();
            }
          }
        });

    setLayout(new BorderLayout());

    add(Util.packInJP(new FlowLayout(FlowLayout.RIGHT), filterLab, filter), BorderLayout.NORTH);
    add(new JScrollPane(table));
    add(Util.packInJP(new FlowLayout(FlowLayout.RIGHT), lookUp, delete), BorderLayout.SOUTH);

    filter.getParent().setVisible(false);
  }
  @SuppressWarnings("unchecked")
  private void initComponents() {

    ruletypePanel = new JScrollPane();
    ruletypeTable = new JTable();
    violationtypePanel = new JScrollPane();
    violationtypeTable = new JTable();
    applyViolationTypes = new JButton();

    ruletypeTable.setModel(ruletypeModel);
    ruletypeTable.setFillsViewportHeight(true);
    ruletypeTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked() {
            ruletypeTableMouseClicked();
          }
        });
    ruletypeTable.addKeyListener(
        new KeyAdapter() {
          public void keyPressed() {
            ruletypeTableKeyPressed();
          }
        });
    ruletypePanel.setViewportView(ruletypeTable);

    violationtypeTable.setModel(violationtypeModel);
    violationtypeTable.setFillsViewportHeight(true);
    violationtypeTable.getTableHeader().setReorderingAllowed(false);
    violationtypePanel.setViewportView(violationtypeTable);

    applyViolationTypes.setText("Apply");
    applyViolationTypes.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            applyViolationTypesActionPerformed();
          }
        });

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        ruletypePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        violationtypePanel,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        249,
                        Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(applyViolationTypes)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                violationtypePanel,
                javax.swing.GroupLayout.Alignment.TRAILING,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                371,
                Short.MAX_VALUE)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout
                    .createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(applyViolationTypes)
                    .addContainerGap())
            .addComponent(
                ruletypePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE));
  }
Example #20
0
  protected void createGUI() {
    setTitle(app.getPlain("Substitute") + " - " + app.getCommand("Row") + " " + (editRow + 1));
    setResizable(true);

    GeoCasCell cell = casView.getConsoleTable().getGeoCasCell(editRow);

    HashSet<GeoElement> vars = cell.getInputVE().getVariables();
    Vector<String> row;
    if (vars != null) {
      data = new Vector<Vector<String>>(vars.size() + 1);
      Iterator<GeoElement> iter = vars.iterator();
      while (iter.hasNext()) {
        row = new Vector<String>(2);
        GeoElement var = iter.next();
        String nextVar = var.getLabel();
        int i = 0;
        for (i = 0; i < data.size(); i++) {
          if (data.get(i).firstElement().compareTo(nextVar) >= 0) {
            break;
          }
        }
        if (i == data.size() || !data.get(i).firstElement().equals(nextVar)) {
          row.add(nextVar);
          row.add("");
          data.insertElementAt(row, i);
        }
      }
    } else {
      data = new Vector<Vector<String>>(1);
    }
    row = new Vector<String>(2);
    row.add("");
    row.add("");
    data.add(row);

    Vector<String> header = new Vector<String>();
    header.add(app.getPlain("OldExpression"));
    header.add(app.getPlain("NewExpression"));
    replaceTable = new JTable(data, header);
    replaceTable.setDefaultEditor(Object.class, new MathTextCellEditor());
    replaceTable.getTableHeader().setReorderingAllowed(false);
    double fontFactor = Math.max(1, app.getGUIFontSize() / DEFAULT_FONT_SIZE);
    replaceTable.setRowHeight((int) (DEFAULT_TABLE_CELL_HEIGHT * fontFactor));

    replaceTable.setPreferredScrollableViewportSize(
        new Dimension(
            (int) (DEFAULT_TABLE_WIDTH * fontFactor), (int) (DEFAULT_TABLE_HEIGHT * fontFactor)));
    scrollPane = new JScrollPane(replaceTable);

    captionPanel = new JPanel(new BorderLayout(5, 0));

    captionPanel.add(scrollPane, BorderLayout.CENTER);

    replaceTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    replaceTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              public void valueChanged(ListSelectionEvent e) {
                addRow(false);
              }
            });

    replaceTable.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && e.getKeyChar() != '\t') addRow(true);
          }
        });

    // buttons
    btEval = new JButton("=");
    btEval.setToolTipText(app.getCommandTooltip("Evaluate"));
    btEval.setActionCommand("Evaluate");
    btEval.addActionListener(this);

    btNumeric = new JButton("\u2248");
    btNumeric.setToolTipText(app.getCommandTooltip("Numeric"));
    btNumeric.setActionCommand("Numeric");
    btNumeric.addActionListener(this);

    btSub = new JButton(app.getPlain("\u2713"));
    btSub.setToolTipText(app.getCommandTooltip("Substitute"));
    btSub.setActionCommand("Substitute");
    btSub.addActionListener(this);

    btPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

    btPanel.add(btEval);
    btPanel.add(btNumeric);
    btPanel.add(btSub);

    // Create the JOptionPane.
    optionPane = new JPanel(new BorderLayout(5, 5));

    // create object list
    optionPane.add(captionPanel, BorderLayout.CENTER);

    optionPane.add(btPanel, BorderLayout.SOUTH);
    optionPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // Make this dialog display it.
    setContentPane(optionPane);
  }
Example #21
0
  private void init() throws Exception {
    model = new MatchTableModel();
    cbox = new JraComboBox();
    cbox.setRenderer(
        new BasicComboBoxRenderer() {
          public Component getListCellRendererComponent(
              JList l, Object val, int idx, boolean sel, boolean foc) {
            if (sel && idx >= 0 && val instanceof MatchableCollection)
              l.setToolTipText(((MatchableCollection) val).getToolTipText());
            return super.getListCellRendererComponent(l, val, idx, sel, foc);
          }
        });
    table =
        new JTable(model) {
          public void paintChildren(Graphics g) {
            super.paintChildren(g);
            paintSections(g);
          }

          public void changeSelection(int row, int col, boolean toggle, boolean extend) {
            int scrow = row;
            int oldrow = getSelectedRow();
            int oldcol = getSelectedColumn();
            int maxrow = model.getRowCount() - 2;
            if (model.isRowHeader(row) && (toggle || extend)) return;
            if (oldrow != -1 && model.isRowHeader(row)) {
              if (oldrow < row) while (row < maxrow && model.isRowHeader(++row)) ;
              else while (row > 0 && model.isRowHeader(--row)) ;
              if (model.isRowHeader(row))
                if (oldrow < row) while (row > 0 && model.isRowHeader(--row)) ;
                else while (row < maxrow && model.isRowHeader(++row)) ;
              if (model.isRowHeader(row)) row = oldrow;
            }
            if (scrow < 2) scrow = 0;
            else if (scrow <= maxrow) scrow = row;
            getSelectionModel().setSelectionInterval(row, row);
            //        super.changeSelection(row, col, false, false);
            if (oldrow < 0) oldrow = row;
            if ((toggle || extend) && (col == oldcol || row != oldrow)) {
              if (!extend) selectOrToggle(row, true);
              else {
                int beg = (oldrow > row ? row : oldrow), end = oldrow + row - beg;
                if (beg == end && extend) return;
                for (int i = beg; i <= end; i++) selectOrToggle(i, toggle);
              }
              repaint();
            }
            if (getAutoscrolls()) {
              Rectangle cellRect = getCellRect(scrow, 0, true);
              if (cellRect != null) scrollRectToVisible(cellRect);
            }
          }

          private void selectOrToggle(int row, boolean toggle) {
            if (toggle) model.toggleRowSelected(row);
            else model.setRowSelected(row, true);
          }
        };
    table.setColumnSelectionAllowed(false);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    for (int i = 0; i < model.m_columns.length; i++)
      table.getColumnModel().getColumn(i).setPreferredWidth(model.m_columns[i].m_width);
    table
        .getColumnModel()
        .getColumn(1)
        .setCellEditor(
            new DefaultCellEditor(cbox) {
              public Component getTableCellEditorComponent(
                  JTable t, Object v, boolean sel, int row, int col) {
                cbox.setModel(new DefaultComboBoxModel(model.getMatchOptions(row)));
                cbox.setToolTipText(
                    v instanceof MatchableCollection
                        ? ((MatchableCollection) v).getToolTipText()
                        : null);
                return super.getTableCellEditorComponent(t, v, sel, row, col);
              }
            });
    table.setDefaultRenderer(
        Object.class,
        new DefaultTableCellRenderer() {
          private javax.swing.border.Border emptyBorder =
              BorderFactory.createEmptyBorder(0, 2, 0, 2);
          private Color m = null;
          private Color g = Color.green.darker().darker().darker();

          private Color halfTone(Color cFrom, Color cTo, float factor) {
            return new Color(
                (int) (cFrom.getRed() * (1 - factor) + cTo.getRed() * factor),
                (int) (cFrom.getGreen() * (1 - factor) + cTo.getGreen() * factor),
                (int) (cFrom.getBlue() * (1 - factor) + cTo.getBlue() * factor));
          }

          public Component getTableCellRendererComponent(
              JTable t, Object v, boolean sel, boolean foc, int row, int col) {
            super.getTableCellRendererComponent(t, v, sel, false, row, col);
            setOpaque(true);
            setBorder(emptyBorder);
            if (model.isRowSelected(row)) {
              if (m == null) m = halfTone(Color.yellow, t.getBackground(), 0.75f);
              super.setBackground(sel ? g : m);
            } else super.setBackground(sel ? t.getSelectionBackground() : t.getBackground());
            int rc = t.convertColumnIndexToModel(col);
            if (rc == 2) setHorizontalAlignment(JLabel.TRAILING);
            else {
              setHorizontalAlignment(JLabel.LEADING);
              if (rc == 0 || rc == 1) setToolTipText(model.getToolTip(row, col));
            }
            return this;
          }
        });

    table.setRowHeight(21);
    table.setPreferredScrollableViewportSize(
        new Dimension(740, table.getPreferredScrollableViewportSize().height));
    /*    table.getActionMap().put("select-all", new AbstractAction() {
      if (e.getKeyCode() == e.VK_A && e.getModifiers() == e.CTRL_MASK) {
        for (int i = 0; i < model.getRowCount(); i++)
          model.toggleRowSelected(i);
        table.repaint();
        e.consume();
      }
    });*/

    table
        .getActionMap()
        .put(
            "selectAll",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (table.isEditing()) table.removeEditor();
                for (int i = 0; i < model.getRowCount(); i++) model.toggleRowSelected(i);
                table.repaint();
              }
            });
    table.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == e.VK_ENTER && table.getSelectedRow() >= 0) {
              model.toggleRowSelected(table.getSelectedRow());
              table.repaint();
            }
          }
        });

    contents = new JPanel(new BorderLayout());
    okp =
        new OKpanel() {
          public void jBOK_actionPerformed() {
            OKPress();
          }

          public void jPrekid_actionPerformed() {
            CancelPress();
          }
        };
    JPanel pd = new JPanel(null);
    pd.setLayout(new BoxLayout(pd, BoxLayout.X_AXIS));

    JButton all = new JraButton();
    all.setText("Oznaèi sve");
    all.setIcon(raImages.getImageIcon(raImages.IMGALIGNJUSTIFY));
    all.setPreferredSize(new Dimension(120, 25));
    all.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < model.getRowCount(); i++) model.setRowSelected(i, true);
            table.repaint();
          }
        });
    okp.add(all, BorderLayout.WEST);

    contents.add(new JraScrollPane(table));
    contents.add(okp, BorderLayout.SOUTH);
    okp.registerOKPanelKeys(table);
  }
Example #22
0
  @Override
  public void downloadBatch(DownloadBatch_Result result) {
    table = new JTable();

    tableModel = new TableModel(bState, result);

    table.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            cells = bState.cells;

            JTable target = (JTable) e.getSource();
            int row = target.getSelectedRow();
            int column = target.getSelectedColumn() - 1;
            for (ArrayList<Cell> cellRow : cells) {
              for (Cell cell : cellRow) {
                if (cell.record == row && cell.field == column) {
                  bState.setSelectedCell(cell);
                }
              }
            }
          }
        });
    table.addKeyListener(
        new KeyListener() {

          @Override
          public void keyTyped(KeyEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void keyReleased(KeyEvent e) {
            JTable target = (JTable) e.getSource();
            int row = target.getSelectedRow();
            int column = target.getSelectedColumn() - 1;
            if (e.getKeyCode() == KeyEvent.VK_TAB) {
              for (ArrayList<Cell> cellRow : cells) {
                for (Cell cell : cellRow) {
                  if (cell.record == row && cell.field == column) {
                    bState.setSelectedCell(cell);
                  }
                }
              }
            }
          }
        });
    table.setModel(tableModel);
    table.setRowHeight(20);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setCellSelectionEnabled(true);
    table.getTableHeader().setReorderingAllowed(false);

    TableColumnModel columnModel = table.getColumnModel();
    for (int i = 0; i < tableModel.getColumnCount(); ++i) {
      TableColumn column = columnModel.getColumn(i);
      column.setPreferredWidth(100);
    }
    for (int i = 0; i < tableModel.getColumnCount(); ++i) {
      TableColumn column = columnModel.getColumn(i);
      column.setCellRenderer(new CellRenderer());
      //			column.setCellEditor(new CellEditor());
    }

    BoxLayout box = new BoxLayout(this, BoxLayout.Y_AXIS);
    setLayout(box);
    add(table.getTableHeader());
    add(table);

    revalidate();
  }
Example #23
0
  public ContentView(final ContentPane control) {
    super(new GridLayout(1, 1));
    this.control = control;

    data = new JTable();
    data.setModel(model = new ContentModel(getControl().getQueryModel() == null));
    data.addMouseListener(popup = new ContentPopup(this));
    data.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent key) {
            if (key.getKeyCode() == KeyEvent.VK_DOWN || key.getKeyCode() == KeyEvent.VK_PAGE_DOWN) {
              if ((ContentView.this.data.getSelectedRow()
                      == ContentView.this.data.getRowCount() - 1)
                  && !control.areAllRowsFetched()) {
                int col = ContentView.this.data.getSelectedColumn();
                int row = ContentView.this.data.getRowCount() - 1;
                ContentView.this.data.scrollRectToVisible(
                    ContentView.this.data.getCellRect(row, col, true));
                ContentView.this.data.setRowSelectionInterval(row + 1, row + 1);
                ContentView.this.data.scrollRectToVisible(
                    ContentView.this.data.getCellRect(row + 1, col, true));
                key.consume();
              }
            }
          }
        });

    JScrollPane scroll = new JScrollPane(data);
    scroll.getViewport().setBackground(UIManager.getDefaults().getColor("Table.background"));
    add(scroll);
    jsb = scroll.getVerticalScrollBar();
    jsb.addAdjustmentListener(new ListenerScrollBar());

    data.setRowSelectionAllowed(false);
    data.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    data.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    data.setDefaultRenderer(Object.class, new InternalCellRenderer());
    data.getTableHeader().addMouseListener(popup);
    data.getTableHeader().setReorderingAllowed(false);

    lines = new LineNumberView();
    lines.addMouseListener(popup);
    lines.setSelectionModel(data.getSelectionModel());
    scroll.setRowHeaderView(lines);

    JLabel cUL = new JLabel("#", JLabel.CENTER);
    cUL.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    cUL.setFont(UIManager.getFont("TableHeader.font"));
    scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, cUL);

    JLabel cLL = new JLabel();
    cLL.setBorder(new CustomLineBorder(true, false, false, false));
    scroll.setCorner(JScrollPane.LOWER_LEFT_CORNER, cLL);

    data.getColumnModel().getSelectionModel().addListSelectionListener(this);

    data.getActionMap().put("copy", ((JMenuItem) popup.getSubElementsAt(1)).getAction());
    data.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), "copy");

    data.getActionMap().put("paste", ((JMenuItem) popup.getSubElementsAt(2)).getAction());
    data.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK), "paste");

    data.getActionMap().put("set-null", ((JMenuItem) popup.getSubElementsAt(3)).getAction());
    data.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "set-null");

    MouseAdapter ma =
        new MouseAdapter() {
          public void mousePressed(MouseEvent me) {
            ContentView.this.data.setColumnSelectionAllowed(
                me.getSource() == ContentView.this.data.getTableHeader());
            ContentView.this.data.setRowSelectionAllowed(me.getSource() == ContentView.this.lines);
          }
        };

    data.getTableHeader().addMouseListener(ma);
    data.addMouseListener(ma);
    lines.addMouseListener(ma);
  }
Example #24
0
  public void startupMapHook() {
    super.startupMapHook();

    mMyMindMapController = super.getMindMapController();
    getMindMapController().getController().getMapModuleManager().addListener(this);

    // get strings from resources:
    COLUMN_MODIFIED = getResourceString("plugins/TimeList.xml_Modified");
    COLUMN_CREATED = getResourceString("plugins/TimeList.xml_Created");
    COLUMN_ICONS = getResourceString("plugins/TimeList.xml_Icons");
    COLUMN_TEXT = getResourceString("plugins/TimeList.xml_Text");
    COLUMN_DATE = getResourceString("plugins/TimeList.xml_Date");
    COLUMN_NOTES = getResourceString("plugins/TimeList.xml_Notes");

    showAllNodes = Tools.xmlToBoolean(getResourceString("show_all_nodes"));
    dialog = new JDialog(getController().getFrame().getJFrame(), false /* unmodal */);
    String windowTitle;
    if (showAllNodes) {
      windowTitle = "plugins/TimeManagement.xml_WindowTitle_All_Nodes";
    } else {
      windowTitle = "plugins/TimeManagement.xml_WindowTitle";
    }
    dialog.setTitle(getResourceString(windowTitle));
    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent event) {
            disposeDialog();
          }
        });
    Tools.addEscapeActionToDialog(
        dialog,
        new AbstractAction() {
          public void actionPerformed(ActionEvent arg0) {
            disposeDialog();
          }
        });
    Container contentPane = dialog.getContentPane();
    GridBagLayout gbl = new GridBagLayout();
    gbl.columnWeights = new double[] {1.0f};
    gbl.rowWeights = new double[] {1.0f};
    contentPane.setLayout(gbl);
    contentPane.add(
        new JLabel(getResourceString("plugins/TimeManagement.xml_Find")),
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mFilterTextSearchField = new JTextField();
    mFilterTextSearchField.getDocument().addDocumentListener(new FilterTextDocumentListener());
    mFilterTextSearchField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent pEvent) {
            // logger.info("Key event:" + pEvent.getKeyCode());
            if (pEvent.getKeyCode() == KeyEvent.VK_DOWN) {
              logger.info("Set Focus to replace fields");
              mFilterTextReplaceField.requestFocusInWindow();
            }
          }
        });
    contentPane.add(
        /* new JScrollPane */ (mFilterTextSearchField),
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    contentPane.add(
        new JLabel(getResourceString("plugins/TimeManagement.xml_Replace")),
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mFilterTextReplaceField = new JTextField();
    contentPane.add(
        /* new JScrollPane */ (mFilterTextReplaceField),
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mFilterTextReplaceField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent pEvent) {
            if (pEvent.getKeyCode() == KeyEvent.VK_DOWN) {
              logger.info("Set Focus to table");
              timeTable.requestFocusInWindow();
            } else if (pEvent.getKeyCode() == KeyEvent.VK_UP) {
              logger.info("Set Focus to table");
              mFilterTextSearchField.requestFocusInWindow();
            }
          }
        });
    dateRenderer = new DateRenderer();
    nodeRenderer = new NodeRenderer();
    notesRenderer = new NotesRenderer();
    iconsRenderer = new IconsRenderer(getController());
    timeTable = new FlatNodeTable();
    timeTable.addKeyListener(new FlatNodeTableKeyListener());
    // double click = goto.
    timeTable.addMouseListener(new FlatNodeTableMouseAdapter());
    // disable moving:
    timeTable.getTableHeader().setReorderingAllowed(false);
    updateModel();

    sorter.setTableHeader(timeTable.getTableHeader());
    sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMAPRATOR);
    sorter.setColumnComparator(NodeHolder.class, TableSorter.LEXICAL_COMPARATOR);
    sorter.setColumnComparator(NotesHolder.class, TableSorter.LEXICAL_COMPARATOR);
    sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMAPRATOR);
    // Sort by default by date.
    sorter.setSortingStatus(DATE_COLUMN, TableSorter.ASCENDING);
    JScrollPane pane = new JScrollPane(timeTable);
    contentPane.add(
        pane,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            1.0,
            10.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    mTreeLabel = new JLabel();
    contentPane.add(
        new JScrollPane(mTreeLabel),
        new GridBagConstraints(
            0,
            5,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    // button bar
    AbstractAction selectAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Select")) {
          public void actionPerformed(ActionEvent arg0) {
            selectSelectedRows();
          }
        };
    AbstractAction exportAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Export")) {
          public void actionPerformed(ActionEvent arg0) {
            exportSelectedRowsAndClose();
          }
        };
    AbstractAction replaceAllAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Replace_All")) {
          public void actionPerformed(ActionEvent arg0) {
            replace(new ReplaceAllInfo());
          }
        };
    AbstractAction replaceSelectedAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Replace_Selected")) {
          public void actionPerformed(ActionEvent arg0) {
            replace(new ReplaceSelectedInfo());
          }
        };
    AbstractAction gotoAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Goto")) {
          public void actionPerformed(ActionEvent arg0) {
            selectSelectedRows();
            disposeDialog();
          }
        };
    AbstractAction disposeAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Cancel")) {
          public void actionPerformed(ActionEvent arg0) {
            disposeDialog();
          }
        };

    AbstractAction toggleViewFoldedNodesAction =
        new ToggleViewFoldedNodesAction(
            getResourceString("plugins/TimeManagement.xml_ToggleViewFoldedNodesAction"));

    /** Menu * */
    StructuredMenuHolder menuHolder = new StructuredMenuHolder();
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu(getResourceString("plugins/TimeManagement.xml_menu_actions"));
    menuHolder.addMenu(menu, "main/actions/.");
    final JMenuItem selectMenuItem =
        addAccelerator(
            menuHolder.addAction(selectAction, "main/actions/select"),
            "keystroke_plugins/TimeList_select");
    final JMenuItem gotoMenuItem =
        addAccelerator(
            menuHolder.addAction(gotoAction, "main/actions/goto"),
            "keystroke_plugins/TimeList_goto");
    final JMenuItem replaceSelectedMenuItem =
        addAccelerator(
            menuHolder.addAction(replaceSelectedAction, "main/actions/replaceSelected"),
            "keystroke_plugins/TimeList_replaceSelected");
    final JMenuItem replaceAllMenuItem =
        addAccelerator(
            menuHolder.addAction(replaceAllAction, "main/actions/replaceAll"),
            "keystroke_plugins/TimeList_replaceAll");

    final JMenuItem exportMenuItem =
        addAccelerator(
            menuHolder.addAction(exportAction, "main/actions/export"),
            "keystroke_plugins/TimeList_export");
    addAccelerator(
        menuHolder.addAction(disposeAction, "main/actions/dispose"),
        "keystroke_plugins/TimeList_dispose");
    JMenu viewMenu = new JMenu(getResourceString("plugins/TimeManagement.xml_menu_view"));
    menuHolder.addMenu(viewMenu, "main/view/.");
    addAccelerator(
        menuHolder.addAction(toggleViewFoldedNodesAction, "main/view/showFoldedNodes"),
        "keystroke_plugins/TimeList_showFoldedNodes");
    menuHolder.updateMenus(menuBar, "main/");
    dialog.setJMenuBar(menuBar);

    /* Initial State */
    selectMenuItem.setEnabled(false);
    gotoMenuItem.setEnabled(false);
    exportMenuItem.setEnabled(false);
    replaceSelectedMenuItem.setEnabled(false);

    // table selection listeners to enable/disable menu actions:
    ListSelectionModel rowSM = timeTable.getSelectionModel();
    rowSM.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            // Ignore extra messages.
            if (e.getValueIsAdjusting()) return;

            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            boolean enable = !(lsm.isSelectionEmpty());
            replaceSelectedMenuItem.setEnabled(enable);
            selectMenuItem.setEnabled(enable);
            gotoMenuItem.setEnabled(enable);
            exportMenuItem.setEnabled(enable);
          }
        });
    // table selection listener to display the history of the selected nodes
    rowSM.addListSelectionListener(
        new ListSelectionListener() {
          String getNodeText(MindMapNode node) {
            return Tools.getNodeTextHierarchy(node, getMindMapController());
          }

          public void valueChanged(ListSelectionEvent e) {
            // Ignore extra messages.
            if (e.getValueIsAdjusting()) return;

            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            if (lsm.isSelectionEmpty()) {
              mTreeLabel.setText("");
              return;
            }
            int selectedRow = lsm.getLeadSelectionIndex();
            MindMapNode mindMapNode = getMindMapNode(selectedRow);
            mTreeLabel.setText(getNodeText(mindMapNode));
          }
        });

    // restore preferences:
    // Retrieve window size and column positions.
    WindowConfigurationStorage storage =
        getMindMapController().decorateDialog(dialog, WINDOW_PREFERENCE_STORAGE_PROPERTY);
    if (storage != null) {
      setTableConfiguration(storage);
    }
    dialog.setVisible(true);
  }
Example #25
0
  public static void setPopup(
      final JTextField tf,
      Object[][] obj,
      final JLabel[] labels,
      final int[] tbl_widths_customers,
      String[] col_names) {

    final JPopupMenu popup = new JPopupMenu();
    Dimension d = tf.getSize();
    popup.setLayout(new BorderLayout());

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.setBackground(Color.white);
    JScrollPane pl = new JScrollPane();
    final JTable tbl = new JTable();
    pl.setBorder(null);
    TableRenderer.setModel(tbl, obj, col_names, tbl_widths_customers);
    tbl.getTableHeader().setPreferredSize(new Dimension(0, 0));
    tbl.setBorder(null);
    tbl.setGridColor(new java.awt.Color(204, 204, 204));
    pl.setViewportView(tbl);
    p.add(pl);
    popup.add(p);
    popup.setPopupSize(d.width, 150);
    popup.show(tf, 0, tf.getHeight());
    tf.grabFocus();
    tf.addKeyListener(
        new KeyAdapter() {

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN) {
              if (tbl.getRowCount() != 0) {
                tbl.setRowSelectionInterval(0, 0);
                tbl.grabFocus();
              }
            }
          }
        });
    tbl.addKeyListener(
        new KeyAdapter() {

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_LEFT) {
              int row = tbl.getSelectedRow();
              tbl.removeRowSelectionInterval(row, row);
              tf.grabFocus();
            }
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              int row = tbl.getSelectedRow();
              int i = 0;
              for (JLabel lbl : labels) {
                lbl.setText(tbl.getModel().getValueAt(row, i).toString());
                i++;
              }
              String[] output = new String[tbl_widths_customers.length];
              int u = 0;
              for (int y : tbl_widths_customers) {
                output[u] = tbl.getModel().getValueAt(row, u).toString();
                u++;
              }
              tf.grabFocus();
              popup.setVisible(false);
              ok1(output, row);
            }
          }
        });
    tbl.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            int row = tbl.getSelectedRow();
            String[] output = new String[tbl_widths_customers.length];
            int u = 0;
            for (int y : tbl_widths_customers) {
              output[u] = tbl.getModel().getValueAt(row, u).toString();
              u++;
            }
            tf.grabFocus();
            popup.setVisible(false);
            ok1(output, row);
          }
        });
  }
Example #26
0
  /** Create the dialog. */
  public TaEditor(X10flash flash, Vector<TaEntry> v) {
    _flash = flash;
    setModalityType(ModalityType.APPLICATION_MODAL);
    setTitle("TA Editor");
    setBounds(100, 100, 715, 450);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.RELATED_GAP_COLSPEC,
              ColumnSpec.decode("max(63dlu;min)"),
              FormFactory.RELATED_GAP_COLSPEC,
              ColumnSpec.decode("default:grow"),
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
            },
            new RowSpec[] {
              FormFactory.RELATED_GAP_ROWSPEC,
              FormFactory.DEFAULT_ROWSPEC,
              FormFactory.RELATED_GAP_ROWSPEC,
              RowSpec.decode("default:grow"),
              FormFactory.RELATED_GAP_ROWSPEC,
              FormFactory.DEFAULT_ROWSPEC,
              FormFactory.RELATED_GAP_ROWSPEC,
              RowSpec.decode("default:grow"),
            }));
    {
      JScrollPane scrollPane = new JScrollPane();
      contentPanel.add(scrollPane, "2, 2, 1, 7, fill, fill");
      {
        tablePartition =
            new JTable() {
              /** */
              private static final long serialVersionUID = 1L;

              public boolean isCellEditable(int rowIndex, int vColIndex) {
                return false;
              }
            };
        tablePartition.addKeyListener(
            new KeyAdapter() {
              @Override
              public void keyReleased(KeyEvent arg0) {
                reloadUnit();
              }
            });
        tablePartition.addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseReleased(MouseEvent arg0) {
                String result =
                    (String) modelPartition.getValueAt(tablePartition.getSelectedRow(), 0);
                try {
                  if (ta != null) ta.setData(hex.getByteContent());
                  ta = (TaEntry) content.get(result);
                  hex.setByteContent(ta.getDataString().getBytes());
                } catch (Exception e) {
                }
              }
            });
        JMenuItem mntmResize = new JMenuItem("Resize Unit");
        mntmResize.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                TAUnitResizeGUI resize = new TAUnitResizeGUI();
                String newsize = resize.getUnitSize();
                if (newsize.length() > 0) {
                  ta.resize(Integer.parseInt(newsize));
                  hex.setByteContent(ta.getDataString().getBytes());
                }
              }
            });
        popupMenu.add(mntmResize);
        JMenuItem mntmLoad = new JMenuItem("Load from file");
        mntmLoad.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                TaSelectGUI tasel =
                    new TaSelectGUI(
                        ".bin",
                        _flash.getPhoneProperty("MSN")
                            + "_"
                            + (String)
                                modelPartition.getValueAt(tablePartition.getSelectedRow(), 0));
                String result = tasel.getTa();
                if (result.length() > 0) {
                  String path = OS.getWorkDir() + "/custom/ta/" + result;
                  try {
                    byte[] array = BytesUtil.getBytesFromFile(new File(path));
                    ta.setData(array);
                    hex.setByteContent(array);
                  } catch (Exception e) {
                    MyLogger.getLogger().error(e.getMessage());
                  }
                }
              }
            });
        popupMenu.add(mntmLoad);
        JMenuItem mntmWriteFile = new JMenuItem("Write to file");
        mntmWriteFile.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                String rootpath = OS.getWorkDir() + "/custom/ta/";
                String path =
                    _flash.getPhoneProperty("MSN")
                        + "_"
                        + (String) modelPartition.getValueAt(tablePartition.getSelectedRow(), 0)
                        + "-"
                        + org.logger.TextAreaAppender.timestamp
                        + ".bin";
                File f = new File(rootpath + path);
                try {
                  FileOutputStream fos = new FileOutputStream(f);
                  fos.write(hex.getByteContent());
                  fos.flush();
                  fos.close();
                  JOptionPane.showMessageDialog(null, "Unit saved to \n" + path);
                } catch (Exception e) {
                }
              }
            });
        popupMenu.add(mntmWriteFile);
        JMenuItem mntmWrite = new JMenuItem("Write to phone");
        mntmWrite.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                reloadUnit();
                try {
                  _flash.sendTAUnit(ta);
                } catch (Exception e) {
                  MyLogger.getLogger().error(e.getMessage());
                }
              }
            });
        popupMenu.add(mntmWrite);
        MouseListener popupListener = new PopupListener();
        tablePartition.addMouseListener(popupListener);
        tablePartition.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        scrollPane.setViewportView(tablePartition);
      }
    }
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton cancelButton = new JButton("Close");
        cancelButton.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                dispose();
              }
            });
        cancelButton.setActionCommand("Cancel");
        buttonPane.add(cancelButton);
      }
    }
    contentPanel.add(hex, "4, 2, 1, 7");
    hex.setColorBorderBackGround(Color.LIGHT_GRAY);
    {
      JMenuBar menuBar = new JMenuBar();
      setJMenuBar(menuBar);
      {
        JMenu mnFile = new JMenu("File");
        menuBar.add(mnFile);
        {
          JMenuItem mntmLoad_1 = new JMenuItem("Load");
          mntmLoad_1.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                  TaSelectGUI tasel = new TaSelectGUI(".ta", _flash.getPhoneProperty("MSN"));
                  String result = tasel.getTa();
                  if (result.length() > 0) {
                    String tafile = OS.getWorkDir() + "/custom/ta/" + result;
                    try {
                      TaFile ta = new TaFile(new FileInputStream(new File(tafile)));
                      Vector<TaEntry> entries = ta.entries();
                      fill(entries);
                    } catch (Exception e1) {
                    }
                  }
                }
              });
          mnFile.add(mntmLoad_1);
        }
        {
          JMenuItem mntmSave = new JMenuItem("Save");
          mntmSave.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                  try {
                    String rootpath = OS.getWorkDir() + "/custom/ta/";
                    String path =
                        _flash.getPhoneProperty("MSN")
                            + "-"
                            + org.logger.TextAreaAppender.timestamp
                            + ".ta";
                    TextFile tazone = new TextFile(rootpath + path, "ISO8859-1");
                    tazone.open(false);
                    Iterator i = content.values().iterator();
                    while (i.hasNext()) {
                      tazone.writeln(i.next().toString());
                    }
                    tazone.close();
                    JOptionPane.showMessageDialog(null, "TA saved to \n" + path);
                  } catch (Exception e) {
                    MyLogger.getLogger().error(e.getMessage());
                  }
                }
              });
          mnFile.add(mntmSave);
        }
      }
    }
    fill(v);
  }
  public LoadFromMemoryFrame(final MainFrame mainFrame) {
    setSize(800, 600);
    // setAlwaysOnTop(true);
    setTitle(translate("dialog.title"));

    this.mainFrame = mainFrame;

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            if (!mainFrame.isVisible()) {
              mainFrame.setVisible(true);
            }
          }
        });
    model = new DefaultListModel<>();

    resTableModel =
        new DefaultTableModel() {
          @Override
          public Class<?> getColumnClass(int columnIndex) {
            switch (columnIndex) {
              case 0:
                return Integer.class;
              case 1:
                return Integer.class;
              case 2:
                return String.class;
              case 3:
                return String.class;
            }
            return null;
          }

          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        };
    resTableModel.addColumn(translate("column.version"));
    resTableModel.addColumn(translate("column.fileSize"));
    resTableModel.addColumn(translate("column.pid"));
    resTableModel.addColumn(translate("column.processName"));
    tableRes = new JTable(resTableModel);
    TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<>(resTableModel);
    tableRes.setRowSorter(sorter);
    list = new JList<>(model);
    list.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == 10) { // Enter pressed
              selectProcess();
            }
          }
        });
    list.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
              selectProcess();
            }
          }
        });
    tableRes.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
              openSWF();
            }
          }
        });
    tableRes.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == 10) { // Enter pressed
              openSWF();
            }
          }
        });
    list.setCellRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

            JLabel label =
                (JLabel)
                    super.getListCellRendererComponent(
                        list, value, index, isSelected, cellHasFocus);

            if (value instanceof com.jpexs.process.Process) {
              if (((com.jpexs.process.Process) value).getIcon() != null) {
                label.setIcon(new ImageIcon(((com.jpexs.process.Process) value).getIcon()));
              }
            }
            if (!isSelected) {
              label.setBackground(Color.white);
            }
            return label;
          }
        });
    refreshList();
    Container cnt = getContentPane();
    cnt.setLayout(new BorderLayout());

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(new JScrollPane(list), BorderLayout.CENTER);
    JPanel leftButtonsPanel = new JPanel(new FlowLayout());
    JButton selectButton = new JButton(translate("button.select"));
    selectButton.setActionCommand(ACTION_SELECT_PROCESS);
    selectButton.addActionListener(this);
    JButton refreshButton = new JButton(translate("button.refresh"));
    refreshButton.setActionCommand(ACTION_REFRESH_PROCESS_LIST);
    refreshButton.addActionListener(this);
    leftButtonsPanel.add(selectButton);
    leftButtonsPanel.add(refreshButton);
    leftPanel.add(leftButtonsPanel, BorderLayout.SOUTH);

    JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.add(new JScrollPane(tableRes), BorderLayout.CENTER);
    JPanel rightButtonsPanel = new JPanel(new FlowLayout());
    JButton openButton = new JButton(translate("button.open"));
    openButton.setActionCommand(ACTION_OPEN_SWF);
    openButton.addActionListener(this);

    JButton saveButton = new JButton(translate("button.save"));
    saveButton.setActionCommand(ACTION_SAVE);
    saveButton.addActionListener(this);

    rightButtonsPanel.add(openButton);
    rightButtonsPanel.add(saveButton);
    rightPanel.add(rightButtonsPanel, BorderLayout.SOUTH);

    JPanel statePanel = new JPanel();
    statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));

    stateLabel = new JLabel(translate("noprocess"));
    statePanel.add(stateLabel);
    progress = new JProgressBar(0, 100);
    statePanel.add(progress);
    progress.setVisible(false);
    rightPanel.add(statePanel, BorderLayout.NORTH);

    cnt.add(
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel), BorderLayout.CENTER);
    View.setWindowIcon(this);
    View.centerScreen(this);
    List<Image> images = new ArrayList<>();
    images.add(View.loadImage("loadmemory16"));
    images.add(View.loadImage("loadmemory32"));
    setIconImages(images);
  }