@Override
 public void keyPressed(KeyEvent e) {
   Rectangle rect;
   switch (e.getKeyCode()) {
     case KeyEvent.VK_EQUALS:
     case KeyEvent.VK_PLUS:
     case KeyEvent.VK_ADD:
       FontSize++;
       textArea.setFont(new Font("monospaced", Font.PLAIN, FontSize));
       rect = textArea.getBounds();
       rect.x = 0;
       rect.y = 0;
       textArea.paintImmediately(rect);
       break;
     case KeyEvent.VK_MINUS:
     case KeyEvent.VK_SUBTRACT:
       if (FontSize > 8) {
         FontSize--;
         textArea.setFont(new Font("monospaced", Font.PLAIN, FontSize));
         rect = textArea.getBounds();
         rect.x = 0;
         rect.y = 0;
         textArea.paintImmediately(rect);
       }
       break;
   }
 }
Пример #2
0
  private void buildLayout(String hostProgramTitle) {
    DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:p:grow"));

    b.append(
        "<html>The following programs are needed for full functionality of "
            + hostProgramTitle
            + ".<br>"
            + "Install the external program first, then click 'relocate'.<br>"
            + "If the program is installed but cannot be found, double-click on the program to assign its location manually.</html>");

    model = new DefaultListModel();
    for (Binary bin : binaries) model.addElement(bin);
    list = new JList(model);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setFont(list.getFont().deriveFont(Font.PLAIN));
    list.setVisibleRowCount(4);
    list.setCellRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel l =
                (JLabel)
                    super.getListCellRendererComponent(
                        list, value, index, isSelected, cellHasFocus);
            Binary b = (Binary) value;
            String found = "";
            if (b.isFound()) {
              l.setIcon(ImageLoader.getImage(ImageLoader.Image.ok));
              found = b.getLocation();
            } else {
              l.setIcon(ImageLoader.getImage(ImageLoader.Image.error));
              found = "<b>Not found</b>";
            }
            l.setText(
                "<html><b>"
                    + b.getDescription()
                    + "</b><br><table><tr><td>Program:</td><td>"
                    + b.getCommand()
                    + "</td></tr><tr><td>Location:</td><td>"
                    + found
                    + "</td></tr></html>");

            l.setBorder(new EmptyBorder(5, 0, 5, 0));

            return l;
          }
        });
    b.append(new JScrollPane(list));

    close = new JButton("Close");
    relocate = new JButton("Relocate program automatically.");
    JPanel buttons = ButtonBarFactory.buildRightAlignedBar(relocate, close);
    b.append(buttons);

    b.setBorder(new EmptyBorder(10, 10, 10, 10));

    setLayout(new BorderLayout());
    add(b.getPanel());
  }
  public FPGACommanderListWindow(
      String Title, Color fg, boolean count, FPGACommanderListModel model) {
    super((count) ? Title + " (0)" : Title);
    this.Title = Title;
    setResizable(true);
    setAlwaysOnTop(false);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    Color bg = Color.black;

    textArea.setBackground(bg);
    textArea.setForeground(fg);
    textArea.setSelectionBackground(fg);
    textArea.setSelectionForeground(bg);
    textArea.setFont(new Font("monospaced", Font.PLAIN, FontSize));
    textArea.setModel(model);
    textArea.setCellRenderer(model.getMyRenderer(count));
    textArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    model.addListDataListener(this);

    JScrollPane textMessages = new JScrollPane(textArea);
    textMessages.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    textMessages.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    add(textMessages);
    setLocationRelativeTo(null);
    textArea.addKeyListener(this);
    pack();
    addWindowListener(this);
    this.count = count;
    this.model = model;
  }
Пример #4
0
  public void initFenster() {
    // SplitPane
    JSplitPane splitPane = new JSplitPane();
    getContentPane().add(splitPane, BorderLayout.CENTER);
    JScrollPane scrollPane = new JScrollPane();
    splitPane.setLeftComponent(scrollPane);

    // Weinpanel
    weinpanel = new Weinpanel(this, betrieb);
    splitPane.setRightComponent(weinpanel);

    // Weinliste
    weinlist = new JList<Weine>(weinModel);
    weinlist.setFont(new Font("Tahoma", Font.PLAIN, 15));
    weinlist.setBorder(new EmptyBorder(0, 0, 0, 100));
    scrollPane.setViewportView(weinlist);
    weinlist.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            doWeineValueChanged(arg0);
          }
        });

    // Label Header
    JLabel lblHeader = new JLabel("alle Weine");
    lblHeader.setFont(new Font("Tahoma", Font.BOLD, 15));
    scrollPane.setColumnHeaderView(lblHeader);
  }
  private void init() {

    listMultipleSelection = getMultipleSelection();
    listModel = new DefaultListModel();

    // create GUI
    if (listMultipleSelection.getPossibleValues().isEmpty()) {
      panel = null;
      itemsContainerList = null;
      return;
    }

    final Border padding = BorderFactory.createEmptyBorder(5, 10, 5, 10);
    panel = new JPanel();
    BorderLayout layout = new BorderLayout();
    panel.setLayout(layout);
    final JTextArea jta = new JTextArea(getDescription());
    jta.setPreferredSize(new Dimension(200, 50));
    jta.setLineWrap(true);
    jta.setWrapStyleWord(true);
    jta.setBorder(padding);
    panel.add(jta, BorderLayout.PAGE_START);
    jta.setBackground(null);
    jta.setEditable(false);

    // put the items in a list
    itemsContainerList =
        new JList(listModel); // new JList(listMultipleSelection.getPossibleValues().toArray());
    for (T value : getMultipleSelection().getPossibleValues()) listModel.addElement(value);

    itemsContainerList.setFont(new Font("sansserif", Font.PLAIN, 11));
    itemsContainerList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    itemsContainerList.addListSelectionListener(this);

    // selected items
    final List<T> selectedVals = listMultipleSelection.getSelectedValues();
    final List<T> allValues = listMultipleSelection.getPossibleValues();

    final int[] selectedIdx = new int[selectedVals.size()];
    int index = 0;
    for (T selected : selectedVals) {
      for (int i = 0; i < allValues.size(); i++) {
        if (itemsContainerList.getModel().getElementAt(i).equals(selected)) {
          selectedIdx[index] = i;
          index++;
        }
      }
    }
    itemsContainerList.setSelectedIndices(selectedIdx);

    // use a JscrollPane to visualize the items

    final JScrollPane scrollpane = new JScrollPane(itemsContainerList);
    scrollpane.setAutoscrolls(true);
    scrollpane.setOpaque(false);
    scrollpane.setBorder(padding);
    panel.add(scrollpane, BorderLayout.CENTER);
  }
Пример #6
0
  /** Create the frame. */
  public BrowseModule() {
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 800, 600);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JPanel panel = new JPanel();
    panel.setBorder(
        new TitledBorder(
            null, "Vehicle Selection", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panel.setBounds(16, 10, 376, 291);
    contentPane.add(panel);
    panel.setLayout(null);

    list = new JList<String>(listStr);
    list.setBounds(6, 16, 364, 268);
    panel.add(list);
    list.setFont(new Font("Arial", Font.PLAIN, 16));
    list.addListSelectionListener(this);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(
        new TitledBorder(
            null, "Vehicle Example", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panel_1.setBounds(399, 10, 381, 291);
    contentPane.add(panel_1);
    panel_1.setLayout(null);

    lblNewLabel = new JLabel();
    lblNewLabel.setBounds(6, 16, 369, 268);
    panel_1.add(lblNewLabel);
    lblNewLabel.setIcon(pics[0]);

    panel_2 = new JPanel();
    panel_2.setBorder(
        new TitledBorder(
            null,
            "Additional Equipment/Services",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_2.setBounds(122, 316, 512, 198);
    contentPane.add(panel_2);
    panel_2.setLayout(null);

    label = new JLabel();
    label.setBounds(6, 16, 500, 175);
    panel_2.add(label);
    label.setText(
        "<HTML>GPS Receiver - $15/day<BR>Child Seat - $10/day<BR>K-TAG Rental - $2/day (plus accumulated tolls)"
            + "<BR>Roadside Assistance - $7/day<BR>Loss Damage Waiver Insurance - $25/day<BR>Personal Accident Insurance - $5/day</HTML>");
  }
Пример #7
0
  private JList<String> getTagList() {
    if (tagList == null) {
      tagList = new JList<>();
      tagList.setLayoutOrientation(JList.VERTICAL);
      tagList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
      tagList.setFont(new java.awt.Font("Default", java.awt.Font.PLAIN, 12));

      tagListModel = new DefaultListModel<>();
      tagList.setModel(tagListModel);
    }
    return tagList;
  }
Пример #8
0
  /**
   * Makes the chart and places it inside a jpanel to update the GUI with the amount of items in
   * machines.
   *
   * @param An array of ints to display.
   * @return A jpanel with the chart.
   */
  private JPanel machineItemChart(int[] IDS) {

    AnalyticsEngine tempEngine;
    final AnalyticsEngine engine = new AnalyticsEngine(IDS, manager.localVends.size());
    Set<String> differentNames = engine.getDifferentNames();
    String[] itemNames = new String[differentNames.size()];
    int i = 0;
    for (String itemName : differentNames) {
      itemNames[i] = itemName;
      ++i;
    }

    final JList<String> jListItemData = new JList<String>(itemNames);
    jListItemData.setFont(new Font("Arial", Font.PLAIN, 20));
    jListItemData.setFixedCellHeight(50);
    jListItemData.setSelectedIndex(0);
    jListItemData.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JPanel itemPanel = new JPanel(new BorderLayout(0, 20));

    JLabel heading = new JLabel("<html><center>List of Items in <br>Machine</center></html>");
    JScrollPane itemScroll = new JScrollPane(jListItemData);
    heading.setFont(new Font("Verdana", Font.BOLD, 20));

    itemPanel.add(heading, BorderLayout.NORTH);
    itemPanel.add(itemScroll, BorderLayout.CENTER);

    ChartPanel chartPanel =
        new ChartPanel(engine.generateItemPieChart(jListItemData.getSelectedValue()));
    final JPanel chartPanelwork = new JPanel(); // new FlowLayout());
    chartPanelwork.add(chartPanel);

    JPanel jpanelMain = new JPanel(new BorderLayout(2, 20));

    jpanelMain.add(itemPanel, BorderLayout.WEST);
    jpanelMain.add(chartPanelwork, BorderLayout.CENTER);

    jListItemData.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            chartPanelwork.removeAll();

            chartPanelwork.add(
                new ChartPanel(engine.generateItemPieChart(jListItemData.getSelectedValue())));
            chartPanelwork.revalidate();
            chartPanelwork.repaint();
          }
        });

    return jpanelMain;
  }
Пример #9
0
  private JScrollPane getClusterList() {
    if (clustList == null) {
      clustList = new JList();

      clustList.setSelectionBackground(new Color(83, 126, 126));
      clustList.setSelectionForeground(Color.BLACK);
      clustList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      clustList.setFont(
          new Font(
              clustList.getFont().getName(),
              clustList.getFont().getStyle(),
              clustList.getFont().getSize() + 1));

      String[] clustStr = new String[numClusters];
      for (int i = 0; i < numClusters; i++) {
        clustStr[i] = "Cluster " + (i + 1);
      }

      clustList.setListData(clustStr);

      clustList.addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (clustInfo != null && clustList.getSelectedIndex() >= 0) {
                if (!e.getValueIsAdjusting()) {
                  ((clustTableModel) clustInfo.getModel())
                      .setData(infos.infoCluster[clustList.getSelectedIndex()].statClust);
                  clustInfo.tableChanged(new TableModelEvent(clustInfo.getModel()));
                  clustDet.setCluster(clustList.getSelectedIndex());
                  String cur =
                      DESCR_LABEL.replaceFirst(
                          "X", Integer.toString(clustList.getSelectedIndex() + 1));
                  cur = cur.replaceFirst("Y", Integer.toString(numClusters));
                  desctText.setText(
                      cur.replaceFirst(
                          "Z", Integer.toString(infos.numElem[clustList.getSelectedIndex()])));
                }
              }
            }
          });
    }
    clustList.setSelectedIndex(0);

    JScrollPane p =
        new JScrollPane(
            clustList,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    p.setPreferredSize(new Dimension(120, 115));
    return p;
  }
Пример #10
0
 public void listVolInit() {
   this.listModel = new DefaultListModel<Vol>();
   List<Vol> listes = FabriqueVol.getInstance().getAllVol();
   for (Vol v : listes) {
     this.listModel.addElement(v);
   }
   this.list = new JList<Vol>(listModel);
   list.setLayoutOrientation(JList.VERTICAL_WRAP);
   list.setVisibleRowCount(-1);
   list.setModel(listModel);
   list.getSelectionModel().addListSelectionListener(this);
   list.setForeground(bleuStyle);
   list.setFont(lato);
 }
Пример #11
0
 private void buildList() {
   // Create the list and put it in a scroll pane.
   iListModel = new DefaultListModel();
   iCellList = new JList(iListModel);
   iCellList.setFont(new Font("courier", Font.PLAIN, 16));
   // iCellList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   iCellList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
   iCellList.setSelectedIndex(0);
   iCellList.addListSelectionListener(this);
   iCellList.setVisibleRowCount(5);
   iScrollPane = new JScrollPane(iCellList);
   // add(iScrollPane);
   iListModel.addElement(help());
 }
Пример #12
0
 public PanelJugadores(ControladorServidor control) {
   setLayout(new BorderLayout());
   controlador = control;
   jPanel1 = new JPanel();
   jPanel2 = new JPanel();
   jLabelJugadores = new JLabel("     Jugadores en mesa:");
   jJugadores = new JList(controlador.getListaJugadores());
   jJugadores.setFont(new Font("Serif", Font.ITALIC, 12));
   jJugadores.setBorder(BorderFactory.createEtchedBorder());
   jJugadores.setToolTipText("Jugadores");
   add(jLabelJugadores, BorderLayout.NORTH);
   add(jJugadores, BorderLayout.CENTER);
   add(jPanel1, BorderLayout.EAST);
   add(jPanel2, BorderLayout.WEST);
 }
Пример #13
0
 // 用于把所有生词添加到List中的函数
 private static void AddWordToList() {
   NewwordsList.setFont(dictionary.myFont);
   String[] newword = new String[NewWord.size()];
   for (int i = 0; i < NewWord.size(); i++) {
     String blank = "";
     for (int j = 0; j < 20 - NewWord.get(i).length(); j++) {
       blank = blank + " ";
     }
     newword[i] =
         NewWord.get(i) + blank + wordLib.getMean(dictionary.Tree.getWordIndex(NewWord.get(i)));
   }
   NewwordsList.setListData(newword);
   NewWordListPanel.setViewportView(null);
   NewWordListPanel.setViewportView(NewwordsList);
 }
