Esempio n. 1
0
 private JMenu createFileMenu() {
   ActionMap actionMap = context.getActionMap(this);
   final JMenu file = new JMenu("File");
   file.setMnemonic('f');
   file.add(actionMap.get("openProject"));
   final JMenu fileRecent = new JMenu("Recent Projects");
   fileRecent.setIcon(new ImageIcon("/resources/icons/open.png"));
   fileRecent.addMenuListener(new RecentProjectsMenuManager(application, projectService));
   file.add(fileRecent);
   file.addSeparator();
   final JMenu fileExport = new JMenu("Export To");
   fileExport.setIcon(new ImageIcon("/resources/icons/exportTo.png"));
   fileExport.add(application.getAction(ExportToHtml.COMMAND));
   fileExport.add(application.getAction(ExportToRecordBundle.COMMAND));
   file.add(fileExport);
   final JMenu fileImport = new JMenu("Import From");
   fileExport.setIcon(new ImageIcon("/resources/icons/import.png"));
   fileImport.add(application.getAction(ImportFromRecordBundle.COMMAND));
   file.add(fileImport);
   file.addSeparator();
   file.add(application.getAction(NewRvConnection.COMMAND));
   final JMenu connRecent = new JMenu("Recent Connections");
   connRecent.addMenuListener(new RecentConnectionsMenuManager(application));
   file.add(connRecent);
   return file;
 }
Esempio n. 2
0
 private void setupMenus() {
   JMenuBar menuBar = new JMenuBar();
   JMenu menuFile = new JMenu("File");
   menuFile.setMnemonic(KeyEvent.VK_F);
   JMenu menuEdit = new JMenu("Edit");
   menuEdit.setMnemonic(KeyEvent.VK_E);
   JMenu menuView = new JMenu("View");
   menuView.setMnemonic(KeyEvent.VK_V);
   JMenu menuModify = new JMenu("Modify");
   menuModify.setMnemonic(KeyEvent.VK_M);
   JMenu menuHelp = new JMenu("Help");
   menuHelp.setMnemonic(KeyEvent.VK_H);
   /*layout*/
   setJMenuBar(menuBar);
   menuBar.add(menuFile);
   menuFile.add(new OpenExistingAction(this));
   menuFile.add(new OpenFileAction(this));
   menuFile.add(new JSeparator());
   menuFile.add(new SaveAction(this));
   JMenu saveAs = new JMenu("Save As");
   menuFile.add(saveAs);
   saveAs.add(new SaveAsBlueprintAction(this, false));
   saveAs.add(new SaveAsBlueprintAction(this, true));
   saveAs.add(new SaveAsFileAction(this));
   JSeparator menuFileStart = new JSeparator();
   menuFileStart.setName("pluginsStartHere");
   menuFile.add(menuFileStart);
   menuFile.add(new JSeparator());
   menuFile.add(new QuitAction(this));
   menuBar.add(menuEdit);
   menuEdit.add(new UndoAction(this));
   menuEdit.add(new RedoAction(this));
   menuEdit.add(new JSeparator());
   menuBar.add(menuView);
   menuView.add(new JCheckBoxMenuItem(new PlainAction(this)));
   menuView.add(new JCheckBoxMenuItem(new AxisAction(this)));
   menuView.add(new JCheckBoxMenuItem(new DontDrawAction(this)));
   JSeparator viewFileStart = new JSeparator();
   viewFileStart.setName("pluginsStartHere");
   menuView.add(viewFileStart);
   menuBar.add(menuModify);
   menuBar.add(menuHelp);
   /*link*/
   menuFile.addMenuListener(new PluginPopupListener(this, IBlocksPlugin.SUBTYPE_FILE));
   menuEdit.addMenuListener(new PluginPopupListener(this, IBlocksPlugin.SUBTYPE_EDIT));
   menuView.addMenuListener(new PluginPopupListener(this, IBlocksPlugin.SUBTYPE_VIEW));
   menuModify.addMenuListener(
       new PluginPopupListener(
           this, IBlocksPlugin.SUBTYPE_MODIFY, IBlocksPlugin.SUBTYPE_GENERATE));
 }
Esempio n. 3
0
 private JMenu createViewMenu(RecordLedgerTable table) {
   final JMenu view = new JMenu("View");
   view.setMnemonic('v');
   view.add(application.getAction(SelectAllRecords.COMMAND));
   view.add(application.getAction(ShowAllColumns.COMMAND));
   view.addSeparator();
   view.add(application.getAction(Filter.COMMAND));
   view.add(application.getAction(FilterBySelection.COMMAND));
   view.addSeparator();
   final JMenu viewColumns = new JMenu("Columns");
   viewColumns.setIcon(new ImageIcon("/resources/icons/filter_columns.png"));
   viewColumns.addMenuListener(new VisibleColumnsMenuManager(table.getTableFormat()));
   view.add(viewColumns);
   final JMenu viewTypes = new JMenu("Types");
   viewTypes.setIcon(new ImageIcon("/resources/icons/editRecordTypes.png"));
   viewTypes.addMenuListener(new RecordTypesMenuManager(application));
   view.add(viewTypes);
   return view;
 }
Esempio n. 4
0
  private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu("文件");
    file.addMenuListener(
        new MenuListener() {

          public void menuSelected(MenuEvent e) {
            if (worker != null && worker.isAlive()) {
              worker.setPaused(true);
              setMsg("暂停");
            }
          }

          public void menuDeselected(MenuEvent e) {
            if (worker != null && worker.isAlive()) {
              worker.setPaused(false);
              setMsg("运行");
            }
          }

          public void menuCanceled(MenuEvent e) {
            System.out.println("canzzzz");
          }
        });
    menuBar.add(file);
    JMenuItem open =
        new JMenuItem(
            new AbstractAction("打开") {

              public void actionPerformed(ActionEvent e) {
                if (worker != null && worker.isAlive()) {
                  worker.setPaused(true);
                  setMsg("暂停");
                }
                openLavFile();
              }
            });
    file.add(open);
    file.add(
        new AbstractAction("退出") {

          public void actionPerformed(ActionEvent e) {
            if (worker != null && worker.isAlive()) {
              worker.interrupt();
              try {
                worker.join();
              } catch (InterruptedException ex) {
                System.err.println(ex);
              }
            }
            System.exit(0);
          }
        });
    return menuBar;
  }
Esempio n. 5
0
  /**
   * Add the menus into the menu bar
   *
   * @param menuBar The menu bar
   */
  public void initMenuBar(JMenuBar menuBar) {
    stationModelMenu = new JMenu("Layout Models");
    stationModelMenu.addMenuListener(
        new MenuListener() {
          public void menuCanceled(MenuEvent e) {}

          public void menuDeselected(MenuEvent e) {}

          public void menuSelected(MenuEvent e) {
            makeStationModelMenu();
          }
        });

    fileMenu = new JMenu("File");
    fileMenu.addMenuListener(
        new MenuListener() {
          public void menuCanceled(MenuEvent e) {}

          public void menuDeselected(MenuEvent e) {}

          public void menuSelected(MenuEvent e) {
            makeFileMenu();
          }
        });

    menuBar.add(fileMenu);
    super.initMenuBar(menuBar);

    menuBar.add(stationModelMenu);

    JMenu helpMenu = new JMenu("Help");
    JMenuItem helpMenuItem = new JMenuItem("Layout Models");
    helpMenu.add(helpMenuItem);
    helpMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            showHelp();
          }
        });

    menuBar.add(helpMenu);
  }
Esempio n. 6
0
  /**
   * Creates and returns a new JMenu.
   *
   * @param title title of the menu
   * @param mnemonicHelper an optional (can be null) mnemonic helper which will be used along with
   *     the title to set a mnemonic to the menu.
   * @param menuListener an optional (can be null) menu listener which will listen to the events
   *     triggered by the menu.
   */
  public static JMenu addMenu(
      String title, MnemonicHelper mnemonicHelper, MenuListener menuListener) {
    JMenu menu = new JMenu(title);

    if (mnemonicHelper != null) {
      char mnemonic = mnemonicHelper.getMnemonic(title);
      if (mnemonic != 0) menu.setMnemonic(mnemonic);
    }

    if (menuListener != null) menu.addMenuListener(menuListener);

    return menu;
  }
