public CFSecuritySwingISOTimezoneFinderJPanel(ICFSecuritySwingSchema argSchema) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   swingSchema = argSchema;
   dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
   dataTable.addMouseListener(getDataListMouseAdapter());
   dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   dataTable.setUpdateSelectionOnSort(true);
   dataTable.setRowHeight(25);
   getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
   dataScrollPane =
       new JScrollPane(
           dataTable,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   dataScrollPane.setColumnHeader(
       new JViewport() {
         @Override
         public Dimension getPreferredSize() {
           Dimension sz = super.getPreferredSize();
           sz.height = 25;
           return (sz);
         }
       });
   dataTable.setFillsViewportHeight(true);
   add(dataScrollPane);
   loadData(true);
   doLayout();
   swingIsInitializing = false;
 }
 protected void createWidgets() {
   ReadOnlyTableModel<B> model = new ReadOnlyTableModel<>(getAssignments());
   model.addColumn(
       "Profesor",
       "request",
       new ToStringConverter<Request>() {
         @Override
         public String convert(Request aRequest) {
           return aRequest.getProfessor().getName();
         }
       });
   model.addColumn(
       "Materia",
       "request",
       new ToStringConverter<Request>() {
         @Override
         public String convert(Request aRequest) {
           return aRequest.getSubject().getName();
         }
       });
   assignmentsTable = new JTable(model);
   assignmentsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   assignmentsTable
       .getSelectionModel()
       .addListSelectionListener(
           AssignmentsDetailWindow.this::whenAssignmentsTableSelectionChanged);
   periodDetail = new JTextArea();
   periodDetail.setPreferredSize(new Dimension(480, 100));
   periodDetail.setEditable(false);
   createOtherWidgets();
 }
예제 #3
0
  public void update() {
    infoPanel.update();

    Object[][] history = new Object[account.getHistory().size()][5];
    int i = 0;
    for (Transaction t : account.getHistory()) {
      history[i][0] = t.getType();
      BigDecimal amount;
      BigDecimal balance;
      if (account.getType().isLoan()) {
        amount = (t.getType().isPositive() ? t.getAmount().negate() : t.getAmount());
        balance = t.getBalance().negate();
      } else {
        amount = (t.getType().isPositive() ? t.getAmount() : t.getAmount().negate());
        balance = t.getBalance();
      }
      history[i][1] = FORMATTER.valueToString(amount);
      history[i][2] = FORMATTER.valueToString(balance);
      history[i][3] = t.getTimestamp();
      history[i][4] = t.getFraudStatus();
      i++;
    }
    historyTable.setModel(
        new javax.swing.table.DefaultTableModel(
            history, new String[] {"Type", "Amount", "Balance", "Month", "Flag"}) {
          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        });
    historyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    historyTable.revalidate();
  }
 /** Creates and displays the main GUI This GUI has the list and the main * buttons */
 public void showGUI() {
   final JScrollPane scrollPane = new JScrollPane();
   table =
       new JTable(
           new DefaultTableModel(
               new Object[][] {}, new String[] {"Username", "Password", "Pin", "Reward"}));
   AccountManager.loadAccounts();
   if (AccountManager.hasAccounts()) {
     for (Account account : AccountManager.getAccounts()) {
       ((DefaultTableModel) table.getModel())
           .addRow(
               new Object[] {
                 account.getUsername(), account.getReward(), account.getPin(), account.getReward()
               });
     }
   }
   final JToolBar bar = new JToolBar();
   bar.setMargin(new Insets(1, 1, 1, 1));
   bar.setFloatable(false);
   removeButton = new JButton("Remove");
   final JButton newButton = new JButton("Add");
   final JButton doneButton = new JButton("Save");
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   table.getSelectionModel().addListSelectionListener(new TableSelectionListener());
   table.setShowGrid(true);
   final TableColumnModel cm = table.getColumnModel();
   cm.getColumn(cm.getColumnIndex("Password")).setCellRenderer(new PasswordCellRenderer());
   cm.getColumn(cm.getColumnIndex("Password")).setCellEditor(new PasswordCellEditor());
   cm.getColumn(cm.getColumnIndex("Pin")).setCellRenderer(new PasswordCellRenderer());
   cm.getColumn(cm.getColumnIndex("Pin")).setCellEditor(new PasswordCellEditor());
   cm.getColumn(cm.getColumnIndex("Reward")).setCellEditor(new RandomRewardEditor());
   scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   scrollPane.setViewportView(table);
   add(scrollPane, BorderLayout.CENTER);
   newButton.setFocusable(false);
   newButton.setToolTipText(newButton.getText());
   newButton.setText("+");
   bar.add(newButton);
   removeButton.setFocusable(false);
   removeButton.setToolTipText(removeButton.getText());
   removeButton.setText("-");
   bar.add(removeButton);
   bar.add(Box.createHorizontalGlue());
   doneButton.setToolTipText(doneButton.getText());
   bar.add(doneButton);
   newButton.addActionListener(this);
   removeButton.addActionListener(this);
   doneButton.addActionListener(this);
   add(bar, BorderLayout.SOUTH);
   final int row = table.getSelectedRow();
   removeButton.setEnabled(row >= 0 && row < table.getRowCount());
   table.clearSelection();
   doneButton.requestFocus();
   setPreferredSize(new Dimension(600, 300));
   pack();
   setLocationRelativeTo(getOwner());
   setResizable(false);
 }
 private void createClassroomsTable() {
   ReadOnlyTableModel<Classroom> tableModel =
       new ReadOnlyTableModel<>(department.getClassroomsDepartment().searchClassroomByName(""));
   addClassroomsColumns(tableModel);
   classroomsTable = new JTable(tableModel);
   classroomsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   classroomsTable
       .getSelectionModel()
       .addListSelectionListener(EditAssignmentWindow.this::whenClassroomsTableSelectionChanged);
   classroomsTableScrollPane = new JScrollPane(classroomsTable);
 }
 public CFInternetSwingVersionListJPanel(
     ICFInternetSwingSchema argSchema,
     ICFLibAnyObj argContainer,
     ICFInternetVersionObj argFocus,
     Collection<ICFInternetVersionObj> argDataCollection,
     ICFJRefreshCallback refreshCallback,
     boolean sortByChain) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   // argFocus is optional; focus may be set later during execution as
   // conditions of the runtime change.
   swingSchema = argSchema;
   swingFocus = argFocus;
   swingContainer = argContainer;
   swingRefreshCallback = refreshCallback;
   swingSortByChain = sortByChain;
   setSwingDataCollection(argDataCollection);
   dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
   dataTable.addMouseListener(getDataListMouseAdapter());
   dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   dataTable.setUpdateSelectionOnSort(true);
   dataTable.setRowHeight(25);
   getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
   dataScrollPane =
       new JScrollPane(
           dataTable,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   dataScrollPane.setColumnHeader(
       new JViewport() {
         @Override
         public Dimension getPreferredSize() {
           Dimension sz = super.getPreferredSize();
           sz.height = 25;
           return (sz);
         }
       });
   dataTable.setFillsViewportHeight(true);
   // Do initial layout
   setSize(1024, 480);
   JMenuBar menuBar = getPanelMenuBar();
   add(menuBar);
   menuBar.setBounds(0, 0, 1024, 25);
   add(dataScrollPane);
   dataScrollPane.setBounds(0, 25, 1024, 455);
   adjustListMenuBar();
   doLayout();
   swingIsInitializing = false;
 }
  public AppointmentGUI() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setBounds(100, 100, 500, 600); // window size
    setTitle("Appointment List"); // window title
    contentPane = new JPanel();
    contentPane.setBorder(
        new EmptyBorder(3, 6, 3, 6)); // distance the plane is from the edges of the window
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(0, 0));
    scrollPane = new JScrollPane();
    contentPane.add(scrollPane, BorderLayout.CENTER);

    table =
        new JTable(
            new DefaultTableModel(new Object[] {"Doctor's Name", "Location", "Date", "Time"}, 60)) {
          public boolean isCellEditable(
              int row,
              int column) { // prevents user from editing cells; there apparently is not a cleaner
            // way of doing this
            return false;
          }
        };
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setShowGrid(false);
    table.getTableHeader().setReorderingAllowed(false); // prevent user from swapping columns
    table.getTableHeader().setResizingAllowed(false); // prevent user from resizing columns
    table.setSelectionMode(
        ListSelectionModel
            .SINGLE_INTERVAL_SELECTION); // prevent user from selecting multiple doctors
    table.setAutoCreateColumnsFromModel(
        false); // forgot why I have this here; it's probably important

    scrollPane.setViewportView(table); // lets table be scroll able

    btnPane = new JPanel();
    btnPane.setLayout(new GridLayout(0, 2, 0, 0));
    contentPane.add(btnPane, BorderLayout.SOUTH);

    btnViewAppointment = new JButton("View Appointment");
    btnPane.add(btnViewAppointment);

    btnCancelAppointment = new JButton("Cancel Appointment");
    btnPane.add(btnCancelAppointment);

    btnUpdateAppointment = new JButton("Update Appointment");
    btnPane.add(btnUpdateAppointment);

    btnGoBack = new JButton("Go Back");
    btnPane.add(btnGoBack);
  }
  private void init() {
    setLayout(new BorderLayout());

    tableModel = new NotesTableModel(getCharacter());
    table = new JTable(tableModel);
    table.setRowHeight(50);
    tableModel.updateColumns(table);
    table.setDefaultRenderer(String.class, new NotesCellRenderer());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                updateControls();
              }
            });

    add(new JScrollPane(table), "Center");

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    addNoteButton = new JButton("Add Custom");
    addNoteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            String note = JOptionPane.showInputDialog("Custom Note");
            getCharacter().addNote(getGameHandler().getClient().getClientName(), "Custom", note);
            updatePanel();
          }
        });
    box.add(addNoteButton);
    box.add(Box.createHorizontalGlue());
    deleteNoteButton = new JButton("Delete Custom");
    deleteNoteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            Note note = getSelectedNote();
            if (note != null) {
              getCharacter().deleteNote(note.getId());
              updatePanel();
            }
          }
        });
    box.add(deleteNoteButton);
    box.add(Box.createHorizontalGlue());
    add(box, "South");

    updateControls();
  }
  public void update() {
    graphicPanel.removeAll();
    graphicPanel.add(title);
    graphicPanel.add(mainMenuButton);
    graphicPanel.add(refreshButton);
    graphicPanel.add(logoutButton);
    graphicPanel.setLayout(new FlowLayout());

    JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
    separator.setPreferredSize(new Dimension(600, 10));
    graphicPanel.add(separator);

    if (page.matches("main")) {
      graphicPanel.add(reportLocationButton);
      graphicPanel.add(loadShipmentButton);
    } else if (page.matches("reportloc")) {
      locationComboBox = new JComboBox(driver.getLocation().getNeighbours().toArray());
      graphicPanel.add(locationComboBox);
      graphicPanel.add(reportButton);
    } else if (page.matches("loadShipment")) {
      shipmentList = new ArrayList<Shipment>();

      for (int i = 0; i < driverService.getAssignedShipments().size(); ++i) {
        if (driverService.canPickup(driver, driverService.getAssignedShipments().get(i))) {
          shipmentList.add(driverService.getAssignedShipments().get(i));
        }
      }

      Object[][] tableContent = new Object[shipmentList.size()][shipmentTableColumnTitles.length];
      for (int i = 0; i < shipmentList.size(); ++i) {
        tableContent[i][0] = shipmentList.get(i).getType();
        tableContent[i][1] = shipmentList.get(i).getApproximateWeight();
        tableContent[i][2] = shipmentList.get(i).getDueDate();
        tableContent[i][3] = shipmentList.get(i).getDestination();
      }

      shipmentTable = new JTable(tableContent, shipmentTableColumnTitles);
      shipmentTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      JScrollPane tablePane = new JScrollPane(shipmentTable);
      tablePane.setPreferredSize(new Dimension(550, 250));
      graphicPanel.add(tablePane);
      graphicPanel.add(pickupButton);
    }

    graphicPanel.validate();
    graphicPanel.repaint();
  }
 public static void main(String[] args) {
   PropertyTableModel model = new PropertyTableModel(System.getProperties());
   JTable table = new JTable();
   table.setModel(model);
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   JScrollPane spane = new JScrollPane(table);
   JFrame frame = new JFrame("System Properties");
   frame.getContentPane().add(spane);
   frame.pack();
   frame.setVisible(true);
   frame.addWindowListener(
       new java.awt.event.WindowAdapter() {
         public void windowClosing(java.awt.event.WindowEvent e) {
           System.exit(0);
         };
       });
 }