Пример #14
0
  @NotNull
  public static <T extends PsiElement> JBPopup getPsiElementPopup(
      @NotNull T[] elements,
      @NotNull final PsiElementListCellRenderer<T> renderer,
      @Nullable final String title,
      @NotNull final PsiElementProcessor<T> processor,
      @Nullable final T selection) {
    final JList list =
        new JBListWithHintProvider(elements) {
          @Nullable
          @Override
          protected PsiElement getPsiElementForHint(Object selectedValue) {
            return (PsiElement) selectedValue;
          }
        };
    list.setCellRenderer(renderer);

    list.setFont(EditorUtil.getEditorFont());

    if (selection != null) {
      list.setSelectedValue(selection, true);
    }

    final Runnable runnable =
        () -> {
          int[] ids = list.getSelectedIndices();
          if (ids == null || ids.length == 0) return;
          for (Object element : list.getSelectedValues()) {
            if (element != null) {
              processor.execute((T) element);
            }
          }
        };

    PopupChooserBuilder builder = new PopupChooserBuilder(list);
    if (title != null) {
      builder.setTitle(title);
    }
    renderer.installSpeedSearch(builder, true);

    JBPopup popup = builder.setItemChoosenCallback(runnable).createPopup();

    builder.getScrollPane().setBorder(null);
    builder.getScrollPane().setViewportBorder(null);

    return popup;
  }
Пример #15
0
  /** Refreshes the game list panel */
  public void refreshPlayerList() {
    DefaultListModel model = new DefaultListModel();

    List players = this.graphicLobby.lobbyClient.getPlayers();

    if (players != null)
      for (Iterator iterator = players.iterator(); iterator.hasNext(); )
        model.addElement((String) iterator.next());

    JList list = new JList(model);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    list.setLayoutOrientation(JList.VERTICAL);
    list.setVisibleRowCount(-1);
    list.setFont(new Font("Comic Sans MS", Font.BOLD, 15));
    list.setForeground(Color.black);
    list.setOpaque(false);

    list.repaint();
    list.revalidate();

    super.setViewportView(list);
  }
 public void setPreferredFont(Font font) {
   list.setFont(font);
 }
Пример #17
0
  // again, sets the gui
  void init(final int perspective, final Puzzle puzzle) {
    con.removeAll();
    setBounds(0, 0, 1400, 1030);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel header = new JLabel("Edit Puzzle");
    header.setFont(new Font("Serif", Font.BOLD, 40));
    header.setForeground(Color.BLACK);
    header.setBounds(600, 0, 290, 50);
    canvas = new MyCanvas(perspective);
    canvas.setBounds(30, 120, 800, 800);
    canvas.boxItem = puzzle.boxItems;
    canvas.isfromEditBoard = true;
    panel.setBackground(Color.orange);
    panel.setBounds(0, 0, 1300, 1000);
    JLabel[] alphabets = asigningalphabets(perspective);
    JLabel[] alphabets1 = asigningalphabets1(perspective);
    JLabel[] numbers = assigningnumbers(perspective);
    JLabel[] numbers1 = assigningnumbers1(perspective);
    JButton buttonNext = new JButton("Edit");
    buttonNext.setBounds(1150, 850, 120, 30);
    buttonNext.setFont(new Font("Serif", Font.BOLD, 20));
    buttonNext.setFocusable(false);
    JButton backButton = new JButton("Return");
    backButton.setBounds(930, 850, 120, 30);
    backButton.setFont(new Font("Serif", Font.BOLD, 20));
    backButton.setFocusable(false);
    listmodel = new DefaultListModel();
    enterPuzzle(puzzle.getcategoryName());
    final JList listofMoves = new JList(listmodel);
    JScrollPane list = new JScrollPane();
    list.setViewportView(listofMoves);
    list.setBounds(870, 350, 500, 300);
    listofMoves.setFont(new Font("Serif", Font.PLAIN, 20));
    for (int i = 0; i < listmodel.getSize(); i++) {
      CategoryNode tmp = ChessApplication.l.head;
      while (tmp != null) {
        if (tmp.categoryName.equalsIgnoreCase(puzzle.getcategoryName())) {
          Puzzle temp = tmp.h;
          int counter = 0;
          while (temp != null) {
            if (temp.getFenString().equalsIgnoreCase(puzzle.getFenString())) {
              listofMoves.setSelectedIndex(counter);
            }
            temp = temp.next;
            counter++;
          }
        }
        tmp = tmp.next;
      }
    }
    JLabel categoryLabel = new JLabel("Select Category");
    categoryLabel.setFont(new Font("Serif", Font.BOLD, 20));
    categoryLabel.setBounds(1020, 160, 290, 30);
    JLabel movesLabel = new JLabel("Select Puzzle");
    movesLabel.setFont(new Font("Serif", Font.BOLD, 20));
    movesLabel.setBounds(1030, 310, 290, 30);
    DefaultComboBoxModel catagorylist = new DefaultComboBoxModel();
    for (int i = 1; i < BoardtoAdd.listofCategory.getSize(); i++) {
      catagorylist.addElement(BoardtoAdd.listofCategory.getElementAt(i));
    }
    final JComboBox categoryBox = new JComboBox(catagorylist);
    categoryBox.setBounds(1000, 200, 200, 30);
    categoryBox.setFont(new Font("Serif", Font.BOLD, 20));
    categoryBox.setSelectedItem(puzzle.getcategoryName());
    backButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            setRunningFalse();
            ChessApplication.editboard.setVisible(false);
            ChessApplication.startform.setVisible(true);
          }
        });
    buttonNext.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            setRunningFalse();
            ChessApplication.editboard.setVisible(false);
            ChessApplication.boardtoedit.init("Edit Moves", perspective, false, puzzle);
          }
        });
    listofMoves.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseClicked(MouseEvent e) {
            setRunningFalse();
            ChessApplication.editboard.setVisible(false);
            puzzle.setBoxItems();
            ChessApplication.editboard.init(
                getPuzzle(categoryBox.getSelectedItem().toString(), listofMoves.getSelectedIndex())
                    .position
                    .getToPlay(),
                getPuzzle(
                    categoryBox.getSelectedItem().toString(), listofMoves.getSelectedIndex()));
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}
        });
    categoryBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            setRunningFalse();
            ChessApplication.editboard.setVisible(false);
            puzzle.setBoxItems();
            ChessApplication.editboard.init(
                getPuzzle(categoryBox.getSelectedItem().toString()).position.getToPlay(),
                getPuzzle(categoryBox.getSelectedItem().toString()));
          }
        });
    for (int i = 0; i < 8; i++) {
      con.add(alphabets[i]);
      con.add(numbers[i]);
      con.add(alphabets1[i]);
      con.add(numbers1[i]);
    }
    con.add(categoryLabel);
    con.add(movesLabel);
    con.add(categoryBox);
    con.add(list);
    con.add(backButton);
    con.add(buttonNext);
    con.add(header);
    con.add(canvas);
    con.setBackground(Color.orange);
    con.add(panel);
    setVisible(true);
    canvas.start();
  }
Пример #18
0
 /**
  * constructor
  *
  * @param controller is the parent object
  * @throws Exception
  */
 public PseudoHYDC3View(PseudoHYDC3 controller) throws Exception {
   this.controller = controller;
   {
     String sFontName = "DFKai-SB2" /*"PMingLiU"*/;
     if (System.getProperty("hydc3.fontName") != null) {
       sFontName = System.getProperty("hydc3.fontName");
     }
     UIManager.put(
         "TextPane.font",
         new Font(
             sFontName,
             UIManager.getFont("TextPane.font").getStyle(),
             UIManager.getFont("TextPane.font").getSize()));
     UIManager.put(
         "List.font",
         new Font(
             sFontName,
             UIManager.getFont("List.font").getStyle(),
             UIManager.getFont("List.font").getSize()));
     UIManager.put(
         "TextField.font",
         new Font(
             sFontName,
             UIManager.getFont("TextField.font").getStyle(),
             UIManager.getFont("TextField.font").getSize()));
   }
   frame = new JFrame("漢語大詞典もどき");
   frame.setPreferredSize(new Dimension(800, 600));
   {
     JMenuBar menuBar = new JMenuBar();
     {
       JMenu menu = new JMenu("File");
       {
         JMenuItem menuItem = new JMenuItem("Exit");
         menuItem.addActionListener(
             new ActionListener() {
               @Override
               public void actionPerformed(ActionEvent event) {
                 System.exit(0);
               }
             });
         menu.add(menuItem);
       }
       menuBar.add(menu);
     }
     {
       JMenu menu = new JMenu("Help");
       {
         JMenuItem menuItem = new JMenuItem("About...");
         menuItem.addActionListener(
             new ActionListener() {
               @Override
               public void actionPerformed(ActionEvent event) {
                 JOptionPane.showMessageDialog(
                     frame,
                     "漢語大詞典もどき  version 0.1  by Beu",
                     "about",
                     JOptionPane.INFORMATION_MESSAGE);
               }
             });
         menu.add(menuItem);
       }
       menuBar.add(menu);
     }
     frame.setJMenuBar(menuBar);
     JPanel rootPanel = new JPanel(new BorderLayout());
     {
       JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
       {
         JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
         {
           JTabbedPane tabbedPane = new JTabbedPane();
           {
             JPanel panel = new JPanel();
             BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS);
             panel.setLayout(layout);
             {
               JPanel panel2 = new JPanel();
               {
                 inputTextField = new JTextField(8);
                 Font font = inputTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 3);
                 inputTextField.setFont(font);
                 panel2.add(inputTextField);
               }
               panel.add(panel2);
             }
             {
               JPanel panel2 = new JPanel();
               {
                 JButton button = new JButton("字");
                 button.setActionCommand("searchWithCharacter");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("詞");
                 button.setActionCommand("searchWithWord");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("音");
                 button.setActionCommand("searchWithReading");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("碼");
                 button.setActionCommand("searchWithCode");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               panel.add(panel2);
             }
             tabbedPane.addTab("輸入", panel);
           }
           {
             DefaultMutableTreeNode root = controller.getRadicalTree();
             JTree tree = new JTree(root);
             Font font = tree.getFont();
             font = font.deriveFont(font.getSize2D() * 1.5F);
             tree.setFont(font);
             tree.addTreeSelectionListener(controller);
             JScrollPane scrollPane =
                 new JScrollPane(
                     tree,
                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
             tabbedPane.addTab("部首", scrollPane);
           }
           {
             JPanel panel = new JPanel();
             BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS);
             panel.setLayout(layout);
             {
               JPanel panel2 = new JPanel();
               panel2.add(new JLabel("從"));
               {
                 fromStrokesTextField = new JTextField("1", 2);
                 Font font = fromStrokesTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 2);
                 fromStrokesTextField.setFont(font);
                 fromStrokesTextField.setHorizontalAlignment(JTextField.RIGHT);
                 panel2.add(fromStrokesTextField);
               }
               panel2.add(new JLabel("到"));
               {
                 toStrokesTextField = new JTextField("10", 2);
                 Font font = toStrokesTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 2);
                 toStrokesTextField.setFont(font);
                 toStrokesTextField.setHorizontalAlignment(JTextField.RIGHT);
                 panel2.add(toStrokesTextField);
               }
               panel.add(panel2);
             }
             {
               JPanel panel2 = new JPanel();
               {
                 JButton button = new JButton("査");
                 button.setActionCommand("searchWithStrokes");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               panel.add(panel2);
             }
             tabbedPane.addTab("畫數", panel);
           }
           splitPane2.add(tabbedPane, JSplitPane.TOP);
         }
         {
           selectingList = new JList();
           Font font = selectingList.getFont();
           font = font.deriveFont(font.getSize2D() * 2);
           selectingList.setFont(font);
           selectingList.addMouseListener(controller);
           JScrollPane scrollPane =
               new JScrollPane(
                   selectingList,
                   JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                   JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
           scrollPane.setBorder(new TitledBorder("候補"));
           splitPane2.add(scrollPane, JSplitPane.BOTTOM);
         }
         splitPane.add(splitPane2, JSplitPane.LEFT);
       }
       {
         descriptionTextPane = new JTextPane();
         Font font = descriptionTextPane.getFont();
         font = font.deriveFont(font.getSize2D() * 1.5F);
         descriptionTextPane.setFont(font);
         descriptionTextPane.addMouseListener(controller);
         descriptionTextPane.addMouseMotionListener(controller);
         JScrollPane scrollPane =
             new JScrollPane(
                 descriptionTextPane,
                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         splitPane.add(scrollPane, JSplitPane.RIGHT);
       }
       rootPanel.add(splitPane, BorderLayout.CENTER);
     }
     {
       JPanel panel = new JPanel(new BorderLayout());
       {
         JLabel label = new JLabel("status");
         panel.add(label, BorderLayout.WEST);
       }
       rootPanel.add(panel, BorderLayout.SOUTH);
     }
     frame.setContentPane(rootPanel);
   }
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
Пример #19
0
  ////////////////////////////////////////////////////////////////
  // contructors
  public PropPanelInterface() {
    super("Interface", _interfaceIcon, 3);

    Class mclass = MInterface.class;

    addCaption("Name:", 1, 0, 0);
    addField(nameField, 1, 0, 0);

    addCaption("Stereotype:", 2, 0, 0);
    //    stereotypeBox.setEnabled(false);
    addField(new UMLComboBoxNavigator(this, "NavStereo", stereotypeBox), 2, 0, 0);

    addCaption("Namespace:", 3, 0, 0);
    addField(namespaceScroll, 3, 0, 0);

    addCaption("Extends:", 4, 0, 0);
    addField(extendsScroll, 4, 0, 0);

    addCaption("Modifiers:", 5, 0, 1);
    JPanel modifiersPanel = new JPanel(new GridLayout(0, 2));
    modifiersPanel.add(
        new UMLCheckBox(
            localize("Public"),
            this,
            new UMLEnumerationBooleanProperty(
                "visibility",
                mclass,
                "getVisibility",
                "setVisibility",
                MVisibilityKind.class,
                MVisibilityKind.PUBLIC,
                null)));
    modifiersPanel.add(
        new UMLCheckBox(
            localize("Abstract"),
            this,
            new UMLReflectionBooleanProperty("isAbstract", mclass, "isAbstract", "setAbstract")));
    modifiersPanel.add(
        new UMLCheckBox(
            localize("Final"),
            this,
            new UMLReflectionBooleanProperty("isLeaf", mclass, "isLeaf", "setLeaf")));
    modifiersPanel.add(
        new UMLCheckBox(
            localize("Root"),
            this,
            new UMLReflectionBooleanProperty("isRoot", mclass, "isRoot", "setRoot")));
    addField(modifiersPanel, 5, 0, 1);

    addCaption("Associations:", 0, 1, 0.3);
    addField(connectScroll, 0, 1, 0.3);

    addCaption("Implementations:", 1, 1, 0.4);
    JList implementations = new UMLList(new UMLSupplierDependencyListModel(this, null, true), true);
    implementations.setForeground(Color.blue);
    implementations.setVisibleRowCount(1);
    implementations.setFont(smallFont);
    addField(new JScrollPane(implementations), 1, 1, 0.4);

    addCaption("Derived:", 2, 1, 0.3);
    addField(derivedScroll, 2, 1, 0.3);

    addCaption("Operations:", 0, 2, 0.5);
    addField(opsScroll, 0, 2, 0.5);

    addCaption("Attributes:", 1, 2, 0.5);
    addField(attrScroll, 1, 2, 0.5);

    new PropPanelButton(
        this, buttonPanel, _navUpIcon, localize("Go up"), "navigateNamespace", null);
    new PropPanelButton(
        this,
        buttonPanel,
        _navBackIcon,
        localize("Go back"),
        "navigateBackAction",
        "isNavigateBackEnabled");
    new PropPanelButton(
        this,
        buttonPanel,
        _navForwardIcon,
        localize("Go forward"),
        "navigateForwardAction",
        "isNavigateForwardEnabled");
    new PropPanelButton(
        this, buttonPanel, _addOpIcon, localize("Add operation"), "addOperation", null);
    // new PropPanelButton(this,buttonPanel,_generalizationIcon,localize("Add
    // generalization"),"addGeneralization",null);
    // new PropPanelButton(this,buttonPanel,_realizationIcon,localize("Add
    // realization"),"addRealization",null);
    new PropPanelButton(
        this, buttonPanel, _deleteIcon, localize("Delete interface"), "removeElement", null);
    // does this make sense?? new PropPanelButton(this,buttonPanel,_interfaceIcon,localize("New
    // interface"),"newInterface",null);

  }
Пример #20
0
  public SQLiteDataBrowser() {
    SQLiteDbManager dbManager = new SQLiteDbManager();

    setLayout(new BorderLayout());

    showTablesList = new JList();
    showTablesList.setLayoutOrientation(JList.VERTICAL_WRAP);
    showTablesList.setSelectedIndex(ListSelectionModel.SINGLE_SELECTION);
    showTablesList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    showTablesList.setFont(new Font("Times New Roman", Font.PLAIN, 13));
    showTablesList.setDragEnabled(false);
    showTablesList.setFixedCellWidth(150);
    showTablesList.setVisibleRowCount(-1);
    showTablesList.setEnabled(false);

    showTablesListScroller = new JScrollPane(showTablesList);
    showTablesListScroller.setBorder(
        BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "List of Tables"));
    showTablesListScroller.setPreferredSize(new Dimension(160, this.getHeight()));

    add(showTablesListScroller, BorderLayout.EAST);

    loadDbPanel = new JPanel(new FlowLayout());
    loadDbPanel.setBackground(new Color(0xe8e8e8));
    loadDbPanel.setPreferredSize(new Dimension(getWidth(), 40));

    loadDbLabel = new JLabel("Load SQLite Database: ");
    loadDbLabel.setToolTipText("Possible extensions being .sqlite|.sqlite3|.db|.db3");

    loadedDbPath = new JTextField("Click browse to choose the database file.", 60);
    loadedDbPath.setForeground(Color.GRAY);
    loadedDbPath.setFont(new Font("Times New Roman", Font.ITALIC, 13));
    loadedDbPath.setEditable(false);

    lastFolderLocation = new File(Utils.getUserHome());
    fc = new JFileChooser(lastFolderLocation);

    browseDb = new JButton("Browse");
    browseDb.addActionListener(
        actionEvent -> {
          int retVal = fc.showOpenDialog(SQLiteDataBrowser.this);
          if (retVal == JFileChooser.APPROVE_OPTION) {
            File dbPath = fc.getSelectedFile();
            if (Utils.checkIfSQLiteDb(dbPath)) {
              loadedDbPath.setText(dbPath.toString());
              lastFolderLocation = fc.getCurrentDirectory();
              new SwingWorker<Void, Void>() {

                @Override
                protected Void doInBackground() throws Exception {
                  try {
                    dbManager.setDbPath(dbPath.toString());
                    dbManager.initialize();
                    showTablesList.setListData(dbManager.getTables().toArray());
                    showTablesList.setEnabled(true);
                  } catch (SQLException e) {
                    e.printStackTrace();
                  }
                  return null;
                }
              }.execute();
            } else {
              JOptionPane.showMessageDialog(
                  SQLiteDataBrowser.this,
                  "The Selected file is not in SQLite Format",
                  "File Format Error",
                  JOptionPane.ERROR_MESSAGE);
              loadedDbPath.setText("Click browse to choose the database file.");
            }
          }
        });

    loadDbPanel.add(loadDbLabel);
    loadDbPanel.add(loadedDbPath);
    loadDbPanel.add(browseDb);

    loadDbRecords = new JLabel("Records Fetched (Rows x Cols): ");
    loadDbRecords.setFont(new Font("Times New Roman", Font.ITALIC, 12));
    loadDbPanel.add(loadDbRecords);

    loadDbRecordsCount = new JLabel();
    loadDbRecordsCount.setFont(new Font("Times New Roman", Font.ITALIC, 12));
    loadDbPanel.add(loadDbRecordsCount);

    final class DataBrowserTableModal extends DefaultTableModel {

      public DataBrowserTableModal() {}

      public DataBrowserTableModal(Object[][] tableData, Object[] colNames) {
        super(tableData, colNames);
      }

      @Override
      public void setDataVector(Object[][] tableData, Object[] colNames) {
        super.setDataVector(tableData, colNames);
      }

      @Override
      public boolean isCellEditable(int row, int column) {
        return false;
      }
    }

    DataBrowserTableModal tableModal = new DataBrowserTableModal();
    defaultTableModel = tableModal;

    table = new JTable();
    table.setModel(defaultTableModel);

    showTablesList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            JList list = (JList) evt.getSource();
            if (evt.getClickCount() == 2) {
              String tableName = list.getSelectedValue().toString();

              new SwingWorker<Void, Void>() {

                @Override
                protected Void doInBackground() throws Exception {
                  try {
                    ResultSet rs = dbManager.executeQuery("SELECT * from " + tableName);
                    Vector<String> columnNames = dbManager.getColumnNames(rs);
                    Vector<Vector<Object>> tableData = new Vector<>();
                    while (rs.next()) {
                      Vector<Object> vector = new Vector<>();

                      for (int i = 1; i <= columnNames.size(); i++) {
                        vector.add(rs.getObject(i));
                      }
                      tableData.add(vector);
                    }
                    defaultTableModel.setDataVector(tableData, columnNames);
                  } catch (SQLException e) {
                    e.printStackTrace();
                  }

                  loadDbRecordsCount.setText(
                      defaultTableModel.getRowCount() + " x " + defaultTableModel.getColumnCount());

                  if (defaultTableModel.getColumnCount() < 5) {
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
                  } else {
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                  }

                  return null;
                }
              }.execute();
            }
          }
        });

    tableScrollPane = new JScrollPane(table);
    tableScrollPane.setHorizontalScrollBarPolicy(
        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    tableScrollPane.setPreferredSize(new Dimension(getWidth(), getHeight()));
    add(tableScrollPane, BorderLayout.CENTER);

    add(loadDbPanel, BorderLayout.NORTH);
  }