Esempio n. 7
0
  private void addNotificationSettings(final JMenu parentMenu) {
    final JMenu notificationMenu = new JMenu();
    notificationMenu.setMnemonic(KeyEvent.VK_U);
    notificationMenu.setText("User Notifications");
    final JCheckBoxMenuItem showEndOfTurnReport = new JCheckBoxMenuItem("Show End of Turn Report");
    showEndOfTurnReport.setMnemonic(KeyEvent.VK_R);
    final JCheckBoxMenuItem showTriggeredNotifications =
        new JCheckBoxMenuItem("Show Triggered Notifications");
    showTriggeredNotifications.setMnemonic(KeyEvent.VK_T);
    final JCheckBoxMenuItem showTriggerChanceSuccessful =
        new JCheckBoxMenuItem("Show Trigger/Condition Chance Roll Successful");
    showTriggerChanceSuccessful.setMnemonic(KeyEvent.VK_S);
    final JCheckBoxMenuItem showTriggerChanceFailure =
        new JCheckBoxMenuItem("Show Trigger/Condition Chance Roll Failure");
    showTriggerChanceFailure.setMnemonic(KeyEvent.VK_F);
    notificationMenu.addMenuListener(
        new MenuListener() {
          @Override
          public void menuSelected(final MenuEvent e) {
            showEndOfTurnReport.setSelected(iuiContext.getShowEndOfTurnReport());
            showTriggeredNotifications.setSelected(iuiContext.getShowTriggeredNotifications());
            showTriggerChanceSuccessful.setSelected(iuiContext.getShowTriggerChanceSuccessful());
            showTriggerChanceFailure.setSelected(iuiContext.getShowTriggerChanceFailure());
          }

          @Override
          public void menuDeselected(final MenuEvent e) {}

          @Override
          public void menuCanceled(final MenuEvent e) {}
        });
    showEndOfTurnReport.addActionListener(
        e -> iuiContext.setShowEndOfTurnReport(showEndOfTurnReport.isSelected()));
    showTriggeredNotifications.addActionListener(
        e -> iuiContext.setShowTriggeredNotifications(showTriggeredNotifications.isSelected()));
    showTriggerChanceSuccessful.addActionListener(
        e -> iuiContext.setShowTriggerChanceSuccessful(showTriggerChanceSuccessful.isSelected()));
    showTriggerChanceFailure.addActionListener(
        e -> iuiContext.setShowTriggerChanceFailure(showTriggerChanceFailure.isSelected()));
    notificationMenu.add(showEndOfTurnReport);
    notificationMenu.add(showTriggeredNotifications);
    notificationMenu.add(showTriggerChanceSuccessful);
    notificationMenu.add(showTriggerChanceFailure);
    parentMenu.add(notificationMenu);
  }
  public void addMenu(JMenu menu) {
    if (_menuListener == null) {
      _menuListener =
          new MenuListener() {
            public void menuCanceled(MenuEvent ev) {
              onMenuCanceled((JMenu) ev.getSource());
            }

            public void menuDeselected(MenuEvent ev) {
              onMenuDeselected((JMenu) ev.getSource());
            }

            public void menuSelected(MenuEvent ev) {
              onMenuSelected((JMenu) ev.getSource());
            }
          };
    }

    menu.addMenuListener(_menuListener);
  }
    public MenuCentral(JMenu mnu, ControleurPanneaux cp) {
      _mnu = mnu;
      mnu.addMenuListener(
          new MenuListener() {
            public void menuSelected(MenuEvent e) {
              majContenuMenu();
            }

            public void menuDeselected(MenuEvent e) {}

            public void menuCanceled(MenuEvent e) {}
          });
      lnkControleurPanneaux = cp;
      jMenuAjouterContenu.setText(
          lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("ajoutercontenu"));
      jMenuChangerContenu.setText(
          lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("changerdecontenu"));
      jMenuSupprimerContenu.setText(
          lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("supprimercontenu"));
      jMenuAjouterGuide.setText(
          lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("ajouterguide"));
      jMenuSupprimer.setText(lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("supprimer"));

      jMenuAjouterContenu.setVisible(false);
      jMenuChangerContenu.setVisible(false);
      jMenuAjouterGuide.setVisible(false);
      jMenuSupprimerContenu.setVisible(false);
      jMenuSupprimer.setVisible(false);

      jMenuAjouterContenu.addActionListener(this);
      jMenuChangerContenu.addActionListener(this);
      jMenuAjouterGuide.addActionListener(this);
      jMenuSupprimerContenu.addActionListener(this);
      jMenuSupprimer.addActionListener(this);

      _mnu.add(jMenuAjouterContenu);
      _mnu.add(jMenuChangerContenu);
      _mnu.add(jMenuSupprimerContenu);
      _mnu.add(jMenuAjouterGuide);
      _mnu.add(jMenuSupprimer);
    }