예제 #11
0
  /** Creates an instance <tt>PropertiesEditorPanel</tt>. */
  public PropertiesEditorPanel() {
    super(new BorderLayout());

    /**
     * Instantiates the properties table and adds selection model and listener and adds a row sorter
     * to the table model
     */
    ResourceManagementService r = PropertiesEditorActivator.getResourceManagementService();
    String[] columnNames =
        new String[] {r.getI18NString("service.gui.NAME"), r.getI18NString("service.gui.VALUE")};

    propsTable = new JTable(new PropsTableModel(initTableModel(), columnNames));
    propsTable.setRowSorter(new TableRowSorter<TableModel>(propsTable.getModel()));
    propsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    PropsListSelectionListener selectionListener = new PropsListSelectionListener();

    propsTable.getSelectionModel().addListSelectionListener(selectionListener);
    propsTable.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener);

    JScrollPane scrollPane = new JScrollPane(propsTable);
    SearchField searchField = new SearchField("", propsTable);

    buttonsPanel = new ButtonsPanel(propsTable, searchField);

    centerPanel = new TransparentPanel(new BorderLayout());
    centerPanel.add(scrollPane, BorderLayout.CENTER);
    centerPanel.add(buttonsPanel, BorderLayout.EAST);

    JLabel needRestart = new JLabel(r.getI18NString("plugin.propertieseditor.NEED_RESTART"));

    needRestart.setForeground(Color.RED);

    TransparentPanel searchPanel = new TransparentPanel(new BorderLayout(5, 0));

    searchPanel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    searchPanel.add(searchField, BorderLayout.CENTER);

    setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
    add(searchPanel, BorderLayout.NORTH);
    add(centerPanel, BorderLayout.CENTER);
    add(needRestart, BorderLayout.SOUTH);
  }
예제 #12
0
  public static void main(String[] xx) {
    JFrame fr = new JFrame("belajar table");

    MahasiswaTableModel model = new MahasiswaTableModel(data);
    model.addTableModelListener(new TabelDiubahListener());
    tabel.setModel(model);

    tabel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tabel.getSelectionModel().addListSelectionListener(new TabelDipilihListener());

    JScrollPane scrTabel = new JScrollPane(tabel);

    JTextArea txtOutput = new JTextArea(5, 20);
    JScrollPane scrText = new JScrollPane(txtOutput);

    fr.getContentPane().add(scrText, BorderLayout.SOUTH);
    fr.getContentPane().add(scrTabel, BorderLayout.CENTER);

    fr.setSize(600, 600);
    fr.setLocationRelativeTo(null);
    fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    fr.setVisible(true);
  }
  void tableInitialise(JTable table) {

    JScrollPane scroll;
    TableColumn column = null;

    int colunms = table.getColumnCount();
    for (int y = 0; y < colunms; y++) {
      column = table.getColumnModel().getColumn(y);
      /*将每一列的默认宽度设置为100*/
      column.setPreferredWidth(100);
    }
    /*
     * 设置JTable自动调整列表的状态,此处设置为关闭
     */
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    table.setFont(new Font("Menu.font", Font.PLAIN, 14));
    table.getTableHeader().setFont(new Font("Menu.font", Font.BOLD, 15));
    /*用JScrollPane装载JTable,这样超出范围的列就可以通过滚动条来查看*/

    scroll = new JScrollPane(table);
    TablePanel.removeAll();

    TablePanel.setLayout(new BoxLayout(TablePanel, BoxLayout.Y_AXIS));
    TablePanel.add(scroll);

    TablePanel.revalidate();

    table.setRowSelectionAllowed(true); // 设置JTable可被选择
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 设置JTable为单行选择
    table.getTableHeader().setBackground(new Color(206, 231, 255)); // 设置JTable表头颜色
    table.getTableHeader().setReorderingAllowed(false); // 设置JTable每个字段的顺序不可以改变
    table.getTableHeader().setResizingAllowed(false); // 设置JTable每个表头的大小不可以改变
    makeFace(table); // 设置JTable 颜色

    table.setVisible(true);
  }
예제 #14
0
  public DownloadGUI() {

    setTitle("Rav's Download Manager");

    setSize(640, 480);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            actionExit();
          }
        });

    JPanel addPanel = new JPanel();
    pauseButton = new JButton("", new ImageIcon("icons/pause.gif"));
    pauseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPause();
          }
        });
    pauseButton.setEnabled(false);
    addPanel.add(pauseButton);
    resumeButton = new JButton("", new ImageIcon("icons/resume.gif"));
    resumeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionResume();
          }
        });
    resumeButton.setEnabled(false);
    addPanel.add(resumeButton);
    cancelButton = new JButton("", new ImageIcon("icons/cancel.gif"));
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionCancel();
          }
        });
    cancelButton.setEnabled(false);
    addPanel.add(cancelButton);
    clearButton = new JButton("", new ImageIcon("icons/clear.gif"));
    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionClear();
          }
        });
    clearButton.setEnabled(false);
    addPanel.add(clearButton);

    JPanel addPane2 = new JPanel();
    addTextField = new JTextField(30);
    addPane2.add(addTextField);
    JButton addButton = new JButton("", new ImageIcon("icons/add.gif"));
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionAdd();
          }
        });
    addPane2.add(addButton);

    tableModel = new DownloadList();
    table = new JTable(tableModel);
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                tableSelectionChanged();
              }
            });

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ProgressBar renderer = new ProgressBar(0, 100);
    renderer.setStringPainted(true);
    table.setDefaultRenderer(JProgressBar.class, renderer);

    table.setRowHeight((int) renderer.getPreferredSize().getHeight());

    JPanel downloadsPanel = new JPanel();
    downloadsPanel.setBorder(BorderFactory.createTitledBorder("Downloads"));
    downloadsPanel.setLayout(new BorderLayout());
    downloadsPanel.add(new JScrollPane(table), BorderLayout.CENTER);

    getContentPane().setLayout(new GridLayout(3, 1));
    getContentPane().add(addPane2);
    getContentPane().add(addPanel);
    getContentPane().add(downloadsPanel);
  }
