コード例 #1
0
  // Initializes this component.
  private void jbInit() {
    segmentTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            segmentTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            segmentTable_focusLost(e);
          }
        });
    segmentTable.setTableHeader(null);
    scrollPane = new JScrollPane(segmentTable);
    scrollPane.setMinimumSize(new Dimension(getTableWidth(), 0));

    setLayout(new BorderLayout(0, 0));

    determineColumnWidth();
    nameLbl.setPreferredSize(new Dimension(getTableWidth(), 25));
    nameLbl.setMinimumSize(new Dimension(getTableWidth(), 0));
    nameLbl.setFont(Utilities.labelsFont);

    segmentTable.setFont(Utilities.valueFont);
    setBorder(BorderFactory.createEtchedBorder());

    setMinimumSize(new Dimension(getTableWidth(), 0));

    this.add(nameLbl, BorderLayout.NORTH);
    this.add(scrollPane, BorderLayout.CENTER);
  }
コード例 #2
0
 public void setTableHeader(JTableHeader tableHeader) {
   super.setTableHeader(tableHeader);
   if (headerPanel != null) {
     if (tableHeader == null) headerPanel.removeAll();
     else headerPanel.add(tableHeader, BorderLayout.NORTH);
   }
 }
コード例 #3
0
  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);
  }
コード例 #4
0
ファイル: config.java プロジェクト: Angelmath/SIC
  public void tablasmodelos(final JTable pane, final JPanel panel) {

    JTableHeader jtableHeader = pane.getTableHeader();

    jtableHeader.setDefaultRenderer(new HeaderCellRenderer());

    pane.setTableHeader(jtableHeader);

    jtableHeader.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent e) {

            base = (DefaultTableModel) pane.getModel();

            sortColumn = pane.getSelectedColumn();

            int size = base.getRowCount();

            row = new int[size];

            for (int i = 0; i < size; i++) {

              row[i] = i;
            }

            for (int i = 1; i < row.length; i++) {
              int j = i;
              while (j > 0 && compare(j - 1, j) > 0) {
                int temp = row[j];
                row[j] = row[j - 1];
                row[j - 1] = temp;
                j--;
              }
            }
            ArrayList cd = new ArrayList();
            for (int i = 0; i < row.length; i++) {
              cd.add(((Vector) base.getDataVector().elementAt(row[i])));
            }

            while (base.getRowCount() != 0) {
              base.removeRow(0);
            }
            for (int i = 0; i < row.length; i++) {
              base.addRow(((Vector) cd.get(i)).toArray());
            }
            pane.setModel(base);
            pane.repaint();
            panel.validate();
            panel.repaint();
            getContentPane().repaint();
          }
        });
  }
コード例 #5
0
ファイル: NodeChatTab.java プロジェクト: conicalflask/fs2
  private void setupTab() {

    // The chat area
    BorderLayout chatLayout = new BorderLayout();
    JPanel chatWrapper = new JPanel(chatLayout);

    chatLog = new JTextPane();
    chatLog.setEditable(false);
    chatLog.setDocument(new ChatDocument());
    chatLogScrollPane = new JScrollPane(chatLog);
    chatLogScrollPane.addMouseListener(this);

    chatWrapper.add(chatLogScrollPane, BorderLayout.CENTER);

    // The send message panel
    message = new JTextArea();
    message.addMouseListener(this);
    message.addKeyListener(this);
    messageScrollPane = new JScrollPane(message);
    message.setLineWrap(true);
    message.setWrapStyleWord(true);
    message.requestFocus();
    message.setDocument(new JTextFieldLimit(512));

    sendMessage = new JButton("Send", frame.getGui().getUtil().getImage("sendmessage"));
    sendMessage.addMouseListener(this);
    sendMessage.addActionListener(this);

    chatMessagePanel = new JPanel();
    chatMessagePanel.setLayout(new BoxLayout(chatMessagePanel, BoxLayout.X_AXIS));
    chatMessagePanel.add(messageScrollPane);
    chatMessagePanel.add(sendMessage);

    chatWrapper.add(chatMessagePanel, BorderLayout.PAGE_END);

    // Setup the avatars
    avatarTable = new JTable(new AvatarTableModel(indexNode));
    avatarTable.addMouseListener(this);
    avatarTable.setTableHeader(null);
    avatarTable.setDefaultRenderer(Object.class, new AvatarRenderer(frame));
    avatarTable.setRowHeight(70);
    avatarScrollPane = new JScrollPane(avatarTable);
    avatarScrollPane.setMaximumSize(new Dimension(200, -1));
    avatarScrollPane.setPreferredSize(new Dimension(200, -1));

    // Add all to parent
    BorderLayout pageLayout = new BorderLayout();

    this.setLayout(pageLayout);
    this.add(avatarScrollPane, BorderLayout.LINE_END);
    this.add(chatWrapper, BorderLayout.CENTER);

    // Set the status
    active = true;
  }
コード例 #6
0
  @Override
  public JComponent getComponent(IMraLogGroup source, double timestep) {
    table = new JTable(model);

    table.setTableHeader(null);

    model.map = LogUtils.generateStatistics(source);
    add(new JScrollPane(table), "w 100%, h 100%");

    return this;
  }
コード例 #7
0
  public TimelimitTaskController(Preferences prefsParent, TimelimitTaskDelegate tltaskDelegate) {
    super();

    this.timelimittaskview = new TimelimitTaskView();
    this.timelimittaskview.init();
    this.tltaskDelegate = tltaskDelegate;
    this.popupTimelimit = new TimelimitTasksPopupMenu(timelimittaskview);
    this.prefs = prefsParent.node(PREFS_NODE_TIMELIMITTASKS);

    this.timelimittaskview.setTimelimitTaskTableModel(newTimelimitTaskTableModel());

    final JTable tblTimelimit = timelimittaskview.getTable();
    tblTimelimit.setTableHeader(
        new ToolTipsTableHeader(
            this.timelimittaskview.getTimelimitTaskTableModel(), tblTimelimit.getColumnModel()));
    TableUtils.addMouseListenerForSortingToTableHeader(
        tblTimelimit,
        this.timelimittaskview.getTimelimitTaskTableModel(),
        new CommonRunnable() {
          @Override
          public void run() {
            timelimittaskview.getTimelimitTaskTableModel().sort();
            storeOrderBySelectedColumnToPreferences();
          }
        });

    /** todo calculate row height */
    tblTimelimit.setRowHeight(20);

    setupRenderers(tblTimelimit);
    setupColumnModelListener(tblTimelimit);
    setupActions(tblTimelimit);
    setupDataTransfer(tblTimelimit);
    setupTableModelSorting();

    KeyBinding keybinding = KeyBindingProvider.REFRESH;
    this.timelimittaskview
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(keybinding.getKeystroke(), keybinding.getKey());
    this.timelimittaskview
        .getActionMap()
        .put(
            keybinding.getKey(),
            new AbstractAction() {

              @Override
              public void actionPerformed(ActionEvent e) {
                TimelimitTaskController.this.cmdRefreshTimelimitTaskView();
              }
            });
  }
コード例 #8
0
ファイル: CallStackComponent.java プロジェクト: ybakos/Tecs-3
  // Initializing this component.
  private void jbInit() {
    callStackTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            callStackTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            callStackTable_focusLost(e);
          }
        });
    callStackTable.setTableHeader(null);
    callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer());
    scrollPane = new JScrollPane(callStackTable);
    setVisibleRows(DEFAULT_VISIBLE_ROWS);
    scrollPane.setLocation(0, 27);
    setBorder(BorderFactory.createEtchedBorder());
    // this.setLayout(null);
    this.setLayout(new GridBagLayout());
    nameLbl.setText("Call Stack");
    nameLbl.setBounds(new Rectangle(3, 4, 70, 23));
    nameLbl.setFont(Utilities.labelsFont);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 7;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.PAGE_END;
    c.gridx = 0;
    c.gridy = 2;
    this.add(scrollPane, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.gridwidth = 3;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 0, 0, 0);
    this.add(nameLbl, c);
  }
コード例 #9
0
ファイル: ListEditor.java プロジェクト: codesman/josm
  @Override
  protected final JPanel build() {
    JPanel p = new JPanel(new GridBagLayout());
    p.add(new JLabel(tr("Key: {0}", entry.getKey())), GBC.eol().insets(0, 0, 5, 0));
    ListSettingTableModel listModel = new ListSettingTableModel();
    JTable table = new JTable(listModel);
    table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    table.setTableHeader(null);

    DefaultCellEditor editor = new DefaultCellEditor(new JosmTextField());
    editor.setClickCountToStart(1);
    table.setDefaultEditor(table.getColumnClass(0), editor);

    JScrollPane pane = new JScrollPane(table);
    p.add(pane, GBC.eol().insets(5, 10, 0, 0).fill());
    return p;
  }
コード例 #10
0
  public ButtonTable(Dimension buttonSize, final JButton... buttons) {
    // setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    JTable table = new JTable();
    table.setTableHeader(null);
    // table.setFillsViewportHeight(true);
    setViewportView(table);

    table.setModel(
        new AbstractTableModel() {

          @Override
          public Object getValueAt(int rowIndex, int columnIndex) {
            return null;
          }

          @Override
          public int getRowCount() {
            return buttons.length;
          }

          @Override
          public int getColumnCount() {
            return 1;
          }

          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
          }
        });

    // set all to left align... looks better
    for (JButton button : buttons) {
      button.setHorizontalAlignment(SwingConstants.LEFT);
    }

    CustomTableItemRenderer<JButton> renderer = new CustomTableItemRenderer(buttons);
    TableColumn buttonCol = table.getColumnModel().getColumn(0);
    buttonCol.setCellEditor(renderer);
    buttonCol.setCellRenderer(renderer);
    buttonCol.setWidth(buttonSize.width);
    table.setRowHeight(buttonSize.height);
    setPreferredSize(
        new Dimension(buttonSize.width + 6, table.getRowHeight() * table.getRowCount() + 10));
  }
