Esempio n. 1
0
 public SISCFrame(AppContext ctx) {
   setLayout(new BorderLayout());
   SchemePanel.SchemeDocument d = new SchemePanel.SchemeDocument();
   sp = new SchemePanel(ctx, d, new JTextPane(d));
   input = new JTextArea(4, 70);
   input.setText("; Enter s-expressions here");
   JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, sp, input);
   JPanel execPanel = new JPanel();
   execPanel.setLayout(new BoxLayout(execPanel, BoxLayout.X_AXIS));
   execPanel.add(Box.createHorizontalGlue());
   eval = new JButton("Evaluate");
   clear = new JButton("Clear");
   autoClear = new JCheckBox("Auto-Clear");
   submitOnEnter = new JCheckBox("Evaluate on Enter");
   autoClear.setSelected(true);
   submitOnEnter.setSelected(true);
   execPanel.add(submitOnEnter);
   execPanel.add(autoClear);
   execPanel.add(clear);
   execPanel.add(eval);
   add(split, BorderLayout.CENTER);
   add(execPanel, BorderLayout.SOUTH);
   eval.addActionListener(this);
   clear.addActionListener(this);
   input.addKeyListener(this);
   /*	addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
   System.exit(0);
         }
         });*/
 }
  public DistributedTextEditor() {
    area1.setFont(new Font("Monospaced", Font.PLAIN, 12));

    area2.setFont(new Font("Monospaced", Font.PLAIN, 12));
    ((AbstractDocument) area1.getDocument()).setDocumentFilter(dec);
    area2.setEditable(false);

    Container content = getContentPane();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

    JScrollPane scroll1 =
        new JScrollPane(
            area1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    content.add(scroll1, BorderLayout.CENTER);

    JScrollPane scroll2 =
        new JScrollPane(
            area2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    content.add(scroll2, BorderLayout.CENTER);

    content.add(ipaddress, BorderLayout.CENTER);
    content.add(portNumber, BorderLayout.CENTER);

    JMenuBar JMB = new JMenuBar();
    setJMenuBar(JMB);
    JMenu file = new JMenu("File");
    JMenu edit = new JMenu("Edit");
    JMB.add(file);
    JMB.add(edit);

    file.add(Listen);
    file.add(Connect);
    file.add(Disconnect);
    file.addSeparator();
    file.add(Save);
    file.add(SaveAs);
    file.add(Quit);

    edit.add(Copy);
    edit.add(Paste);
    edit.getItem(0).setText("Copy");
    edit.getItem(1).setText("Paste");

    Save.setEnabled(false);
    SaveAs.setEnabled(false);
    Disconnect.setEnabled(false);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    area1.addKeyListener(k1);
    area1.addMouseListener(m1);
    setTitle("Disconnected");
    setVisible(true);
    area1.insert("Welcome to Hjortehandlerne's distributed text editor. \n", 0);

    this.addWindowListener(w1);
  }
Esempio n. 3
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);
  }
  /** Constructor to create the frame and its components */
  public CoreyTextEditor() {
    // Create a scroll pane
    area.setFont(new Font("Monospaced", Font.PLAIN, 12));
    JScrollPane scroll =
        new JScrollPane(
            area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    add(scroll, BorderLayout.CENTER);

    // Adds the system default look and feel

    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException
        | InstantiationException
        | UnsupportedLookAndFeelException
        | IllegalAccessException e) {
      e.printStackTrace();
    }

    // Create a menu bar
    JMenuBar JMB = new JMenuBar();
    setJMenuBar(JMB);
    JMenu file = new JMenu("File");
    JMenu edit = new JMenu("Edit");
    JMB.add(file);
    JMB.add(edit);

    // Finishing our menu bar
    file.add(New);
    file.add(Open);
    file.add(Save);
    file.add(SaveAs);
    file.addSeparator();
    file.add(Quit);

    edit.add(Cut);
    edit.add(Copy);
    edit.add(Paste);

    edit.getItem(0).setText("Cut");
    edit.getItem(0).setIcon(new ImageIcon("cut.gif"));
    edit.getItem(1).setText("Copy");
    edit.getItem(1).setIcon(new ImageIcon("copy.gif"));
    edit.getItem(2).setText("Paste");
    edit.getItem(2).setIcon(new ImageIcon("paste.gif"));

    // Time to make a toolbar!
    JToolBar tool = new JToolBar();
    add(tool, BorderLayout.NORTH);
    tool.add(New);
    tool.add(Open);
    tool.add(Save);
    tool.addSeparator();

    JButton cut = tool.add(Cut);
    JButton cop = tool.add(Copy);
    JButton pas = tool.add(Paste);

    cut.setText(null);
    cut.setIcon(new ImageIcon("cut.gif"));
    cop.setText(null);
    cop.setIcon(new ImageIcon("copy.gif"));
    pas.setText(null);
    pas.setIcon(new ImageIcon("paste.gif"));

    Save.setEnabled(false);
    SaveAs.setEnabled(false);

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    pack();

    /*
     KeyListener to change Save and SaveAs
    */
    KeyListener k1 =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            changed = true;
            Save.setEnabled(true);
            SaveAs.setEnabled(true);
          }
        };
    area.addKeyListener(k1);
    setTitle(currentFile + " - CoreyTextEditor");
    setVisible(true);
  }