예제 #15
0
  /** 公開スタンプブラウズペインを生成する。 */
  private JPanel createBrowsePane() {

    JPanel browsePane = new JPanel();

    tableModel = new ListTableModel<PublishedTreeModel>(COLUMN_NAMES, 10, METHOD_NAMES, CLASSES);
    browseTable = new JTable(tableModel);
    for (int i = 0; i < COLUMN_WIDTH.length; i++) {
      browseTable.getColumnModel().getColumn(i).setPreferredWidth(COLUMN_WIDTH[i]);
    }
    browseTable.setDefaultRenderer(Object.class, new OddEvenRowRenderer());

    importBtn = new JButton("インポート");
    importBtn.setEnabled(false);
    cancelBtn = new JButton("閉じる");
    deleteBtn = new JButton("削除");
    deleteBtn.setEnabled(false);
    publicLabel = new JLabel("グローバル", WEB_ICON, SwingConstants.CENTER);
    localLabel = new JLabel("院内", HOME_ICON, SwingConstants.CENTER);
    importedLabel = new JLabel("インポート済", FLAG_ICON, SwingConstants.CENTER);

    JScrollPane tableScroller = new JScrollPane(browseTable);
    tableScroller.getViewport().setPreferredSize(new Dimension(730, 380));

    // レイアウトする
    browsePane.setLayout(new BorderLayout(0, 17));
    JPanel flagPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 7, 5));
    flagPanel.add(localLabel);
    flagPanel.add(publicLabel);
    flagPanel.add(importedLabel);
    JPanel cmdPanel =
        GUIFactory.createCommandButtonPanel(new JButton[] {cancelBtn, deleteBtn, importBtn});
    browsePane.add(flagPanel, BorderLayout.NORTH);
    browsePane.add(tableScroller, BorderLayout.CENTER);
    browsePane.add(cmdPanel, BorderLayout.SOUTH);

    // レンダラを設定する
    PublishTypeRenderer pubTypeRenderer = new PublishTypeRenderer();
    browseTable.getColumnModel().getColumn(4).setCellRenderer(pubTypeRenderer);
    ImportedRenderer importedRenderer = new ImportedRenderer();
    browseTable.getColumnModel().getColumn(5).setCellRenderer(importedRenderer);

    // BrowseTableをシングルセレクションにする
    browseTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel sleModel = browseTable.getSelectionModel();
    sleModel.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
              int row = browseTable.getSelectedRow();
              PublishedTreeModel model = tableModel.getObject(row);
              if (model != null) {
                if (model.isImported()) {
                  importBtn.setEnabled(false);
                  deleteBtn.setEnabled(true);
                } else {
                  importBtn.setEnabled(true);
                  deleteBtn.setEnabled(false);
                }
              } else {
                importBtn.setEnabled(false);
                deleteBtn.setEnabled(false);
              }
            }
          }
        });

    // import
    importBtn.addActionListener(
        new ActionListener() {

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

    // remove
    deleteBtn.addActionListener(
        new ActionListener() {

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

    // キャンセル
    cancelBtn.addActionListener(
        new ActionListener() {

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

    return browsePane;
  }
예제 #16
0
  /**
   * Create a new, empty, not-visible TaxRef window. Really just activates the setup frame and setup
   * memory monitor components, then starts things off.
   */
  public MainFrame() {
    setupMemoryMonitor();

    // Set up the main frame.
    mainFrame = new JFrame(basicTitle);
    mainFrame.setJMenuBar(setupMenuBar());
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set up the JTable.
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setSelectionBackground(COLOR_SELECTION_BACKGROUND);
    table.setShowGrid(true);

    // Add a blank table model so that the component renders properly on
    // startup.
    table.setModel(blankDataModel);

    // Add a list selection listener so we can tell the matchInfoPanel
    // that a new name was selected.
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (currentCSV == null) return;

                int row = table.getSelectedRow();
                int column = table.getSelectedColumn();

                columnInfoPanel.columnChanged(column);

                Object o = table.getModel().getValueAt(row, column);
                if (Name.class.isAssignableFrom(o.getClass())) {
                  matchInfoPanel.nameSelected(currentCSV.getRowIndex(), (Name) o, row, column);
                } else {
                  matchInfoPanel.nameSelected(currentCSV.getRowIndex(), null, -1, -1);
                }
              }
            });

    // Set up the left panel (table + matchInfoPanel)
    JPanel leftPanel = new JPanel();

    matchInfoPanel = new MatchInformationPanel(this);
    leftPanel.setLayout(new BorderLayout());
    leftPanel.add(matchInfoPanel, BorderLayout.SOUTH);
    leftPanel.add(new JScrollPane(table));

    // Set up the right panel (columnInfoPanel)
    JPanel rightPanel = new JPanel();

    columnInfoPanel = new ColumnInformationPanel(this);

    progressBar.setStringPainted(true);

    rightPanel.setLayout(new BorderLayout());
    rightPanel.add(columnInfoPanel);
    rightPanel.add(progressBar, BorderLayout.SOUTH);

    // Set up a JSplitPane to split the panels up.
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, leftPanel, rightPanel);
    split.setResizeWeight(1);
    mainFrame.add(split);
    mainFrame.pack();

    // Set up a drop target so we can pick up files
    mainFrame.setDropTarget(
        new DropTarget(
            mainFrame,
            new DropTargetAdapter() {
              @Override
              public void dragEnter(DropTargetDragEvent dtde) {
                // Accept any drags.
                dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
              }

              @Override
              public void dragOver(DropTargetDragEvent dtde) {}

              @Override
              public void dropActionChanged(DropTargetDragEvent dtde) {}

              @Override
              public void dragExit(DropTargetEvent dte) {}

              @Override
              public void drop(DropTargetDropEvent dtde) {
                // Accept a drop as long as its File List.

                if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                  dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

                  Transferable t = dtde.getTransferable();

                  try {
                    java.util.List<File> files =
                        (java.util.List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);

                    // If we're given multiple files, pick up only the last file and load that.
                    File f = files.get(files.size() - 1);
                    loadFile(f, DarwinCSV.FILE_CSV_DELIMITED);

                  } catch (UnsupportedFlavorException ex) {
                    dtde.dropComplete(false);

                  } catch (IOException ex) {
                    dtde.dropComplete(false);
                  }
                }
              }
            }));
  }
예제 #17
0
  // ambil data dari database untuk tabel
  public void setDataTabel() {
    // combobox jenis
    JComboBox cbJenis = new JComboBox();
    cbJenis.setModel(new DefaultComboBoxModel(dataJenis.toArray()));

    dataProduk = new ArrayList<Produk>();
    try {
      String qry =
          "SELECT * FROM produk,suplier,jenis,stok_produk WHERE produk.id_jenis = jenis.id_jenis AND produk.id_suplier = suplier.id_suplier AND produk.id_produk=stok_produk.id_produk";
      ResultSet rs = stm.executeQuery(qry);
      while (rs.next()) {
        Produk p = new Produk();
        p.setIdProduk(rs.getInt("id_produk"));
        p.setNamaProduk(rs.getString("nama_produk"));
        p.setJenis(rs.getString("nama_jenis"));
        p.setHarga(rs.getInt("harga"));
        p.setStok(rs.getInt("stok"));
        p.setNamaSuplier(rs.getString("nama_suplier"));

        p.setComboJenis(cbJenis);

        dataProduk.add(p);
      }
    } catch (Exception err) {
      err.printStackTrace();
    }

    model = new TableModelProduk(dataProduk);
    tabel.setModel(model);
    tabel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    class EditProdukListener implements TableModelListener {
      public void tableChanged(TableModelEvent tme) {
        int baris = tme.getFirstRow();
        int kolom = tme.getColumn();

        TableModel model = (TableModel) tme.getSource();
        int id = (Integer) model.getValueAt(baris, 0);

        String query = "";
        switch (kolom) {
          case 1:
            String nama = (String) model.getValueAt(baris, kolom);
            query = "UPDATE produk SET nama_produk='" + nama + "' WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 2:
            String jenis = (String) model.getValueAt(baris, kolom);
            try {
              query = "select * from jenis where nama_jenis='" + jenis + "'";
              ResultSet rs = stm.executeQuery(query);
              if (rs.next()) {
                int idJenis = rs.getInt("id_jenis");
                query = "UPDATE produk SET id_jenis=" + idJenis + " WHERE id_produk=" + id;
                prosesEdit(query);
              } else {
                setDataTabel();
                JOptionPane.showMessageDialog(null, "gagal,jenis tidak ada");
              }
            } catch (SQLException SQLerr) {
              SQLerr.printStackTrace();
            }
            break;
          case 3:
            int stok = (Integer) model.getValueAt(baris, kolom);
            query = "UPDATE `stok_produk` SET stok=" + stok + " WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 4:
            int harga = (Integer) model.getValueAt(baris, kolom);
            query = "UPDATE produk SET harga=" + harga + " WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 5:
            String suplier = (String) model.getValueAt(baris, kolom);
            try {
              query = "SELECT * FROM suplier WHERE nama_suplier='" + suplier + "'";
              ResultSet rs = stm.executeQuery(query);
              if (rs.next()) {
                int idSuplier = rs.getInt("id_suplier");
                query = "UPDATE produk SET id_suplier=" + idSuplier + " WHERE id_produk=" + id;
                prosesEdit(query);
              } else {
                setDataTabel();
                JOptionPane.showMessageDialog(null, "gagal,suplier belum terdaftar");
              }
            } catch (SQLException SQLerr) {
              SQLerr.printStackTrace();
            }
            break;
          default:
            break;
        }
      }

      private void prosesEdit(String query) {
        try {
          int hasil = stm.executeUpdate(query);
          if (hasil == 1) {
            setDataTabel();
            JOptionPane.showMessageDialog(null, "edit berhasil");
          } else {
            JOptionPane.showMessageDialog(null, "gagal");
          }
        } catch (SQLException SQLerr) {
          SQLerr.printStackTrace();
        }
      }
    }
    model.addTableModelListener(new EditProdukListener());
  }