コード例 #11
0
ファイル: LifePanel.java プロジェクト: ut5/telemediclab.life
  private void confLifeTable() {
    lifeModel =
        new DefaultTableModel(ROW_COUNT, COL_COUNT) {

          @Override
          public Class<?> getColumnClass(int columnIndex) {
            return LifeCell.class;
          }
        };
    clearModel();
    lifeTable.setModel(lifeModel);
    lifeTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    lifeTable.setDefaultRenderer(LifeCell.class, new LifeTableCellRenderer());
    lifeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lifeTable.setTableHeader(null);
    lifeTable.setRowHeight(CELL_SIZE);
    confColumnModel();
  }
コード例 #12
0
  protected void toWindow() {
    table = new JTable(model);

    if (!viewHeaders) {
      table.setTableHeader(null);
    }

    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    // table.setCellSelectionEnabled(true);
    table.setEnabled(false);

    scrollPane = new JScrollPane(table);

    /*
     * scrollPane.setPreferredSize(getSize());
     * scrollPane.setSize(getSize());
     */

    add(scrollPane, BorderLayout.CENTER);
  }
コード例 #13
0
ファイル: SecurityPanel.java プロジェクト: richardwhiuk/jitsi
  private void initComponents() {
    setLayout(new BorderLayout());
    final JPanel mainPanel = new TransparentPanel();
    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;

    // general encryption option
    enableDefaultEncryption =
        new SIPCommCheckBox(
            UtilActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"),
            regform.isDefaultEncryption());
    enableDefaultEncryption.addActionListener(this);
    mainPanel.add(enableDefaultEncryption, c);

    // warning message and button to show advanced options
    JLabel lblWarning = new JLabel();
    lblWarning.setBorder(new EmptyBorder(10, 5, 10, 0));
    lblWarning.setText(
        UtilActivator.getResources()
            .getI18NString(
                "plugin.sipaccregwizz.SECURITY_WARNING",
                new String[] {
                  UtilActivator.getResources().getSettingsString("service.gui.APPLICATION_NAME")
                }));
    c.gridy++;
    mainPanel.add(lblWarning, c);

    cmdExpandAdvancedSettings = new JLabel();
    cmdExpandAdvancedSettings.setBorder(new EmptyBorder(0, 5, 0, 0));
    cmdExpandAdvancedSettings.setIcon(
        UtilActivator.getResources().getImage("service.gui.icons.RIGHT_ARROW_ICON"));
    cmdExpandAdvancedSettings.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SHOW_ADVANCED"));
    cmdExpandAdvancedSettings.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            cmdExpandAdvancedSettings.setIcon(
                UtilActivator.getResources()
                    .getImage(
                        pnlAdvancedSettings.isVisible()
                            ? "service.gui.icons.RIGHT_ARROW_ICON"
                            : "service.gui.icons.DOWN_ARROW_ICON"));

            pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible());

            pnlAdvancedSettings.revalidate();
          }
        });
    c.gridy++;
    mainPanel.add(cmdExpandAdvancedSettings, c);

    pnlAdvancedSettings = new TransparentPanel();
    pnlAdvancedSettings.setLayout(new GridBagLayout());
    pnlAdvancedSettings.setVisible(false);
    c.gridy++;
    mainPanel.add(pnlAdvancedSettings, c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    pnlAdvancedSettings.add(new JSeparator(), c);

    // Encryption protcol preferences.
    JLabel lblEncryptionProtocolPreferences = new JLabel();
    lblEncryptionProtocolPreferences.setText(
        UtilActivator.getResources()
            .getI18NString("plugin.sipaccregwizz.ENCRYPTION_PROTOCOL_PREFERENCES"));
    c.gridy++;
    pnlAdvancedSettings.add(lblEncryptionProtocolPreferences, c);

    int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length;
    String[] encryptions = new String[nbEncryptionProtocols];
    boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols];

    this.encryptionConfigurationTableModel =
        new EncryptionConfigurationTableModel(encryptions, selectedEncryptions);
    loadEncryptionProtocols(new HashMap<String, Integer>(), new HashMap<String, Boolean>());
    this.encryptionProtocolPreferences =
        new PriorityTable(this.encryptionConfigurationTableModel, 60);
    this.encryptionConfigurationTableModel.addTableModelListener(this);
    c.gridy++;
    pnlAdvancedSettings.add(this.encryptionProtocolPreferences, c);

    // ZRTP
    JLabel lblZrtpOption = new JLabel();
    lblZrtpOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblZrtpOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.ZRTP_OPTION"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    pnlAdvancedSettings.add(lblZrtpOption, c);
    c.gridx = 1;
    pnlAdvancedSettings.add(new JSeparator(), c);

    enableSipZrtpAttribute =
        new SIPCommCheckBox(
            UtilActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"),
            regform.isSipZrtpAttribute());
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    pnlAdvancedSettings.add(enableSipZrtpAttribute, c);

    // SDES
    JLabel lblSDesOption = new JLabel();
    lblSDesOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblSDesOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SDES_OPTION"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    pnlAdvancedSettings.add(lblSDesOption, c);
    c.gridx = 1;
    pnlAdvancedSettings.add(new JSeparator(), c);

    JLabel lblCipherInfo = new JLabel();
    lblCipherInfo.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.CIPHER_SUITES"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    pnlAdvancedSettings.add(lblCipherInfo, c);

    cipherModel = new CipherTableModel(regform.getSDesCipherSuites());
    tabCiphers = new JTable(cipherModel);
    tabCiphers.setShowGrid(false);
    tabCiphers.setTableHeader(null);
    TableColumnModel tableColumnModel = tabCiphers.getColumnModel();
    TableColumn tableColumn = tableColumnModel.getColumn(0);
    tableColumn.setMaxWidth(tableColumn.getMinWidth());
    JScrollPane scrollPane = new JScrollPane(tabCiphers);
    scrollPane.setPreferredSize(new Dimension(tabCiphers.getWidth(), 100));
    c.gridy++;
    pnlAdvancedSettings.add(scrollPane, c);

    // SAVP selection
    c.gridx = 0;
    c.gridwidth = 1;
    JLabel lblSavpOption = new JLabel();
    lblSavpOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblSavpOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SAVP_OPTION"));
    if (this.displaySavpOtions) {
      c.gridy++;
      pnlAdvancedSettings.add(lblSavpOption, c);
    }
    c.gridx = 1;
    if (this.displaySavpOtions) {
      pnlAdvancedSettings.add(new JSeparator(), c);
    }

    cboSavpOption =
        new JComboBox(new SavpOption[] {new SavpOption(0), new SavpOption(1), new SavpOption(2)});
    c.gridx = 0;
    c.gridwidth = 2;
    c.insets = new Insets(0, 20, 0, 0);
    if (this.displaySavpOtions) {
      c.gridy++;
      pnlAdvancedSettings.add(cboSavpOption, c);
    }
  }