Пример #21
0
  /** Creates the GUI. */
  protected void createGUI() {
    JButton throwaway = new JButton("by"); // $NON-NLS-1$
    throwaway.setBorder(LibraryBrowser.buttonBorder);
    int h = throwaway.getPreferredSize().height;
    sharedFont = throwaway.getFont();

    // create collections list
    ListModel collectionListModel =
        new AbstractListModel() {
          public int getSize() {
            return library.pathList.size();
          }

          public Object getElementAt(int i) {
            String path = library.pathList.get(i);
            return library.pathToNameMap.get(path);
          }
        };
    collectionList = new JList(collectionListModel);
    collectionList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            refreshGUI();
          }
        });
    collectionList.setFixedCellHeight(h);
    collectionList.setFont(sharedFont);
    collectionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // create import list
    ListModel importListModel =
        new AbstractListModel() {
          public int getSize() {
            return library.importedPathList.size();
          }

          public Object getElementAt(int i) {
            String path = library.importedPathList.get(i);
            return library.importedPathToLibraryMap.get(path).getName();
          }
        };
    guestList = new JList(importListModel);
    guestList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            refreshGUI();
          }
        });
    guestList.setFont(sharedFont);
    guestList.setFixedCellHeight(h);
    guestList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // create name action, field and label
    nameAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String path = pathField.getText();
            String prev = library.pathToNameMap.get(path);
            String input = nameField.getText().trim();
            if (input == null || input.equals("") || input.equals(prev)) { // $NON-NLS-1$
              return;
            }
            library.renameCollection(path, input);
            browser.refreshCollectionsMenu();
            collectionList.repaint();
            refreshGUI();
          }
        };
    nameField = new LibraryTreePanel.EntryField();
    nameField.addActionListener(nameAction);
    nameField.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent e) {
            nameField.selectAll();
          }

          public void focusLost(FocusEvent e) {
            nameAction.actionPerformed(null);
          }
        });
    nameField.setBackground(Color.white);

    nameLabel = new JLabel();
    nameLabel.setFont(sharedFont);
    nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 2));
    nameLabel.setHorizontalAlignment(SwingConstants.TRAILING);

    // create path action, field and label
    //		pathAction = new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //	    	int i = collectionList.getSelectedIndex();
    //      	String path = library.pathList.get(i);
    //  			String name = library.pathToNameMap.get(path);
    //      	String input = pathField.getText().trim();
    //        if(input==null || input.equals("") || input.equals(path)) { //$NON-NLS-1$
    //          return;
    //        }
    //        library.pathList.remove(i);
    //        library.pathList.add(i, input);
    //        library.pathToNameMap.remove(path);
    //        library.pathToNameMap.put(input, name);
    //
    //        browser.refreshCollectionsMenu();
    //  			collectionList.repaint();
    //  			refreshGUI();
    //     	}
    //    };
    pathField = new LibraryTreePanel.EntryField();
    pathField.setEditable(false);
    //  	pathField.addActionListener(pathAction);
    //  	pathField.addFocusListener(new FocusAdapter() {
    //      public void focusGained(FocusEvent e) {
    //      	pathField.selectAll();
    //      }
    //      public void focusLost(FocusEvent e) {
    //      	pathAction.actionPerformed(null);
    //      }
    //    });
    pathField.setBackground(Color.white);

    pathLabel = new JLabel();
    pathLabel.setFont(sharedFont);
    pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 2));
    pathLabel.setHorizontalAlignment(SwingConstants.TRAILING);

    // create buttons
    okButton = new JButton();
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    moveUpButton = new JButton();
    moveUpButton.setOpaque(false);
    moveUpButton.setBorder(LibraryBrowser.buttonBorder);
    moveUpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            paths.add(i - 1, path);
            list.setSelectedIndex(i - 1);
            browser.refreshCollectionsMenu();
            browser.refreshGUI();
          }
        });
    moveDownButton = new JButton();
    moveDownButton.setOpaque(false);
    moveDownButton.setBorder(LibraryBrowser.buttonBorder);
    moveDownButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            paths.add(i + 1, path);
            list.setSelectedIndex(i + 1);
            browser.refreshCollectionsMenu();
            browser.refreshGUI();
          }
        });
    addButton = new JButton();
    addButton.setOpaque(false);
    addButton.setBorder(LibraryBrowser.buttonBorder);
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean imported = tabbedPane.getSelectedComponent() == importsPanel;
            String message =
                imported
                    ? ToolsRes.getString("LibraryBrowser.Dialog.AddLibrary.Message")
                    : //$NON-NLS-1$
                    ToolsRes.getString(
                        "LibraryBrowser.Dialog.AddCollection.Message"); //$NON-NLS-1$
            String title =
                imported
                    ? ToolsRes.getString("LibraryBrowser.Dialog.AddLibrary.Title")
                    : //$NON-NLS-1$
                    ToolsRes.getString("LibraryBrowser.Dialog.AddCollection.Title"); // $NON-NLS-1$

            Object input =
                JOptionPane.showInputDialog(
                    browser, message, title, JOptionPane.QUESTION_MESSAGE, null, null, null);

            if (input == null || input.equals("")) { // $NON-NLS-1$
              return;
            }
            String path = input.toString();
            path = XML.forwardSlash(path);
            path = ResourceLoader.getNonURIPath(path);

            if (tabbedPane.getSelectedComponent() == collectionsPanel) {
              boolean isResource = false;
              if (!path.startsWith("http") && new File(path).isDirectory()) { // $NON-NLS-1$
                isResource = true;
              } else {
                XMLControl control = new XMLControlElement(path);
                if (!control.failedToRead()
                    && control.getObjectClass() == LibraryCollection.class) {
                  isResource = true;
                }
              }
              if (isResource) {
                browser.addToCollections(path);
                ListModel model = collectionList.getModel();
                collectionList.setModel(model);
                refreshGUI();
                collectionList.repaint();
                collectionList.setSelectedIndex(library.pathList.size() - 1);
                browser.refreshCollectionsMenu();
                return;
              }
            }
            if (tabbedPane.getSelectedComponent() == importsPanel) {
              boolean isLibrary = false;
              XMLControl control = new XMLControlElement(path);
              if (!control.failedToRead() && control.getObjectClass() == Library.class) {
                isLibrary = true;
              }
              if (isLibrary) {
                Library newLibrary = new Library();
                newLibrary.browser = LibraryManager.this.browser;
                control.loadObject(newLibrary);
                if (library.importLibrary(path, newLibrary)) {
                  ListModel model = guestList.getModel();
                  guestList.setModel(model);
                  refreshGUI();
                  guestList.repaint();
                  guestList.setSelectedIndex(library.importedPathList.size() - 1);
                  browser.refreshCollectionsMenu();
                }
                return;
              }
            }

            String s =
                ToolsRes.getString(
                    "LibraryBrowser.Dialog.CollectionNotFound.Message"); //$NON-NLS-1$
            JOptionPane.showMessageDialog(
                LibraryManager.this,
                s + ":\n" + path, // $NON-NLS-1$
                ToolsRes.getString("LibraryBrowser.Dialog.CollectionNotFound.Title"), // $NON-NLS-1$
                JOptionPane.WARNING_MESSAGE);
          }
        });
    removeButton = new JButton();
    removeButton.setOpaque(false);
    removeButton.setBorder(LibraryBrowser.buttonBorder);
    removeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            if (isImports) library.importedPathToLibraryMap.remove(path);
            else library.pathToNameMap.remove(path);
            list.repaint();
            if (i >= paths.size()) {
              list.setSelectedIndex(paths.size() - 1);
            }
            browser.refreshCollectionsMenu();
            refreshGUI();
            browser.refreshGUI();
          }
        });
    // create all and none buttons
    allButton = new JButton();
    allButton.setOpaque(false);
    allButton.setBorder(LibraryBrowser.buttonBorder);
    allButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (SearchCheckBox next : checkboxes) {
              next.setSelected(true);
            }
          }
        });
    noneButton = new JButton();
    noneButton.setOpaque(false);
    noneButton.setBorder(LibraryBrowser.buttonBorder);
    noneButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (SearchCheckBox next : checkboxes) {
              next.setSelected(false);
            }
          }
        });

    clearCacheButton = new JButton();
    clearCacheButton.setOpaque(false);
    clearCacheButton.setBorder(LibraryBrowser.buttonBorder);
    clearCacheButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            File cache = ResourceLoader.getOSPCache();
            ResourceLoader.clearOSPCache(cache, false);
            refreshCacheTab();
            tabbedPane.repaint();
          }
        });

    setCacheButton = new JButton();
    setCacheButton.setOpaque(false);
    setCacheButton.setBorder(LibraryBrowser.buttonBorder);
    setCacheButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            File newCache = ResourceLoader.chooseOSPCache(browser);
            ResourceLoader.setOSPCache(newCache);
            refreshCacheTab();
          }
        });
    Border emptyInside = BorderFactory.createEmptyBorder(1, 2, 1, 2);
    Border etched = BorderFactory.createEtchedBorder();
    Border buttonbarBorder = BorderFactory.createCompoundBorder(etched, emptyInside);

    libraryButtonbar = new JToolBar();
    libraryButtonbar.setFloatable(false);
    libraryButtonbar.setBorder(buttonbarBorder);
    libraryButtonbar.add(moveUpButton);
    libraryButtonbar.add(moveDownButton);
    libraryButtonbar.add(addButton);
    libraryButtonbar.add(removeButton);

    nameBox = Box.createHorizontalBox();
    nameBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 4));
    nameBox.add(nameLabel);
    nameBox.add(nameField);
    pathBox = Box.createHorizontalBox();
    pathBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 4));
    pathBox.add(pathLabel);
    pathBox.add(pathField);
    libraryEditBox = Box.createVerticalBox();
    libraryEditBox.add(nameBox);
    libraryEditBox.add(pathBox);

    // create and assemble tabs
    // collections tab
    collectionsPanel = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(collectionList);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    collectionsTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(collectionsTitleBorder);
    collectionsPanel.add(scroller, BorderLayout.CENTER);
    collectionsPanel.add(libraryEditBox, BorderLayout.SOUTH);
    collectionsPanel.add(libraryButtonbar, BorderLayout.NORTH);

    // imports tab
    importsPanel = new JPanel(new BorderLayout());
    scroller = new JScrollPane(guestList);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    importsTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(importsTitleBorder);
    importsPanel.add(scroller, BorderLayout.CENTER);

    // search tab
    searchPanel = new JPanel(new BorderLayout());
    searchBox = Box.createVerticalBox();
    searchBox.setBackground(Color.white);
    searchBox.setOpaque(true);
    refreshSearchTab();

    scroller = new JScrollPane(searchBox);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    searchTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(searchTitleBorder);
    searchPanel.add(scroller, BorderLayout.CENTER);
    JToolBar searchButtonbar = new JToolBar();
    searchButtonbar.setFloatable(false);
    searchButtonbar.setBorder(buttonbarBorder);
    searchButtonbar.add(allButton);
    searchButtonbar.add(noneButton);
    searchPanel.add(searchButtonbar, BorderLayout.NORTH);

    // cache tab
    cachePanel = new JPanel(new BorderLayout());
    cacheBox = Box.createVerticalBox();
    cacheBox.setBackground(Color.white);
    cacheBox.setOpaque(true);
    refreshCacheTab();

    scroller = new JScrollPane(cacheBox);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    cacheTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(cacheTitleBorder);
    cachePanel.add(scroller, BorderLayout.CENTER);
    JToolBar cacheButtonbar = new JToolBar();
    cacheButtonbar.setFloatable(false);
    cacheButtonbar.setBorder(buttonbarBorder);
    cacheButtonbar.add(clearCacheButton);
    cacheButtonbar.add(setCacheButton);
    cachePanel.add(cacheButtonbar, BorderLayout.NORTH);

    // create tabbedPane
    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("", collectionsPanel); // $NON-NLS-1$
    //		tabbedPane.addTab("", importsPanel); //$NON-NLS-1$
    tabbedPane.addTab("", searchPanel); // $NON-NLS-1$
    tabbedPane.addTab("", cachePanel); // $NON-NLS-1$

    // add change listener last
    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (tabbedPane.getSelectedComponent() == collectionsPanel) {
              collectionsPanel.add(libraryButtonbar, BorderLayout.NORTH);
              collectionsPanel.add(libraryEditBox, BorderLayout.SOUTH);
              refreshGUI();
            } else if (tabbedPane.getSelectedComponent() == importsPanel) {
              importsPanel.add(libraryButtonbar, BorderLayout.NORTH);
              importsPanel.add(libraryEditBox, BorderLayout.SOUTH);
              refreshGUI();
            }
          }
        });

    Border space = BorderFactory.createEmptyBorder(0, 2, 0, 2);
    listButtonBorder = BorderFactory.createCompoundBorder(etched, space);

    // assemble content pane
    JPanel contentPane = new JPanel(new BorderLayout());
    setContentPane(contentPane);
    contentPane.add(tabbedPane, BorderLayout.CENTER);
    JPanel south = new JPanel();
    south.add(okButton);
    contentPane.add(south, BorderLayout.SOUTH);
  }