예제 #18
0
  private void addInformationPanel() {
    // Create UI elements for connection information.
    JPanel informationPanel = new JPanel();
    informationPanel.setLayout(new BorderLayout());

    // Add the Host information
    JPanel connPanel = new JPanel();
    connPanel.setLayout(new GridBagLayout());
    connPanel.setBorder(BorderFactory.createTitledBorder("Connection information"));

    JLabel label = new JLabel("Host: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    JFormattedTextField field = new JFormattedTextField(connection.getServiceName());
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the Port information
    label = new JLabel("Port: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    field = new JFormattedTextField(connection.getPort());
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the connection's User information
    label = new JLabel("User: "******"Creation time: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    field = new JFormattedTextField(new SimpleDateFormat("yyyy.MM.dd hh:mm:ss:SS aaa"));
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setValue(creationTime);
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the connection's creationTime information
    label = new JLabel("Status: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    statusField = new JFormattedTextField();
    statusField.setMinimumSize(new java.awt.Dimension(150, 20));
    statusField.setMaximumSize(new java.awt.Dimension(150, 20));
    statusField.setValue("Active");
    statusField.setEditable(false);
    statusField.setBorder(null);
    connPanel.add(
        statusField,
        new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
    // Add the connection panel to the information panel
    informationPanel.add(connPanel, BorderLayout.NORTH);

    // Add the Number of sent packets information
    JPanel packetsPanel = new JPanel();
    packetsPanel.setLayout(new GridLayout(1, 1));
    packetsPanel.setBorder(BorderFactory.createTitledBorder("Transmitted Packets"));

    statisticsTable =
        new DefaultTableModel(
            new Object[][] {
              {"IQ", 0, 0}, {"Message", 0, 0}, {"Presence", 0, 0}, {"Other", 0, 0}, {"Total", 0, 0}
            },
            new Object[] {"Type", "Received", "Sent"}) {
          private static final long serialVersionUID = -6793886085109589269L;

          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }
        };
    JTable table = new JTable(statisticsTable);
    // Allow only single a selection
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    packetsPanel.add(new JScrollPane(table));

    // Add the packets panel to the information panel
    informationPanel.add(packetsPanel, BorderLayout.CENTER);

    tabbedPane.add("Information", new JScrollPane(informationPanel));
    tabbedPane.setToolTipTextAt(4, "Information and statistics about the debugged connection");
  }
  public AutoFocusator() {
    super(new BorderLayout());

    taskList = new TaskList();
    Task task0 = new Task("Use right click to change the states of the tasks.");
    taskList.add(task0);
    Task task1 = new Task("Just play araound with this small app.");
    taskList.add(task1);
    Task task2 = new Task("Check http://sourceforge.net/projects/autofocusator/");
    taskList.add(task2);

    // task1.setState(State.crossed);
    // task0.setState(State.dismissed);

    table = new JTable(taskList);
    table.setPreferredScrollableViewportSize(new Dimension(500, 700));
    table.setFillsViewportHeight(true);
    table.getColumnModel().getColumn(0).setPreferredWidth(300);
    table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    table.setRowSelectionAllowed(true);

    table.getColumnModel().getColumn(0).setCellRenderer(new TaskRenderer());
    // TableCellRenderer renderer = table.getColumnModel().getColumn(0).getCellRenderer();
    // double height = ((TaskRenderer)renderer).getRendererHeight();

    // @todo: The height should be set dependent on the content
    table.setRowHeight(28);

    table.getModel().addTableModelListener(this);

    toolBar = new JToolBar("Autofocusator - Toolbar");

    JButton buttonAddTask = new JButton("Add a Task", new ImageIcon(loadPics("res/list-add.png")));
    buttonAddTask.setActionCommand("addTask");
    buttonAddTask.addActionListener(this);
    toolBar.add(buttonAddTask);

    JButton buttonDeleteTask =
        new JButton("Delete a Task", new ImageIcon(loadPics("res/list-remove.png")));
    buttonDeleteTask.setActionCommand("deleteTask");
    buttonDeleteTask.addActionListener(this);
    toolBar.add(buttonDeleteTask);

    JButton buttonSave = new JButton("Save", new ImageIcon(loadPics("res/document-save-as.png")));
    buttonSave.setActionCommand("save");
    buttonSave.addActionListener(this);
    toolBar.add(buttonSave);

    JButton buttonOpen = new JButton("open", new ImageIcon(loadPics("res/document-open.png")));
    buttonOpen.setActionCommand("open");
    buttonOpen.addActionListener(this);
    toolBar.add(buttonOpen);

    add(toolBar, BorderLayout.NORTH);

    contextMenu = new JPopupMenu();
    JMenuItem contextMenuItem;
    contextMenuItem = new JMenuItem("delete Task");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("deleteTask");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("add Task");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("addTask");
    contextMenu.add(contextMenuItem);

    contextMenu.addSeparator();

    contextMenuItem = new JMenuItem("cross");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("cross");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("dismiss");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("dismiss");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("worked on");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("workedOn");
    contextMenu.add(contextMenuItem);

    fileChooser = new JFileChooser();
    FileFilter filter = new FileNameExtensionFilter("XML File", "xml");
    fileChooser.addChoosableFileFilter(filter);

    table.addMouseListener(this);

    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane, BorderLayout.CENTER);
  }
예제 #20
0
  public TableModelDemo() {

    try {
      // Load the JDBC driver
      Class.forName("com.mysql.jdbc.Driver");
      Class.forName("oracle.jdbc.driver.OracleDriver");
      System.out.println("Driver loaded");

      // Create a row set
      rowSet = new CachedRowSetImpl();

      // Set RowSet properties
      //      rowSet.setUrl("jdbc:mysql://localhost/javabook");
      rowSet.setUrl("jdbc:oracle:thin:@liang.armstrong.edu:1521:orcl");
      rowSet.setUsername("scott");
      rowSet.setPassword("tiger");

      rowSet.setCommand("select * from StateCapital");

      rowSet.setConcurrency(ResultSet.CONCUR_UPDATABLE);
      rowSet.execute();
      tableModel.setRowSet(rowSet);
      rowSet.addRowSetListener(tableModel);
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayout(2, 2));
    panel1.add(jbtAddRow);
    panel1.add(jbtAddColumn);
    panel1.add(jbtDeleteRow);
    panel1.add(jbtDeleteColumn);

    JPanel panel2 = new JPanel();
    panel2.add(jbtSave);
    panel2.add(jbtClear);
    panel2.add(jbtRestore);

    JPanel panel3 = new JPanel();
    panel3.setLayout(new BorderLayout(5, 0));
    panel3.add(new JLabel("Selection Mode"), BorderLayout.WEST);
    panel3.add(jcboSelectionMode, BorderLayout.CENTER);

    JPanel panel4 = new JPanel();
    panel4.setLayout(new FlowLayout(FlowLayout.LEFT));
    panel4.add(jchkRowSelectionAllowed);
    panel4.add(jchkColumnSelectionAllowed);

    JPanel panel5 = new JPanel();
    panel5.setLayout(new GridLayout(2, 1));
    panel5.add(panel3);
    panel5.add(panel4);

    JPanel panel6 = new JPanel();
    panel6.setLayout(new BorderLayout());
    panel6.add(panel1, BorderLayout.SOUTH);
    panel6.add(panel2, BorderLayout.CENTER);

    add(panel5, BorderLayout.NORTH);
    add(new JScrollPane(jTable1), BorderLayout.CENTER);
    add(panel6, BorderLayout.SOUTH);

    // Initialize table selection mode
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    jbtAddRow.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              rowSet.absolute(2);
              rowSet.moveToInsertRow();
              rowSet.updateString("state", "Georia");
              rowSet.updateString("capital", "Atlanta");
              rowSet.insertRow();
              ((CachedRowSetImpl) rowSet).acceptChanges();
              rowSet.moveToCurrentRow();
            } catch (Exception ex) {
              ex.printStackTrace();
            }

            //        if (jTable1.getSelectedRow() >= 0)
            //          tableModel.insertRow(jTable1.getSelectedRow(),
            //            new java.util.Vector());
            //        else
            //          tableModel.addRow(new java.util.Vector());
          }
        });

    jbtAddColumn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            //        String name = JOptionPane.showInputDialog("New Column Name");
            //        tableModel.addColumn(name, new java.util.Vector());
          }
        });

    jbtDeleteRow.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (jTable1.getSelectedRow() >= 0) {
              try {
                rowSet.absolute(jTable1.getSelectedRow() + 1);
                rowSet.deleteRow();
                ((CachedRowSetImpl) rowSet).acceptChanges();
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
          }
        });

    jbtDeleteColumn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (jTable1.getSelectedColumn() >= 0) {
              TableColumnModel columnModel = jTable1.getColumnModel();
              TableColumn tableColumn = columnModel.getColumn(jTable1.getSelectedColumn());
              columnModel.removeColumn(tableColumn);
            }
          }
        });

    jbtSave.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              ObjectOutputStream out =
                  new ObjectOutputStream(new FileOutputStream("tablemodel.dat"));
              //          out.writeObject(tableModel.getDataVector());
              out.writeObject(getColumnNames());
              out.close();
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    jbtClear.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            //        tableModel.setRowCount(0);
          }
        });

    jbtRestore.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              ObjectInputStream in = new ObjectInputStream(new FileInputStream("tablemodel.dat"));
              Vector rowData = (Vector) in.readObject();
              Vector columnNames = (Vector) in.readObject();
              //          tableModel.setDataVector(rowData, columnNames);
              in.close();
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    jchkRowSelectionAllowed.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            jTable1.setRowSelectionAllowed(jchkRowSelectionAllowed.isSelected());
          }
        });

    jchkColumnSelectionAllowed.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            jTable1.setColumnSelectionAllowed(jchkColumnSelectionAllowed.isSelected());
          }
        });

    jcboSelectionMode.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String selectedItem = (String) jcboSelectionMode.getSelectedItem();

            if (selectedItem.equals("SINGLE_SELECTION"))
              jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            else if (selectedItem.equals("SINGLE_INTERVAL_SELECTION"))
              jTable1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            else if (selectedItem.equals("MULTIPLE_INTERVAL_SELECTION"))
              jTable1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
          }
        });
  }
 /** Constructor (create and layout page) */
 public SOAPMonitorPage(String host_name) {
   host = host_name;
   // Set up default filter (show all messages)
   filter = new SOAPMonitorFilter();
   // Use borders to help improve appearance
   etched_border = new EtchedBorder();
   // Build top portion of split (list panel)
   model = new SOAPMonitorTableModel();
   table = new JTable(model);
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   table.setRowSelectionInterval(0, 0);
   table.setPreferredScrollableViewportSize(new Dimension(600, 96));
   table.getSelectionModel().addListSelectionListener(this);
   scroll = new JScrollPane(table);
   remove_button = new JButton("Remove");
   remove_button.addActionListener(this);
   remove_button.setEnabled(false);
   remove_all_button = new JButton("Remove All");
   remove_all_button.addActionListener(this);
   filter_button = new JButton("Filter ...");
   filter_button.addActionListener(this);
   list_buttons = new JPanel();
   list_buttons.setLayout(new FlowLayout());
   list_buttons.add(remove_button);
   list_buttons.add(remove_all_button);
   list_buttons.add(filter_button);
   list_panel = new JPanel();
   list_panel.setLayout(new BorderLayout());
   list_panel.add(scroll, BorderLayout.CENTER);
   list_panel.add(list_buttons, BorderLayout.SOUTH);
   list_panel.setBorder(empty_border);
   // Build bottom portion of split (message details)
   details_time = new JLabel("Time: ", SwingConstants.RIGHT);
   details_target = new JLabel("Target Service: ", SwingConstants.RIGHT);
   details_status = new JLabel("Status: ", SwingConstants.RIGHT);
   details_time_value = new JLabel();
   details_target_value = new JLabel();
   details_status_value = new JLabel();
   Dimension preferred_size = details_time.getPreferredSize();
   preferred_size.width = 1;
   details_time.setPreferredSize(preferred_size);
   details_target.setPreferredSize(preferred_size);
   details_status.setPreferredSize(preferred_size);
   details_time_value.setPreferredSize(preferred_size);
   details_target_value.setPreferredSize(preferred_size);
   details_status_value.setPreferredSize(preferred_size);
   details_header = new JPanel();
   details_header_layout = new GridBagLayout();
   details_header.setLayout(details_header_layout);
   details_header_constraints = new GridBagConstraints();
   details_header_constraints.fill = GridBagConstraints.BOTH;
   details_header_constraints.weightx = 0.5;
   details_header_layout.setConstraints(details_time, details_header_constraints);
   details_header.add(details_time);
   details_header_layout.setConstraints(details_time_value, details_header_constraints);
   details_header.add(details_time_value);
   details_header_layout.setConstraints(details_target, details_header_constraints);
   details_header.add(details_target);
   details_header_constraints.weightx = 1.0;
   details_header_layout.setConstraints(details_target_value, details_header_constraints);
   details_header.add(details_target_value);
   details_header_constraints.weightx = .5;
   details_header_layout.setConstraints(details_status, details_header_constraints);
   details_header.add(details_status);
   details_header_layout.setConstraints(details_status_value, details_header_constraints);
   details_header.add(details_status_value);
   details_header.setBorder(etched_border);
   request_label = new JLabel("SOAP Request", SwingConstants.CENTER);
   request_text = new SOAPMonitorTextArea();
   request_text.setEditable(false);
   request_scroll = new JScrollPane(request_text);
   request_panel = new JPanel();
   request_panel.setLayout(new BorderLayout());
   request_panel.add(request_label, BorderLayout.NORTH);
   request_panel.add(request_scroll, BorderLayout.CENTER);
   response_label = new JLabel("SOAP Response", SwingConstants.CENTER);
   response_text = new SOAPMonitorTextArea();
   response_text.setEditable(false);
   response_scroll = new JScrollPane(response_text);
   response_panel = new JPanel();
   response_panel.setLayout(new BorderLayout());
   response_panel.add(response_label, BorderLayout.NORTH);
   response_panel.add(response_scroll, BorderLayout.CENTER);
   details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
   details_soap.setTopComponent(request_panel);
   details_soap.setRightComponent(response_panel);
   details_soap.setResizeWeight(.5);
   details_panel = new JPanel();
   layout_button = new JButton("Switch Layout");
   layout_button.addActionListener(this);
   reflow_xml = new JCheckBox("Reflow XML text");
   reflow_xml.addActionListener(this);
   details_buttons = new JPanel();
   details_buttons.setLayout(new FlowLayout());
   details_buttons.add(reflow_xml);
   details_buttons.add(layout_button);
   details_panel.setLayout(new BorderLayout());
   details_panel.add(details_header, BorderLayout.NORTH);
   details_panel.add(details_soap, BorderLayout.CENTER);
   details_panel.add(details_buttons, BorderLayout.SOUTH);
   details_panel.setBorder(empty_border);
   // Add the two parts to the age split pane
   split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
   split.setTopComponent(list_panel);
   split.setRightComponent(details_panel);
   // Build status area
   start_button = new JButton("Start");
   start_button.addActionListener(this);
   stop_button = new JButton("Stop");
   stop_button.addActionListener(this);
   status_buttons = new JPanel();
   status_buttons.setLayout(new FlowLayout());
   status_buttons.add(start_button);
   status_buttons.add(stop_button);
   status_text = new JLabel();
   status_text.setBorder(new BevelBorder(BevelBorder.LOWERED));
   status_text_panel = new JPanel();
   status_text_panel.setLayout(new BorderLayout());
   status_text_panel.add(status_text, BorderLayout.CENTER);
   status_text_panel.setBorder(empty_border);
   status_area = new JPanel();
   status_area.setLayout(new BorderLayout());
   status_area.add(status_buttons, BorderLayout.WEST);
   status_area.add(status_text_panel, BorderLayout.CENTER);
   status_area.setBorder(etched_border);
   // Add the split and status area to page
   setLayout(new BorderLayout());
   add(split, BorderLayout.CENTER);
   add(status_area, BorderLayout.SOUTH);
 }