コード例 #14
0
  public void viewNotebook() {
    // TODO Auto-generated method stub
    // Log in to genspace

    System.out.println("Logging in");
    GenSpaceServerFactory.userLogin("jon", "test123");
    System.out.println("Getting my notes");
    JFrame frame = new JFrame("My Notebook");
    frame.setSize(800, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel mainContainer = new JPanel();
    frame.add(mainContainer);
    mainContainer.setLayout(new BorderLayout(0, 9));
    List<Tool> toolStrings = GenSpaceServerFactory.getUsageOps().getAllTools();
    List<AnalysisEvent> events = GenSpaceServerFactory.getPrivUsageFacade().getMyNotes(null, null);
    final NoteListModel nlm = new NoteListModel();
    nlm.setMyList(events);
    final JTable noteList = new JTable();
    noteList.setModel(nlm);
    String[] toolNames = new String[toolStrings.size()];
    String blank = "";
    blank = toolNames[0];
    for (int i = 1; i < toolStrings.size(); i++) {
      toolNames[i] = toolStrings.get(i).getName();
    }
    System.out.println(Arrays.toString(toolNames));
    JComboBox dropdown = new JComboBox(toolNames); // dropdown box
    dropdown.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            ItemSelectable is = (ItemSelectable) e.getSource();
            setFirstParam(selectedString(is));
            List<AnalysisEvent> searchEvents =
                GenSpaceServerFactory.getPrivUsageFacade().getMyNotes(firstParam, secondParam);
            nlm.setMyList(searchEvents);
            noteList.setModel(nlm);
            noteList.revalidate();
          }
        });
    JPanel sortBy = new JPanel(new FlowLayout());
    String[] sortByStrings = {" ", "Sort by tool", "Sort by date"};
    final JComboBox sortByDropdown = new JComboBox(sortByStrings);
    sortByDropdown.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (sortByDropdown.getSelectedIndex() == 1) {
              setSecondParam("tool");
              List<AnalysisEvent> searchEvents =
                  GenSpaceServerFactory.getPrivUsageFacade().getMyNotes(firstParam, secondParam);
              nlm.setMyList(searchEvents);
              noteList.setModel(nlm);
              noteList.revalidate();
            }
            if (sortByDropdown.getSelectedIndex() == 2) {
              setSecondParam("date");
              List<AnalysisEvent> searchEvents =
                  GenSpaceServerFactory.getPrivUsageFacade().getMyNotes(firstParam, secondParam);
              nlm.setMyList(searchEvents);
              noteList.setModel(nlm);
              noteList.revalidate();
            }
          }
        });
    sortBy.add(sortByDropdown);
    JPanel searchPanel = new JPanel(new BorderLayout());
    final JTextArea searchBox =
        new JTextArea("Enter your search query here or use the dropdown below");
    searchBox.setEditable(true);
    searchBox.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (searchBox
                .getText()
                .equals("Enter your search query here or use the dropdown below"))
              searchBox.setText("");
            super.mousePressed(e);
          }
        });
    JButton searchButton = new JButton("Search");
    searchButton.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent event) {
            ItemSelectable searchName = (ItemSelectable) event.getSource();
            String query = searchBox.getText();
            setFirstParam(query);
            List<AnalysisEvent> searchQueryList =
                GenSpaceServerFactory.getPrivUsageFacade()
                    .getMyNotes(firstParam, secondParam); // same problem as above
            nlm.setMyList(searchQueryList);
            noteList.setModel(nlm);
            noteList.revalidate();
          }
        });
    JLabel searchLabel = new JLabel("Filter your notes here:");
    Font f = new Font("Dialog", Font.PLAIN, 24);
    searchLabel.setFont(f);
    searchPanel.add(searchLabel, BorderLayout.NORTH);
    searchPanel.add(searchBox, BorderLayout.CENTER);
    searchPanel.add(searchButton, BorderLayout.EAST);
    searchPanel.setBackground(Color.white);
    SimpleDateFormat format = new SimpleDateFormat("F/M/yy h:mm a");
    noteList.setSize(800, 600);
    noteList.getColumnModel().getColumn(0).setCellRenderer(MyCellRenderer);
    noteList.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor());
    int lines = countLines(((MyCellEditor) MyCellEditor).getNoteText()); // counts lines needed
    System.out.println(lines);
    ((MyCellRenderer) MyCellRenderer).setLines(lines);
    noteList.setTableHeader(null);
    JScrollPane notePane = new JScrollPane(noteList);
    JPanel noteArea = new JPanel(new BorderLayout());
    JPanel sortArea = new JPanel(new BorderLayout()); // dropdown menus
    sortArea.add(searchPanel, BorderLayout.NORTH); // panel to hold sorting area
    sortArea.add(dropdown, BorderLayout.CENTER);
    sortArea.add(sortBy, BorderLayout.EAST);
    JLabel noteLabel = new JLabel("My Notebook:");
    noteLabel.setFont(f);
    noteArea.add(noteLabel, BorderLayout.NORTH);
    noteArea.add(notePane, BorderLayout.CENTER);
    mainContainer.add(noteArea, BorderLayout.CENTER);
    mainContainer.add(sortArea, BorderLayout.NORTH);
    mainContainer.setBackground(Color.white);
    frame.pack();
    frame.setVisible(true);
  }
コード例 #15
0
  /** Create an agenda panel. */
  public ProcessViewPanel(final BpmnInterpreter instance, IBreakpointPanel bpp) {
    this.instance = instance;
    this.bpp = bpp;
    this.ptmodel = new ProcessThreadModel();
    this.hmodel = new HistoryModel();

    // todo: problem should be called on process execution thread!
    instance.setHistoryEnabled(true); // Todo: Disable history on close?

    threads_clone = getThreadInfos();
    history_clone = instance.getHistory().toArray();

    TableSorter sorter = new TableSorter(ptmodel);
    this.threads = new JTable(sorter);
    ResizeableTableHeader header = new ResizeableTableHeader(threads.getColumnModel());
    header.setIncludeHeaderWidth(true);
    //		threads.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    threads.setTableHeader(header);
    threads.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    sorter.setTableHeader(header);
    threads.getColumnModel().setColumnMargin(10);

    sorter = new TableSorter(hmodel);
    this.history = new JTable(sorter);
    header = new ResizeableTableHeader(history.getColumnModel());
    header.setIncludeHeaderWidth(true);
    //		history.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    history.setTableHeader(header);
    history.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    sorter.setTableHeader(header);
    history.getColumnModel().setColumnMargin(10);

    this.listener =
        new IChangeListener() {
          ProcessThreadInfo[] threads_clone;
          Object[] history_clone;
          Object next;
          boolean invoked;

          public void changeOccurred(ChangeEvent event) {
            synchronized (ProcessViewPanel.this) {
              List his = instance.getHistory();
              threads_clone = getThreadInfos();
              history_clone = his != null ? his.toArray() : new Object[0];
              //					next	= instance.getNextActivation();
            }
            if (!invoked) {
              invoked = true;
              SwingUtilities.invokeLater(
                  new Runnable() {
                    public void run() {
                      invoked = false;
                      synchronized (ProcessViewPanel.this) {
                        ProcessViewPanel.this.threads_clone = threads_clone;
                        ProcessViewPanel.this.history_clone = history_clone;
                        ProcessViewPanel.this.next = next;
                      }
                      updateViews();
                    }
                  });
            }
          }
        };
    instance.addChangeListener(listener);

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            updateViews();
          }
        });

    JButton clear = new JButton("Clear");
    clear.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // todo: invoke on agent thread with invoke later
            // works because history is synchronized.
            List his = instance.getHistory();
            if (his != null) {
              his.clear();
              history_clone = new Object[0];
              history.repaint();
            }
          }
        });

    final JCheckBox hon = new JCheckBox("Store History");
    hon.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // todo: invoke on agent thread with invoke later
            instance.setHistoryEnabled(hon.isSelected());
          }
        });
    hon.setSelected(true);

    JPanel procp = new JPanel(new BorderLayout());
    procp.add(new JScrollPane(threads));
    procp.setBorder(BorderFactory.createTitledBorder("Processes"));

    JPanel historyp = new JPanel(new BorderLayout());
    historyp.add(new JScrollPane(history));
    historyp.setBorder(BorderFactory.createTitledBorder("History"));

    JPanel buts = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buts.add(hon);
    buts.add(clear);
    historyp.add(buts, BorderLayout.SOUTH);

    JSplitPane tmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    tmp.add(procp);
    tmp.add(historyp);
    tmp.setDividerLocation(200); // Hack?!

    setLayout(new BorderLayout());
    add(tmp, BorderLayout.CENTER);
  }