Пример #22
0
    /**
     * Create new interval panel.
     *
     * @param column the current column name
     * @param parent used to refresh column list is number of bins has changed
     * @param type the type for the spinner model
     */
    IntervalPanel(final Component parent, final DataType type) {
      super(new BorderLayout());
      setBorder(BorderFactory.createTitledBorder(" " + "Title" + " "));
      m_intervalMdl = new DefaultListModel();
      m_intervalList = new JList(m_intervalMdl);
      Font font = new Font("Monospaced", Font.PLAIN, 12);
      m_intervalList.setFont(font);
      final JButton addButton = new JButton("Add");
      addButton.addActionListener(
          new ActionListener() {
            /** */
            @Override
            public void actionPerformed(final ActionEvent e) {
              final int size = m_intervalMdl.getSize();
              // if the first interval is added
              if (size == 0) {
                m_intervalMdl.addElement(
                    new IntervalItemPanel(IntervalPanel.this, null, null, 0.0, type));
              } else {
                // if the first interval needs to be split
                if (size == 1) {
                  IntervalItemPanel p =
                      new IntervalItemPanel(IntervalPanel.this, 0.0, null, 1.0, type);
                  m_intervalMdl.addElement(p);
                  p.updateInterval();
                } else {
                  Object o = m_intervalList.getSelectedValue();
                  // if non is selected or the last one is selected
                  if (o == null || m_intervalMdl.indexOf(o) == size - 1) {
                    IntervalItemPanel p1 = (IntervalItemPanel) m_intervalMdl.getElementAt(size - 1);
                    double d = p1.getLeftValue(false);
                    IntervalItemPanel p =
                        new IntervalItemPanel(
                            IntervalPanel.this, d, POSITIVE_INFINITY, (size + 1.0), type);
                    m_intervalMdl.insertElementAt(p, size);
                    p.updateInterval();
                  } else {
                    IntervalItemPanel p1 = (IntervalItemPanel) o;
                    IntervalItemPanel p2 =
                        (IntervalItemPanel)
                            m_intervalMdl.getElementAt(m_intervalMdl.indexOf(p1) + 1);
                    double d1 = p1.getRightValue(false);
                    double d2 = p2.getLeftValue(false);
                    IntervalItemPanel p =
                        new IntervalItemPanel(IntervalPanel.this, d1, d2, +(size + 1.0), type);
                    m_intervalMdl.insertElementAt(p, m_intervalMdl.indexOf(p1) + 1);
                    p.updateInterval();
                  }
                }
              }
              updateInfo();
              parent.validate();
              parent.repaint();
            }
          });
      final JButton removeButton = new JButton("Remove");
      removeButton.addActionListener(
          new ActionListener() {
            /** */
            @Override
            public void actionPerformed(final ActionEvent e) {
              IntervalItemPanel p = (IntervalItemPanel) m_intervalList.getSelectedValue();
              if (p != null) {
                int i = m_intervalMdl.indexOf(p);
                m_intervalMdl.removeElement(p);
                int size = m_intervalMdl.getSize();
                if (size > 0) {
                  if (size == 1 || size == i) {
                    m_intervalList.setSelectedIndex(size - 1);
                  } else {
                    m_intervalList.setSelectedIndex(i);
                  }
                  ((IntervalItemPanel) m_intervalList.getSelectedValue()).updateInterval();
                }
                updateInfo();
                parent.validate();
                parent.repaint();
              }
            }
          });
      final JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
      buttonPanel.add(addButton);
      buttonPanel.add(removeButton);
      super.add(buttonPanel, BorderLayout.NORTH);

      //
      // interval list
      //

      final JPanel selInterval = new JPanel(new GridLayout(1, 1));
      selInterval.add(new IntervalItemPanel(this, null, null, null, type));
      selInterval.validate();
      selInterval.repaint();

      m_intervalList.addListSelectionListener(
          new ListSelectionListener() {
            /** */
            @Override
            public void valueChanged(final ListSelectionEvent e) {
              selInterval.removeAll();
              Object o = m_intervalList.getSelectedValue();
              if (o == null) {
                selInterval.add(new IntervalItemPanel(IntervalPanel.this, null, null, null, type));
              } else {
                selInterval.add((IntervalItemPanel) o);
              }
              m_intervalPanel.validate();
              m_intervalPanel.repaint();
            }
          });
      m_intervalList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      final JScrollPane intervalScroll = new JScrollPane(m_intervalList);
      intervalScroll.setMinimumSize(new Dimension(200, 155));
      intervalScroll.setPreferredSize(new Dimension(200, 155));
      super.add(intervalScroll, BorderLayout.CENTER);

      JPanel southPanel = new JPanel(new BorderLayout());
      southPanel.add(selInterval, BorderLayout.CENTER);
      super.add(southPanel, BorderLayout.SOUTH);
    }
Пример #23
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frmMaker = new JFrame();
    frmMaker.setTitle("ThulikaMaker");
    frmMaker.setBounds(100, 100, 564, 637);
    frmMaker.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    fcOpen = new JFileChooser();
    fcOpen.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fcSave = new JFileChooser();
    fcSave.setFileSelectionMode(JFileChooser.FILES_ONLY);
    frmMaker.getContentPane().setLayout(new BorderLayout(0, 0));

    JLayeredPane layeredPane = new JLayeredPane();
    frmMaker.getContentPane().add(layeredPane, BorderLayout.NORTH);
    layeredPane.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
            },
            new RowSpec[] {
              FormFactory.RELATED_GAP_ROWSPEC,
              FormFactory.DEFAULT_ROWSPEC,
              FormFactory.RELATED_GAP_ROWSPEC,
              FormFactory.DEFAULT_ROWSPEC,
              FormFactory.RELATED_GAP_ROWSPEC,
              FormFactory.DEFAULT_ROWSPEC,
            }));

    JLabel lblWidth = new JLabel("Width");
    layeredPane.add(lblWidth, "2, 2");

    widthBox = new JTextField();
    layeredPane.add(widthBox, "6, 2");
    widthBox.setColumns(10);

    JLabel lblHeight = new JLabel("Height");
    layeredPane.add(lblHeight, "2, 4");

    heightBox = new JTextField();
    layeredPane.add(heightBox, "6, 4");
    heightBox.setColumns(10);

    JButton btnLoadBundle = new JButton("Load Bundle");
    layeredPane.add(btnLoadBundle, "6, 6");
    final JFileChooser openBox;
    openBox = new JFileChooser();
    openBox.setFileSelectionMode(JFileChooser.FILES_ONLY);
    btnLoadBundle.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int returnVal = fcOpen.showOpenDialog(frmMaker);

            if (returnVal == JFileChooser.APPROVE_OPTION) {
              File file = fcOpen.getSelectedFile();
              letterFilePath = file.getPath();
              trainer.loadLettersAction(
                  letterFilePath,
                  Integer.parseInt(widthBox.getText()),
                  Integer.parseInt(heightBox.getText()));
            } else {
              // nothing
            }
            charListBox.setListData(trainer.getCharSet().keySet().toArray());
            charListBox.setSelectedIndex(0);
          }
        });

    JLayeredPane layeredPane_1 = new JLayeredPane();
    frmMaker.getContentPane().add(layeredPane_1, BorderLayout.SOUTH);
    layeredPane_1.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
            },
            new RowSpec[] {
              FormFactory.RELATED_GAP_ROWSPEC,
              FormFactory.DEFAULT_ROWSPEC,
              FormFactory.RELATED_GAP_ROWSPEC,
              FormFactory.DEFAULT_ROWSPEC,
            }));

    JLabel lblLanguageId = new JLabel("Language ID");
    layeredPane_1.add(lblLanguageId, "2, 2");

    langBox = new JTextField();
    layeredPane_1.add(langBox, "6, 2");
    langBox.setColumns(10);

    JButton btnSaveEngine = new JButton("Save Engine");
    layeredPane_1.add(btnSaveEngine, "6, 4");
    btnSaveEngine.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (letterFilePath == null || letterFilePath.isEmpty()) {
              JOptionPane.showMessageDialog(frmMaker, "Please load a file");
            } else {
              int returnVal = fcSave.showSaveDialog(frmMaker);
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fcSave.getSelectedFile();
                try {
                  if (trainer.trainAndSave(file.getPath(), langBox.getText())) {
                    JOptionPane.showMessageDialog(frmMaker, "Engine saved!");
                  }
                } catch (IOException e) {
                  JOptionPane.showMessageDialog(frmMaker, e.getMessage());
                  e.printStackTrace();
                }
              } else {
                // nothing
              }
            }
          }
        });

    JLayeredPane layeredPane_2 = new JLayeredPane();
    frmMaker.getContentPane().add(layeredPane_2);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(165, 11, 102, 150);
    layeredPane_2.add(scrollPane);

    imageListBox = new JList();
    imageListBox.setFont(new Font("Kartika", Font.PLAIN, 11));
    imageListBox.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent arg0) {
            // try {
            ImageFile iFile = (ImageFile) imageListBox.getSelectedValue();

            if (iFile == null) {
              imageListBox.setSelectedIndex(0);
              iFile = (ImageFile) imageListBox.getSelectedValue();
              if (iFile == null) {
                return;
              }
            }
            ImageData iData = iFile.getImageData();
            imageLabel.setIcon(
                new ImageIcon(
                    getImageFromArray(iData.getPixels(), iData.getWidth(), iData.getHeight())));
            imageLabel.setBounds(0, 0, iData.getWidth(), iData.getHeight());
            /*} catch (Exception e) {
            	// ignore
            }*/
          }
        });
    imageListBox.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scrollPane.setViewportView(imageListBox);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(277, 11, 261, 259);
    layeredPane_2.add(scrollPane_1);

    imageLabel = new JLabel("Image");
    scrollPane_1.setViewportView(imageLabel);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setBounds(9, 11, 102, 259);
    layeredPane_2.add(scrollPane_2);

    charListBox = new JList();
    scrollPane_2.setViewportView(charListBox);
    charListBox.setFont(new Font("Kartika", Font.PLAIN, 11));

    JLayeredPane layeredPane_3 = new JLayeredPane();
    layeredPane_3.setBounds(10, 295, 486, 142);
    layeredPane_2.add(layeredPane_3);

    JLabel lblSymbol = new JLabel("Symbol");
    lblSymbol.setBounds(10, 11, 46, 14);
    layeredPane_3.add(lblSymbol);

    JLabel lblAlign = new JLabel("Align");
    lblAlign.setBounds(10, 39, 46, 14);
    layeredPane_3.add(lblAlign);

    JLabel lblRules = new JLabel("Rules");
    lblRules.setBounds(10, 66, 46, 14);
    layeredPane_3.add(lblRules);

    symField = new JTextField();
    symField.setEditable(false);
    symField.setFont(new Font("Kartika", Font.PLAIN, 12));
    symField.setBounds(81, 5, 86, 20);
    layeredPane_3.add(symField);
    symField.setColumns(10);

    alignSelector = new JSpinner();
    alignSelector.setModel(new SpinnerNumberModel(0, -1, 1, 1));
    alignSelector.setBounds(81, 36, 29, 20);
    layeredPane_3.add(alignSelector);

    rulesBox = new JTextField();
    rulesBox.setFont(new Font("Kartika", Font.PLAIN, 12));
    rulesBox.setBounds(81, 64, 381, 20);
    layeredPane_3.add(rulesBox);
    rulesBox.setColumns(10);

    JButton btnSaveSymbol = new JButton("Save Symbol");
    btnSaveSymbol.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            CharData currentChar = (CharData) charListBox.getSelectedValue();
            currentChar.setAlign((Integer) alignSelector.getValue());
            Map<String, String> rules = getRules(rulesBox.getText());
            if (rules != null) {
              currentChar.setMergeRules(rules);
            }
            String alterStr = alterBox.getText();
            // String msg = setAlternativesList(currentChar, alterStr);
            // currentChar.setAlternatives(getAlternativesList(currentChar, alterStr));
            /*if(msg!=null && !msg.isEmpty()) {
            	JOptionPane.showMessageDialog(frmMaker,"Characters "+msg +" cannot be found");
            }*/
          }
        });
    btnSaveSymbol.setBounds(81, 95, 106, 23);
    layeredPane_3.add(btnSaveSymbol);

    JLabel lblAlternates = new JLabel("Alternates");
    lblAlternates.setBounds(234, 11, 60, 14);
    layeredPane_3.add(lblAlternates);

    alterBox = new JTextField();
    alterBox.setFont(new Font("Kartika", Font.PLAIN, 11));
    alterBox.setBounds(304, 8, 158, 20);
    layeredPane_3.add(alterBox);
    alterBox.setColumns(10);

    JButton btnDeleteFile = new JButton("Delete File");
    btnDeleteFile.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            String filename = ((ImageFile) imageListBox.getSelectedValue()).getFilename();
            if (trainer.deleteFile(filename)) {
              JOptionPane.showMessageDialog(frmMaker, "File " + filename + " is deleted");
            }
            try {
              populateImageData();
            } catch (Exception e) {
              imageListBox.clearSelection();
              charListBox.setSelectedIndex(0);
              charListBox.setListData(trainer.getCharSet().keySet().toArray());
            }
          }
        });
    btnDeleteFile.setBounds(165, 196, 89, 23);
    layeredPane_2.add(btnDeleteFile);
    charListBox.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent arg0) {
            populateImageData();
          }
        });
  }