예제 #22
0
  private void initComponents() {
    setLayout(new BorderLayout());

    JPanel sidePanel = new JPanel(new BorderLayout());
    sidePanel.add(infoPanel, BorderLayout.NORTH);
    sidePanel.add(new JSeparator(), BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel(new GridLayout(3, 1));

    JButton spendButton = new JButton("Spend");
    spendButton.setVisible(
        !account.isClosed()
            && controller.getCurrentUser() == accountOwner
            && (account.getType() == Account.Type.CHECKING
                || account.getType() == Account.Type.LINE_OF_CREDIT));
    spendButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            spend();
          }
        });
    buttonPanel.add(spendButton);

    JButton transferButton = new JButton("Transfer");
    transferButton.setVisible(
        !account.isClosed()
            && controller.getCurrentUser() == accountOwner
            && !account.getType().isLoan());
    transferButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            transfer();
          }
        });
    buttonPanel.add(transferButton);

    final JButton flagButton = new JButton("Flag transaction");
    flagButton.setEnabled(false);
    flagButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            flag();
          }
        });
    buttonPanel.add(flagButton);

    sidePanel.add(buttonPanel, BorderLayout.SOUTH);

    add(sidePanel, BorderLayout.WEST);

    historyTable = new JTable();
    historyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    historyTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                flagButton.setEnabled(false);
                if (!account.isClosed() && historyTable.getSelectedRow() >= 0) {
                  Transaction transaction = account.getHistory().get(historyTable.getSelectedRow());
                  if (Bank.getInstance().getCurrentMonth() - transaction.getTimestamp() < 2
                      && transaction.getFraudStatus() != Transaction.FraudStatus.REVERSED) {
                    flagButton.setEnabled(true);
                  }
                }
              }
            });
    JScrollPane tablePane = new JScrollPane(historyTable);
    add(tablePane, BorderLayout.CENTER);
  }
  private void fillList() {
    model.setService(null);
    model.getCurrentNavigationState().NEXT.setEnabled(false);
    serviceList = new ArrayList<Service>();
    mobileServices.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    final ReadOnlyCellTableModel messageTableModel = new ReadOnlyCellTableModel();
    messageTableModel.addColumn("Message");
    Vector<String> vector = new Vector<String>();
    vector.add("(loading... )");
    messageTableModel.addRow(vector);

    mobileServices.setModel(messageTableModel);

    ApplicationManager.getApplication()
        .invokeLater(
            new Runnable() {
              @Override
              public void run() {
                int selectedIndex = -1;

                try {
                  List<Subscription> subscriptionList =
                      AzureRestAPIManager.getManager().getSubscriptionList();

                  if (subscriptionList != null && subscriptionList.size() > 0) {
                    buttonAddService.setEnabled(true);

                    ReadOnlyCellTableModel serviceTableModel = new ReadOnlyCellTableModel();
                    serviceTableModel.addColumn("Name");
                    serviceTableModel.addColumn("Region");
                    serviceTableModel.addColumn("Type");
                    serviceTableModel.addColumn("Subscription");

                    int rowIndex = 0;

                    for (Subscription s : subscriptionList) {
                      List<Service> currentSubServices =
                          AzureRestAPIManager.getManager().getServiceList(s.getId());

                      for (Service service : currentSubServices) {
                        Vector<String> row = new Vector<String>();
                        row.add(service.getName());
                        row.add(service.getRegion());
                        row.add("Mobile service");
                        row.add(s.getName());

                        serviceTableModel.addRow(row);
                        serviceList.add(service);

                        if (model.getService() != null
                            && model.getService().getName().equals(service.getName())
                            && model
                                .getService()
                                .getSubcriptionId()
                                .toString()
                                .equals(service.getSubcriptionId().toString())) {
                          selectedIndex = rowIndex;
                        }

                        rowIndex++;
                      }
                    }

                    if (rowIndex == 0) {
                      while (messageTableModel.getRowCount() > 0) {
                        messageTableModel.removeRow(0);
                      }

                      Vector<String> vector = new Vector<String>();
                      vector.add(
                          "There are no Azure Mobile Services on the imported subscriptions");
                      messageTableModel.addRow(vector);

                      mobileServices.setModel(messageTableModel);
                    } else {
                      mobileServices.setModel(serviceTableModel);
                    }
                  } else {
                    buttonAddService.setEnabled(false);

                    while (messageTableModel.getRowCount() > 0) {
                      messageTableModel.removeRow(0);
                    }

                    Vector<String> vector = new Vector<String>();
                    vector.add("Please sign in/import your Azure subscriptions.");
                    messageTableModel.addRow(vector);
                    mobileServices.setModel(messageTableModel);

                    buttonEdit.doClick();
                  }
                } catch (Throwable ex) {
                  UIHelper.showException("Error retrieving service list", ex);
                  serviceList.clear();

                  while (messageTableModel.getRowCount() > 0) {
                    messageTableModel.removeRow(0);
                  }

                  Vector<String> vector = new Vector<String>();
                  vector.add(
                      "There has been an error while loading the list of Azure Mobile Services");
                  messageTableModel.addRow(vector);
                  mobileServices.setModel(messageTableModel);
                }

                mobileServices.getSelectionModel().clearSelection();

                if (selectedIndex >= 0) {
                  mobileServices.getSelectionModel().setLeadSelectionIndex(selectedIndex);
                }
              }
            },
            this.modalityState);
  }