コード例 #16
0
  // Método construtor da Tela que contem os Tabuleiros
  // public BoardWindow(int[][] tabuleiro, String gameType, Server server, Client client){
  public BoardWindow(String gameType, Server server, Client client) {
    // Determina nome Janela
    super("Batalha Naval XP");

    // Cria um Container
    bwFrame = this.getContentPane();

    // Guarda qual o modo que está rodando
    setType(gameType);

    // Cria um Painel
    panel = new JPanel();

    // Cria uma Tabela
    table = new JTable(11, 11);
    tableEnemy = new JTable(11, 11);
    tableScore = new JTable(3, 4);

    // Determina a cor das bordas da tabela
    Color c = Color.BLACK;
    table.setGridColor(c);
    tableEnemy.setGridColor(c);
    tableScore.setGridColor(c);

    // Colorir coluna
    // Color index = Color.GREEN;
    // io_rd_renderer.setBackground(index);
    // table.getColumnModel().getColumn(0).setCellRenderer(io_rd_renderer);

    // Retira o cabeçalho da tabela
    table.setTableHeader(null);
    tableEnemy.setTableHeader(null);
    tableScore.setTableHeader(null);

    // Exibe as bordas da tabela
    table.setShowGrid(true);
    tableEnemy.setShowGrid(true);
    tableScore.setShowGrid(true);

    // Númera a primeira coluna e linha
    setFirstColumn(table);
    setFirstRow(table);

    setFirstColumn(tableEnemy);
    setFirstRow(tableEnemy);

    mountTableScore(tableScore);

    // Cria um frame para colocar a tabela e ajusta o seu tamanho

    // Tabela "Seu tabuleiro"
    pane = new JScrollPane(table);
    pane.getViewport().setPreferredSize(table.getPreferredSize());

    // Tabela "Respostas"
    paneEnemy = new JScrollPane(tableEnemy);
    paneEnemy.getViewport().setPreferredSize(tableEnemy.getPreferredSize());

    // Tabela de Pontuação
    paneScore = new JScrollPane(tableScore);
    paneScore.getViewport().setPreferredSize(tableScore.getPreferredSize());

    // Botão para Iniciar Disparo
    btShot = new JButton("Iniciar Disparo");
    btShot.setSize(50, 50);
    btShot.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Instancia Objeto a ser enviado por Socket
            Shot shot = new Shot();

            int check = 1;
            int error = 0;

            // Enquanto não foi apertado o botão certo e os dados não estiverem corretos, o
            // aplicativo irá solicitar coordenadas
            while (check != 0) {

              // Limpa possíveis rastros nos JTexts
              tf1c.setText(null);
              tf1r.setText(null);

              // Cria campos para Inserção
              message = new Object[] {"Coordenadas do Tiro", "Coluna", tf1c, "Linha", tf1r};

              // Cria Mensagem de Erro
              errorMessage =
                  new Object[] {
                    "Verifique os coordenadas inseridos, pois existem coordenadas inválidas.\n"
                        + "Coordenadas válidas são de 1 a 10. Letras não são válidas\n"
                        + "Coordenadas repetidas."
                  };

              // Solicita dados aos usuário
              check =
                  JOptionPane.showConfirmDialog(
                      null, message, "Inserir coordenada do Tiro", JOptionPane.OK_OPTION);

              // Se o botão pressionado for Sim
              if (check == 0) {

                // Faz validação do tiro. Se for válidado envia tiro pelo Socket. Se não exibe
                // mensagem de erro
                if (validateShot(tf1r.getText(), tf1c.getText(), shots)) {

                  // Cria Objeto a ser enviado
                  shot.createShot(tf1r.getText(), tf1c.getText(), board);

                  try {

                    // Verifica se é Cliente ou Servidor. Desabilita o Botão para não enviar mais de
                    // um tiro e envia objeto por Socket
                    if (type.equals("Server")) {
                      btShot.setEnabled(false);
                      socketServer.sendObject.flush();
                      socketServer.sendObject.writeObject(shot);
                      socketServer.sendObject.flush();
                    }

                    if (type.equals("Client")) {
                      btShot.setEnabled(false);
                      socketClient.sendObject.flush();
                      socketClient.sendObject.writeObject(shot);
                      socketClient.sendObject.flush();
                    }
                  } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                  }
                } else {
                  // Mensagem de erro
                  error =
                      JOptionPane.showConfirmDialog(
                          null,
                          errorMessage,
                          "Erro ao inserir Coordenadas",
                          JOptionPane.CANCEL_OPTION);
                  check = 1;
                }
              }
            }
          }
        });

    // Adiciona frame ao painel
    panel.add(player1);
    panel.add(pane);
    panel.add(player2);
    panel.add(paneEnemy);
    panel.add(paneScore);
    panel.add(btShot);
    panel.setAlignmentX(CENTER_ALIGNMENT);

    // Adiciona o painel ao container
    bwFrame.add(panel);

    // Instancia Objeto Board
    board = new Board();

    // Inicia o jogo pelo Servidor
    if (type.equals("Client")) {
      btShot.setEnabled(false);
    }

    // Adiciona as referências aos objetos que serão usados pelas Classes na thread
    if (getType().equals("Server")) {
      socketServer = server;
      socketServer.setServerTable(table);
      socketServer.setServerScore(tableScore);
      socketServer.setServerButton(btShot);
      socketServer.setServerTableAnswer(tableEnemy);
    } else {
      socketClient = client;
      socketClient.setClientTable(table);
      socketClient.setClientScore(tableScore);
      socketClient.setClientButton(btShot);
      socketClient.setClientTableAnswer(tableEnemy);
    }

    // Configura detalhes do Frame
    // 1. Encerrar Applicação ao Fechar
    // 2. Setar Frame como Visível
    // 3. Setar as dimensões do Frame
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 1
    this.setVisible(true); // 2
    this.setSize(1024, 460); // 3	

    btHorizontal.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (btHorizontal.isSelected()) {
              btVertical.setSelected(false);
            }
          }
        });

    btVertical.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (btVertical.isSelected()) {
              btHorizontal.setSelected(false);
            }
          }
        });

    mountBoard(table);

    // Percorre matriz do tabuleiro preenchida com valores dos barcos posicionados pelo usuario
    /*for( int linha = 1; linha < 10; linha++ )
    {
    	for( int coluna = 1; coluna < 10; coluna++ )
    	{
    		// Se houver algum barco na posicao corrente, exibe na celula da tabela
    		if ( tabuleiro[linha][coluna] > 0 )
    		{
    			// Coloca as Iniciais dos Barcos(P, Q, T, D e S)
    			switch (tabuleiro[linha][coluna]){
     			case 1:
     			{
     				table.setValueAt("S", linha, coluna);
     				break;
     			}
     			case 2:
     			{
     				table.setValueAt("D", linha, coluna);
     				break;
     			}
     			case 3:
     			{
     				table.setValueAt("T", linha, coluna);
     				break;
     			}
     			case 4:
     			{
     				table.setValueAt("Q", linha, coluna);
     				break;
     			}
     			case 5:
     			{
     				table.setValueAt("P", linha, coluna);
     				break;
     			}
    			}

    		}
    	}
    }*/

  }
コード例 #17
0
  @NotNull
  private JBPopup createUsagePopup(
      @NotNull final List<Usage> usages,
      @NotNull final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor,
      @NotNull Set<UsageNode> visibleNodes,
      @NotNull final FindUsagesHandler handler,
      final Editor editor,
      @NotNull final RelativePoint popupPosition,
      final int maxUsages,
      @NotNull final UsageViewImpl usageView,
      @NotNull final FindUsagesOptions options,
      @NotNull final JTable table,
      @NotNull final UsageViewPresentation presentation,
      @NotNull final AsyncProcessIcon processIcon,
      boolean hadMoreSeparator) {
    table.setRowHeight(PlatformIcons.CLASS_ICON.getIconHeight() + 2);
    table.setShowGrid(false);
    table.setShowVerticalLines(false);
    table.setShowHorizontalLines(false);
    table.setTableHeader(null);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    table.setIntercellSpacing(new Dimension(0, 0));

    PopupChooserBuilder builder = new PopupChooserBuilder(table);
    final String title = presentation.getTabText();
    if (title != null) {
      String result = getFullTitle(usages, title, hadMoreSeparator, visibleNodes.size() - 1, true);
      builder.setTitle(result);
      builder.setAdText(getSecondInvocationTitle(options, handler));
    }

    builder.setMovable(true).setResizable(true);
    builder.setItemChoosenCallback(
        new Runnable() {
          @Override
          public void run() {
            int[] selected = table.getSelectedRows();
            for (int i : selected) {
              Object value = table.getValueAt(i, 0);
              if (value instanceof UsageNode) {
                Usage usage = ((UsageNode) value).getUsage();
                if (usage == MORE_USAGES_SEPARATOR) {
                  appendMoreUsages(editor, popupPosition, handler, maxUsages);
                  return;
                }
                navigateAndHint(usage, null, handler, popupPosition, maxUsages, options);
              }
            }
          }
        });
    final JBPopup[] popup = new JBPopup[1];

    KeyboardShortcut shortcut = UsageViewImpl.getShowUsagesWithSettingsShortcut();
    if (shortcut != null) {
      new DumbAwareAction() {
        @Override
        public void actionPerformed(AnActionEvent e) {
          popup[0].cancel();
          showDialogAndFindUsages(handler, popupPosition, editor, maxUsages);
        }
      }.registerCustomShortcutSet(new CustomShortcutSet(shortcut.getFirstKeyStroke()), table);
    }
    shortcut = getShowUsagesShortcut();
    if (shortcut != null) {
      new DumbAwareAction() {
        @Override
        public void actionPerformed(AnActionEvent e) {
          popup[0].cancel();
          searchEverywhere(options, handler, editor, popupPosition, maxUsages);
        }
      }.registerCustomShortcutSet(new CustomShortcutSet(shortcut.getFirstKeyStroke()), table);
    }

    InplaceButton settingsButton =
        createSettingsButton(
            handler,
            popupPosition,
            editor,
            maxUsages,
            new Runnable() {
              @Override
              public void run() {
                popup[0].cancel();
              }
            });

    ActiveComponent spinningProgress =
        new ActiveComponent() {
          @Override
          public void setActive(boolean active) {}

          @Override
          public JComponent getComponent() {
            return processIcon;
          }
        };
    builder.setCommandButton(new CompositeActiveComponent(spinningProgress, settingsButton));

    DefaultActionGroup toolbar = new DefaultActionGroup();
    usageView.addFilteringActions(toolbar);

    toolbar.add(UsageGroupingRuleProviderImpl.createGroupByFileStructureAction(usageView));
    toolbar.add(
        new AnAction(
            "Open Find Usages Toolwindow",
            "Show all usages in a separate toolwindow",
            AllIcons.Toolwindows.ToolWindowFind) {
          {
            AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_USAGES);
            setShortcutSet(action.getShortcutSet());
          }

          @Override
          public void actionPerformed(AnActionEvent e) {
            hideHints();
            popup[0].cancel();
            FindUsagesManager findUsagesManager =
                ((FindManagerImpl) FindManager.getInstance(usageView.getProject()))
                    .getFindUsagesManager();

            findUsagesManager.findUsages(
                handler.getPrimaryElements(),
                handler.getSecondaryElements(),
                handler,
                options,
                FindSettings.getInstance().isSkipResultsWithOneUsage());
          }
        });

    ActionToolbar actionToolbar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.USAGE_VIEW_TOOLBAR, toolbar, true);
    actionToolbar.setReservePlaceAutoPopupIcon(false);
    final JComponent toolBar = actionToolbar.getComponent();
    toolBar.setOpaque(false);
    builder.setSettingButton(toolBar);

    popup[0] = builder.createPopup();
    JComponent content = popup[0].getContent();

    myWidth =
        (int)
            (toolBar.getPreferredSize().getWidth()
                + new JLabel(
                        getFullTitle(
                            usages, title, hadMoreSeparator, visibleNodes.size() - 1, true))
                    .getPreferredSize()
                    .getWidth()
                + settingsButton.getPreferredSize().getWidth());
    myWidth = -1;
    for (AnAction action : toolbar.getChildren(null)) {
      action.unregisterCustomShortcutSet(usageView.getComponent());
      action.registerCustomShortcutSet(action.getShortcutSet(), content);
    }

    return popup[0];
  }