Пример #24
0
  /** The globalvend screen which shows statistics of the overall system. */
  private void globalVendScreen() {
    // TODO Auto-generated method stub
    mainLayout.removeAll();

    mainLayout.setLayout(new BorderLayout(0, 20));
    JPanel mainLeftSide = new JPanel(new BorderLayout(0, 20));

    JLabel heading = new JLabel("<html><center>List of Vending <br>Machines</center></html>");
    heading.setFont(new Font("Verdana", Font.BOLD, 20));

    String data[] = new String[numberOfMachines];

    for (int i = 0; i < numberOfMachines; ++i) {
      data[i] = "Vending Machine " + (i + 1);
    }

    final JList<String> listVendingMachine = new JList<String>(data);

    listVendingMachine.setFont(new Font("Arial", Font.PLAIN, 20));
    listVendingMachine.setFixedCellHeight(50);
    listVendingMachine.setSelectedIndex(0);
    numOfSelected = listVendingMachine.getSelectedIndices();

    JScrollPane listOfMachineScroll = new JScrollPane(listVendingMachine);

    JPanel southPanel = new JPanel(new GridLayout(3, 1));
    JPanel southButtonPanel = new JPanel(new GridLayout(1, 2));
    JPanel southTextPanel = new JPanel(new FlowLayout());

    JLabel textLabel = new JLabel("ID's: ");
    final JTextField idNumbers = new JTextField();
    idNumbers.setPreferredSize(new Dimension(200, 50));
    southTextPanel.add(textLabel);
    southTextPanel.add(idNumbers);

    final JButton updateButton = new JButton("Update");
    JButton selectButton = new JButton("Select All");
    JButton deselectButton = new JButton("Deselect All");
    southButtonPanel.add(deselectButton);
    southButtonPanel.add(selectButton);
    southPanel.add(southTextPanel);
    southPanel.add(southButtonPanel);
    southPanel.add(updateButton);

    mainLeftSide.add(heading, BorderLayout.NORTH);
    mainLeftSide.add(listOfMachineScroll, BorderLayout.CENTER);
    mainLeftSide.add(southPanel, BorderLayout.SOUTH);

    JTabbedPane tabbedPane = new JTabbedPane();

    final JComponent panel1 = localVendListStockPanel();
    JScrollPane scrollPanel1 = new JScrollPane(panel1);
    tabbedPane.addTab("List Stock", scrollPanel1);
    tabbedPane.setMnemonicAt(0, KeyEvent.VK_5);

    // final JComponent panel4 = machineChart(curID+1);

    // tabbedPane.addTab("", panel4);

    final JComponent panel2 = localVendRestockerPanel();
    JScrollPane scrollPanel2 = new JScrollPane(panel2);
    tabbedPane.addTab("Restocker", scrollPanel2);
    tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

    final JComponent panel3 = new JPanel();
    localVendMarketingPanel((JPanel) panel3);
    JScrollPane scrollPanel3 = new JScrollPane(panel3);
    tabbedPane.addTab("Marketing", panel3);
    tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);

    final JComponent panel4 = machineChart(numOfSelected);
    JScrollPane scrollPanel4 = new JScrollPane(panel4);
    tabbedPane.addTab("Item %", scrollPanel4);
    tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);

    final JComponent panelGross = machineGrossChart(numOfSelected);
    JScrollPane scrollpanelGross = new JScrollPane(panelGross);
    tabbedPane.addTab("Item Gross", scrollpanelGross);
    tabbedPane.setMnemonicAt(4, KeyEvent.VK_5);

    final JComponent panel5 = machineItemChart(numOfSelected);
    JScrollPane scrollPanel5 = new JScrollPane(panel5);
    tabbedPane.addTab("% Reasons Item Sold", scrollPanel5);
    tabbedPane.setMnemonicAt(5, KeyEvent.VK_6);

    final JComponent panelIncome = makeIncomeGraph(numOfSelected);
    panelIncome.setRequestFocusEnabled(true);
    JScrollPane scrollpanelIncome = new JScrollPane(panelIncome);
    tabbedPane.addTab("Income Graph", scrollpanelIncome);
    tabbedPane.setMnemonicAt(6, KeyEvent.VK_7);

    mainLayout.add(mainLeftSide, BorderLayout.WEST);
    mainLayout.add(tabbedPane, BorderLayout.CENTER);

    SwingUtilities.updateComponentTreeUI(this);

    listVendingMachine.setSelectionModel(
        new DefaultListSelectionModel() {
          private static final long serialVersionUID = 1L;

          boolean gestureStarted = false;

          @Override
          public void setSelectionInterval(int index0, int index1) {
            if (!gestureStarted) {
              if (isSelectedIndex(index0)) {
                super.removeSelectionInterval(index0, index1);
              } else {
                super.addSelectionInterval(index0, index1);
              }
            }
            gestureStarted = true;
          }

          @Override
          public void setValueIsAdjusting(boolean isAdjusting) {
            if (isAdjusting == false) {
              gestureStarted = false;
            }
          }
        });

    listVendingMachine.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            // TODO Auto-generated method stub
            numOfSelected = listVendingMachine.getSelectedIndices();
            ArrayList<Integer> addOns = new ArrayList<Integer>();
            if (numOfSelected.length != 0) {
              String temp = "";
              for (int i = 0; i < numOfSelected.length; ++i) {
                if (i != (numOfSelected.length - 1)) {
                  if (numOfSelected[i] + 1 == numOfSelected[i + 1]) {
                    addOns.add(numOfSelected[i]);
                  } else {
                    if (addOns.size() == 0) {
                      temp += (numOfSelected[i] + 1) + ",";
                    } else {
                      temp += (addOns.get(0) + 1) + "-" + (numOfSelected[i] + 1) + ",";
                      addOns = new ArrayList<Integer>();
                    }
                  }
                } else {
                  if (addOns.size() == 0) {
                    temp += (numOfSelected[i] + 1) + ",";
                  } else {
                    temp += (addOns.get(0) + 1) + "-" + (numOfSelected[i] + 1) + ",";
                    addOns = new ArrayList<Integer>();
                  }
                }
                // temp += (numOfSelected[i] + 1) + ",";

              }
              temp = temp.substring(0, temp.length() - 1);
              idNumbers.setText(temp);
            }
          }
        });

    idNumbers.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            char last = ' ';

            if (idNumbers.getText().length() >= 1)
              last = idNumbers.getText().charAt(idNumbers.getText().length() - 1);

            int lastDash = idNumbers.getText().lastIndexOf('-');
            int lastComma = idNumbers.getText().lastIndexOf(',');
            if ((last == ' ' && (c == '-' || c == ','))
                || (c == '-' && (lastComma - lastDash) < 0)
                || (last == '-' && (c == '-' || c == ','))
                || (last == ',' && (c == ',' || c == '-'))
                || (!Character.isDigit(c) && c != '-' && c != ',')
                    && (c != KeyEvent.VK_BACK_SPACE)) {
              e.consume(); // ignore event
            }
          }
        });

    selectButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            listVendingMachine.addSelectionInterval(0, numberOfMachines - 1);

            // TODO Auto-generated method stub

          }
        });
    deselectButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            idNumbers.setText("");
            listVendingMachine.removeSelectionInterval(0, numberOfMachines - 1);
          }
        });

    updateButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            listVendingMachine.removeSelectionInterval(0, numberOfMachines - 1);
            String numbers = idNumbers.getText();
            String[] splitNumbers = numbers.split(",");

            for (int i = 0; i < splitNumbers.length; ++i) {

              if (!splitNumbers[i].equals("")) {
                if (!splitNumbers[i].contains("-")) {
                  int num = Integer.valueOf(splitNumbers[i]) - 1;
                  if (num < 0) {
                    num = 0;
                  }
                  if (num > numberOfMachines - 1) {
                    num = numberOfMachines - 1;
                  }

                  listVendingMachine.addSelectionInterval(num, num);
                } else {
                  String[] temp = splitNumbers[i].split("-");
                  if (!temp[0].equals("") && !temp[1].equals("")) {
                    int num1 = Integer.valueOf(temp[0]) - 1;
                    int num2 = Integer.valueOf(temp[1]) - 1;
                    if (num1 < 0) {
                      num1 = 0;
                    }
                    if (num2 > numberOfMachines - 1) {
                      num2 = numberOfMachines - 1;
                    }
                    listVendingMachine.addSelectionInterval(num1, num2);
                  }
                }
              }
            }

            numOfSelected = listVendingMachine.getSelectedIndices();
            if (numOfSelected.length != 0) {

              panel1.removeAll();
              panel2.removeAll();
              panel3.removeAll();
              panel4.removeAll();
              panel5.removeAll();
              panelGross.removeAll();
              panelIncome.removeAll();

              panel1.add(localVendListStockPanel());
              panel2.add(localVendRestockerPanel());
              localVendMarketingPanel((JPanel) panel3);
              panel4.add(machineChart(numOfSelected));
              panel5.add(machineItemChart(numOfSelected));
              panelGross.add(machineGrossChart(numOfSelected));
              panelIncome.add(makeIncomeGraph(numOfSelected));

              panel1.revalidate();
              panel1.repaint();
              panel2.revalidate();
              panel2.repaint();
              panel3.revalidate();
              panel3.repaint();
              panel4.revalidate();
              panel4.repaint();
              panel5.revalidate();
              panel5.repaint();
              panelGross.revalidate();
              panelGross.repaint();
              panelIncome.revalidate();
              panelIncome.repaint();
            } else {
              panel1.removeAll();
              panel2.removeAll();
              panel3.removeAll();
              panel4.removeAll();
              panel5.removeAll();
              panelGross.removeAll();
              panelIncome.removeAll();

              panel1.setLayout(new FlowLayout());
              panel2.setLayout(new FlowLayout());
              panel3.setLayout(new FlowLayout());
              panel4.setLayout(new FlowLayout());
              panel5.setLayout(new FlowLayout());
              panelGross.setLayout(new FlowLayout());
              panelIncome.setLayout(new FlowLayout());

              panel1.add(returnEmptyPanelInfo());
              panel2.add(returnEmptyPanelInfo());
              panel3.add(returnEmptyPanelInfo());
              panel4.add(returnEmptyPanelInfo());
              panel5.add(returnEmptyPanelInfo());
              panelGross.add(returnEmptyPanelInfo());
              panelIncome.add(returnEmptyPanelInfo());

              panel1.revalidate();
              panel1.repaint();
              panel2.revalidate();
              panel2.repaint();
              panel3.revalidate();
              panel3.repaint();
              panel4.revalidate();
              panel4.repaint();
              panel5.revalidate();
              panel5.repaint();
              panelGross.revalidate();
              panelGross.repaint();
              panelIncome.revalidate();
              panelIncome.repaint();
            }
          }
        });
  }