예제 #24
0
  public void initPanel() {
    // The panel uses an absolute layout.
    setLayout(null);

    // Name
    nameField = new JFormattedTextField(20);
    nameField.setEditable(false);
    addRow("Name", nameField);

    // Label
    labelField = new JTextField(20);
    labelField.addActionListener(this);
    labelField.addFocusListener(this);
    addRow("Label", labelField);

    // Help Text
    helpTextField = new JTextField(20);
    helpTextField.addActionListener(this);
    helpTextField.addFocusListener(this);
    addRow("Help Text", helpTextField);

    // Widget
    widgetBox = new JComboBox(humanizedWidgets);
    widgetBox.addActionListener(this);
    addRow("Type", widgetBox);

    // Value
    valueField = new JTextField(20);
    valueField.addActionListener(this);
    valueField.addFocusListener(this);
    addRow("Value", valueField);

    // Enable If
    enableIfField = new JTextField(20);
    enableIfField.addActionListener(this);
    enableIfField.addFocusListener(this);
    addRow("Enable If", enableIfField);

    // Bounding Method
    boundingMethodBox = new JComboBox(new String[] {"none", "soft", "hard"});
    boundingMethodBox.addActionListener(this);
    addRow("Bounding", boundingMethodBox);

    // Minimum Value
    minimumValueCheck = new JCheckBox();
    minimumValueCheck.addActionListener(this);
    minimumValueField = new JTextField(10);
    minimumValueField.addActionListener(this);
    minimumValueField.addFocusListener(this);
    JPanel minimumValuePanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
    minimumValuePanel.add(minimumValueCheck);
    minimumValuePanel.add(minimumValueField);
    addRow("Minimum", minimumValuePanel);

    // Maximum Value
    maximumValueCheck = new JCheckBox();
    maximumValueCheck.addActionListener(this);
    maximumValueField = new JTextField(10);
    maximumValueField.addActionListener(this);
    maximumValueField.addFocusListener(this);
    JPanel maximumValuePanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
    maximumValuePanel.add(maximumValueCheck);
    maximumValuePanel.add(maximumValueField);
    addRow("Maximum", maximumValuePanel);

    // Display Level
    displayLevelBox = new JComboBox(new String[] {"hud", "detail", "hidden"});
    displayLevelBox.addActionListener(this);
    addRow("Display Level", displayLevelBox);

    // Menu Items
    menuItemsTable = new JTable(new MenuItemsModel());
    menuItemsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JPanel tablePanel = new JPanel(new BorderLayout(5, 5));
    JScrollPane tableScroll =
        new JScrollPane(
            menuItemsTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    tableScroll.setSize(200, 170);
    tableScroll.setPreferredSize(new Dimension(200, 170));
    tableScroll.setMaximumSize(new Dimension(200, 170));
    tableScroll.setMinimumSize(new Dimension(200, 170));
    tablePanel.add(tableScroll, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5));
    addButton = new JButton(new Icons.PlusIcon());
    addButton.addActionListener(this);
    removeButton = new JButton(new Icons.MinusIcon());
    removeButton.addActionListener(this);
    upButton = new JButton(new Icons.ArrowIcon(Icons.ArrowIcon.NORTH));
    upButton.addActionListener(this);
    downButton = new JButton(new Icons.ArrowIcon(Icons.ArrowIcon.SOUTH));
    downButton.addActionListener(this);
    buttonPanel.add(addButton);
    buttonPanel.add(removeButton);
    buttonPanel.add(upButton);
    buttonPanel.add(downButton);
    tablePanel.add(buttonPanel, BorderLayout.SOUTH);
    addRow("Menu Items", tablePanel);
  }