コード例 #18
0
  public MemoryPanel(final Debugger debugger, boolean is64Bit) {
    super();
    this.debugger = debugger;
    this.is64Bit = is64Bit;
    if (is64Bit) {
      addressSize = 8;
      unmappedAddrString = "??????????????????";
    } else {
      addressSize = 4;
      unmappedAddrString = "??????????";
    }
    setLayout(new BorderLayout());
    setupScrollBar();
    add(scrollBar, BorderLayout.EAST);

    model =
        new AbstractTableModel() {
          public int getRowCount() {
            return numVisibleRows;
          }

          public int getColumnCount() {
            return 2;
          }

          public Object getValueAt(int row, int column) {
            switch (column) {
              case 0:
                return bigIntToHexString(
                    startVal.add(new BigInteger(Integer.toString((row * addressSize)))));
              case 1:
                {
                  try {
                    Address addr =
                        bigIntToAddress(
                            startVal.add(new BigInteger(Integer.toString((row * addressSize)))));
                    if (addr != null) {
                      return addressToString(addr.getAddressAt(0));
                    }
                    return unmappedAddrString;
                  } catch (UnmappedAddressException e) {
                    return unmappedAddrString;
                  }
                }
              default:
                throw new RuntimeException("Column " + column + " out of bounds");
            }
          }

          public boolean isCellEditable(int row, int col) {
            return false;
          }
        };

    // View with JTable with no header
    table = new JTable(model);
    table.setTableHeader(null);
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setCellSelectionEnabled(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    table.setDragEnabled(true);
    Font font = GraphicsUtilities.lookupFont("Courier");
    if (font == null) {
      throw new RuntimeException("Error looking up monospace font Courier");
    }
    table.setFont(font);

    // Export proper data.
    // We need to keep our own notion of the selection in order to
    // properly export data, since the selection can go beyond the
    // visible area on the screen (and since the table's model doesn't
    // back all of those slots).
    // Code thanks to Shannon.Hickey@sfbay
    table.setTransferHandler(
        new TransferHandler() {
          protected Transferable createTransferable(JComponent c) {
            JTable table = (JTable) c;
            if (haveSelection()) {
              StringBuffer buf = new StringBuffer();
              int iDir = (getRowAnchor() < getRowLead() ? 1 : -1);
              int jDir = (getColAnchor() < getColLead() ? 1 : -1);

              for (int i = getRowAnchor(); i != getRowLead() + iDir; i += iDir) {
                for (int j = getColAnchor(); j != getColLead() + jDir; j += jDir) {
                  Object val = model.getValueAt(i, j);
                  buf.append(val == null ? "" : val.toString());
                  if (j != getColLead()) {
                    buf.append("\t");
                  }
                }
                if (i != getRowLead()) {
                  buf.append("\n");
                }
              }

              return new StringTransferable(buf.toString());
            }
            return null;
          }

          public int getSourceActions(JComponent c) {
            return COPY;
          }

          public boolean importData(JComponent c, Transferable t) {
            if (canImport(c, t.getTransferDataFlavors())) {
              try {
                String str = (String) t.getTransferData(DataFlavor.stringFlavor);
                handleImport(c, str);
                return true;
              } catch (UnsupportedFlavorException ufe) {
              } catch (IOException ioe) {
              }
            }

            return false;
          }

          public boolean canImport(JComponent c, DataFlavor[] flavors) {
            for (int i = 0; i < flavors.length; i++) {
              if (DataFlavor.stringFlavor.equals(flavors[i])) {
                return true;
              }
            }
            return false;
          }

          private void handleImport(JComponent c, String str) {
            // do whatever you want with the string here
            try {
              makeVisible(debugger.parseAddress(str));
              clearSelection();
              table.clearSelection();
            } catch (NumberFormatException e) {
              System.err.println("Unable to parse address \"" + str + "\"");
            }
          }
        });

    // Supporting keyboard scrolling
    // See src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java,
    // search for Table.AncestorInputMap

    // Actions to override:
    // selectPreviousRow, selectNextRow,
    // scrollUpChangeSelection, scrollDownChangeSelection,
    // selectPreviousRowExtendSelection, selectNextRowExtendSelection,
    // scrollDownExtendSelection, scrollUpExtendSelection (Shift-PgDn/PgUp)

    ActionMap map = table.getActionMap();

    // Up arrow
    installActionWrapper(
        map,
        "selectPreviousRow",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            clearSelection();
            if (table.getSelectedRow() == 0) {
              scrollBar.scrollUpOrLeft();
              table.setRowSelectionInterval(0, 0);
            } else {
              super.actionPerformed(e);
            }
            maybeGrabSelection();
            endUpdate();
          }
        });
    // Down arrow
    installActionWrapper(
        map,
        "selectNextRow",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            clearSelection();
            int row = table.getSelectedRow();
            if (row >= numUsableRows) {
              scrollBar.scrollDownOrRight();
              table.setRowSelectionInterval(row, row);
            } else {
              super.actionPerformed(e);
            }
            maybeGrabSelection();
            endUpdate();
          }
        });
    // Page up
    installActionWrapper(
        map,
        "scrollUpChangeSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            clearSelection();
            int row = table.getSelectedRow();
            scrollBar.pageUpOrLeft();
            if (row >= 0) {
              table.setRowSelectionInterval(row, row);
            }
            maybeGrabSelection();
            endUpdate();
          }
        });
    // Page down
    installActionWrapper(
        map,
        "scrollDownChangeSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            clearSelection();
            int row = table.getSelectedRow();
            scrollBar.pageDownOrRight();
            if (row >= 0) {
              table.setRowSelectionInterval(row, row);
            }
            maybeGrabSelection();
            endUpdate();
          }
        });
    // Shift + Up arrow
    installActionWrapper(
        map,
        "selectPreviousRowExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
              //            setAnchor(table.getSelectedRow());
              //            setLead(table.getSelectedRow());
            }
            int newLead = getRowLead() - 1;
            int newAnchor = getRowAnchor();
            if (newLead < 0) {
              scrollBar.scrollUpOrLeft();
              ++newLead;
              ++newAnchor;
            }
            setSelection(newAnchor, newLead, getColAnchor(), getColLead());
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Left arrow
    installActionWrapper(
        map,
        "selectPreviousColumnExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
            }
            int newLead = Math.max(0, getColLead() - 1);
            setSelection(getRowAnchor(), getRowLead(), getColAnchor(), newLead);
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Down arrow
    installActionWrapper(
        map,
        "selectNextRowExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
              //            setAnchor(table.getSelectedRow());
              //            setLead(table.getSelectedRow());
            }
            int newLead = getRowLead() + 1;
            int newAnchor = getRowAnchor();
            if (newLead > numUsableRows) {
              scrollBar.scrollDownOrRight();
              --newLead;
              --newAnchor;
            }
            setSelection(newAnchor, newLead, getColAnchor(), getColLead());
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Right arrow
    installActionWrapper(
        map,
        "selectNextColumnExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
            }
            int newLead = Math.min(model.getColumnCount() - 1, getColLead() + 1);
            setSelection(getRowAnchor(), getRowLead(), getColAnchor(), newLead);
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Page up
    installActionWrapper(
        map,
        "scrollUpExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
              //            setAnchor(table.getSelectedRow());
              //            setLead(table.getSelectedRow());
            }
            int newLead = getRowLead() - numUsableRows;
            int newAnchor = getRowAnchor();
            if (newLead < 0) {
              scrollBar.pageUpOrLeft();
              newLead += numUsableRows;
              newAnchor += numUsableRows;
            }
            setSelection(newAnchor, newLead, getColAnchor(), getColLead());
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Page down
    installActionWrapper(
        map,
        "scrollDownExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
              //            setAnchor(table.getSelectedRow());
              //            setLead(table.getSelectedRow());
            }
            int newLead = getRowLead() + numUsableRows;
            int newAnchor = getRowAnchor();
            if (newLead > numUsableRows) {
              scrollBar.pageDownOrRight();
              newLead -= numUsableRows;
              newAnchor -= numUsableRows;
            }
            setSelection(newAnchor, newLead, getColAnchor(), getColLead());
            //          printSelection();
            endUpdate();
          }
        });

    // Clear our notion of selection upon mouse press
    table.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            if (shouldIgnore(e)) {
              return;
            }
            // Make shift-clicking work properly
            if (e.isShiftDown()) {
              maybeGrabSelection();
              return;
            }
            //          System.err.println("  Clearing selection on mouse press");
            clearSelection();
          }
        });

    // Watch for mouse going out of bounds
    table.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            if (shouldIgnore(e)) {
              //            System.err.println("  (Ignoring consumed mouse event)");
              return;
            }

            // Look for drag events outside table and scroll if necessary
            Point p = e.getPoint();
            if (table.rowAtPoint(p) == -1) {
              // See whether we are above or below the table
              Rectangle rect = new Rectangle();
              getBounds(rect);
              beginUpdate();
              if (p.y < rect.y) {
                //              System.err.println("  Scrolling up due to mouse event");
                // Scroll up
                scrollBar.scrollUpOrLeft();
                setSelection(getRowAnchor(), 0, getColAnchor(), getColLead());
              } else {
                //              System.err.println("  Scrolling down due to mouse event");
                // Scroll down
                scrollBar.scrollDownOrRight();
                setSelection(getRowAnchor(), numUsableRows, getColAnchor(), getColLead());
              }
              //            printSelection();
              endUpdate();
            } else {
              maybeGrabSelection();
            }
          }
        });

    add(table, BorderLayout.CENTER);

    // Make sure we recompute number of visible rows
    addComponentListener(
        new ComponentAdapter() {
          public void componentResized(ComponentEvent e) {
            recomputeNumVisibleRows();
            constrain();
          }
        });
    addHierarchyListener(
        new HierarchyListener() {
          public void hierarchyChanged(HierarchyEvent e) {
            recomputeNumVisibleRows();
            constrain();
          }
        });
    updateFromScrollBar();
  }