Пример #25
0
  public SaveDialog(Frame parent) {
    super(parent, true);
    this.setLayout(new BorderLayout());
    // gather unsaved tab
    Set<Tab> unsaved = new LinkedHashSet<>();
    for (Tab tab : MainPanel.getAllTab()) {
      if (!tab.isSaved()) {
        unsaved.add(tab);
      }
    }
    if (unsaved.isEmpty()) {
      // close directly
      this.setTitle("Confirm close");
      // upper labels
      JPanel labels = new JPanel(new FlowLayout(FlowLayout.LEFT, 11, 7));
      labels.add(iconLabel);
      labels.add(new MyLabel(" Do you really want to close RefluxEdit?"));
      // buttons
      JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 7));
      buttons.add(
          new MyButton("YES") {
            {
              SaveDialog.this.getRootPane().setDefaultButton(this);
              this.setFocusPainted(true);
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              close = true;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.add(
          new MyButton("NO") {
            {
              this.setFocusPainted(true);
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              close = false;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.setBorder(new EmptyBorder(0, 0, 5, 0));
      //
      this.add(labels, BorderLayout.CENTER);
      this.add(buttons, BorderLayout.PAGE_END);
    } else {
      // ask save changes
      this.setTitle("Unsaved changes");
      // upper components: icon and list
      JPanel upper = new JPanel(new GridBagLayout());
      JPanel listPane = new JPanel(new BorderLayout());
      final DefaultListModel<Tab> listModel = new DefaultListModel<>();
      final JList<Tab> tabList = new JList<>(listModel);
      tabList.setFont(f13);
      tabList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
      tabList.setCellRenderer(
          new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(
                JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
              JLabel label =
                  (JLabel)
                      (super.getListCellRendererComponent(
                          list, value, index, isSelected, cellHasFocus));
              if (value instanceof Tab) {
                String text = ((Tab) value).getTabLabel().getText();
                label.setText(text.substring(1)); // remove "*"
              }
              return label;
            }
          });
      for (Tab tab : unsaved) {
        listModel.addElement(tab);
      }
      tabList.getSelectionModel().setSelectionInterval(0, listModel.size() - 1);
      JScrollPane scrollPane = new JScrollPane(tabList);
      scrollPane.setPreferredSize(new Dimension(350, 170));
      listPane.add(new MyLabel("The following tabs are unsaved:"), BorderLayout.PAGE_START);
      listPane.add(scrollPane, BorderLayout.CENTER);
      // setup upper
      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 0;
      c.weighty = 1;
      c.insets = new Insets(5, 5, 5, 5);
      c.anchor = GridBagConstraints.FIRST_LINE_START;
      upper.add(iconLabel, c);
      //
      c.gridx = 1;
      c.weightx = 1;
      c.fill = GridBagConstraints.BOTH;
      upper.add(listPane, c);
      // lower components: buttons
      JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 7));
      buttons.add(
          new MyButton("Save") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Save selected tab(s)");
              SaveDialog.this.getRootPane().setDefaultButton(this);
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              for (Tab tab : tabList.getSelectedValuesList()) {
                if (tab.getFile() != null) {
                  try {
                    tab.save();
                    MainPanel.close(tab);
                    listModel.removeElement(tab);
                  } catch (Exception ex) {
                    exception(ex);
                    break;
                  }
                } else {
                  File file =
                      FileChooser.showPreferredFileDialog(
                          RefluxEdit.getInstance(), FileChooser.SAVE, new String[0]);
                  if (file != null) {
                    try {
                      tab.save(file, false);
                      MainPanel.close(tab);
                      listModel.removeElement(tab);
                    } catch (Exception ex) {
                      exception(ex);
                      break;
                    }
                  }
                }
              }
              if (listModel.size() == 0) {
                RefluxEdit.getInstance().close();
              }
            }
          });
      buttons.add(
          new MyButton("Discard") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Discard selected tab(s)");
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              for (Tab tab : tabList.getSelectedValuesList()) {
                MainPanel.close(tab);
                listModel.removeElement(tab);
              }
              if (listModel.size() == 0) {
                RefluxEdit.getInstance().close();
              }
            }
          });
      buttons.add(
          new MyButton("Close") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Close RefluxEdit");
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              SaveDialog.this.close = true;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.add(
          new MyButton("Cancel") {
            {
              this.setFocusPainted(true);
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              SaveDialog.this.close = false;
              SaveDialog.this.setVisible(false);
            }
          });
      this.add(upper, BorderLayout.CENTER);
      this.add(buttons, BorderLayout.PAGE_END);
    }
  }