예제 #25
0
  private void addBasicPanels() {
    JSplitPane allPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    allPane.setOneTouchExpandable(true);

    messagesTable =
        new DefaultTableModel(
            new Object[] {"Hide", "Timestamp", "", "", "Message", "Id", "Type", "To", "From"}, 0) {
          private static final long serialVersionUID = 8136121224474217264L;

          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }

          public Class<?> getColumnClass(int columnIndex) {
            if (columnIndex == 2 || columnIndex == 3) {
              return Icon.class;
            }
            return super.getColumnClass(columnIndex);
          }
        };
    JTable table = new JTable(messagesTable);
    // Allow only single a selection
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // Hide the first column
    table.getColumnModel().getColumn(0).setMaxWidth(0);
    table.getColumnModel().getColumn(0).setMinWidth(0);
    table.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
    table.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
    // Set the column "timestamp" size
    table.getColumnModel().getColumn(1).setMaxWidth(300);
    table.getColumnModel().getColumn(1).setPreferredWidth(90);
    // Set the column "direction" icon size
    table.getColumnModel().getColumn(2).setMaxWidth(50);
    table.getColumnModel().getColumn(2).setPreferredWidth(30);
    // Set the column "packet type" icon size
    table.getColumnModel().getColumn(3).setMaxWidth(50);
    table.getColumnModel().getColumn(3).setPreferredWidth(30);
    // Set the column "Id" size
    table.getColumnModel().getColumn(5).setMaxWidth(100);
    table.getColumnModel().getColumn(5).setPreferredWidth(55);
    // Set the column "type" size
    table.getColumnModel().getColumn(6).setMaxWidth(200);
    table.getColumnModel().getColumn(6).setPreferredWidth(50);
    // Set the column "to" size
    table.getColumnModel().getColumn(7).setMaxWidth(300);
    table.getColumnModel().getColumn(7).setPreferredWidth(90);
    // Set the column "from" size
    table.getColumnModel().getColumn(8).setMaxWidth(300);
    table.getColumnModel().getColumn(8).setPreferredWidth(90);
    // Create a table listener that listen for row selection events
    SelectionListener selectionListener = new SelectionListener(table);
    table.getSelectionModel().addListSelectionListener(selectionListener);
    table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener);
    allPane.setTopComponent(new JScrollPane(table));
    messageTextArea = new JTextArea();
    messageTextArea.setEditable(false);
    // Add pop-up menu.
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(messageTextArea.getText()), null);
          }
        });
    menu.add(menuItem1);
    // Add listener to the text area so the popup menu can come up.
    messageTextArea.addMouseListener(new PopupListener(menu));
    JPanel sublayout = new JPanel(new BorderLayout());
    sublayout.add(new JScrollPane(messageTextArea), BorderLayout.CENTER);

    JButton clearb = new JButton("Clear All Packets");

    clearb.addActionListener(
        new AbstractAction() {
          private static final long serialVersionUID = -8576045822764763613L;

          @Override
          public void actionPerformed(ActionEvent e) {
            messagesTable.setRowCount(0);
          }
        });

    sublayout.add(clearb, BorderLayout.NORTH);
    allPane.setBottomComponent(sublayout);

    allPane.setDividerLocation(150);

    tabbedPane.add("All Packets", allPane);
    tabbedPane.setToolTipTextAt(0, "Sent and received packets processed by Smack");

    // Create UI elements for client generated XML traffic.
    final JTextArea sentText = new JTextArea();
    sentText.setWrapStyleWord(true);
    sentText.setLineWrap(true);
    sentText.setEditable(false);
    sentText.setForeground(new Color(112, 3, 3));
    tabbedPane.add("Raw Sent Packets", new JScrollPane(sentText));
    tabbedPane.setToolTipTextAt(1, "Raw text of the sent packets");

    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(sentText.getText()), null);
          }
        });

    JMenuItem menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sentText.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    sentText.addMouseListener(new PopupListener(menu));
    menu.add(menuItem1);
    menu.add(menuItem2);

    // Create UI elements for server generated XML traffic.
    final JTextArea receivedText = new JTextArea();
    receivedText.setWrapStyleWord(true);
    receivedText.setLineWrap(true);
    receivedText.setEditable(false);
    receivedText.setForeground(new Color(6, 76, 133));
    tabbedPane.add("Raw Received Packets", new JScrollPane(receivedText));
    tabbedPane.setToolTipTextAt(2, "Raw text of the received packets before Smack process them");

    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(receivedText.getText()), null);
          }
        });

    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            receivedText.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    receivedText.addMouseListener(new PopupListener(menu));
    menu.add(menuItem1);
    menu.add(menuItem2);

    // Create a special Reader that wraps the main Reader and logs data to the GUI.
    ObservableReader debugReader = new ObservableReader(reader);
    readerListener =
        new ReaderListener() {
          public void read(final String str) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER
                        && !EnhancedDebuggerWindow.getInstance().isVisible()) {
                      // Do not add content if the parent is not visible
                      return;
                    }

                    int index = str.lastIndexOf(">");
                    if (index != -1) {
                      if (receivedText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
                        try {
                          receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0));
                        } catch (BadLocationException e) {
                          e.printStackTrace();
                        }
                      }
                      receivedText.append(str.substring(0, index + 1));
                      receivedText.append(NEWLINE);
                      if (str.length() > index) {
                        receivedText.append(str.substring(index + 1));
                      }
                    } else {
                      receivedText.append(str);
                    }
                  }
                });
          }
        };
    debugReader.addReaderListener(readerListener);

    // Create a special Writer that wraps the main Writer and logs data to the GUI.
    ObservableWriter debugWriter = new ObservableWriter(writer);
    writerListener =
        new WriterListener() {
          public void write(final String str) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER
                        && !EnhancedDebuggerWindow.getInstance().isVisible()) {
                      // Do not add content if the parent is not visible
                      return;
                    }

                    if (sentText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
                      try {
                        sentText.replaceRange("", 0, sentText.getLineEndOffset(0));
                      } catch (BadLocationException e) {
                        e.printStackTrace();
                      }
                    }

                    sentText.append(str);
                    if (str.endsWith(">")) {
                      sentText.append(NEWLINE);
                    }
                  }
                });
          }
        };
    debugWriter.addWriterListener(writerListener);

    // Assign the reader/writer objects to use the debug versions. The packet reader
    // and writer will use the debug versions when they are created.
    reader = debugReader;
    writer = debugWriter;
  }
예제 #26
0
  public void makeGUI() {
    frm = new JFrame();
    c = frm.getContentPane();

    btnImport = new JButton("Import");
    btnImport.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureImport();
          }
        });
    btnMove = new JButton("Move");
    btnMove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureMove();
          }
        });
    btnDelete = new JButton("Delete");
    btnDelete.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureDelete();
          }
        });
    btnAnalyse = new JButton("Analyse");
    btnAnalyse.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureAnalysis();
          }
        });

    tblItems = new JTable(store);
    tblItems.setRowSorter(tableSorter);
    tblItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblItems.setFillsViewportHeight(true);
    tblItems.getRowSorter().toggleSortOrder(Storage.COL_DATE);
    tblItems.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
              tblItems.setRowSelectionInterval(
                  e.getY() / tblItems.getRowHeight(), e.getY() / tblItems.getRowHeight());
            }
            if (e.getClickCount() > 1 || e.getButton() == MouseEvent.BUTTON3) {
              int idx = tblItems.convertRowIndexToModel(tblItems.getSelectedRow());
              secureExport(idx);
            }
          }

          public void mouseEntered(MouseEvent arg0) {}

          public void mouseExited(MouseEvent arg0) {}

          public void mousePressed(MouseEvent arg0) {}

          public void mouseReleased(MouseEvent arg0) {}
        });

    txaStatus = new JTextArea(TXA_HEIGHT, TXA_WIDTH);
    txaStatus.setEditable(false);
    txaStatus.setBorder(BorderFactory.createTitledBorder("Status"));
    txaSearch = new JTextArea(4, TXA_WIDTH);
    txaSearch.setBorder(BorderFactory.createTitledBorder("Search"));
    txaSearch.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent arg0) {}

          public void keyReleased(KeyEvent arg0) {
            filterBase(txaSearch.getText());
            // EXPORT settings here, as in mass export (export everything)
            if (allowExport && txaSearch.getText().equalsIgnoreCase(CMD_EXPORT)) {
              // txaSearch.setText("");
              if (JOptionPane.showConfirmDialog(
                      frm,
                      "Do you really want to export the whole secure base?",
                      "Confirm Export",
                      JOptionPane.OK_CANCEL_OPTION)
                  == JOptionPane.OK_OPTION) {
                totalExport();
              }
            }
            // LOST X IMPORT asin look through the store for files not listed
            if (txaSearch.getText().equalsIgnoreCase(CMD_STOCKTAKE)) {
              for (int i = 0; i < storeLocs.size(); i++) {
                if (store.stockTake(i)) needsSave = true;
              }
            }
          }

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

    JPanel pnlTop = new JPanel(new GridLayout(1, 4));
    JPanel pnlEast = new JPanel(new BorderLayout());
    JPanel pnlCenterEast = new JPanel(new BorderLayout());
    JScrollPane jspItems = new JScrollPane(tblItems);

    pnlTop.add(btnImport);
    pnlTop.add(btnMove);
    pnlTop.add(btnDelete);
    pnlTop.add(btnAnalyse);
    pnlCenterEast.add(txaStatus, BorderLayout.CENTER);
    pnlCenterEast.add(txaSearch, BorderLayout.NORTH);
    // pnlEast.add(pswPass, BorderLayout.NORTH);
    pnlEast.add(pnlCenterEast, BorderLayout.CENTER);
    c.setLayout(new BorderLayout());
    c.add(pnlTop, BorderLayout.NORTH);
    c.add(pnlEast, BorderLayout.EAST);
    c.add(jspItems, BorderLayout.CENTER);
    frm.setContentPane(c);
  }