Esempio n. 10
0
  /** Create the frame. */
  public MainWindow() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(new Dimension(1050, 550));
    setLocationRelativeTo(null);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnMenu = new JMenu("Menu");
    menuBar.add(mnMenu);

    mnWindows = new JMenu("Windows");

    JMenuItem mntmOpen = new JMenuItem("Open");
    mntmOpen.setAccelerator(
        KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            openFile(true);
          }
        });

    JMenuItem mntmNew = new JMenuItem("New");
    mntmNew.setAccelerator(
        KeyStroke.getKeyStroke('N', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmNew.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              CacheListController.newCLC(
                  desktopPane,
                  mnWindows,
                  (Location) comboBox.getSelectedItem(),
                  null,
                  new CacheListView.RunLocationDialogI() {
                    public void openDialog(Geocache g) {
                      openLocationDialog(g);
                    }
                  });
            } catch (Throwable e1) {
            }
          }
        });
    mnMenu.add(mntmNew);
    mnMenu.add(mntmOpen);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            THIS.dispatchEvent(new WindowEvent(THIS, WindowEvent.WINDOW_CLOSING));
          }
        });

    JMenuItem mntmSettings = new JMenuItem("Settings");
    mntmSettings.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SettingsDialog sw = new SettingsDialog();
            sw.setModalityType(ModalityType.APPLICATION_MODAL);
            sw.setLocationRelativeTo(THIS);
            sw.setVisible(true);
          }
        });

    final JMenuItem mntmSave = new JMenuItem("Save");
    mntmSave.setAccelerator(
        KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            saveFile(false);
          }
        });
    mntmSave.setEnabled(false);
    mnMenu.add(mntmSave);

    final JMenuItem mntmSaveAs = new JMenuItem("Save As");
    //		mntmSaveAs.setAccelerator(KeyStroke.getKeyStroke('S',
    //				Toolkit.getDefaultToolkit
    // ().getMenuShortcutKeyMask() ));
    mntmSaveAs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            saveFile(true);
          }
        });
    mntmSaveAs.setEnabled(false);
    mnMenu.add(mntmSaveAs);

    JSeparator separator = new JSeparator();
    mnMenu.add(separator);
    mnMenu.add(mntmSettings);

    JSeparator separator_1 = new JSeparator();
    mnMenu.add(separator_1);
    mnMenu.add(mntmExit);

    final JMenu mnList = new JMenu("List");
    mnList.setEnabled(false);
    menuBar.add(mnList);

    JMenuItem mntmFindSimilarOc = new JMenuItem("Find on OC");
    mntmFindSimilarOc.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            findOnOC(null, null);
          }
        });
    mnList.add(mntmFindSimilarOc);

    JMenuItem mntmFind = new JMenuItem("Find on OC (exclude found)");
    mntmFind.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              OCUser user = null;
              String uuid = null;
              try {
                user = OCUser.getOCUser();
                uuid = OKAPI.getUUID(user);
              } catch (Exception ex) {
                JOptionPane.showMessageDialog(
                    null,
                    "Testing the OKAPI token failed. Check your settings!",
                    "Error",
                    JOptionPane.ERROR_MESSAGE);
                return;
              }

              findOnOC(user, uuid);
            } catch (Throwable ex) {
              ExceptionPanel.showErrorDialog(ex);
            }
          }
        });
    mnList.add(mntmFind);

    JSeparator separator_2 = new JSeparator();
    mnList.add(separator_2);

    JMenuItem mntmCopy = new JMenuItem("Copy");
    mntmCopy.setAccelerator(
        KeyStroke.getKeyStroke('C', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmCopy.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            CacheListController.getTopViewCacheController(desktopPane).copySelected();
          }
        });

    JMenuItem mntmSelectAll = new JMenuItem("Select All / none");
    mntmSelectAll.setAccelerator(
        KeyStroke.getKeyStroke('A', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmSelectAll.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CacheListController.getTopViewCacheController(desktopPane)
                .getView()
                .tableSelectAllNone();
          }
        });
    mnList.add(mntmSelectAll);

    JMenuItem mntInvertSelection = new JMenuItem("Invert Selection");
    mntInvertSelection.setAccelerator(
        KeyStroke.getKeyStroke('I', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntInvertSelection.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CacheListController.getTopViewCacheController(desktopPane)
                .getView()
                .invertTableSelection();
          }
        });
    mnList.add(mntInvertSelection);

    JSeparator separator_6 = new JSeparator();
    mnList.add(separator_6);
    mnList.add(mntmCopy);

    JMenuItem mntmPaste = new JMenuItem("Paste");
    mntmPaste.setAccelerator(
        KeyStroke.getKeyStroke('V', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmPaste.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CacheListController.getTopViewCacheController(desktopPane).pasteSelected();
          }
        });

    JMenuItem mntmCut = new JMenuItem("Cut");
    mntmCut.setAccelerator(
        KeyStroke.getKeyStroke('X', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmCut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CacheListController.getTopViewCacheController(desktopPane).cutSelected();
          }
        });
    mnList.add(mntmCut);
    mnList.add(mntmPaste);

    final JMenuItem mntmDeleteSelectedCaches = new JMenuItem("Delete");
    mntmDeleteSelectedCaches.setAccelerator(
        KeyStroke.getKeyStroke('D', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmDeleteSelectedCaches.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            CacheListController.getTopViewCacheController(desktopPane).removeSelectedCaches();
          }
        });
    mnList.add(mntmDeleteSelectedCaches);

    JSeparator separator_7 = new JSeparator();
    mnList.add(separator_7);

    final JMenuItem mntmUndoAction = new JMenuItem("Undo");
    mntmUndoAction.setAccelerator(
        KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmUndoAction.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            CacheListController.getTopViewCacheController(desktopPane).replayLastUndoAction();
          }
        });
    mnList.add(mntmUndoAction);

    // only enable undo menu when undo actions are available
    mnList.addMenuListener(
        new MenuAdapter() {
          public void menuSelected(MenuEvent e) {
            mntmUndoAction.setEnabled(
                CacheListController.getTopViewCacheController(desktopPane).getUndoActionCount()
                    > 0);
          }
        });

    JSeparator separator_3 = new JSeparator();
    mnList.add(separator_3);

    JSeparator separator_4 = new JSeparator();
    mnList.add(separator_4);

    JMenuItem mntmAddFromFile = new JMenuItem("Add from File");
    mntmAddFromFile.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            openFile(false);
          }
        });
    mnList.add(mntmAddFromFile);

    final JMenu mnFilter = new JMenu("Filter");
    mnFilter.setEnabled(false);
    menuBar.add(mnFilter);

    JMenu mntmAddFilter = new JMenu("Add");
    mnFilter.add(mntmAddFilter);

    JMenuItem mntmTerrainFilter = new JMenuItem("Terrain");
    mntmTerrainFilter.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            CacheListController.getTopViewCacheController(desktopPane)
                .addFilter(new CacheListFilterTerrain());
          }
        });
    mntmAddFilter.add(mntmTerrainFilter);

    JMenuItem mntmCacheNameFilter = new JMenuItem("Cachename");
    mntmCacheNameFilter.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            CacheListController.getTopViewCacheController(desktopPane)
                .addFilter(new CacheListFilterCacheName());
          }
        });
    mntmAddFilter.add(mntmCacheNameFilter);

    JMenuItem mntmDifficultyFilter = new JMenuItem("Difficulty");
    mntmDifficultyFilter.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CacheListController.getTopViewCacheController(desktopPane)
                .addFilter(new CacheListFilterDifficulty());
          }
        });
    mntmAddFilter.add(mntmDifficultyFilter);

    JMenuItem mntmNotFoundBy = new JMenuItem("Not Found By");
    mntmNotFoundBy.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            CacheListController.getTopViewCacheController(desktopPane)
                .addFilter(new CacheListFilterNotFoundBy());
          }
        });
    mntmAddFilter.add(mntmNotFoundBy);

    JSeparator separator_5 = new JSeparator();
    mnFilter.add(separator_5);

    JMenuItem mntmDeleteCachesNot = new JMenuItem("Delete Caches NOT in Filter");
    mntmDeleteCachesNot.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CacheListController.getTopViewCacheController(desktopPane).removeCachesNotInFilter();
          }
        });
    mnFilter.add(mntmDeleteCachesNot);

    JMenuItem mntmDistance = new JMenuItem("Distance");
    mntmDistance.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            final CacheListFilterDistance filter = new CacheListFilterDistance();
            CacheListController.getTopViewCacheController(desktopPane).addFilter(filter);

            // set current location
            filter.setLocation((Location) comboBox.getSelectedItem());

            // update filter on location change
            final ActionListener al =
                new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    filter.setLocation((Location) comboBox.getSelectedItem());
                  }
                };
            comboBox.addActionListener(al);

            // remove update hook on removal
            filter.addRemoveAction(
                new Runnable() {
                  public void run() {
                    comboBox.removeActionListener(al);
                  }
                });
          }
        });
    mntmAddFilter.add(mntmDistance);

    mnWindows.setEnabled(false);
    menuBar.add(mnWindows);

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    desktopPane = new JDesktopPane();
    contentPane.add(desktopPane, BorderLayout.CENTER);
    desktopPane.addContainerListener(
        new ContainerListener() {
          public void componentRemoved(ContainerEvent e) {
            updateVisibility(desktopPane.getAllFrames().length != 0);
          }

          public void componentAdded(ContainerEvent e) {
            updateVisibility(desktopPane.getAllFrames().length != 0);
          }

          private void updateVisibility(boolean visible) {
            mntmSave.setEnabled(visible);
            mntmSaveAs.setEnabled(visible);
            mnList.setEnabled(visible);
            mnFilter.setEnabled(visible);
            //				mntmDeleteSelectedCaches.setEnabled(
            // visible );
            mnWindows.setEnabled(visible);
          }
        });
    desktopPane.setMinimumSize(new Dimension(200, 200));

    JPanel panelSouth = new JPanel();
    panelSouth.setLayout(new BorderLayout(0, 0));
    contentPane.add(panelSouth, BorderLayout.SOUTH);

    ExceptionPanel panelException = ExceptionPanel.getPanel();
    panelSouth.add(panelException, BorderLayout.NORTH);

    JPanel panelUpdate = new JPanel();
    panelSouth.add(panelUpdate, BorderLayout.SOUTH);

    final JButton btnUpdate = new JButton("");
    btnUpdate.setVisible(false);
    btnUpdate.setBorderPainted(false);
    btnUpdate.setOpaque(false);
    btnUpdate.setContentAreaFilled(false);
    btnUpdate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Main.openUrl("https://github.com/RoffelKartoffel/cmanager/releases");
          }
        });
    panelUpdate.add(btnUpdate);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            // Display update message if there is a nother version available
            if (Updates.updateAvailable_block()) {
              setText(
                  "Version "
                      + Updates.getNewVersion()
                      + " of "
                      + Main.APP_NAME
                      + " is available. Click here for updates!");
              btnUpdate.setVisible(true);
            }
          }

          private void setText(String text) {
            btnUpdate.setText("<HTML><FONT color=\"#008000\"><U>" + text + "</U></FONT></HTML>");
          }
        });

    JPanel panelNorth = new JPanel();
    contentPane.add(panelNorth, BorderLayout.NORTH);
    panelNorth.setLayout(new BorderLayout(0, 0));

    JPanel panel = new JPanel();
    panelNorth.add(panel, BorderLayout.EAST);

    JLabel lblNewLabel = new JLabel("Location:");
    lblNewLabel.setFont(new Font("Dialog", Font.BOLD, 10));
    panel.add(lblNewLabel);

    comboBox = new JComboBox<Location>();
    comboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            propagateSelectedLocationComboboxEntry();
          }
        });
    comboBox.setFont(new Font("Dialog", Font.BOLD, 10));
    panel.add(comboBox);

    JButton btnEdit = new JButton("Edit");
    btnEdit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            openLocationDialog(null);
          }
        });
    btnEdit.setFont(new Font("Dialog", Font.BOLD, 10));
    panel.add(btnEdit);

    updateLocationCombobox();
    propagateSelectedLocationComboboxEntry();

    //
    // store and reopen cache lists
    //

    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            try {
              CacheListController.storePersistanceInfo(desktopPane);
            } catch (IOException e1) {
              ExceptionPanel.showErrorDialog(e1);
            }
          }
        });

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            actionWithWaitDialog(
                new Runnable() {
                  public void run() {
                    CacheListController.reopenPersitantCLCs(
                        desktopPane,
                        mnWindows,
                        (Location) comboBox.getSelectedItem(),
                        new CacheListView.RunLocationDialogI() {
                          public void openDialog(Geocache g) {
                            openLocationDialog(g);
                          }
                        });
                  }
                },
                THIS);
          }
        });
  }
  public SearchPatient(final String type, final int docID) {

    try {
      // "Load" the JDBC driver
      Class.forName("java.sql.Driver");

      // Establish the connection to the database
      String url = "jdbc:mysql://localhost:3306/cse";
      conn = DriverManager.getConnection(url, "root", "admin");
    } catch (Exception e) {
      System.err.println("Got an exception!");
      System.err.println(e.getMessage());
    }

    // Menu
    // MENU ACTIONS

    // Action to view new patient registered
    class NewPatientAction extends AbstractAction {
      private static final long serialVersionUID = 1L;

      public NewPatientAction() {
        putValue(SHORT_DESCRIPTION, "View list of new patients");
      }

      public void actionPerformed(ActionEvent e) {
        ViewRegisteredPatients vp = new ViewRegisteredPatients("new");
        vp.setVisible(true);
        ViewRegisteredPatients.hasNew = false;
      }
    }
    Action newPatientAction = new NewPatientAction();

    // Action to view all patient registered
    class AllPatientAction extends AbstractAction {
      private static final long serialVersionUID = 1L;

      public AllPatientAction() {
        putValue(SHORT_DESCRIPTION, "View list of all patients");
      }

      public void actionPerformed(ActionEvent e) {
        ViewRegisteredPatients vp = new ViewRegisteredPatients("all");
        vp.setVisible(true);
      }
    }
    Action allPatientAction = new AllPatientAction();

    // Action to open Statistical Report
    class StatsReportAction implements MenuListener {
      public void menuSelected(MenuEvent e) {
        StatsReport report = new StatsReport();
        setAlwaysOnTop(false);
        report.setVisible(true);
        report.setAlwaysOnTop(true);
      }

      public void menuDeselected(MenuEvent e) {}

      public void menuCanceled(MenuEvent e) {}
    }

    // Action to open Statistical Report
    class ProfileAction implements MenuListener {
      public void menuSelected(MenuEvent e) {
        Profile profilePage = new Profile("staff", docID, type);
        profilePage.setVisible(true);
        dispose();
      }

      public void menuDeselected(MenuEvent e) {}

      public void menuCanceled(MenuEvent e) {}
    }

    // MENU COMPONENTS
    menu = new JMenuBar();

    menuOp1 = new JMenu();
    menuOp2 = new JMenu();
    menuOp3 = new JMenu();
    menuOp4 = new JMenu();
    menuOp5 = new JMenu();

    menuOp1.setText("Profile");
    menuOp1.addMenuListener(new ProfileAction());

    optionsFrame = new JFrame("Options");

    optionsContainer = new JPanel();
    optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.Y_AXIS));
    optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));

    if (type.equals("Doctor")) // if a doctor is logging in
    {
      menuOp2.setText("Patients");
      menuOp3.setText("Appointments Request");
      menuOp4.setText("View Medical Alerts");

      menuItem1 = new JMenuItem("Search Patient");

      menuOp2.add(menuItem1);

      menu.add(menuOp1);
      menu.add(menuOp2);
      menu.add(menuOp3);
      menu.add(menuOp4);

      // optionsFrame
      optionUpdateHCC = new JLabel("Update Healthcare Condition");
      optionUpdateHCC.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCC.addMouseListener(new MouseUpdateHCCListener());

      optionPrescription = new JLabel("e-Prescription");
      optionPrescription.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      // optionPrescription.addMouseListener(new MousePrescriptionListener());

      optionLabRecord = new JLabel("View Lab Records");
      optionLabRecord.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionLabRecord.addMouseListener(new MouseLabRecordListener());

      optionUpdateHCR = new JLabel("Update Healthcare Records");
      optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener());

      // add option to container
      optionsContainer.add(optionUpdateHCC);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionPrescription);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionLabRecord);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionLabRecord);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionUpdateHCR);
    } else if (type.equals("HSP")) // if the HSP is logging in
    {
      menuOp2.setText("Patients");
      menuOp3.setText("Appointment Request");
      menuOp4.setText("View Medical Alerts");
      menuOp5.setText("Generate Statistical Report");
      menuOp5.addMenuListener(new StatsReportAction());

      menuItem1 = new JMenuItem("Search Patient");
      menuOp6 = new JMenu("List of Registered Patient");
      menuOp6.setMnemonic(KeyEvent.VK_S);

      menuItem2 = new JMenuItem(newPatientAction);
      menuItem2.setText("List of New Registered Patient");
      menuItem3 = new JMenuItem(allPatientAction);
      menuItem3.setText("List of All Registered Patient");

      menuOp2.add(menuItem1);
      menuOp2.add(menuOp6);
      menuOp6.add(menuItem2);
      menuOp6.add(menuItem3);

      menu.add(menuOp1);
      menu.add(menuOp2);
      menu.add(menuOp3);
      menu.add(menuOp4);
      menu.add(menuOp5);

      // optionsFrame
      optionUpdateHCC = new JLabel("Update Healthcare Condition");
      optionUpdateHCC.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCC.addMouseListener(new MouseUpdateHCCListener());

      optionLabRecord = new JLabel("View Lab Records");
      optionLabRecord.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionLabRecord.addMouseListener(new MouseLabRecordListener());

      optionHCR = new JLabel("Upload Healthcare Records");
      optionHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionHCR.addMouseListener(new MouseUploadHCRListener());

      optionUpdateHCR = new JLabel("Update Healthcare Records");
      optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener());

      // add option to container
      optionsContainer.add(optionUpdateHCC);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionLabRecord);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionLabRecord);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionHCR);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionUpdateHCR);
    } else if (type.equals("Pharmacist")) // if the Pharmacist is logging in
    {
      menuOp2.setText("Patients");

      menuItem1 = new JMenuItem("Search Patients");

      menuOp2.add(menuItem1);

      menu.add(menuOp1);
      menu.add(menuOp2);

      // optionsFrame
      optionViewPrescription = new JLabel("View e-Prescription");
      optionViewPrescription.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionViewPrescription.addMouseListener(new MouseViewPrescriptionListener());

      // add option to container
      optionsContainer.add(optionViewPrescription);

    } else if (type.equals("Nurse")) // if the nurse is logging in
    {
      menuOp2.setText("Patients");

      menuItem1 = new JMenuItem("Search Patients");

      menuOp2.add(menuItem1);

      menu.add(menuOp1);
      menu.add(menuOp2);

      // optionsFrame
      optionUpdateHCR = new JLabel("Update Healthcare Records");
      optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener());

      // add option to container
      optionsContainer.add(optionUpdateHCR);
    }

    // Labels
    firstNameLabel = new JLabel(" First name:"); // first name label
    lastNameLabel = new JLabel("Last name:"); // last name label
    patientListLabel = new JLabel("Patient List:"); // patient list label

    // Text Fields
    firstNameField = new JTextField(10); // first name text field
    lastNameField = new JTextField(10); // last name text field

    // Buttons
    searchButton = new JButton("Search"); // search button
    searchButton.addActionListener(new SearchButtonListener()); // add listener

    selectButton = new JButton("Select");
    selectButton.addActionListener(new SelectButtonListener()); // add listener

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new CancelButtonListener()); // add listener

    // JPanels
    firstNamePanel = new JPanel(); // First name panel
    firstNamePanel.add(firstNameLabel);
    firstNamePanel.add(firstNameField);

    lastNamePanel = new JPanel(); // Last name panel
    lastNamePanel.add(lastNameLabel);
    lastNamePanel.add(lastNameField);

    patientInfoPanel = new JPanel();
    patientInfoPanel.setLayout(new BoxLayout(patientInfoPanel, BoxLayout.X_AXIS));
    patientInfoPanel.add(firstNamePanel);
    patientInfoPanel.add(lastNamePanel);
    patientInfoPanel.add(searchButton);

    buttonPanel = new JPanel(); // button panel
    buttonPanel.add(selectButton);
    buttonPanel.add(cancelButton);

    // Patient List
    patientVector = new Vector(); // Vector of Patient objects
    patientList =
        new JList(patientVector); // creates a JList that show the content of the recordVector

    scrollPatientList = new JScrollPane(patientList); // add scroll option to the list
    patientList.setSelectionMode(
        ListSelectionModel.SINGLE_SELECTION); // Allow the selection of only one item at a time

    String[] patients = new String[1000000];

    // Populates the patient list with the patients from the database
    if (type.equals("Doctor")) {
      int i = 0;
      try {
        // checks if the patient is a patient of the doctor logged
        statement = conn.createStatement();
        rs =
            statement.executeQuery(
                "SELECT * FROM appointments WHERE `docID`='" + docID + "' ORDER BY `patientID`");

        while (rs.next()) {
          int patientID = rs.getInt("patientID");
          patients[i] = String.valueOf(patientID);

          i++;
        }

        String[] patientSet =
            (String[]) new HashSet(Arrays.asList(patients)).toArray(new String[0]);

        // gets information from the specific set of patients
        for (int j = 0; j < patientSet.length; j++) {
          statement = conn.createStatement();
          rs =
              statement.executeQuery(
                  "SELECT * FROM patient WHERE `idpatient`='" + patientSet[j] + "';");

          while (rs.next()) {
            Patient obj = new Patient();
            obj.setFirstName(rs.getString("fname"));
            obj.setLastName(rs.getString("lname"));
            obj.setDOB(rs.getString("dob"));
            obj.setPatientId(Integer.parseInt(patientSet[j]));

            patientVector.add(obj);
          }
        }

      } catch (Exception e) {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());
        System.err.println(e);
      }
    } else {
      try {
        statement = conn.createStatement();
        rs = statement.executeQuery("SELECT * FROM patient ORDER BY fname");

        while (rs.next()) {
          Patient obj = new Patient();
          obj.setFirstName(rs.getString("fname"));
          obj.setLastName(rs.getString("lname"));
          obj.setDOB(rs.getString("dob"));
          obj.setPatientId(rs.getInt("idpatient"));

          patientVector.add(obj);
        }
      } catch (Exception e) {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());
      }
    }

    searchVector = new Vector();

    // set options frame
    optionsFrame.add(optionsContainer);
    optionsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // close the window on close
    optionsFrame.setSize(300, 150); // set size of window
    optionsFrame.setLocation(600, 280);
    optionsFrame.setVisible(false);

    searchPanel = new JPanel();
    searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.Y_AXIS));
    searchPanel.add(patientInfoPanel);
    searchPanel.add(patientListLabel);
    searchPanel.add(scrollPatientList);
    searchPanel.add(buttonPanel);

    Border padding = BorderFactory.createEmptyBorder(20, 20, 10, 10);
    searchPanel.setBorder(padding);

    setJMenuBar(menu);
    add(searchPanel);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(1200, 580);
  }