コード例 #19
0
ファイル: ZrtpConfigurePanel.java プロジェクト: 0xbb/jitsi
  private <T extends Enum<T>> void createControls(JPanel panel, ZrtpConfigureTableModel<T> model) {
    ResourceManagementService resources = NeomediaActivator.getResources();

    final JButton upButton = new JButton(resources.getI18NString("impl.media.configform.UP"));
    upButton.setOpaque(false);

    final JButton downButton = new JButton(resources.getI18NString("impl.media.configform.DOWN"));
    downButton.setOpaque(false);

    Container buttonBar = new TransparentPanel(new GridLayout(0, 1));
    buttonBar.add(upButton);
    buttonBar.add(downButton);

    panel.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN));
    panel.setLayout(new GridBagLayout());

    final JTable table = new JTable(model.getRowCount(), 2);
    table.setShowGrid(false);
    table.setTableHeader(null);
    table.setModel(model);
    // table.setFillsViewportHeight(true); // Since 1.6 only - nicer view

    /*
     * The first column contains the check boxes which enable/disable their
     * associated encodings and it doesn't make sense to make it wider than
     * the check boxes.
     */
    TableColumnModel tableColumnModel = table.getColumnModel();
    TableColumn tableColumn = tableColumnModel.getColumn(0);
    tableColumn.setMaxWidth(tableColumn.getMinWidth() + 5);
    table.doLayout();

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridwidth = 1;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    panel.add(new JScrollPane(table), constraints);

    constraints.anchor = GridBagConstraints.NORTHEAST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridwidth = 1;
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    panel.add(buttonBar, constraints);

    ListSelectionListener tableSelectionListener =
        new ListSelectionListener() {
          @SuppressWarnings("unchecked")
          public void valueChanged(ListSelectionEvent event) {
            if (table.getSelectedRowCount() == 1) {
              int selectedRow = table.getSelectedRow();
              if (selectedRow > -1) {
                ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel();
                upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow));
                downButton.setEnabled(
                    selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow));
                return;
              }
            }
            upButton.setEnabled(false);
            downButton.setEnabled(false);
          }
        };
    table.getSelectionModel().addListSelectionListener(tableSelectionListener);

    TableModelListener tableListener =
        new TableModelListener() {
          @SuppressWarnings("unchecked")
          public void tableChanged(TableModelEvent e) {
            if (table.getSelectedRowCount() == 1) {
              int selectedRow = table.getSelectedRow();
              if (selectedRow > -1) {
                ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel();
                upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow));
                downButton.setEnabled(
                    selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow));
                return;
              }
            }
            upButton.setEnabled(false);
            downButton.setEnabled(false);
          }
        };
    table.getModel().addTableModelListener(tableListener);

    tableSelectionListener.valueChanged(null);

    ActionListener buttonListener =
        new ActionListener() {
          @SuppressWarnings("unchecked")
          public void actionPerformed(ActionEvent event) {
            Object source = event.getSource();
            boolean up;
            if (source == upButton) up = true;
            else if (source == downButton) up = false;
            else return;

            int index =
                ((ZrtpConfigureTableModel<T>) table.getModel())
                    .move(table.getSelectedRow(), up, up);
            table.getSelectionModel().setSelectionInterval(index, index);
          }
        };
    upButton.addActionListener(buttonListener);
    downButton.addActionListener(buttonListener);
  }
コード例 #20
0
  public DetectedPluginsPanel() {
    super(PluginDownloader.class);
    final JTable entryTable = getEntryTable();
    myHeader = new PluginHeaderPanel(null, entryTable);
    entryTable.setTableHeader(null);
    entryTable.setDefaultRenderer(
        PluginDownloader.class,
        new ColoredTableCellRenderer() {
          protected void customizeCellRenderer(
              final JTable table,
              final Object value,
              final boolean selected,
              final boolean hasFocus,
              final int row,
              final int column) {
            setBorder(null);
            final PluginDownloader downloader = (PluginDownloader) value;
            if (downloader != null) {
              final String pluginName = downloader.getPluginName();
              append(pluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
              final IdeaPluginDescriptor ideaPluginDescriptor =
                  PluginManager.getPlugin(PluginId.getId(downloader.getPluginId()));
              if (ideaPluginDescriptor != null) {
                final String oldPluginName = ideaPluginDescriptor.getName();
                if (!Comparing.strEqual(pluginName, oldPluginName)) {
                  append(" - " + oldPluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
                }
              }
              final String loadedVersion = downloader.getPluginVersion();
              if (loadedVersion != null
                  || (ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null)) {
                final String installedVersion =
                    ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null
                        ? "v. "
                            + ideaPluginDescriptor.getVersion()
                            + (loadedVersion != null ? " -> " : "")
                        : "";
                final String availableVersion = loadedVersion != null ? loadedVersion : "";
                append(
                    " (" + installedVersion + availableVersion + ")",
                    SimpleTextAttributes.GRAY_ATTRIBUTES);
              }
            }
          }
        });
    entryTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                final int selectedRow = entryTable.getSelectedRow();
                if (selectedRow != -1) {
                  final PluginDownloader selection = getValueAt(selectedRow);
                  final IdeaPluginDescriptor descriptor = selection.getDescriptor();
                  if (descriptor != null) {
                    PluginManagerMain.pluginInfoUpdate(
                        descriptor, null, myDescriptionPanel, myHeader, null);
                  }
                }
              }
            });
    setCheckboxColumnName("");
    myDescriptionPanel.setPreferredSize(new Dimension(400, -1));
    myDescriptionPanel.setEditable(false);
    myDescriptionPanel.setContentType(UIUtil.HTML_MIME);
    myDescriptionPanel.addHyperlinkListener(new PluginManagerMain.MyHyperlinkListener());
    removeAll();

    final Splitter splitter = new Splitter(false);
    splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(entryTable));
    splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myDescriptionPanel));
    add(splitter, BorderLayout.CENTER);
  }
コード例 #21
0
ファイル: ParametersPanel.java プロジェクト: sprig/MPS
  private void initPanel() {
    this.setLayout(new GridBagLayout());

    final JTable parametersTable = new JBTable(this.myTableModel);

    JPanel buttonsPanel = new JPanel(new GridBagLayout());
    final JButton upButton =
        this.createParametersRowMoveButton(parametersTable, "Move up", -1, 0, buttonsPanel);
    final JButton downButton =
        this.createParametersRowMoveButton(parametersTable, "Move down", 1, 1, buttonsPanel);

    parametersTable.setShowGrid(false);
    parametersTable.setCellSelectionEnabled(false);
    parametersTable.setRowSelectionAllowed(true);
    parametersTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    parametersTable.setIntercellSpacing(new Dimension(0, 0));
    parametersTable.setTableHeader(null);
    parametersTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent p0) {
                int s = parametersTable.getSelectedRow();
                upButton.setEnabled(s > 0);
                downButton.setEnabled(
                    s != 0
                        && s
                            < ListSequence.fromList(ParametersPanel.this.myModel.getParameters())
                                    .count()
                                - 1);
              }
            });
    this.fitTableColumns(parametersTable);
    parametersTable.getColumnModel().getColumn(1).setCellEditor(this.createCellEditor());
    parametersTable
        .getColumnModel()
        .getColumn(0)
        .setMaxWidth(new JCheckBox().getPreferredSize().width);
    this.myTableModel.addTableModelListener(
        new TableModelListener() {
          @Override
          public void tableChanged(TableModelEvent p0) {
            ParametersPanel.this.fitTableColumns(parametersTable);
          }
        });
    parametersTable.setPreferredScrollableViewportSize(
        new Dimension(
            parametersTable.getPreferredScrollableViewportSize().width,
            parametersTable.getRowHeight() * 7));
    JScrollPane scrollPane =
        new JScrollPane(
            parametersTable,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    GridBagConstraints c =
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0);

    this.add(scrollPane, c);

    c.gridx = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(buttonsPanel, c);
  }