Пример #26
0
  /** Build the widget structure of the main window */
  private void createFrame() {

    // Set up the actions table for the whole application
    Toolkit t = Toolkit.getDefaultToolkit();
    Dimension d = t.getScreenSize();

    int width = DEFAULT_WIDTH;
    int height = d.height * 3 / 4;

    top = new JFrame();
    top.setIconImage(
        t.getImage(this.getClass().getResource(rb.getString("frame.jWinDiff.iconImage"))));
    top.setTitle(rb.getString("frame.title.scanning"));
    top.setSize(width, height);

    JPanel base = new JPanel();
    base.setLayout(new BorderLayout());
    top.getContentPane().add(base);

    pictView = new PicturePanel();
    pictView.setOpaque(true);
    pictView.setBackground(Color.white);
    base.add(pictView, BorderLayout.WEST);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.setOpaque(true);
    //      panel.setBackground(Color.cyan);
    base.add(panel, BorderLayout.NORTH);

    mainView = new JList();
    mainView.setFont(new Font(rb.getString("panel.jWinDiff.font.name"), Font.PLAIN, 12));

    sp = new JScrollPane();
    sp.setViewportView(mainView);
    base.add(sp);

    // Now create each of the menus

    JMenuBar menuBar = new JMenuBar();

    // file
    JMenu menu = new JMenu();
    menu.setText(rb.getString("menu.file.text"));
    menu.setMnemonic(KeyEvent.VK_F);

    compareTargetsMenuItem = new JMenuItem();
    compareTargetsMenuItem.setText(rb.getString("menuItem.compareTargets.text"));
    compareTargetsMenuItem.setMnemonic(KeyEvent.VK_T);
    menu.add(compareTargetsMenuItem);

    menu.addSeparator();

    abortMenuItem = new JMenuItem();
    abortMenuItem.setText(rb.getString("menuItem.abort.text"));
    abortMenuItem.setMnemonic(KeyEvent.VK_A);
    abortMenuItem.setEnabled(false);
    menu.add(abortMenuItem);

    menu.addSeparator();

    saveFilelistMenuItem = new JMenuItem();
    saveFilelistMenuItem.setText(rb.getString("menuItem.saveFileList.text"));
    saveFilelistMenuItem.setMnemonic(KeyEvent.VK_S);
    menu.add(saveFilelistMenuItem);

    JMenuItem menuItem = new JMenuItem();
    menuItem.setText(rb.getString("menuItem.copyFiles.text"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.setEnabled(false);
    menu.add(menuItem);

    menuItem = new JMenuItem();
    menuItem.setText(rb.getString("menuItem.print.text"));
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setEnabled(false);
    menu.add(menuItem);

    exitMenuItem = new JMenuItem();
    exitMenuItem.setText(rb.getString("menuItem.exit.text"));
    exitMenuItem.setMnemonic(KeyEvent.VK_X);
    menu.add(exitMenuItem);

    menuBar.add(menu);

    // edit
    menu = new JMenu();
    menu.setText(rb.getString("menu.edit.text"));
    menu.setMnemonic(KeyEvent.VK_E);

    editLeftMenuItem = new JMenuItem();
    editLeftMenuItem.setText(rb.getString("menuItem.editLeftFile.text"));
    editLeftMenuItem.setMnemonic(KeyEvent.VK_L);
    menu.add(editLeftMenuItem);

    editRightMenuItem = new JMenuItem();
    editRightMenuItem.setText(rb.getString("menuItem.editRightFile.text"));
    editRightMenuItem.setMnemonic(KeyEvent.VK_R);
    menu.add(editRightMenuItem);

    menuItem = new JMenuItem();
    menuItem.setText(rb.getString("menuItem.editCompositeFile.text"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.setEnabled(false);
    menu.add(menuItem);

    menu.addSeparator();

    setEditorMenuItem = new JMenuItem();
    setEditorMenuItem.setText(rb.getString("menuItem.setEditor.text"));
    setEditorMenuItem.setMnemonic(KeyEvent.VK_E);
    menu.add(setEditorMenuItem);

    menuBar.add(menu);

    // view
    ButtonGroup bg = new ButtonGroup();

    menu = new JMenu(rb.getString("menu.view.text"));
    menu.setMnemonic(KeyEvent.VK_V);

    viewOutline = new JCheckBoxMenuItem();
    viewOutline.setText(rb.getString("menuItem.outline.text"));
    viewOutline.setMnemonic(KeyEvent.VK_O);
    menu.add(viewOutline);
    bg.add(viewOutline);

    viewExpand = new JCheckBoxMenuItem();
    viewExpand.setText(rb.getString("menuItem.expand.text"));
    viewExpand.setMnemonic(KeyEvent.VK_E);
    menu.add(viewExpand);
    bg.add(viewExpand);

    menu.addSeparator();

    menuItem = new JCheckBoxMenuItem();
    menuItem.setText(rb.getString("menuItem.picture.text"));
    //      menuItem.setMnemonic(KeyEvent.VK_P); // M+p
    menuItem.setEnabled(false);
    menu.add(menuItem);

    menu.addSeparator();

    prevMenuItem = new JMenuItem();
    prevMenuItem.setText(rb.getString("menuItem.previousChange.text"));
    prevMenuItem.setMnemonic(KeyEvent.VK_P); // F7
    menu.add(prevMenuItem);

    nextMenuItem = new JMenuItem();
    nextMenuItem.setText(rb.getString("menuItem.nextChange.text"));
    nextMenuItem.setMnemonic(KeyEvent.VK_N); // F8
    menu.add(nextMenuItem);

    menu.addSeparator();

    rescanMenuItem = new JMenuItem();
    rescanMenuItem.setText(rb.getString("menuItem.rescanSelectedFile.text"));
    rescanMenuItem.setMnemonic(KeyEvent.VK_R);
    menu.add(rescanMenuItem);

    menuBar.add(menu);

    // expand
    menu = new JMenu(rb.getString("menu.expand.text"));
    menu.setMnemonic(KeyEvent.VK_X);

    bg = new ButtonGroup();

    showLeftOnly = new JCheckBoxMenuItem();
    showLeftOnly.setText(rb.getString("menuItem.leftFileOnly.text"));
    showLeftOnly.setMnemonic(KeyEvent.VK_F); // M+l
    showLeftOnly.setActionCommand(ShowExpandMode.left.name());
    menu.add(showLeftOnly);
    bg.add(showLeftOnly);

    showRightOnly = new JCheckBoxMenuItem();
    showRightOnly.setText(rb.getString("menuItem.rightFileOnly.text"));
    showRightOnly.setMnemonic(KeyEvent.VK_H); // M-r
    showRightOnly.setActionCommand(ShowExpandMode.right.name());
    menu.add(showRightOnly);
    bg.add(showRightOnly);

    showBoth = new JCheckBoxMenuItem();
    showBoth.setText(rb.getString("menuItem.bothFiles.text"));
    showBoth.setMnemonic(KeyEvent.VK_O); // M-b
    showBoth.setActionCommand(ShowExpandMode.both.name());
    showBoth.setSelected(true);
    menu.add(showBoth);
    bg.add(showBoth);

    menu.addSeparator();

    bg = new ButtonGroup();

    showLeftNums = new JCheckBoxMenuItem();
    showLeftNums.setText(rb.getString("menuItem.leftLineNumbers.text"));
    showLeftNums.setMnemonic(KeyEvent.VK_L);
    showLeftNums.setActionCommand(ShowNumMode.left.name());
    menu.add(showLeftNums);
    bg.add(showLeftNums);

    showRightNums = new JCheckBoxMenuItem();
    showRightNums.setText(rb.getString("menuItem.rightLineNumbers.text"));
    showRightNums.setMnemonic(KeyEvent.VK_R);
    showRightNums.setActionCommand(ShowNumMode.right.name());
    menu.add(showRightNums);
    bg.add(showRightNums);

    hideNums = new JCheckBoxMenuItem();
    hideNums.setText(rb.getString("menuItem.noLineNumbers.text"));
    hideNums.setMnemonic(KeyEvent.VK_N);
    hideNums.setActionCommand(ShowNumMode.none.name());
    hideNums.setSelected(true);
    menu.add(hideNums);
    bg.add(hideNums);

    menuBar.add(menu);

    // opts
    menu = new JMenu(rb.getString("menu.opts.text"));
    menu.setMnemonic(KeyEvent.VK_O);

    ignoreBlanks = new JCheckBoxMenuItem();
    ignoreBlanks.setText(rb.getString("menuItem.ignoreBlanks.text"));
    ignoreBlanks.setMnemonic(KeyEvent.VK_B);
    ignoreBlanks.setSelected(true);
    menu.add(ignoreBlanks);

    menu.addSeparator();

    menuItem = new JCheckBoxMenuItem(rb.getString("menuItem.monoColours.text"));
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuItem.setEnabled(false);
    menu.add(menuItem);

    menu.addSeparator();

    showIdentical = new JCheckBoxMenuItem();
    showIdentical.setText(rb.getString("menuItem.showIdenticalFiles.text"));
    showIdentical.setMnemonic(KeyEvent.VK_I);
    showIdentical.setSelected(true);
    menu.add(showIdentical);

    showLeft = new JCheckBoxMenuItem();
    showLeft.setText(rb.getString("menuItem.showLeftOnlyFiles.text"));
    showLeft.setMnemonic(KeyEvent.VK_L);
    showLeft.setSelected(true);
    menu.add(showLeft);

    showRight = new JCheckBoxMenuItem();
    showRight.setText(rb.getString("menuItem.showRightOnlyFiles.text"));
    showRight.setMnemonic(KeyEvent.VK_R);
    showRight.setSelected(true);
    menu.add(showRight);

    showDifferent = new JCheckBoxMenuItem();
    showDifferent.setText(rb.getString("menuItem.showDifferentFiles.text"));
    showDifferent.setMnemonic(KeyEvent.VK_D);
    showDifferent.setSelected(true);
    menu.add(showDifferent);

    menuBar.add(menu);

    // mark
    menu = new JMenu();
    menu.setText(rb.getString("menu.mark.text"));
    menu.setMnemonic(KeyEvent.VK_K);

    markFileMenuItem = new JMenuItem();
    markFileMenuItem.setText(rb.getString("menuItem.markFile.text"));
    markFileMenuItem.setMnemonic(KeyEvent.VK_M); // M+m
    menu.add(markFileMenuItem);

    markPatternMenuItem = new JMenuItem();
    markPatternMenuItem.setText(rb.getString("menuItem.markPattern.text"));
    markPatternMenuItem.setMnemonic(KeyEvent.VK_P);
    menu.add(markPatternMenuItem);

    hideMarked = new JCheckBoxMenuItem();
    hideMarked.setText(rb.getString("menuItem.hideMarkedFiles.text"));
    hideMarked.setMnemonic(KeyEvent.VK_H);
    menu.add(hideMarked);

    toggleMarkedMenuItem = new JMenuItem();
    toggleMarkedMenuItem.setText(rb.getString("menuItem.toggleMarkedState.text"));
    toggleMarkedMenuItem.setMnemonic(KeyEvent.VK_T);
    menu.add(toggleMarkedMenuItem);

    menuBar.add(menu);

    // help
    menu = new JMenu();
    menu.setText(rb.getString("menu.help.text"));
    menu.setMnemonic(KeyEvent.VK_H);

    menuItem = new JMenuItem();
    menuItem.setText(rb.getString("menuItem.contents.text"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.setEnabled(false);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem();
    menuItem.setText(rb.getString("menuItem.about.text"));
    menuItem.setMnemonic(KeyEvent.VK_A);
    menuItem.setEnabled(false);
    menu.add(menuItem);

    menuBar.add(menu);

    top.setJMenuBar(menuBar);

    // popup outline menu
    popupOutline = new JPopupMenu();

    markFileMenuItem.setMnemonic(KeyEvent.VK_M);
    popupOutline.add(markFileMenuItem);

    popupOutline.addSeparator();

    nextMenuItem2 = new JMenuItem();
    nextMenuItem2.setText(rb.getString("menuItem.nextChange.text"));
    nextMenuItem2.setMnemonic(KeyEvent.VK_N); // F8
    popupOutline.add(nextMenuItem2);

    prevMenuItem2 = new JMenuItem();
    prevMenuItem2.setText(rb.getString("menuItem.previousChange.text"));
    prevMenuItem2.setMnemonic(KeyEvent.VK_P); // F7
    popupOutline.add(prevMenuItem2);

    expandMenuItem = new JMenuItem();
    expandMenuItem.setText(rb.getString("button.changeMode.text.expand"));
    expandMenuItem.setMnemonic(KeyEvent.VK_E);
    popupOutline.add(expandMenuItem);

    rescanMenuItem2 = new JMenuItem();
    rescanMenuItem2.setText(rb.getString("menuItem.rescanSelectedFile.text"));
    rescanMenuItem2.setMnemonic(KeyEvent.VK_R);
    popupOutline.add(rescanMenuItem2);

    popupOutline.addSeparator();

    editLeftMenuItem2 = new JMenuItem();
    editLeftMenuItem2.setText(rb.getString("menuItem.editLeftFile.text"));
    editLeftMenuItem2.setMnemonic(KeyEvent.VK_L);
    popupOutline.add(editLeftMenuItem2);

    editRightMenuItem2 = new JMenuItem();
    editRightMenuItem2.setText(rb.getString("menuItem.editRightFile.text"));
    editRightMenuItem2.setMnemonic(KeyEvent.VK_R);
    popupOutline.add(editRightMenuItem2);

    menuItem = new JMenuItem();
    menuItem.setText(rb.getString("menuItem.editCompositeFile.text"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.setEnabled(false);
    popupOutline.add(menuItem);

    // popup expanded menu
    popupExpanded = new JPopupMenu();

    menuItem = popupExpanded.add(rb.getString("menuItem.showMoveDest.text"));
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setEnabled(false);

    popupExpanded.addSeparator();

    nextMenuItem3 = new JMenuItem();
    nextMenuItem3.setText(rb.getString("menuItem.nextChange.text"));
    nextMenuItem3.setMnemonic(KeyEvent.VK_N); // F8
    popupExpanded.add(nextMenuItem3);

    prevMenuItem3 = new JMenuItem();
    prevMenuItem3.setText(rb.getString("menuItem.previousChange.text"));
    prevMenuItem3.setMnemonic(KeyEvent.VK_P); // F7
    popupExpanded.add(prevMenuItem3);

    outlineMenuItem = new JMenuItem();
    outlineMenuItem.setText(rb.getString("button.changeMode.text.outline"));
    outlineMenuItem.setMnemonic(KeyEvent.VK_O);
    popupExpanded.add(outlineMenuItem);

    rescanMenuItem3 = new JMenuItem();
    rescanMenuItem3.setText(rb.getString("menuItem.rescanSelectedFile.text"));
    rescanMenuItem3.setMnemonic(KeyEvent.VK_R);
    popupExpanded.add(rescanMenuItem3);

    popupExpanded.addSeparator();

    editLeftMenuItem3 = new JMenuItem();
    editLeftMenuItem3.setText(rb.getString("menuItem.editLeftFile.text"));
    editLeftMenuItem3.setMnemonic(KeyEvent.VK_L);
    popupExpanded.add(editLeftMenuItem3);

    editRightMenuItem3 = new JMenuItem();
    editRightMenuItem3.setText(rb.getString("menuItem.editRightFile.text"));
    editRightMenuItem3.setMnemonic(KeyEvent.VK_R);
    popupExpanded.add(editRightMenuItem3);

    menuItem = new JMenuItem();
    menuItem.setText(rb.getString("menuItem.editCompositeFile.text"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.setEnabled(false);
    popupExpanded.add(menuItem);

    // labels
    names = new JLabel();
    names.setForeground(Color.blue);
    panel.add(BorderLayout.WEST, names);

    paths = new JLabel();
    paths.setBorder(new BevelBorder(BevelBorder.LOWERED));
    panel.add(BorderLayout.CENTER, paths);

    // chageMode button
    changeMode = new JButton();
    changeMode.setMnemonic(KeyEvent.VK_D);
    panel.add(BorderLayout.EAST, changeMode);
  }
Пример #27
0
  public static void ConfigureMainWindow() {
    userNameLabel.setFont(new Font("Lucida Console", 0, 14));
    userNameLabel.setForeground(new Color(255, 255, 255));

    mainWindow.getContentPane().setBackground(new Color(4, 3, 10));
    mainWindow.setSize(800, 600);
    mainWindow.getContentPane().setLayout(null);
    connectButton.setBackground(new Color(255, 255, 255));
    connectButton.setForeground(new Color(4, 3, 10));
    connectButton.setFont(new Font("Lucida Console", 0, 14));

    connectButton.setText("Anslut");
    connectButton.setToolTipText("");
    mainWindow.getContentPane().add(connectButton);
    connectButton.setBounds(455, 10, 100, 25);

    conversation.setColumns(20);
    conversation.setFont(new Font("Lucida Console", 0, 14));
    conversation.setForeground(new Color(4, 3, 10));
    conversation.setLineWrap(true);
    conversation.setRows(5);
    // conversation.setEditable(false);

    tpConversation.setForeground(new Color(255, 255, 255));
    tpConversation.setBounds(10, 10, 600, 500);
    tpConversation.setBackground(new Color(4, 3, 10));
    tpConversation.setFont(new Font("Lucida Console", 0, 14));

    spConversation.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    spConversation.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    spConversation.setViewportView(tpConversation);
    mainWindow.getContentPane().add(spConversation);
    spConversation.setBounds(10, 10, 600, 500);

    userNameBox.setBounds(120, 10, 325, 25);
    userNameLabel.setBounds(10, 10, 130, 25);
    mainWindow.getContentPane().add(userNameBox);
    mainWindow.getContentPane().add(userNameLabel);

    usersOnline.setForeground(new Color(0, 180, 255));
    usersOnline.setBackground(new Color(4, 3, 10));
    usersOnline.setFont(new Font("Lucida Console", 0, 14));
    spUsersOnline.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    spUsersOnline.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    spUsersOnline.setViewportView(usersOnline);
    mainWindow.getContentPane().add(spUsersOnline);
    spUsersOnline.setBounds(620, 10, 165, 300);

    messageField.setForeground(new Color(255, 255, 255));
    messageField.setBackground(new Color(4, 3, 10));
    messageField.requestFocus();
    messageField.addActionListener(action);
    mainWindow.getContentPane().add(messageField);
    messageField.setBounds(10, 520, 600, 30);

    send.setBackground(new Color(255, 255, 255));
    send.setForeground(new Color(4, 3, 10));
    send.setText("Skicka");
    send.setFont(new Font("Lucida Console", 0, 14));
    mainWindow.getContentPane().add(send);
    send.setBounds(620, 520, 165, 30);

    disconnect.setBackground(new Color(255, 255, 255));
    disconnect.setForeground(new Color(4, 3, 10));
    disconnect.setText("Avsluta chatten");
    disconnect.setFont(new Font("Lucida Console", 0, 14));
    mainWindow.getContentPane().add(disconnect);
    disconnect.setBounds(620, 320, 165, 30);

    error.setFont(new Font("Lucida Console", 0, 14));
    error.setForeground(new Color(255, 0, 23));
    error.setBounds(120, 40, 525, 25);

    mainWindow.getContentPane().add(error);
  }
Пример #28
0
  Liqui(Connection LoginCN) {
    cn = LoginCN;
    liquiwindow = new JFrame("Liquistatus");
    liquiwindow.setSize(800, 560);
    liquiwindow.setLocation(200, 200);
    liquiwindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    liquiwindow.setLayout(null);
    liquiwindow.setResizable(false);

    // schriftenfestlegungen
    fontTxtFields = new Font("Arial", Font.PLAIN, 16);
    fontCmbBoxes = new Font("Arial", Font.PLAIN, 16);
    fontLists = new Font("Arial", Font.PLAIN, 10);

    pnlAbrMonat = new JPanel();
    pnlAbrMonat.setLayout(null);
    pnlAbrMonat.setBounds(30, 30, 150, 60);
    pnlAbrMonat.setBorder(new TitledBorder("Abrechnungsmonat"));
    // inhalt fuer Panel AbrMonat erstellen
    try {
      txtAbrMonat = new JFormattedTextField(new MaskFormatter("01-##-20##"));
    } catch (ParseException e1) {
      e1.printStackTrace();
    }
    txtAbrMonat.setBounds(20, 25, 110, 25);
    txtAbrMonat.setHorizontalAlignment(JFormattedTextField.RIGHT);
    txtAbrMonat.setFont(fontTxtFields);
    txtAbrMonat.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent ke) {}

          @Override
          public void keyReleased(KeyEvent ke) {
            if (ke.getKeyCode() == KeyEvent.VK_ENTER
                && Pattern.matches("\\d{2}.\\d{2}.[1-9]{1}\\d{3}", txtAbrMonat.getText())) {
              txtHinweis.setText(""); // clear txtHinweis Field
              lstModelAllIncome.clear(); // clear form old values from the previos call
              cmbModelPerson.removeAllElements(); // clear befor put new elements in to it
              calculate_profit(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
              putPersonNameToCmbPerson();
              putIncomeToListAllIncome(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));

              // check if the actual liquimonth is already fix and it is so, then set the buttons,
              // who put and remove
              // incomes to and from persons, inactive
              if (is_liqui_fix(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0))) {
                btnAdd.setEnabled(false);
                btnRemove.setEnabled(false);
              } else {
                btnAdd.setEnabled(true);
                btnRemove.setEnabled(true);
              }
            }
          }

          @Override
          public void keyPressed(KeyEvent ke) {}
        });
    // inhalte fuer das Panel AbrMonat auf selbiges legen
    pnlAbrMonat.add(txtAbrMonat);

    pnlRestwert = new JPanel();
    pnlRestwert.setLayout(null);
    pnlRestwert.setBounds(30, 115, 150, 60);
    pnlRestwert.setBorder(new TitledBorder("Monatsrestwert"));
    // inhalt fuer Panel Restwert erstellen
    txtNutzBetr = new JFormattedTextField(new NumberFormatter(new DecimalFormat("#,##0.00")));
    txtNutzBetr.setBounds(20, 25, 110, 25);
    txtNutzBetr.setHorizontalAlignment(JFormattedTextField.RIGHT);
    txtNutzBetr.setFont(fontTxtFields);
    txtNutzBetr.setText("0,00");
    txtNutzBetr.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent fe) {}

          public void focusGained(FocusEvent fe) {
            txtNutzBetr.selectAll();
          }
        });
    // inhalte fuer das Panel AbrMonat auf selbiges legen
    pnlRestwert.add(txtNutzBetr);

    // Textfeld fuer Hinweise zum errechneten Betrag
    txtHinweis = new JTextArea();
    txtHinweis.setBounds(195, 30, 230, 205);
    txtHinweis.setBorder(BorderFactory.createEtchedBorder());
    txtHinweis.setEditable(false); // infos sollen nur vom Programm gesetzt werden

    // Bereich fuer die Einnahmenaufteilung anlegen
    pnlEinahmenAufteilung = new JPanel();
    pnlEinahmenAufteilung.setLayout(null);
    pnlEinahmenAufteilung.setBounds(30, 240, 640, 300);
    pnlEinahmenAufteilung.setBorder(new TitledBorder("Einnahmenaufteilung"));
    // elemente fuer die Einnahmenaufteilung anlegen
    lblPerson = new JLabel("Person");
    lblPerson.setBounds(20, 25, 110, 25);

    cmbModelPerson = new DefaultComboBoxModel<String>();
    cmbPerson = new JComboBox<String>(cmbModelPerson);
    cmbPerson.setBounds(130, 25, 170, 25);
    cmbPerson.setFont(fontCmbBoxes);
    cmbPerson.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == 1) {
              // clear the List IncomePerPerson when Person is changed (to another or to nothing)
              lstModelIncomePerPerson.clear();

              if (cmbPerson.getSelectedIndex() > 0) {
                // extract personen_id from selected Value
                String selectedValue = cmbPerson.getSelectedItem().toString();
                Integer personen_id =
                    Integer.valueOf(
                        selectedValue.substring(
                            selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

                // fill lstIncomePerPerson
                getIncomeForSelectedPerson(
                    personen_id, BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
              }
            }
          }
        });

    // Scrollliste der gesammten Einnahmen
    lstModelAllIncome = new DefaultListModel<String>();

    lstAllIncome = new JList<String>(lstModelAllIncome);
    lstAllIncome.setFont(fontLists);
    lstAllIncome.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseClicked(MouseEvent e) {
            // do someone only when elements exist
            if (lstModelAllIncome.getSize() > 0) {
              String elementValue = lstModelAllIncome.getElementAt(lstAllIncome.getSelectedIndex());
              lblBuchtext.setToolTipText(
                  getBuchText(
                      elementValue.substring(
                          elementValue.indexOf("(") + 1, elementValue.indexOf(")"))));

              // chek if a splitted part of the transaktions_id of the selectet Value is already put
              // to a
              // person, if it is so, the checkbox split must checked and protect against unchecked
              if (existSplittedPartInIpp(
                  elementValue.substring(
                      elementValue.indexOf("(") + 1, elementValue.indexOf(")")))) {
                chkAufteilung.setSelected(true);
                chkAufteilung.setEnabled(false);
              } else {
                chkAufteilung.setSelected(false);
                chkAufteilung.setEnabled(true);
              }
            }
          }
        });

    spAllIncome = new JScrollPane(lstAllIncome);
    spAllIncome.setBounds(20, 65, 100, 205);

    // scrollliste der einnahmen pro Person
    lstModelIncomePerPerson = new DefaultListModel<String>();

    lstIncomPerPerson = new JList<String>(lstModelIncomePerPerson);
    lstIncomPerPerson.setFont(fontLists);

    spIncomePerPerson = new JScrollPane(lstIncomPerPerson);
    spIncomePerPerson.setBounds(220, 65, 100, 205);

    // checkbox fuer die Aufteilungskennzeichnung
    chkAufteilung = new JCheckBox("Split", false);
    chkAufteilung.setBounds(145, 70, 60, 30);

    // Buttons fuer das hinzufuegen und entfernen der Betraege zu den Personen
    btnAdd = new JButton(">>");
    btnAdd.setBounds(145, 130, 60, 20);
    btnAdd.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Integer AllIncomeSelectedIndex;
            Integer PersonSelectedIndex;

            // note important selected Index
            AllIncomeSelectedIndex = lstAllIncome.getSelectedIndex();
            PersonSelectedIndex = cmbPerson.getSelectedIndex();

            // move the selected field from lstAllIncome to lstIncomePerPerson
            if (AllIncomeSelectedIndex >= 0 && PersonSelectedIndex >= 1) {
              // note some selected Values
              String selectedValue = cmbPerson.getSelectedItem().toString();
              Integer personen_id =
                  Integer.valueOf(
                      selectedValue.substring(
                          selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

              // get Selected Value from the AllIncomeList
              String selectedAmountWithKey = lstModelAllIncome.getElementAt(AllIncomeSelectedIndex);

              // extract transaktions_id from the selected Amountvalue
              Integer transaktions_id =
                  Integer.valueOf(
                      selectedAmountWithKey.substring(
                          selectedAmountWithKey.indexOf("(") + 1,
                          selectedAmountWithKey.indexOf(")")));
              String sAmount =
                  selectedAmountWithKey.substring(0, selectedAmountWithKey.indexOf(" ("));

              // check if Amount have to split and get the Person_id who get the splited Amount
              if (chkAufteilung.isSelected()) {
                String AmountPart =
                    JOptionPane.showInputDialog(
                        "Bitte den Teilbetrag von " + sAmount + " eingeben:", sAmount);
                AmountPart = AmountPart.replace(",", ".");
                if (AmountPart.matches("^[0-9]+(\\.[0-9]{1,2})?$")) {
                  lstModelIncomePerPerson.insertElementAt(
                      AmountPart + " (" + transaktions_id + ")", lstModelIncomePerPerson.getSize());

                  // remove old Amount Value from List AllIncome
                  lstModelAllIncome.remove(AllIncomeSelectedIndex);

                  // calculate the diffrence between Old Amount and the AmountPart
                  Float AmountAllIncomeNew = Float.valueOf(sAmount) - Float.valueOf(AmountPart);

                  // put difference in the List AllIncome if it greater then zero
                  if (AmountAllIncomeNew > 0)
                    lstModelAllIncome.insertElementAt(
                        AmountAllIncomeNew.toString() + " (" + transaktions_id + ")",
                        lstModelAllIncome.getSize());

                  // put AmountPart in the IPP Table
                  pushAmountToTableIPP(AmountPart, transaktions_id, personen_id, "true");
                } else {
                  JOptionPane.showMessageDialog(
                      liquiwindow,
                      "Eingabe ist kein gültiger Zahlwert! Der Gesamtbetrag wird genommen.");
                  lstModelIncomePerPerson.insertElementAt(
                      selectedAmountWithKey, lstModelIncomePerPerson.getSize());
                  lstModelAllIncome.remove(AllIncomeSelectedIndex);
                  pushAmountToTableIPP(sAmount, transaktions_id, personen_id, "false");
                }
              } else {
                lstModelIncomePerPerson.insertElementAt(
                    selectedAmountWithKey, lstModelIncomePerPerson.getSize());
                lstModelAllIncome.remove(AllIncomeSelectedIndex);
                pushAmountToTableIPP(sAmount, transaktions_id, personen_id, "false");
              }
            }
          }
        });

    btnRemove = new JButton("<<");
    btnRemove.setBounds(145, 175, 60, 20);
    btnRemove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Integer IncomePerPersonSelectedIndex;
            Integer PersonSelectedIndex;
            Boolean transaktions_id_is_in_elements = false;
            int eID =
                0; // counter for the elements in the Enumeration to find an element with the same
                   // transaktions_id

            // note important selected Indexes
            IncomePerPersonSelectedIndex = lstIncomPerPerson.getSelectedIndex();
            PersonSelectedIndex = cmbPerson.getSelectedIndex();

            // move the selected field from lstIncomePerPerson to lstAllIncome
            if (IncomePerPersonSelectedIndex >= 0 && PersonSelectedIndex >= 1) {
              String selectedPersonAmountWithKey =
                  lstModelIncomePerPerson.getElementAt(IncomePerPersonSelectedIndex);

              // note the transaktions_id from the selectet Value at the right site
              String transaktions_id_right_site =
                  selectedPersonAmountWithKey.substring(
                      selectedPersonAmountWithKey.indexOf("(") + 1,
                      selectedPersonAmountWithKey.indexOf(")"));

              // check if the transaktions_id from the element that remove from the
              // IncomPerPerson List at the right site, is alredy in the list AllIncome at the
              // left Site. If it is so, then we must add the amount of the elements at the left
              // side to the right
              // where the transaktions_id is the same
              Enumeration<String> e = lstModelAllIncome.elements();

              while (e.hasMoreElements() && !transaktions_id_is_in_elements) {
                // note the actual Elemant in the Enumeration
                String actualElement = e.nextElement().toString();

                // note the transaktions_id from the actual element at the left site
                String transaktions_id_left_site =
                    actualElement.substring(
                        actualElement.indexOf("(") + 1, actualElement.indexOf(")"));

                if (transaktions_id_right_site.equals(transaktions_id_left_site)) {
                  // we need not look further and set transaktions_id_is_in_elements to true
                  // that will break the while loop
                  transaktions_id_is_in_elements = true;
                } else {
                  transaktions_id_is_in_elements = false;
                  eID++;
                }
              }

              if (transaktions_id_is_in_elements) {
                // if found an element with the same id in the left field, add the amount of the
                // removed
                // element at the right site, to the amount of the found element and put the result
                // at the end of the listAllIncome

                // note the two Amounts that have to add
                String AmountFromRightSite =
                    selectedPersonAmountWithKey.substring(
                        0, selectedPersonAmountWithKey.indexOf(" ("));
                String AmountFromLeftSite =
                    lstModelAllIncome
                        .getElementAt(eID)
                        .substring(0, lstModelAllIncome.getElementAt(eID).indexOf(" ("));
                Float newAmount =
                    Float.valueOf(AmountFromRightSite) + Float.valueOf(AmountFromLeftSite);

                // remove the element at the right and the left site
                lstModelIncomePerPerson.remove(IncomePerPersonSelectedIndex);
                lstModelAllIncome.remove(eID);

                // put the new build Element to the left site
                lstModelAllIncome.insertElementAt(
                    newAmount + " (" + transaktions_id_right_site + ")",
                    lstModelAllIncome.getSize());
              } else {
                // if not found, only put the removed Elemnt to the end of the List at the left site
                lstModelAllIncome.insertElementAt(
                    selectedPersonAmountWithKey, lstModelAllIncome.getSize());
                lstModelIncomePerPerson.remove(IncomePerPersonSelectedIndex);
              }

              // delete the moved Amount in the Table ipp for the selected Person
              String selectedValue = cmbPerson.getSelectedItem().toString();
              Integer personen_id =
                  Integer.valueOf(
                      selectedValue.substring(
                          selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));
              deleteAmountFromTableIPP(selectedPersonAmountWithKey, personen_id);
            }
          }
        });

    lblBuchtext = new JLabel("Buchungstext (Tooltip)");
    lblBuchtext.setBounds(20, 275, 300, 20);

    btnCalcPercentualPortion = new JButton("Anteilberechnung");
    btnCalcPercentualPortion.setBounds(330, 65, 160, 20);
    btnCalcPercentualPortion.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            int personCount;
            double[] PersonAmount;
            double TotalPersonAmount = 0;

            // clear the infotextfield
            txtHinweisAufteilung.setText("");

            // note the amount of person in the cmb box person
            // the first entry is not a person
            personCount = cmbModelPerson.getSize() - 1;

            // sum up the acounts of each person if there are one
            if (personCount > 0) {
              PersonAmount = new double[personCount];
              double dResidualValue = Double.valueOf(txtNutzBetr.getText().replace(",", "."));

              for (int PersonCounter = 1; PersonCounter <= personCount; PersonCounter++) {
                String selectedValue = cmbPerson.getItemAt(PersonCounter).toString();
                Integer personen_id =
                    Integer.valueOf(
                        selectedValue.substring(
                            selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

                PersonAmount[PersonCounter - 1] =
                    getPersonAcountSumPerLiqui(
                        personen_id, BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
                TotalPersonAmount =
                    roundScale2(TotalPersonAmount + PersonAmount[PersonCounter - 1]);
              }

              // hint the total sum of all person
              txtHinweisAufteilung.append("Gesammtsumme:\n");
              txtHinweisAufteilung.append(
                  Double.toString(TotalPersonAmount).replace(".", ",") + "\n");

              // calc the proportion of the sums in percent, to the total Sum of all persons
              txtHinweisAufteilung.append(
                  "Sparbetrag: " + Double.toString(dResidualValue).replace(".", ",") + "\n");
              for (int PersonCounter = 0; PersonCounter < PersonAmount.length; PersonCounter++) {
                double percent =
                    roundScale2((PersonAmount[PersonCounter] * 100) / TotalPersonAmount);
                double dValue = roundScale2((percent * dResidualValue) / 100);
                txtHinweisAufteilung.append(
                    Double.toString(percent).replace(".", ",")
                        + "% / "
                        + Double.toString(dValue).replace(".", ",")
                        + "\n");
              }
            }
          }
        });

    // Textfeld fuer Hinweise zum errechneten Betrag
    txtHinweisAufteilung = new JTextArea();
    txtHinweisAufteilung.setBounds(330, 90, 180, 180);
    txtHinweisAufteilung.setBorder(BorderFactory.createEtchedBorder());
    txtHinweisAufteilung.setEditable(false); // infos sollen nur vom Programm gesetzt werden

    // zuweisen der Elemente fuer das Panel Einnahmenaufteilung
    pnlEinahmenAufteilung.add(lblPerson);
    pnlEinahmenAufteilung.add(cmbPerson);
    pnlEinahmenAufteilung.add(spAllIncome);
    pnlEinahmenAufteilung.add(spIncomePerPerson);
    pnlEinahmenAufteilung.add(chkAufteilung);
    pnlEinahmenAufteilung.add(btnAdd);
    pnlEinahmenAufteilung.add(btnRemove);
    pnlEinahmenAufteilung.add(lblBuchtext);
    pnlEinahmenAufteilung.add(btnCalcPercentualPortion);
    pnlEinahmenAufteilung.add(txtHinweisAufteilung);

    liquiwindow.add(pnlAbrMonat);
    liquiwindow.add(pnlRestwert);
    liquiwindow.add(txtHinweis);
    liquiwindow.add(pnlEinahmenAufteilung);

    liquiwindow.setVisible(true);
  }