Esempio n. 12
0
  public DialogStammdaten(JFrame fenster, String[][] datensatz1, String s, Methoden datenbank1) {
    super(fenster, true);
    datenbank = datenbank1;
    datensatz = datensatz1;
    p = new JPanel();
    platzhalter = new JLabel();
    text1 = new JLabel("Name");
    text2 = new JLabel("Personalnummer");
    text3 = new JLabel("Titel");
    text4 = new JLabel("Institut");
    feld = new JComboBox();
    textName = new JTextField();
    textPersonalnr = new JTextField();
    textInstitut = new JTextField();
    textTitel = new JTextField();
    menue = new JMenuBar();
    datei = new JMenu("Datei");
    aendern = new JMenuItem("Aendern");
    hinzufuegen = new JMenuItem("Hinzufuegen");
    loeschen = new JMenuItem("Loeschen");
    beenden = new JMenuItem("Beenden");
    final JDialog dialog = this;
    this.setTitle(s);
    feld = new JComboBox(ersteElemente(datensatz));
    textName.setText(datensatz[0][0]);
    textPersonalnr.setText(datensatz[0][1]);
    setzen(datensatz, feld.getSelectedIndex());

    feld.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getID() == ItemEvent.ITEM_STATE_CHANGED
                && e.getStateChange() == ItemEvent.SELECTED) {
              textName.setText((String) e.getItem());
              textPersonalnr.setText(datensatz[feld.getSelectedIndex()][1]);
              setzen(datensatz, feld.getSelectedIndex());
            }
          }
        });

    datei.addMenuListener(
        new MenuListener() {
          public void menuSelected(MenuEvent e) {
            hinzufuegen.setEnabled(false);
            aendern.setEnabled(false);
            loeschen.setEnabled(false);

            if (!geaendert(datensatz, feld.getSelectedIndex())) {
              loeschen.setEnabled(true);
            } else if (!(textName.getText().equals("") || textPersonalnr.getText().equals(""))) {
              hinzufuegen.setEnabled(true);
              aendern.setEnabled(true);
            }
          }

          public void menuDeselected(MenuEvent e) {}

          public void menuCanceled(MenuEvent e) {}
        });

    hinzufuegen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (hinzufuegen(daten)) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Hinzufuegen geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    aendern.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (aendern(datensatz[feld.getSelectedIndex()][1], daten)) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Aendern geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    loeschen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (loeschen(datensatz[feld.getSelectedIndex()][1])) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Loeschen geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    beenden.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });

    datei.add(hinzufuegen);
    datei.add(aendern);
    datei.add(loeschen);
    datei.add(beenden);
    menue.add(datei);
    this.setJMenuBar(menue);

    p.setLayout(new GridLayout(2, 5));
    p.add(platzhalter);
    p.add(text1);
    p.add(text2);
    p.add(text3);
    p.add(text4);
    p.add(feld);
    p.add(textName);
    p.add(textPersonalnr);
    p.add(textTitel);
    p.add(textInstitut);
    this.setContentPane(p);

    this.pack();
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  }
Esempio n. 13
0
  private void jbInit() throws Exception {
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    this.setIconImage(icon.getImage());
    this.addComponentListener(
        new java.awt.event.ComponentAdapter() {
          public void componentShown(ComponentEvent e) {
            this_componentShown(e);
          }
        });
    this.getContentPane().setLayout(borderLayout1);
    this.addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            this_windowClosing(e);
          }
        });
    this.setJMenuBar(menuBar);

    // This size is chosen so that when the user hits the Info tool, the
    // window
    // fits between the lower edge of the TaskFrame and the lower edge of
    // the
    // WorkbenchFrame. See the call to #setSize in InfoFrame. [Jon Aquino]
    setSize(900, 665);

    // OUTLINE_DRAG_MODE is excruciatingly slow in JDK 1.4.1, so don't use
    // it.
    // (although it's supposed to be fixed in 1.4.2, which has not yet been
    // released). (see Sun Java Bug ID 4665237). [Jon Aquino]
    // desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    messageLabel.setOpaque(true);
    memoryLabel.setText("jLabel1");
    wmsLabel.setHorizontalAlignment(SwingConstants.LEFT);
    wmsLabel.setText(" ");
    this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
    exitMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exitMenuItem_actionPerformed(e);
          }
        });
    windowMenu.addMenuListener(
        new javax.swing.event.MenuListener() {
          public void menuCanceled(MenuEvent e) {}

          public void menuDeselected(MenuEvent e) {}

          public void menuSelected(MenuEvent e) {
            windowMenu_menuSelected(e);
          }
        });
    coordinateLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    wmsLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    coordinateLabel.setText(" ");
    statusPanel.setLayout(gridBagLayout1);
    statusPanel.setBorder(BorderFactory.createRaisedBevelBorder());
    messageLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    messageLabel.setText(" ");
    timeLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    timeLabel.setText(" ");
    memoryLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    memoryLabel.setText(" ");
    menuBar.add(fileMenu);
    menuBar.add(windowMenu);
    getContentPane().add(toolBar, BorderLayout.NORTH);
    getContentPane().add(desktopPane, BorderLayout.CENTER);
    fileMenu.addSeparator();
    fileMenu.add(exitMenuItem);
    statusPanel.add(
        coordinateLabel,
        new GridBagConstraints(
            5,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    statusPanel.add(
        timeLabel,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    statusPanel.add(
        messageLabel,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    // Give memoryLabel the 1.0 weight. All the rest should have their
    // sizes
    // configured using #configureStatusLabel. [Jon Aquino]
    statusPanel.add(
        memoryLabel,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    statusPanel.add(
        wmsLabel,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
  }
 public XJMenu() {
   jMenu.addMenuListener(new XJMenuListener());
 }
Esempio n. 15
0
  @Override
  public void createMenuItems() {
    add(
        new AbstractAction(I18n.tr("&Home")) {
          @Override
          public void actionPerformed(ActionEvent e) {
            storeVisited++;
            navigator.getNavItem(NavCategory.LIMEWIRE, StoreMediator.NAME).select();
            storeMediator.getComponent().loadDefaultUrl();
          }
        });

    add(
        new StoreUrlAction(
            I18n.tr("&Log In"),
            "https://www.store.limewire.com/store/app/pages/account/LogIn/noDest/1/"));
    add(
        new StoreUrlAction(
            I18n.tr("&Sign Up"),
            "https://www.store.limewire.com/store/app/pages/register/RegisterSelection/"));

    JMenu genres = new MnemonicMenu(I18n.tr("&Genres"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Alternative"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/31/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Country"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/14/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Electronica"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/20/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Folk"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/3/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Jazz"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/6/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Pop"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/27/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Rap"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/8/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Rhythm and Blues"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/26/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&Rock"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/1/"));
    genres.add(
        new StoreUrlAction(
            I18n.tr("&World"),
            "http://www.store.limewire.com/store/app/pages/genre/GenreHome/genreId/2/"));
    add(genres);

    //        add(new StoreUrlAction(I18n.tr("&Free Songs"), "http://www.store.limewire.com/free"));
    add(
        new StoreUrlAction(
            I18n.tr("LimeWire Store Hel&p"),
            "http://www.store.limewire.com/store/app/pages/help/Help/"));

    // The history menu is not working on Mac OS X. Calls to retrieve it go into native code and
    // never return.
    if (!OSUtils.isMacOSX()) {
      final JMenu history = new MnemonicMenu(I18n.tr("His&tory"));
      history.addMenuListener(
          new MenuListener() {
            @Override
            public void menuCanceled(MenuEvent e) {
              history.removeAll();
            }

            @Override
            public void menuDeselected(MenuEvent e) {
              history.removeAll();
            }

            @Override
            public void menuSelected(MenuEvent e) {
              AtomicReference<Integer> currentPosition = new AtomicReference<Integer>();
              for (HistoryEntry entry : storeMediator.getComponent().getHistory(currentPosition)) {
                JMenuItem item = history.add(new HistoryAction(entry));
                if (entry.getIndex() == currentPosition.get()) {
                  FontUtils.bold(item);
                }
              }
            }
          });
      add(history);
    }
  }
Esempio n. 16
0
  private void initMenuBar() {
    Application application = RDV.getInstance();
    ApplicationContext context = application.getContext();

    ResourceMap resourceMap = context.getResourceMap();
    String platform = resourceMap.getString("platform");
    boolean isMac = (platform != null && platform.equals("osx"));

    ActionFactory actionFactory = ActionFactory.getInstance();

    Actions actions = Actions.getInstance();
    ActionMap actionMap = context.getActionMap(actions);

    menuBar = new JMenuBar();

    JMenuItem menuItem;

    JMenu fileMenu = new JMenu(fileAction);

    menuItem = new JMenuItem(connectAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(disconnectAction);
    fileMenu.add(menuItem);

    fileMenu.addSeparator();

    menuItem = new JMenuItem(loginAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(logoutAction);
    fileMenu.add(menuItem);

    fileMenu.addMenuListener(
        new MenuListener() {
          public void menuCanceled(MenuEvent arg0) {}

          public void menuDeselected(MenuEvent arg0) {}

          public void menuSelected(MenuEvent arg0) {
            if (AuthenticationManager.getInstance().getAuthentication() == null) {
              loginAction.setEnabled(true);
              logoutAction.setEnabled(false);
            } else {
              loginAction.setEnabled(false);
              logoutAction.setEnabled(true);
            }
          }
        });

    fileMenu.addSeparator();

    menuItem = new JMenuItem(loadAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(saveAction);
    fileMenu.add(menuItem);

    fileMenu.addSeparator();

    fileMenu.add(new JMenuItem(actionMap.get("addLocalChannel")));

    fileMenu.addSeparator();

    JMenu importSubMenu = new JMenu(importAction);

    menuItem = new JMenuItem(actionFactory.getDataImportAction());
    importSubMenu.add(menuItem);

    menuItem = new JMenuItem(actionFactory.getOpenSeesDataImportAction());
    importSubMenu.add(menuItem);

    importSubMenu.add(new JMenuItem(actionMap.get("importJPEGs")));

    fileMenu.add(importSubMenu);

    JMenu exportSubMenu = new JMenu(exportAction);

    menuItem = new JMenuItem(actionFactory.getDataExportAction());
    exportSubMenu.add(menuItem);

    menuItem = new JMenuItem(exportVideoAction);
    exportSubMenu.add(menuItem);

    fileMenu.add(exportSubMenu);

    fileMenu.addSeparator();

    menuItem = new DataViewerCheckBoxMenuItem(actionFactory.getOfflineAction());
    fileMenu.add(menuItem);

    if (!isMac) {
      menuItem = new JMenuItem(exitAction);
      fileMenu.add(menuItem);
    }

    menuBar.add(fileMenu);

    JMenu controlMenu = new JMenu(controlAction);

    menuItem = new SelectableCheckBoxMenuItem(realTimeAction);
    controlMenu.add(menuItem);

    menuItem = new SelectableCheckBoxMenuItem(playAction);
    controlMenu.add(menuItem);

    menuItem = new SelectableCheckBoxMenuItem(pauseAction);
    controlMenu.add(menuItem);

    controlMenu.addMenuListener(
        new MenuListener() {
          public void menuCanceled(MenuEvent arg0) {}

          public void menuDeselected(MenuEvent arg0) {}

          public void menuSelected(MenuEvent arg0) {
            int state = rbnb.getState();
            realTimeAction.setSelected(state == Player.STATE_MONITORING);
            playAction.setSelected(state == Player.STATE_PLAYING);
            pauseAction.setSelected(state == Player.STATE_STOPPED);
          }
        });

    controlMenu.addSeparator();

    menuItem = new JMenuItem(beginningAction);
    controlMenu.add(menuItem);

    menuItem = new JMenuItem(endAction);
    controlMenu.add(menuItem);

    menuItem = new JMenuItem(gotoTimeAction);
    controlMenu.add(menuItem);

    menuBar.add(controlMenu);

    controlMenu.addSeparator();

    menuItem = new JMenuItem(updateChannelListAction);
    controlMenu.add(menuItem);

    controlMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(dropDataAction);
    controlMenu.add(menuItem);

    JMenu viewMenu = new JMenu(viewAction);

    menuItem = new JCheckBoxMenuItem(showChannelListAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showMetadataPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showControlPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showAudioPlayerPanelAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showMarkerPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(showHiddenChannelsAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(hideEmptyTimeAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(fullScreenAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuBar.add(viewMenu);

    JMenu windowMenu = new JMenu(windowAction);

    List<Extension> extensions = dataPanelManager.getExtensions();
    for (final Extension extension : extensions) {
      Action action =
          new DataViewerAction("Add " + extension.getName(), "", KeyEvent.VK_J) {
            /** serialization version identifier */
            private static final long serialVersionUID = 36998228704476723L;

            public void actionPerformed(ActionEvent ae) {
              try {
                dataPanelManager.createDataPanel(extension);
              } catch (Exception e) {
                log.error(
                    "Unable to open data panel provided by extension "
                        + extension.getName()
                        + " ("
                        + extension.getID()
                        + ").");
                e.printStackTrace();
              }
            }
          };

      menuItem = new JMenuItem(action);
      windowMenu.add(menuItem);
    }

    windowMenu.addSeparator();

    menuItem = new JMenuItem(closeAllDataPanelsAction);
    windowMenu.add(menuItem);

    windowMenu.addSeparator();
    JMenu dataPanelSubMenu = new JMenu(dataPanelAction);

    ButtonGroup dataPanelLayoutGroup = new ButtonGroup();

    menuItem = new JRadioButtonMenuItem(dataPanelHorizontalLayoutAction);
    dataPanelSubMenu.add(menuItem);
    dataPanelLayoutGroup.add(menuItem);

    menuItem = new JRadioButtonMenuItem(dataPanelVerticalLayoutAction);
    menuItem.setSelected(true);
    dataPanelSubMenu.add(menuItem);
    dataPanelLayoutGroup.add(menuItem);
    windowMenu.add(dataPanelSubMenu);

    menuBar.add(windowMenu);

    JMenu helpMenu = new JMenu(helpAction);

    menuItem = new JMenuItem(usersGuideAction);
    helpMenu.add(menuItem);

    menuItem = new JMenuItem(supportAction);
    helpMenu.add(menuItem);

    menuItem = new JMenuItem(releaseNotesAction);
    helpMenu.add(menuItem);

    if (!isMac) {
      helpMenu.addSeparator();

      menuItem = new JMenuItem(aboutAction);
      helpMenu.add(menuItem);
    }

    menuBar.add(helpMenu);

    menuBar.add(Box.createHorizontalGlue());
    throbberStop = DataViewer.getIcon("icons/throbber.png");
    throbberAnim = DataViewer.getIcon("icons/throbber_anim.gif");
    throbber = new JLabel(throbberStop);
    throbber.setBorder(new EmptyBorder(0, 0, 0, 4));
    menuBar.add(throbber, BorderLayout.EAST);

    if (isMac) {
      registerMacOSXEvents();
    }

    frame.setJMenuBar(menuBar);
  }
 /** Creates and registers all the listeners for this UI delegate. */
 protected void installListeners() {
   ((JMenu) menuItem).addMouseListener(mouseInputListener);
   ((JMenu) menuItem).addMouseMotionListener(mouseInputListener);
   ((JMenu) menuItem).addMenuListener(menuListener);
   ((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener);
 }
  private void initMenuBar(ParticlePicker picker) {
    filemn = new JMenu(bundle.getString("file"));
    helpmn = new JMenu(bundle.getString("help"));
    savemi = new JMenuItem("Save", XmippResource.getIcon("save.gif"));
    savemi.setMnemonic('S');
    savemi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    savemi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            getParticlePicker().saveData();
            showMessage("Data saved successfully");
            setChanged(false);
          }
        });
    filemn.add(savemi);
    importmi = new JMenuItem("Import coordinates...", XmippResource.getIcon("import_wiz.gif"));
    filemn.add(importmi);
    if (picker.getMode() != Mode.Manual) importmi.setEnabled(false);

    importmi.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (importpjd == null)
              importpjd = new ImportParticlesJDialog(ParticlePickerJFrame.this);
            importpjd.showDialog();
          }
        });

    exitmi = new JMenuItem("Exit");
    exitmi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            close();
          }
        });

    ijmi = new JMenuItem("ImageJ", XmippResource.getIcon("ij.gif"));
    ijmi.setEnabled(picker.getMode() != Mode.ReadOnly);
    ijmi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            XmippUtil.showImageJ(Tool.PICKER);
          }
        });

    hcontentsmi = new JMenuItem("Online help", XmippResource.getIcon("online_help.gif"));
    hcontentsmi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              openHelpURl();

            } catch (Exception ex) {
              showException(ex);
            }
          }
        });
    helpmn.add(hcontentsmi);

    keyassistmi = new JMenuItem("Tips...", XmippResource.getIcon("bulb.png"));
    keyassistmi.addActionListener(
        new ActionListener() {

          private QuickHelpJDialog keyassistdlg;

          @Override
          public void actionPerformed(ActionEvent e) {
            if (keyassistdlg == null)
              keyassistdlg =
                  new QuickHelpJDialog(ParticlePickerJFrame.this, false, "Tips", getKeyAssist());
            keyassistdlg.setVisible(true);
          }
        });
    helpmn.add(keyassistmi);

    pmi = new JMenuItem("Particles", XmippResource.getIcon("table_view.gif"));
    pmi.addActionListener(
        new ActionListener() {

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

    mifilters = new ArrayList<JCheckBoxMenuItem>();
    filtersmn = new JMenu(bundle.getString("filters"));
    filtersmn.addMenuListener(
        new MenuListener() {

          @Override
          public void menuCanceled(MenuEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void menuDeselected(MenuEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void menuSelected(MenuEvent arg0) {
            boolean added;
            for (JCheckBoxMenuItem mi : mifilters) {
              added = getParticlePicker().isFilterAdded(mi.getText());
              mi.setSelected(added);
            }
          }
        });

    addFilterMenuItem(XmippImageJ.gaussianBlurFilter, true, picker);
    addFilterMenuItem(ParticlePicker.xmippsmoothfilter, true, picker);
    addFilterMenuItem(XmippImageJ.bandPassFilter, true, picker);
    addFilterMenuItem(XmippImageJ.enhanceContrastFilter, true, picker);
    addFilterMenuItem(XmippImageJ.brightnessContrastFilter, true, picker);

    //		JCheckBoxMenuItem admi = addFilterMenuItem(XmippImageJ.anisotropicDiffFilter, false,
    // picker);
    //		admi.addActionListener(new ActionListener()
    //		{
    //
    //			@Override
    //			public void actionPerformed(ActionEvent e)
    //			{
    //				activefilter = "8-bit";
    //				IJ.run(activefilter);
    //				activefilter = ((JCheckBoxMenuItem) e.getSource()).getText();
    //				IJ.run(activefilter);
    //			}
    //		});
    addFilterMenuItem(XmippImageJ.invertLUTFilter, true, picker);
    addFilterMenuItem(XmippImageJ.substractBackgroundFilter, true, picker);
    addFilterAppliedListener();
  }
  public GraphPanelContextMenu(
      KinDiagramPanel egoSelectionPanelLocal,
      final GraphPanel graphPanelLocal,
      final EntityCollection entityCollection,
      final ArbilWindowManager arbilWindowManager,
      ArbilDataNodeLoader dataNodeLoaderL,
      final SessionStorage sessionStorage) {
    kinDiagramPanel = egoSelectionPanelLocal;
    graphPanel = graphPanelLocal;
    this.dataNodeLoader = dataNodeLoaderL;
    if (egoSelectionPanelLocal != null) {
      final ActionListener addMenuActionListener =
          new java.awt.event.ActionListener() {
            public void actionPerformed(final java.awt.event.ActionEvent evt) {
              if (!kinDiagramPanel.verifyDiagramDataLoaded()) {
                return;
              }
              new Thread() {
                @Override
                public void run() {
                  // node type will be used to determine the schema used from the diagram options
                  kinDiagramPanel.showProgressBar();
                  String nodeType = evt.getActionCommand();
                  try {
                    EntityDocument entityDocument =
                        new EntityDocument(
                            nodeType,
                            new ImportTranslator(true),
                            sessionStorage,
                            entityCollection.getProjectRecord());
                    entityDocument.saveDocument();
                    URI addedEntityUri = entityDocument.getFile().toURI();
                    entityCollection.updateDatabase(
                        entityDocument.getFile().toURI(), entityDocument.getUniqueIdentifier());
                    kinDiagramPanel.addRequiredNodes(
                        new UniqueIdentifier[] {entityDocument.getUniqueIdentifier()},
                        GraphPanelContextMenu.this.eventLocation);
                  } catch (ImportException exception) {
                    kinDiagramPanel.clearProgressBar();
                    BugCatcherManager.getBugCatcher().logError(exception);
                    final String message =
                        java.text.MessageFormat.format(
                            menus.getString("FAILED TO CREATE ENTITY: {0}"),
                            new Object[] {exception.getMessage()});
                    arbilWindowManager.addMessageDialogToQueue(
                        message, menus.getString("ADD ENTITY"));
                  } catch (EntityServiceException exception) {
                    BugCatcherManager.getBugCatcher().logError(exception);
                    arbilWindowManager.addMessageDialogToQueue(
                        exception.getMessage(), "Update Database");
                  }
                }
              }.start();
            }
          };

      addEntityMenu = new JMenu(menus.getString("ADD"));
      addEntityMenu.addMenuListener(
          new MenuListener() {
            public void menuSelected(MenuEvent e) {
              addEntityMenu.removeAll();
              for (ProfileRecord profileRecord : graphPanelLocal.dataStoreSvg.selectedProfiles) {
                JMenuItem addMenuItem = new JMenuItem(profileRecord.profileName);
                addMenuItem.setActionCommand(profileRecord.profileId);
                addMenuItem.addActionListener(addMenuActionListener);
                addEntityMenu.add(addMenuItem);
              }
            }

            public void menuDeselected(MenuEvent e) {}

            public void menuCanceled(MenuEvent e) {}
          });
      this.add(addEntityMenu);

      JMenu shapeSubMenu = new JMenu(menus.getString("ADD GEOMETRY"));
      for (SvgUpdateHandler.GraphicsTypes graphicsType : SvgUpdateHandler.GraphicsTypes.values()) {
        JMenuItem addLabel =
            new JMenuItem(
                java.text.MessageFormat.format(
                    menus.getString("ADD {0}"), new Object[] {graphicsType.name()}));
        addLabel.setActionCommand(graphicsType.name());
        shapeSubMenu.add(addLabel);
        if (SvgUpdateHandler.GraphicsTypes.Polyline.equals(graphicsType)) {
          addLabel.setEnabled(false);
        }
        addLabel.addActionListener(GraphPanelContextMenu.this);
        // todo: addthese into a layer behind the entities, athought lables could be above
        // todo: when geometry is selected construct an arbildatanode to allow the geometries
        // attributes to be edited
      }
      this.add(shapeSubMenu);

      deleteMenu = new JMenuItem(menus.getString("DELETE SELECTED FROM PROJECT"));
      deleteMenu.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              int entityCount = 0;
              for (UniqueIdentifier uniqueIdentifier : selectedIdentifiers) {
                if (!uniqueIdentifier.isGraphicsIdentifier()
                    && !uniqueIdentifier.isTransientIdentifier()) {
                  entityCount++;
                }
              }
              boolean doDelete = false;
              if (entityCount == 0) {
                doDelete = true;
              } else if (JOptionPane.OK_OPTION
                  == arbilWindowManager.showDialogBox(
                      entityCount
                          + menus.getString(" ENTITIES WILL BE DELETED FROM THE CURRENT PROJECT"),
                      menus.getString("DELETE ENTITY"),
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.WARNING_MESSAGE)) {
                doDelete = true;
              }
              if (doDelete) {
                new Thread(
                        new Runnable() {
                          public void run() {
                            kinDiagramPanel.showProgressBar();
                            ArrayList<UniqueIdentifier> affectedIdentifiers =
                                new ArrayList<UniqueIdentifier>();
                            for (UniqueIdentifier uniqueIdentifier : selectedIdentifiers) {
                              if (uniqueIdentifier.isGraphicsIdentifier()) {
                                graphPanel.svgUpdateHandler.deleteGraphics(uniqueIdentifier);
                              } else if (uniqueIdentifier.isTransientIdentifier()) {
                                kinDiagramPanel.clearProgressBar();
                                throw new UnsupportedOperationException(
                                    menus.getString("CANNOT DELETE TRANSIENT ENTITIES."));
                              } else {
                                affectedIdentifiers.add(uniqueIdentifier);
                              }
                            }
                            final UniqueIdentifier[] affectedIdentifiersArray =
                                affectedIdentifiers.toArray(new UniqueIdentifier[] {});
                            try {
                              final RelationLinker relationLinker =
                                  new RelationLinker(
                                      sessionStorage, arbilWindowManager, entityCollection);
                              relationLinker.deleteEntity(affectedIdentifiersArray);
                            } catch (ImportException exception) {
                              final String message =
                                  java.text.MessageFormat.format(
                                      java.util.ResourceBundle.getBundle(
                                              "nl/mpi/kinoath/localisation/Menus")
                                          .getString("FAILED TO DELETE: {0}"),
                                      new Object[] {exception.getMessage()});
                              arbilWindowManager.addMessageDialogToQueue(
                                  message, mergeEntitiesMenu.getText());
                            }
                            kinDiagramPanel.removeRequiredNodes(affectedIdentifiersArray);
                            kinDiagramPanel.removeEgoNodes(affectedIdentifiersArray);
                            kinDiagramPanel.clearProgressBar();
                          }
                        })
                    .start();
              }
            }
          });
      this.add(deleteMenu);

      mergeEntitiesMenu = new JMenuItem(menus.getString("MERGE SELECTED ENTITIES"));
      mergeEntitiesMenu.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              String messageString =
                  java.text.MessageFormat.format(
                      menus.getString(
                          "THE SELECTED ENTITES WILL BE MERGED,ALL RELATIONS WILL BE PRESERVED AND {0} ENTITIES WILL BE DELETED."),
                      new Object[] {(selectedIdentifiers.length - 1)});
              messageString = messageString + menus.getString("DO YOU WISH TO CONTINUE?");
              if (JOptionPane.OK_OPTION
                  == arbilWindowManager.showDialogBox(
                      messageString,
                      menus.getString("MERGE ENTITIES"),
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.WARNING_MESSAGE)) {
                new Thread(
                        new Runnable() {
                          public void run() {
                            kinDiagramPanel.showProgressBar();
                            try {
                              final EntityMerger entityMerger =
                                  new EntityMerger(
                                      sessionStorage, arbilWindowManager, entityCollection);
                              final UniqueIdentifier leadMergedEntity =
                                  entityMerger.mergeEntities(selectedIdentifiers);
                              dataNodeLoader.requestReload(
                                  dataNodeLoader.getArbilDataNode(
                                      null,
                                      leadMergedEntity
                                          .getFileInProject(
                                              kinDiagramPanel
                                                  .getEntityCollection()
                                                  .getProjectRecord())
                                          .toURI()));
                              kinDiagramPanel.entityRelationsChanged(
                                  entityMerger.getAffectedIdentifiersArray());
                              kinDiagramPanel.removeRequiredNodes(
                                  entityMerger.getDeletedIdentifiersArray());
                            } catch (ImportException exception) {
                              arbilWindowManager.addMessageDialogToQueue(
                                  java.text.MessageFormat.format(
                                      menus.getString("FAILED TO MERGE: {0}"),
                                      new Object[] {exception.getMessage()}),
                                  mergeEntitiesMenu.getText());
                            } catch (EntityServiceException exception) {
                              arbilWindowManager.addMessageDialogToQueue(
                                  java.text.MessageFormat.format(
                                      menus.getString("FAILED TO MERGE: {0}"),
                                      new Object[] {exception.getMessage()}),
                                  mergeEntitiesMenu.getText());
                            }
                            kinDiagramPanel.clearProgressBar();
                          }
                        })
                    .start();
              }
            }
          });
      this.add(mergeEntitiesMenu);

      duplicateEntitiesMenu = new JMenuItem(menus.getString("DUPLICATE SELECTED ENTITIES"));
      duplicateEntitiesMenu.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              new Thread(
                      new Runnable() {
                        public void run() {
                          kinDiagramPanel.showProgressBar();
                          try {
                            final UniqueIdentifier[] duplicateEntities =
                                new EntityMerger(
                                        sessionStorage, arbilWindowManager, entityCollection)
                                    .duplicateEntities(selectedIdentifiers);
                            kinDiagramPanel.entityRelationsChanged(selectedIdentifiers);
                            kinDiagramPanel.addRequiredNodes(duplicateEntities, eventLocation);
                          } catch (ImportException exception) {
                            arbilWindowManager.addMessageDialogToQueue(
                                java.text.MessageFormat.format(
                                    menus.getString("FAILED TO DUPLICATE: {0}"),
                                    new Object[] {exception.getMessage()}),
                                duplicateEntitiesMenu.getText());
                          } catch (EntityServiceException exception) {
                            arbilWindowManager.addMessageDialogToQueue(
                                java.text.MessageFormat.format(
                                    menus.getString("FAILED TO DUPLICATE: {0}"),
                                    new Object[] {exception.getMessage()}),
                                duplicateEntitiesMenu.getText());
                          }
                          kinDiagramPanel.clearProgressBar();
                        }
                      })
                  .start();
            }
          });
      this.add(duplicateEntitiesMenu);

      addRelationEntityMenu = new JMenu(menus.getString("ADD RELATION"));
      this.add(addRelationEntityMenu);
      for (RelationType relationType : RelationType.values()) {
        JMenuItem addRelationEntityMenuItem = new JMenuItem(relationType.name());
        addRelationEntityMenuItem.setActionCommand(relationType.name());
        addRelationEntityMenuItem.addActionListener(
            new java.awt.event.ActionListener() {
              public void actionPerformed(final java.awt.event.ActionEvent evt) {
                new Thread(
                        new Runnable() {
                          public void run() {
                            kinDiagramPanel.showProgressBar();
                            try {
                              UniqueIdentifier[] affectedIdentifiers =
                                  new RelationLinker(
                                          sessionStorage, arbilWindowManager, entityCollection)
                                      .linkEntities(
                                          selectedIdentifiers,
                                          RelationType.valueOf(evt.getActionCommand()),
                                          null,
                                          null); // todo: custom relation types could be enabled
                                                 // here as could dcr values..
                              kinDiagramPanel.entityRelationsChanged(affectedIdentifiers);
                            } catch (ImportException exception) {
                              arbilWindowManager.addMessageDialogToQueue(
                                  java.text.MessageFormat.format(
                                      menus.getString("FAILED TO CREATE RELATION: {0}"),
                                      new Object[] {exception.getMessage()}),
                                  addRelationEntityMenu.getText());
                            }
                            kinDiagramPanel.clearProgressBar();
                          }
                        })
                    .start();
              }
            });
        addRelationEntityMenu.add(addRelationEntityMenuItem);
      }

      removeRelationEntityMenu =
          new JMenu(
              menus.getString(
                  "REMOVE RELATIONS")); // todo: if one node only then "remove all relations of this
                                        // entity"
      this.add(removeRelationEntityMenu);
      //            for (RelationType relationType : RelationType.values()) {
      //            relationType.name()
      // todo: add a remove all relations to selection (including unselected and not shown entities)

      String actionString = menus.getString("REMOVE RELATIONS BETWEEN SELECTED");
      JMenuItem removeRelationEntityMenuItem = new JMenuItem(actionString);
      removeRelationEntityMenuItem.setActionCommand(actionString);
      removeRelationEntityMenuItem.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              new Thread(
                      new Runnable() {
                        public void run() {
                          kinDiagramPanel.showProgressBar();
                          try {
                            new RelationLinker(sessionStorage, arbilWindowManager, entityCollection)
                                .unlinkEntities(graphPanel, selectedIdentifiers);
                            kinDiagramPanel.entityRelationsChanged(selectedIdentifiers);
                          } catch (ImportException exception) {
                            arbilWindowManager.addMessageDialogToQueue(
                                java.text.MessageFormat.format(
                                    menus.getString("FAILED TO REMOVE RELATIONS: {0}"),
                                    new Object[] {exception.getMessage()}),
                                removeRelationEntityMenu.getText());
                          }
                          kinDiagramPanel.clearProgressBar();
                        }
                      })
                  .start();
            }
          });
      removeRelationEntityMenu.add(removeRelationEntityMenuItem);
      //            }
      this.add(new JSeparator());
    }
    setAsEgoMenuItem = new JMenuItem(menus.getString("SET AS EGO (LIST WILL BE CLEARED)"));
    setAsEgoMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            kinDiagramPanel.setEgoNodes(selectedIdentifiers); // getSelectedUriArray(),
          }
        });
    this.add(setAsEgoMenuItem);
    addAsEgoMenuItem = new JMenuItem(menus.getString("ADD TO EGO LIST"));
    addAsEgoMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            kinDiagramPanel.addEgoNodes(selectedIdentifiers); // getSelectedUriArray(),
          }
        });
    this.add(addAsEgoMenuItem);
    removeEgoMenuItem = new JMenuItem(menus.getString("REMOVE FROM EGO LIST"));
    removeEgoMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            kinDiagramPanel.removeEgoNodes(selectedIdentifiers);
          }
        });
    this.add(removeEgoMenuItem);
    this.add(jSeparator2);

    addAsRequiredMenuItem = new JMenuItem(menus.getString("ATTACH TO DIAGRAM"));
    addAsRequiredMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            kinDiagramPanel.addRequiredNodes(selectedIdentifiers, null); // getSelectedUriArray(),
          }
        });
    this.add(addAsRequiredMenuItem);
    removeRequiredMenuItem = new JMenuItem(menus.getString("RELEASE FROM DIAGRAM"));
    removeRequiredMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            kinDiagramPanel.removeRequiredNodes(selectedIdentifiers);
          }
        });
    this.add(removeRequiredMenuItem);
    this.add(jSeparator3);

    JMenuItem resetZoomMenuItem = new JMenuItem(menus.getString("RESET ZOOM"));
    resetZoomMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            graphPanel.resetZoom();
          }
        });
    this.add(resetZoomMenuItem);

    JMenuItem resetLayoutMenuItem = new JMenuItem(menus.getString("RESET LAYOUT"));
    resetLayoutMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (!kinDiagramPanel.verifyDiagramDataLoaded()) {
              return;
            }
            graphPanel.resetLayout(true);
          }
        });
    this.add(resetLayoutMenuItem);

    JMenuItem searchEntityServiceMenuItem = new JMenuItem(menus.getString("SEARCH ENTITY SERVICE"));
    searchEntityServiceMenuItem.setToolTipText(
        menus.getString(
            "SEARCH THE ENTITY DATABASE FOR ENTITIES MATCHING THE CURRENT KIN TERMS AND POPULATE HE DIAGRAM WITH THE RESULTS"));
    searchEntityServiceMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            // todo: Search the entity database for entities matching the current kin terms and
            // populate he diagram with the results
          }
        });
    searchEntityServiceMenuItem.setEnabled(false);
    this.add(searchEntityServiceMenuItem);

    saveFileMenuItem = new JMenuItem();
    saveFileMenuItem.setText(menus.getString("SAVE ALL DATA CHANGES"));
    saveFileMenuItem.setEnabled(false);
    saveFileMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            new Thread(
                    new Runnable() {
                      public void run() {
                        kinDiagramPanel.showProgressBar();
                        try {
                          arbilWindowManager.stopEditingInCurrentWindow();
                          dataNodeLoader.saveNodesNeedingSave(true);
                        } catch (Exception ex) {
                          BugCatcherManager.getBugCatcher().logError(ex);
                        }
                        kinDiagramPanel.clearProgressBar();
                      }
                    })
                .start();
          }
        });
    this.add(saveFileMenuItem);
  }