コード例 #22
0
  /**
   * This method is responsible to represent the potential table as a JTable.
   *
   * @return Returns the JTable representing this potential table. TODO MIGRATE TO A DIFFERENT CLASS
   *     - GUI.TABLE.PROBABILISTICTABLE
   */
  public JTable makeTable() {
    JTable table;
    int nStates = 1;
    // Number of variables
    int nVariables = potentialTable.variableCount();
    Node node = (Node) potentialTable.getVariableAt(0);
    NumberFormat df = NumberFormat.getInstance(Locale.getDefault());
    df.setMaximumFractionDigits(4);

    // calculate the number of states by multiplying the number of
    // states that each father (variables) has. Where variable 0 is the
    // node itself. That is why we divide the table size by the number
    // of states in the node itself.
    /*
     * Ex: states = 12 / 3;
     *
     * |------------------------------------------------------|
     * | Father 2     |      State 1      |      State 2      |
     * |--------------|-------------------|-------------------|
     * | Father 1     | State 1 | State 2 | State 1 | State 2 |
     * |------------------------------------------------------|
     * | Node State 1 |    1    |    1    |    1    |    1    |
     * | Node State 2 |    0    |    0    |    0    |    0    |
     * | Node State 3 |    0    |    0    |    0    |    0    |
     * |------------------------------------------------------|
     *
     */
    nStates = potentialTable.tableSize() / node.getStatesSize();

    // the number of rows is the number of states the node has.
    int rows = node.getStatesSize();

    // the number of columns is the number of states that we calculated
    // before plus one that is the column where the fathers names and
    // the states of the node itself will be placed.
    int columns = nStates + 1;

    // Constructing the data of the data model.
    /*
     * Ex: data[3][4 + 1]
     * |------------------------------------------------------|
     * | Node State 1 |    1    |    1    |    1    |    1    |
     * | Node State 2 |    0    |    0    |    0    |    0    |
     * | Node State 3 |    0    |    0    |    0    |    0    |
     * |------------------------------------------------------|
     */
    String[][] data = new String[rows][columns];

    // Constructing the first header's row
    /*
     * Ex: Following the example above this is the first header's row.
     *
     * |--------------|-------------------|-------------------|
     * | Father 1     | State 1 | State 2 | State 1 | State 2 |
     * |------------------------------------------------------|
     *
     */
    String[] column = new String[data[0].length];
    Node firtHeaderNode;
    // If there is no father, this is going to be the first header's
    // row:
    /*
     * |-----------|---------------|
     * | State     |  Probability  |
     * |---------------------------|
     *
     */
    if (nVariables == 1) {
      column[0] = "State";
      column[1] = "Probability";
    } else {
      firtHeaderNode = (Node) potentialTable.getVariableAt(1);
      /*
       * Ex: Here we get the variable "Father 1" and set its name in
       *     the header.
       *
       * |--------------|
       * | Father 1     |
       * |---------------
       *
       */
      column[0] = firtHeaderNode.getName();
      for (int i = 0; i < data[0].length - 1; i++) {
        if (nVariables > 1) {
          // Reapeats all states in the node until there are cells to
          // fill.
          /*
           * Ex: Following the example above. Here the states go.
           *
           * |-------------------|-------------------|
           * | State 1 | State 2 | State 1 | State 2 |
           * ----------------------------------------|
           *
           */
          column[i + 1] = firtHeaderNode.getStateAt(i % firtHeaderNode.getStatesSize());
        }
      }
    }

    // Filling the data of the data model.
    /*
     * Ex: Fill the data[3][5] constructed above.
     * |------------------------------------------------------|
     * | Node State 1 |    1    |    1    |    1    |    1    |
     * | Node State 2 |    0    |    0    |    0    |    0    |
     * | Node State 3 |    0    |    0    |    0    |    0    |
     * |------------------------------------------------------|
     */
    // The values are arranged in the potential table as a vector.
    /*
     * Ex: This would be the vector in the potential table.
     * |-------------------------------------------------------------------|
     * | Vector Position | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
     * | Vector Value    | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0  | 0  |
     * |-------------------------------------------------------------------|
     */
    // So, for each column we jump the number of values corresponding
    // that column, that is, the number of rows.
    for (int c = 1, n = 0; c < columns; c++, n += rows) {
      for (int r = 0; r < rows; r++) {
        // So, data[0][3] = vector[6 + 0] = 1
        data[r][c] = "" + "" + df.format(potentialTable.getValue(n + r));
      }
    }
    // Now that we filled the values, we are going to put this node's
    // states name.
    /*
     * Ex: Fill the data[i][0] constructed above, that is, its states
     *     name.
     * |---------------
     * | Node State 1 |
     * | Node State 2 |
     * | Node State 3 |
     * |---------------
     */
    for (int i = 0; i < rows; i++) {
      data[i][0] = node.getStateAt(i);
    }

    // Constructing the table so far.
    /*
     * Ex: The table so far, following the example above.
     *
     * |--------------|-------------------|-------------------|
     * | Father 1     | State 1 | State 2 | State 1 | State 2 |
     * |------------------------------------------------------|
     * | Node State 1 |    1    |    1    |    1    |    1    |
     * | Node State 2 |    0    |    0    |    0    |    0    |
     * | Node State 3 |    0    |    0    |    0    |    0    |
     * |------------------------------------------------------|
     *
     */
    DefaultTableModel model = new DefaultTableModel();
    model.setDataVector(data, column);
    table = new JTable();

    // Setup to allow grouping the header.
    table.setColumnModel(new GroupableTableColumnModel());
    table.setTableHeader(
        new GroupableTableHeader((GroupableTableColumnModel) table.getColumnModel()));
    table.setModel(model);

    // Setup Column Groups
    GroupableTableColumnModel cModel = (GroupableTableColumnModel) table.getColumnModel();
    ColumnGroup cNodeGroup = null;
    ColumnGroup cNodeTempGroup = null;
    ColumnGroup cGroup = null;
    List<ColumnGroup> cGroupList = new ArrayList<ColumnGroup>();
    List<ColumnGroup> previousCGroupList = new ArrayList<ColumnGroup>();
    int columnIndex;
    boolean firstNode = true;
    int sizeColumn = 1;
    // Sets default color for parents name in first column.
    /*
     * |---------------
     * | Father 2     |
     * |--------------|
     * | Father 1     |
     * |---------------
     *
     */
    cModel.getColumn(0).setHeaderRenderer(new GroupableTableCellRenderer());
    // Sets default color for node's states
    /*
     * |---------------
     * | Node State 1 |
     * | Node State 2 |
     * | Node State 3 |
     * |---------------
     *
     */
    cModel.getColumn(0).setCellRenderer(new GroupableTableCellRenderer(Color.BLACK, Color.YELLOW));
    // Fill all other headers, but the first (that has already been
    // set). It ignores k = 0 (the node itself) and k = 1 (the fist
    // father).
    for (int k = 2; k < nVariables; k++) {
      Node parent = (Node) potentialTable.getVariableAt(k);
      int nPreviousParentStates = potentialTable.getVariableAt(k - 1).getStatesSize();
      sizeColumn *= nPreviousParentStates;
      // Set the node name as a header in the first column
      if (!firstNode) {
        cNodeTempGroup = cNodeGroup;
        cNodeGroup = new ColumnGroup(new GroupableTableCellRenderer(), parent.getName());
        cNodeGroup.add(cNodeTempGroup);
      } else {
        cNodeGroup = new ColumnGroup(new GroupableTableCellRenderer(), parent.getName());
        cNodeGroup.add(cModel.getColumn(0));
      }
      columnIndex = 1;
      cGroup = null;
      while (columnIndex <= nStates) {
        for (int i = 0; i < parent.getStatesSize(); i++) {
          cGroup = new ColumnGroup(parent.getStateAt(i));
          if (!firstNode) {
            for (int j = 0; j < nPreviousParentStates; j++) {
              ColumnGroup group = previousCGroupList.get(columnIndex - 1);
              cGroup.add(group);
              columnIndex++;
            }
          } else {
            for (int j = 0; j < sizeColumn; j++) {
              cGroup.add(cModel.getColumn(columnIndex++));
            }
          }
          cGroupList.add(cGroup);
        }
      }
      previousCGroupList = cGroupList;
      cGroupList = new ArrayList<ColumnGroup>();
      firstNode = false;
      // Update the number of states
      nStates /= nPreviousParentStates;
    }
    // It adds all parents' node name as header
    if (cNodeGroup != null) {
      cModel.addColumnGroup(cNodeGroup);
    }
    // It adds only the first row (here it is the last parent's states)
    // of the header that has all other headers (all other parent's states)
    // as sub-headers.
    if (previousCGroupList != null) {
      for (ColumnGroup group : previousCGroupList) {
        cModel.addColumnGroup(group);
      }
    }
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    return table;
  }
コード例 #23
0
 @SuppressWarnings("unchecked")
 private JTable createTable() {
   Part part = mainFrame.getCurrentPart();
   BookModel model = mainFrame.getBookModel();
   Session session = model.beginTransaction();
   PersonDAOImpl personDAO = new PersonDAOImpl(session);
   List persons = personDAO.findByCategories(selectedCategories);
   SceneDAOImpl sceneDAO = new SceneDAOImpl(session);
   List scenes = sceneDAO.findByPart(part);
   model.commit();
   String[] string1 = new String[scenes.size() + 1];
   string1[0] = "";
   int i = 1;
   Object scenesIterator = scenes.iterator();
   while (((Iterator) scenesIterator).hasNext()) {
     Scene scene = (Scene) ((Iterator) scenesIterator).next();
     string1[i] = ((Scene) scene).getChapterSceneNo(false);
     i++;
   }
   scenesIterator = new ArrayList();
   String[] string2 = new String[scenes.size() + 1];
   Iterator personsIterator = persons.iterator();
   Object localObject6;
   while (personsIterator.hasNext()) {
     Person person = (Person) personsIterator.next();
     int j = 0;
     Object[] string3 = new Object[scenes.size() + 1];
     string3[(j++)] = person.getAbbreviation();
     int n = 0;
     localObject6 = scenes.iterator();
     while (((Iterator) localObject6).hasNext()) {
       Scene localScene = (Scene) ((Iterator) localObject6).next();
       if (localScene.getPersons().contains(person)) {
         n = 1;
         string3[j] = ColorUtil.darker(localScene.getStrand().getJColor(), 0.05D);
       } else {
         string3[j] = null;
       }
       string2[j] = HtmlUtil.wrapIntoTable(localScene.getTitleText(true, 500));
       j++;
     }
     if ((cbShowUnusedPersons == null) || (cbShowUnusedPersons.isSelected()) || (n != 0)) {
       ((List) scenesIterator).add(string3);
     }
   }
   Object[][] localObject31 = new Object[((List) scenesIterator).size()][];
   i = 0;
   Iterator localObject4 = ((List) scenesIterator).iterator();
   while (((Iterator) localObject4).hasNext()) {
     Object[] arrayOfObject1 = (Object[]) ((Iterator) localObject4).next();
     localObject31[(i++)] = arrayOfObject1;
   }
   JTable ntable = new ReadOnlyTable((Object[][]) localObject31, string1);
   if (ntable.getModel().getRowCount() == 0) {
     return ntable;
   }
   ntable.getColumnModel().getColumn(0).setPreferredWidth(200);
   ntable.getColumnModel().getColumn(0).setCellRenderer(new HeaderTableCellRenderer());
   for (int k = 1; k < ntable.getColumnCount(); k++) {
     int m = ntable.getColumnModel().getColumn(k).getModelIndex();
     Object localObject5 = ntable.getModel().getValueAt(0, m);
     localObject6 = ntable.getColumnModel().getColumn(k);
     if ((localObject5 == null) || ((localObject5 instanceof Color))) {
       ((TableColumn) localObject6).setPreferredWidth(colWidth);
       ((TableColumn) localObject6).setCellRenderer(new ColorTableCellRenderer(false));
     }
   }
   ntable.setAutoResizeMode(0);
   ntable.getTableHeader().setReorderingAllowed(false);
   ToolTipHeader localToolTipHeader = new ToolTipHeader(ntable.getColumnModel());
   localToolTipHeader.setToolTipStrings((String[]) string2);
   localToolTipHeader.setToolTipText("Default ToolTip TEXT");
   ntable.setTableHeader(localToolTipHeader);
   return ntable;
 }