Пример #29
0
 private void init(b3financialstaffui b3financialstaffui) {
   documentController = new documentController();
   Font font = new Font("幼圆", Font.BOLD, 20);
   yesButton = new JButton(yesIcon);
   yesButton.setBounds(602, 575, 48, 48);
   yesButton.setContentAreaFilled(false);
   returnButton = new JButton(returnIcon);
   returnButton.setBounds(662, 575, 48, 48);
   returnButton.setContentAreaFilled(false);
   bianhaoJLabel = new JLabel("付款单编号:");
   bianhaoJLabel.setForeground(Color.white);
   bianhaoJLabel.setFont(font);
   bianhaoJLabel.setBounds(50, 50, 150, 30);
   bianhaonumberJLabel = new JLabel();
   try {
     bianhaonumberJLabel.setText(documentController.getDocCode("付款单", account));
   } catch (RemoteException e) {
     // TODO Auto-generated catch block
     new InternetDialog(b3financialstaffui);
   }
   bianhaonumberJLabel.setForeground(Color.white);
   bianhaonumberJLabel.setFont(font);
   bianhaonumberJLabel.setBounds(200, 50, 150, 30);
   riqiJLabel = new JLabel("付款日期:");
   riqiJLabel.setForeground(Color.white);
   riqiJLabel.setFont(font);
   riqiJLabel.setBounds(50, 150, 150, 30);
   Date now = new Date();
   SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   riqi = new JLabel(dateFormat.format(now));
   riqi.setFont(font);
   riqi.setForeground(Color.white);
   riqi.setBounds(150, 150, 210, 30);
   fukuanrenxingmingJLabel = new JLabel("付款人姓名:");
   fukuanrenxingmingJLabel.setForeground(Color.white);
   fukuanrenxingmingJLabel.setFont(font);
   fukuanrenxingmingJLabel.setBounds(50, 250, 150, 30);
   fukuanrenxingmingField = new JTextField();
   fukuanrenxingmingField.setFont(font);
   fukuanrenxingmingField.setBounds(200, 250, 150, 30);
   danjumingJLabel = new JLabel("单据名:");
   danjumingJLabel.setForeground(Color.white);
   danjumingJLabel.setFont(font);
   danjumingJLabel.setBounds(370, 50, 150, 30);
   danjuming = new JLabel("付款单");
   danjuming.setFont(font);
   danjuming.setForeground(Color.white);
   danjuming.setBounds(500, 50, 150, 30);
   jineJLabel = new JLabel("付款金额:");
   jineJLabel.setForeground(Color.white);
   jineJLabel.setFont(font);
   jineJLabel.setBounds(370, 150, 150, 30);
   jineField = new JTextField();
   jineField.setFont(font);
   jineField.setBounds(500, 150, 150, 30);
   zhanghaoJLabel = new JLabel("付款账户:");
   zhanghaoJLabel.setForeground(Color.white);
   zhanghaoJLabel.setFont(font);
   zhanghaoJLabel.setBounds(370, 250, 150, 30);
   zhanghaoField = new JTextField();
   zhanghaoField.setFont(font);
   zhanghaoField.setBounds(500, 250, 150, 30);
   beizhuJLabel = new JLabel("备注:");
   beizhuJLabel.setForeground(Color.white);
   beizhuJLabel.setFont(font);
   beizhuJLabel.setBounds(370, 350, 150, 30);
   tiaomuJLabel = new JLabel("条目:");
   tiaomuJLabel.setForeground(Color.white);
   tiaomuJLabel.setFont(font);
   tiaomuJLabel.setBounds(50, 350, 150, 30);
   DefaultListModel tiaomulistModel = new DefaultListModel();
   tiaomulistModel.addElement("租金(按年收)");
   tiaomulistModel.addElement("运费(按次计算)");
   tiaomulistModel.addElement("人员工资(按月统计)");
   tiaomulistModel.addElement("奖励(一次性)");
   DefaultListModel beizhulistModel = new DefaultListModel();
   beizhulistModel.addElement("租金年份");
   beizhulistModel.addElement("运单号");
   beizhulistModel.addElement("工资月份");
   beizhulistModel.addElement("快递员提成");
   beizhulistModel.addElement("司机计次");
   beizhulistModel.addElement("业务员月薪");
   tiaomuJList = new JList<String>(tiaomulistModel);
   tiaomuJList.setBounds(150, 350, 200, 100);
   tiaomuJList.setFont(font);
   tiaomuJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   beizhuJList = new JList<String>(beizhulistModel);
   beizhuJList.setBounds(500, 350, 150, 150);
   beizhuJList.setFont(font);
   beizhuJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   this.add(bianhaoJLabel);
   this.add(bianhaonumberJLabel);
   this.add(riqiJLabel);
   this.add(riqi);
   this.add(fukuanrenxingmingJLabel);
   this.add(fukuanrenxingmingField);
   this.add(danjumingJLabel);
   this.add(danjuming);
   this.add(jineField);
   this.add(jineJLabel);
   this.add(zhanghaoField);
   this.add(zhanghaoJLabel);
   this.add(beizhuJLabel);
   this.add(tiaomuJLabel);
   this.add(tiaomuJList);
   this.add(beizhuJList);
   this.setBounds(260, 60, 730, 650);
   this.add(yesButton);
   this.add(returnButton);
   this.setLayout(null);
   this.setOpaque(false);
 }
Пример #30
0
 private static <E> JList<E> newList(DefaultListModel<E> listModel) {
   JList<E> list = new JList<>(listModel);
   list.setFont(f13);
   list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   return list;
 }