Esempio n. 20
0
  /**
   * Instantiates a new component source.
   *
   * @param window the window
   */
  public ComponentSource(final NavigatorWindow window) {
    super();
    this.actionPool = new ActionPool(this, window);
    this.window = window;
    this.addressField = new AddressField(this);
    this.progressBar = new ProgressBar();
    this.statusMessageComponent = new JLabel();
    this.searchButton = this.getSearchButton();
    this.updateSearchButtonTooltip();
    JMenu bookmarksMenu = new JMenu("Recent Bookmarks");
    this.recentBookmarksMenu = bookmarksMenu;
    bookmarksMenu.setMnemonic('R');
    bookmarksMenu.addMenuListener(
        new MenuAdapter() {
          @Override
          public void menuSelected(MenuEvent e) {
            populateRecentBookmarks();
          }
        });
    JMenu taggedBookmarksMenu = new JMenu("Tagged Bookmarks");
    this.taggedBookmarksMenu = taggedBookmarksMenu;
    taggedBookmarksMenu.setMnemonic('T');
    taggedBookmarksMenu.setToolTipText(
        "Shows up to "
            + PREFERRED_MAX_MENU_SIZE
            + " tags with up to "
            + PREFERRED_MAX_MENU_SIZE
            + " recent bookmarks each.");
    taggedBookmarksMenu.addMenuListener(
        new MenuAdapter() {
          @Override
          public void menuSelected(MenuEvent e) {
            populateTaggedBookmarks();
          }
        });
    JMenu backMoreMenu = new JMenu();
    // BackMoreAction only used for enabling
    backMoreMenu.setAction(new BackMoreAction(this, window, actionPool));
    backMoreMenu.addMenuListener(
        new MenuAdapter() {
          @Override
          public void menuSelected(MenuEvent e) {
            populateBackMore();
          }
        });
    this.backMoreMenu = backMoreMenu;
    backMoreMenu.setText("Back To");
    JMenu forwardMoreMenu = new JMenu();
    // ForwardMoreAction only used for enabling
    forwardMoreMenu.setAction(new ForwardMoreAction(this, window, actionPool));
    forwardMoreMenu.addMenuListener(
        new MenuAdapter() {
          @Override
          public void menuSelected(MenuEvent e) {
            populateForwardMore();
          }
        });
    this.forwardMoreMenu = forwardMoreMenu;
    forwardMoreMenu.setText("Forward To");

    JMenu searchersMenu = new JMenu();
    searchersMenu.addMenuListener(
        new MenuAdapter() {
          @Override
          public void menuSelected(MenuEvent e) {
            populateSearchers();
          }
        });
    this.searchersMenu = searchersMenu;
    searchersMenu.setText("Searching With");
    searchersMenu.setToolTipText(
        "Select the search engine that is used by the Search button in the address bar.");
  }
Esempio n. 21
0
 @Override
 public void addMenuListener(MenuListener listener) {
   super.addMenuListener(listener);
   recentDownloadsMenu.addMenuListener(listener);
 }