コード例 #24
0
  /**
   * @param stylesPreferencesKey the preferences key with the list of active style sources
   *     (filenames and URLs)
   * @param iconsPreferenceKey the preference key with the list of icon sources (can be null)
   * @param availableStylesUrl the URL to the list of available style sources
   */
  public StyleSourceEditor(
      String stylesPreferencesKey, String iconsPreferenceKey, final String availableStylesUrl) {

    DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
    tblActiveStyles = new JTable(activeStylesModel = new ActiveStylesModel(selectionModel));
    tblActiveStyles.putClientProperty("terminateEditOnFocusLost", true);
    tblActiveStyles.setSelectionModel(selectionModel);
    tblActiveStyles.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    tblActiveStyles.setTableHeader(null);
    tblActiveStyles.getColumnModel().getColumn(0).setCellEditor(new FileOrUrlCellEditor());
    tblActiveStyles.setRowHeight(20);
    activeStylesModel.setActiveStyles(Main.pref.getCollection(stylesPreferencesKey, null));

    selectionModel = new DefaultListSelectionModel();
    lstAvailableStyles =
        new JList(availableStylesModel = new AvailableStylesListModel(selectionModel));
    lstAvailableStyles.setSelectionModel(selectionModel);
    lstAvailableStyles.setCellRenderer(new StyleSourceCellRenderer());
    // availableStylesModel.setStyleSources(reloadAvailableStyles(availableStylesUrl));
    this.availableStylesUrl = availableStylesUrl;

    this.pref = stylesPreferencesKey;
    this.iconpref = iconsPreferenceKey;

    JButton iconadd = null;
    JButton iconedit = null;
    JButton icondelete = null;

    if (iconsPreferenceKey != null) {
      selectionModel = new DefaultListSelectionModel();
      tblIconPaths = new JTable(iconPathsModel = new IconPathTableModel(selectionModel));
      tblIconPaths.setSelectionModel(selectionModel);
      tblIconPaths.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
      tblIconPaths.setTableHeader(null);
      tblIconPaths.getColumnModel().getColumn(0).setCellEditor(new FileOrUrlCellEditor());
      tblIconPaths.setRowHeight(20);
      iconPathsModel.setIconPaths(Main.pref.getCollection(iconsPreferenceKey, null));

      iconadd = new JButton(new NewIconPathAction());

      EditIconPathAction editIconPathAction = new EditIconPathAction();
      tblIconPaths.getSelectionModel().addListSelectionListener(editIconPathAction);
      iconedit = new JButton(editIconPathAction);

      RemoveIconPathAction removeIconPathAction = new RemoveIconPathAction();
      tblIconPaths.getSelectionModel().addListSelectionListener(removeIconPathAction);
      icondelete = new JButton(removeIconPathAction);
      tblIconPaths
          .getInputMap(JComponent.WHEN_FOCUSED)
          .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete");
      tblIconPaths.getActionMap().put("delete", removeIconPathAction);
    }

    JButton add = new JButton(new NewActiveStyleAction());

    EditActiveStyleAction editActiveStyleAction = new EditActiveStyleAction();
    tblActiveStyles.getSelectionModel().addListSelectionListener(editActiveStyleAction);
    JButton edit = new JButton(editActiveStyleAction);

    RemoveActiveStylesAction removeActiveStylesAction = new RemoveActiveStylesAction();
    tblActiveStyles.getSelectionModel().addListSelectionListener(removeActiveStylesAction);
    tblActiveStyles
        .getInputMap(JComponent.WHEN_FOCUSED)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete");
    tblActiveStyles.getActionMap().put("delete", removeActiveStylesAction);
    JButton delete = new JButton(removeActiveStylesAction);

    ActivateStylesAction activateStylesAction = new ActivateStylesAction();
    lstAvailableStyles.addListSelectionListener(activateStylesAction);
    JButton copy = new JButton(activateStylesAction);

    JButton update = new JButton(new ReloadStylesAction(availableStylesUrl));

    setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    setLayout(new GridBagLayout());
    add(new JLabel(tr("Active styles")), GBC.eol().insets(5, 5, 5, 0));
    JScrollPane sp;
    add(sp = new JScrollPane(tblActiveStyles), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
    sp.setColumnHeaderView(null);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
    buttonPanel.add(add, GBC.std().insets(0, 5, 0, 0));
    buttonPanel.add(edit, GBC.std().insets(5, 5, 5, 0));
    buttonPanel.add(delete, GBC.std().insets(0, 5, 5, 0));
    buttonPanel.add(copy, GBC.std().insets(0, 5, 5, 0));
    add(
        new JLabel(tr("Available styles (from {0})", availableStylesUrl)),
        GBC.eol().insets(5, 5, 5, 0));
    add(new JScrollPane(lstAvailableStyles), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
    buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
    buttonPanel.add(update, GBC.std().insets(0, 5, 0, 0));
    if (tblIconPaths != null) {
      add(new JLabel(tr("Icon paths")), GBC.eol().insets(5, -5, 5, 0));
      add(sp = new JScrollPane(tblIconPaths), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
      sp.setColumnHeaderView(null);
      buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
      add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
      buttonPanel.add(iconadd);
      buttonPanel.add(iconedit);
      buttonPanel.add(icondelete);
    }
  }
コード例 #25
-1
  public OpenDecisionsPanel() {
    odList_ = new Vector<List<String>>();
    snList_ = new Vector<Integer>();
    ledList_ = new Vector<String>();

    currentIdx_ = -1;

    labelTotal_ = new JLabel(makeLabelTotal(), SwingConstants.CENTER);
    labelCurrent_ = new JLabel(makeLabelCurrent(), SwingConstants.CENTER);
    JPanel btnPanel = new JPanel(new FlowLayout());

    btnPrev_ = new JButton("<<");
    btnPrev_.addActionListener(this);
    btnPrev_.setActionCommand("prev");
    btnNext_ = new JButton(">>");
    btnNext_.addActionListener(this);
    btnNext_.setActionCommand("next");
    checkButtons();
    JButton btn;
    btn = new JButton("Go To Step");
    btn.addActionListener(this);
    btn.setActionCommand("goto");

    gotoIdx_ = new JTextField(6);
    btnPanel.add(btnPrev_);
    btnPanel.add(btnNext_);
    btnPanel.add(btn);
    btnPanel.add(gotoIdx_);

    lastExecutedDecision_ = new JTextArea(5, 10);
    lastExecutedDecision_.setLineWrap(true);

    JPanel topPanel = new JPanel(new BorderLayout());
    JPanel p = new JPanel(new GridLayout(3, 1));
    p.add(labelTotal_);
    p.add(btnPanel);
    p.add(new JLabel("Last Executed Decision", SwingConstants.CENTER));

    ledTable_ = new JTable();
    ledTable_.setTableHeader(null);
    ledTable_.setPreferredScrollableViewportSize(new Dimension(500, 70));

    JTabbedPane tp = new JTabbedPane();
    tp.addTab("As Table", new JScrollPane(ledTable_));
    tp.addTab("As Text", new JScrollPane(lastExecutedDecision_));

    topPanel.add(BorderLayout.NORTH, p);
    topPanel.add(BorderLayout.CENTER, tp);
    odTable_ = new JTable(Util.makeTableModel(odList_, new String[] {"toString"}));
    odTable_.setTableHeader(null);
    odTable_.setPreferredScrollableViewportSize(new Dimension(500, 70));

    setLayout(new BorderLayout());
    add(BorderLayout.NORTH, topPanel);

    JPanel odPanel = new JPanel(new BorderLayout());
    odPanel.add(BorderLayout.NORTH, labelCurrent_);
    odPanel.add(BorderLayout.CENTER, new JScrollPane(odTable_));
    add(BorderLayout.CENTER, odPanel);
  }