예제 #27
0
  public static void main(String args[]) {
    // style that is necessary
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    } catch (UnsupportedLookAndFeelException e) {
    }

    // Standard preparation for a frame
    fmain = new JFrame("Schedule Appointments"); // Create and name frame
    fmain.setSize(330, 375); // Set size to 400x400 pixels
    pane = fmain.getContentPane();
    pane.setLayout(null); // Apply null layout
    fmain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Close when X is clicked

    // controls and portions of Calendar
    lmonth = new JLabel("January");
    lyear = new JLabel("Change year:");
    cyear = new JComboBox();
    prev = new JButton("<<");
    next = new JButton(">>");
    canc = new JButton("Cancel");
    mcal =
        new DefaultTableModel() {
          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }
        };
    Cal = new JTable(mcal);
    scal = new JScrollPane(Cal);
    pcal = new JPanel(null);

    canc.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });

    // action listeners for buttons and the like
    prev.addActionListener(new btnPrev_Action());
    next.addActionListener(new btnNext_Action());
    cyear.addActionListener(new cmbYear_Action());
    Cal.addMouseListener(new mouseCont());

    // Adding the elements to the pane
    pane.add(pcal);
    pcal.add(lmonth);
    pcal.add(cyear);
    pcal.add(prev);
    pcal.add(next);
    pcal.add(canc);
    pcal.add(scal);

    // Setting where the elements are on the pane
    pcal.setBounds(0, 0, 320, 335);
    lmonth.setBounds(160 - lmonth.getPreferredSize().width / 2, 25, 100, 25);
    canc.setBounds(10, 305, 80, 20);
    cyear.setBounds(215, 305, 100, 20);
    prev.setBounds(10, 25, 50, 25);
    next.setBounds(260, 25, 50, 25);
    scal.setBounds(10, 50, 300, 250);

    // Make frame visible
    fmain.setResizable(false);
    fmain.setVisible(true);

    // Inner workings for the day mechanism
    GregorianCalendar cal = new GregorianCalendar(); // Create calendar
    rday = cal.get(GregorianCalendar.DAY_OF_MONTH); // Get day
    rmonth = cal.get(GregorianCalendar.MONTH); // Get month
    ryear = cal.get(GregorianCalendar.YEAR); // Get year
    currentMonth = rmonth; // Match month and year
    currentYear = ryear;

    // Add days
    String[] days = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; // All of the days
    for (int i = 0; i < 7; i++) {
      mcal.addColumn(days[i]);
    }

    Cal.getParent().setBackground(Cal.getBackground()); // Set background

    // No resize/reorder
    Cal.getTableHeader().setResizingAllowed(false);
    Cal.getTableHeader().setReorderingAllowed(false);

    // Single cell selection
    Cal.setColumnSelectionAllowed(true);
    Cal.setRowSelectionAllowed(true);
    Cal.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Set row/column count
    Cal.setRowHeight(38);
    mcal.setColumnCount(7);
    mcal.setRowCount(6);

    // Placing the dates in the cells
    for (int i = ryear - 100; i <= ryear + 100; i++) {
      cyear.addItem(String.valueOf(i));
    }

    // Refresh calendar
    refreshCalendar(rmonth, ryear); // Refresh calendar
  }
  public FixedColumnExample() {
    super("Fixed Column Example");
    setSize(400, 150);
    data =
        new Object[][] {
          {"1", "11", "A", "", "", "", "", ""},
          {"2", "22", "", "B", "", "", "", ""},
          {"3", "33", "", "", "C", "", "", ""},
          {"4", "44", "", "", "", "D", "", ""},
          {"5", "55", "", "", "", "", "E", ""},
          {"6", "66", "", "", "", "", "", "F"}
        };
    column = new Object[] {"fixed 1", "fixed 2", "a", "b", "c", "d", "e", "f"};
    AbstractTableModel fixedModel =
        new AbstractTableModel() {
          public int getColumnCount() {
            return 2;
          }

          public int getRowCount() {
            return data.length;
          }

          public String getColumnName(int col) {
            return (String) column[col];
          }

          public Object getValueAt(int row, int col) {
            return data[row][col];
          }
        };
    AbstractTableModel model =
        new AbstractTableModel() {
          public int getColumnCount() {
            return column.length - 2;
          }

          public int getRowCount() {
            return data.length;
          }

          public String getColumnName(int col) {
            return (String) column[col + 2];
          }

          public Object getValueAt(int row, int col) {
            return data[row][col + 2];
          }

          public void setValueAt(Object obj, int row, int col) {
            data[row][col + 2] = obj;
          }

          public boolean CellEditable(int row, int col) {
            return true;
          }
        };
    fixedTable =
        new JTable(fixedModel) {
          public void valueChanged(ListSelectionEvent e) {
            super.valueChanged(e);
            checkSelection(true);
          }
        };
    table =
        new JTable(model) {
          public void valueChanged(ListSelectionEvent e) {
            super.valueChanged(e);
            checkSelection(false);
          }
        };
    fixedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fixedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scroll = new JScrollPane(table);
    JViewport viewport = new JViewport();
    viewport.setView(fixedTable);
    viewport.setPreferredSize(fixedTable.getPreferredSize());
    scroll.setRowHeaderView(viewport);
    scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTable.getTableHeader());
    getContentPane().add(scroll, BorderLayout.CENTER);
  }
 public CFInternetSwingISOCountryPickerJPanel(
     ICFInternetSwingSchema argSchema,
     ICFSecurityISOCountryObj argFocus,
     ICFLibAnyObj argContainer,
     Collection<ICFSecurityISOCountryObj> argDataCollection,
     ICFInternetSwingISOCountryChosen whenChosen) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   if (whenChosen == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 5, "whenChosen");
   }
   invokeWhenChosen = whenChosen;
   // argFocus is optional; focus may be set later during execution as
   // conditions of the runtime change.
   swingSchema = argSchema;
   swingFocus = argFocus;
   swingContainer = argContainer;
   setSwingDataCollection(argDataCollection);
   dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
   dataTable.addMouseListener(getDataListMouseAdapter());
   dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   dataTable.setUpdateSelectionOnSort(true);
   dataTable.setRowHeight(25);
   getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
   dataScrollPane =
       new JScrollPane(
           dataTable,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   dataScrollPane.setColumnHeader(
       new JViewport() {
         @Override
         public Dimension getPreferredSize() {
           Dimension sz = super.getPreferredSize();
           sz.height = 25;
           return (sz);
         }
       });
   dataTable.setFillsViewportHeight(true);
   actionCancel = new ActionCancel();
   buttonCancel = new JButton(actionCancel);
   actionChooseNone = new ActionChooseNone();
   buttonChooseNone = new JButton(actionChooseNone);
   actionChooseSelected = new ActionChooseSelectedISOCountry();
   buttonChooseSelected = new JButton(actionChooseSelected);
   // Do initial layout
   setSize(1024, 480);
   add(buttonChooseNone);
   add(buttonChooseSelected);
   add(buttonCancel);
   add(dataScrollPane);
   dataScrollPane.setBounds(0, 35, 1024, 455);
   doLayout();
   setSwingFocusAsISOCountry(argFocus);
 }
  public AzureMobileServiceStep(final String title, final AddServiceWizardModel model) {
    super(title, null, null);
    this.model = model;
    this.modalityState = ModalityState.any();

    ReadOnlyCellTableModel tableModel = new ReadOnlyCellTableModel();
    mobileServices.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel selectionModel = mobileServices.getSelectionModel();

    tableModel.addColumn("Name");
    tableModel.addColumn("Region");
    tableModel.addColumn("Type");
    tableModel.addColumn("Subscription");

    mobileServices.setModel(tableModel);

    List<String> listServicesData = new ArrayList<String>();

    int boldIndex = -1;
    int index = 0;
    for (ServiceType serviceType : this.model.getServiceTypes()) {
      listServicesData.add(serviceType.getDisplayName());

      if (serviceType.equals(AzureMobileServiceStep.serviceType)) {
        boldIndex = index;
      }

      index++;
    }

    final String boldValue = listServicesData.get(boldIndex);
    DefaultListCellRenderer customListCellRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component c =
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

            if (boldValue.equals(value)) { // <= put your logic here
              c.setFont(c.getFont().deriveFont(Font.BOLD));
            } else {
              c.setFont(c.getFont().deriveFont(Font.PLAIN));
            }
            return c;
          }
        };
    this.listServices.setCellRenderer(customListCellRenderer);

    DefaultListSelectionModel customListSelectionModel =
        new DefaultListSelectionModel() {
          @Override
          public void setSelectionInterval(int index0, int index1) {}

          @Override
          public void addSelectionInterval(int index0, int index1) {}
        };
    this.listServices.setSelectionModel(customListSelectionModel);

    this.listServices.setListData(listServicesData.toArray(new String[1]));

    selectionModel.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent listSelectionEvent) {
            Object sourceObj = listSelectionEvent.getSource();

            if (sourceObj instanceof ListSelectionModel
                && !((ListSelectionModel) sourceObj).isSelectionEmpty()
                && listSelectionEvent.getValueIsAdjusting()
                && serviceList.size() > 0) {
              Service s =
                  serviceList.get(mobileServices.getSelectionModel().getLeadSelectionIndex());
              model.setService(s);
              model.getCurrentNavigationState().NEXT.setEnabled(true);
            }
          }
        });

    buttonEdit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            ManageSubscriptionForm form = new ManageSubscriptionForm(null);
            UIHelper.packAndCenterJDialog(form);
            form.setVisible(true);

            if (form.getDialogResult() == ManageSubscriptionForm.DialogResult.OK) {
              fillList();
            } else {
              try {
                List<Subscription> subscriptionList =
                    AzureRestAPIManager.getManager().getSubscriptionList();

                if (subscriptionList == null || subscriptionList.size() == 0) {
                  buttonAddService.setEnabled(false);

                  // clear the mobile services list
                  final ReadOnlyCellTableModel messageTableModel = new ReadOnlyCellTableModel();
                  messageTableModel.addColumn("Message");
                  Vector<String> vector = new Vector<String>();
                  vector.add("Please sign in/import your Azure subscriptions.");
                  messageTableModel.addRow(vector);

                  mobileServices.setModel(messageTableModel);
                } else {
                  fillList();
                }
              } catch (AzureCmdException e) {
                final ReadOnlyCellTableModel messageTableModel = new ReadOnlyCellTableModel();
                messageTableModel.addColumn("Message");
                Vector<String> vector = new Vector<String>();
                vector.add(
                    "There has been an error while retrieving the configured Azure subscriptions.");

                messageTableModel.addRow(vector);
                vector = new Vector<String>();
                vector.add("Please retry signing in/importing your Azure subscriptions.");
                messageTableModel.addRow(vector);

                mobileServices.setModel(messageTableModel);
              }
            }
          }
        });

    buttonAddService.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            CreateNewServiceForm form = new CreateNewServiceForm();
            form.setServiceCreated(
                new Runnable() {
                  @Override
                  public void run() {
                    ApplicationManager.getApplication()
                        .invokeLater(
                            new Runnable() {
                              @Override
                              public void run() {
                                fillList();
                              }
                            });
                  }
                });

            form.setModal(true);
            UIHelper.packAndCenterJDialog(form);
            form.setVisible(true);
          }
        });

    refreshServices();
  }