public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetTopProjectObj selectedObj = getSwingFocusAsTopProject();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
      inEditState = true;
      if (getSwingContainer() != null) {
        allowAdds = true;
      } else {
        allowAdds = false;
      }
    } else {
      inEditState = false;
      allowAdds = false;
    }
    if (selectedObj == null) {
      enableState = false;
    } else {
      enableState = true;
    }

    if (actionViewSelected != null) {
      actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
      actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
      actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddTopProject != null) {
      actionAddTopProject.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
      menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
      menuSelected.setEnabled(enableState);
      int itemCount = menuSelected.getItemCount();
      for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
        menuItem = menuSelected.getItem(itemIdx);
        act = menuItem.getAction();
        if (act != null) {
          if (act == actionViewSelected) {
            menuItem.setEnabled(enableState);
          } else if (act == actionEditSelected) {
            menuItem.setEnabled(inEditState && enableState);
          } else if (act == actionDeleteSelected) {
            menuItem.setEnabled(inEditState && enableState);
          }
        }
      }
    }
  }
Пример #2
0
 private void addMenuItem(
     JMenu menu,
     String label,
     int mnemonic,
     String accessibleDescription,
     String actionCallbackName)
     throws NoSuchMethodException {
   JMenuItem menuItem = new JMenuItem(label, mnemonic);
   menuItem
       .getAccessibleContext()
       .setAccessibleDescription((accessibleDescription != null) ? accessibleDescription : label);
   final Method callback =
       getClass().getMethod(actionCallbackName, new Class[] {ActionEvent.class});
   menuItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           try {
             callback.invoke(WordListScreen.this, new Object[] {e});
           } catch (InvocationTargetException ex) {
             handleException(ex.getTargetException());
           } catch (IllegalAccessException ex) {
             handleException(ex);
           }
         }
       });
   menu.add(menuItem);
 }
Пример #3
0
 public void actionPerformed(ActionEvent e) {
   JMenuItem jmi = (JMenuItem) e.getSource();
   Iterator marks = mediator.getMarkerModel().getMarkersWithLabel(jmi.getText());
   if (marks.hasNext()) {
     ChronicleMarker marker = (ChronicleMarker) marks.next();
     Instant to = marker.getWhen();
     Instant from = mediator.getMajorMoment();
     viper.api.impl.Util.shiftDescriptors(new Descriptor[] {desc}, from, to);
   }
 }
Пример #4
0
 public void actionPerformed(ActionEvent e) {
   Iterator toInterp = Collections.singleton(desc).iterator();
   JMenuItem jmi = (JMenuItem) e.getSource();
   Iterator marks = mediator.getMarkerModel().getMarkersWithLabel(jmi.getText());
   if (marks.hasNext()) {
     ChronicleMarker marker = (ChronicleMarker) marks.next();
     Instant to = marker.getWhen();
     Instant from = mediator.getMajorMoment();
     mediator.getPropagator().interpolateDescriptors(toInterp, from, to);
   }
 }
Пример #5
0
 private JMenuItem closeAction() {
   JMenuItem result = new JMenuItem("Close");
   result.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_MASK));
   result.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           LookSpike.this.dispose();
         }
       });
   return result;
 }
 public final void initUI() {
   // File Exit only
   JMenuBar menubar = new JMenuBar();
   JMenu fileM = new JMenu("File");
   JMenuItem exitM = new JMenuItem("Exit");
   exitM.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent event) {
           System.exit(0);
         }
       });
   fileM.add(exitM);
   menubar.add(fileM);
   setJMenuBar(menubar);
 }
Пример #7
0
  public void populateMenu(JMenu menu, int flags) {
    if (flags == (Plugin.MENU_TOOLS | Plugin.MENU_MID)) {
      Sketch sketch = editor.getSketch();
      JMenuItem item = new JMenu("Program Bootloader");
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              run();
            }
          });
      menu.add(item);

      PropertyFile props = sketch.mergeAllProperties();
      String blProgs = props.get("bootloader.upload");
      if (blProgs == null) {
        JMenuItem sub = new JMenuItem("No bootloader programmer defined!");
        item.add(sub);
        return;
      }
      String[] progs = blProgs.split("::");
      for (String prog : progs) {
        JMenuItem sub = new JMenuItem(sketch.parseString(props.get("upload." + prog + ".name")));
        sub.setActionCommand(prog);
        sub.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                doProgram(e.getActionCommand());
              }
            });
        item.add(sub);
      }
    }
  }
Пример #8
0
    public DescPropPopup() {
      super("Descriptor Properties");
      v = new JCheckBoxMenuItem("Valid");
      v.addActionListener(new ValidAction());
      p = new JCheckBoxMenuItem("Propagating");
      p.addActionListener(new PropAction());
      delete = new JMenuItem("Delete");
      delete.addActionListener(new DeleteAction());
      duplicate = new JMenuItem("Duplicate");
      duplicate.addActionListener(new DuplicateAction());
      interp = new JMenuItem("Interpolate...");
      interp.addActionListener(new InterpAction());
      interpToMark = new JMenu("Interpolate to Mark");
      interpToMark.setEnabled(false);
      itmAction = new InterpToMarkAction();
      shift = new JMenuItem("Shift...");
      shift.addActionListener(new ShiftAction());
      shiftToMark = new JMenu("Shift to Mark");
      shiftToMark.setEnabled(false);
      stmAction = new ShiftToMarkAction();

      occlusions = new JMenuItem("Occlusions...");
      occAction = new OccAction();
      occlusions.addActionListener(occAction);
      occSeparator = new JSeparator();

      wrt = new JCheckBoxMenuItem("Display with Respect To", false);
      wrt.addActionListener(new WithRespectToAction());

      add(occlusions);
      add(occSeparator);
      add(v);
      add(p);
      add(occSeparator);
      add(delete);
      add(duplicate);
      add(occSeparator);
      add(interp);
      add(interpToMark);
      add(occSeparator);
      add(shift);
      add(shiftToMark);
      add(occSeparator);
      add(wrt);
    }
Пример #9
0
  /** Initializes a popup menu. A <tt>popup</tt> must be created previously. */
  protected void initPopupMenu() {
    super.initPopupMenu();

    popup.addSeparator();

    JMenuItem item = new JMenuItem("Save Package File");
    item.addActionListener(new SaveListener());
    popup.add(item);

    item = new JMenuItem("Save As Astrometrica Format");
    item.addActionListener(new SaveAsAstrometricaFormatListener());
    popup.add(item);

    popup.addSeparator();

    item = new JMenuItem("Export Package");
    item.addActionListener(new ExportListener());
    popup.add(item);
  }
Пример #10
0
 private void resetMarks() {
   interpToMark.removeAll();
   shiftToMark.removeAll();
   Iterator marks = mediator.getMarkerModel().getLabels().iterator();
   boolean hasMark = false;
   while (marks.hasNext()) {
     String mark = (String) marks.next();
     if (!ChronicleViewer.CURR_FRAME_LABEL.equals(mark)) {
       JMenuItem mi = new JMenuItem(mark);
       mi.addActionListener(itmAction);
       interpToMark.add(mi);
       mi = new JMenuItem(mark);
       mi.addActionListener(stmAction);
       shiftToMark.add(mi);
       hasMark = true;
     }
   }
   shiftToMark.setEnabled(hasMark);
   interpToMark.setEnabled(hasMark);
 }
Пример #11
0
    /**
     * Make the edit menu
     *
     * @param popup The popup
     * @param row The row
     */
    void makeEditableMenu(JPopupMenu popup, final int row) {

      JMenuItem mi;
      popup.add(GuiUtils.makeMenuItem("Add New Field", this, "addNewRow"));
      ParamInfo paramInfo = getInfo(row);
      if (paramInfo == null) {
        return;
      }

      popup.add(GuiUtils.makeMenuItem("Edit Settings", this, "editRow", paramInfo));

      mi = new JMenuItem("Delete Settings For Parameter");
      mi.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              removeRow(row);
            }
          });
      popup.add(mi);
    }
Пример #12
0
 /**
  * Make the popup menu
  *
  * @param popup The popup menu
  * @param row The row the user clicked on
  */
 void makePopupMenu(JPopupMenu popup, final int row) {
   ParamInfo info = getInfo(row);
   if (isEditable) {
     makeEditableMenu(popup, row);
   } else {
     JMenuItem mi = new JMenuItem("Copy Row to Users Defaults");
     mi.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent ae) {
             try {
               copyToUsers(getInfo(row));
             } catch (Exception exc) {
               LogUtil.printException(log_, "Copying row: " + row + " to users table.", exc);
             }
           }
         });
     popup.add(mi);
   }
   if (info != null) {
     popup.add(
         GuiUtils.makeMenuItem(
             "Export to Plugin", getIdv().getPluginManager(), "addObject", info));
   }
 }
 public PopUpDemo() {
   delR = new JMenuItem("Delete Row(s)");
   add(delR);
   delR.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           if (dtm.getRowCount() > 0 && table.getSelectedRow() != -1) {
             int[] selRow = table.getSelectedRows();
             for (int i = 0; i < selRow.length; i++) {
               dtm.removeRow(selRow[i] - i);
               curRow--;
             }
           }
         }
       });
 }
Пример #14
0
    public void show(Component invoker, int x, int y) {
      ViperViewMediator mediator = getMediator();
      Point pnt = new Point(x, y);
      EnhancedTable tab = getTable();
      int row = tab.rowAtPoint(pnt);
      desc = getCurrentModel().getDescriptorAtRow(row);
      int col = tab.columnAtPoint(pnt);
      Object cellValue = tab.getValueAt(row, col);
      if (cellValue instanceof Attribute) {
        attr = (Attribute) cellValue;

        // hide the "Occlusions..." option when we're not dealing with a Textline object
        boolean isTextline = attr.getAttrConfig().getAttrType().endsWith("textline");
        occlusions.setVisible(isTextline);
        occSeparator.setVisible(isTextline);

        Instant now = mediator.getCurrentFrame();
        if (now == null) {
          mediator.getDisplayWRTManager().setAttribute(null, null);
          wrt.setEnabled(false);
          wrt.setSelected(false);
        } else {
          boolean isDwrt = attr == mediator.getDisplayWRTManager().getAttribute();
          boolean dwrtable =
              (attr.getAttrValueAtInstant(now) instanceof HasCentroid
                  && attr.getDescriptor().getValidRange().contains(now));
          wrt.setEnabled(dwrtable);
          wrt.setSelected(isDwrt);
        }
      } else {
        attr = null;
        wrt.setEnabled(false);
        wrt.setSelected(false);
      }
      if (null != desc) {
        PropagateInterpolateModule proper = getMediator().getPropagator();
        p.setSelected(proper.isPropagatingThis(desc));
        v.setSelected(mediator.isThisValidNow(desc));
        resetMarks();
        super.show(invoker, x, y);
      }
    }
Пример #15
0
    public static void makeMenuBar(JFrame frame, final AirspaceBuilderController controller) {
      JMenuBar menuBar = new JMenuBar();
      final JCheckBoxMenuItem resizeNewShapesItem;
      final JCheckBoxMenuItem enableEditItem;

      JMenu menu = new JMenu("File");
      {
        JMenuItem item = new JMenuItem("Open...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(OPEN);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Open URL...");
        item.setActionCommand(OPEN_URL);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Save...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(SAVE);
        item.addActionListener(controller);
        menu.add(item);

        menu.addSeparator();

        item = new JMenuItem("Load Demo Shapes");
        item.setActionCommand(OPEN_DEMO_AIRSPACES);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      menu = new JMenu("Shape");
      {
        JMenu subMenu = new JMenu("New");
        for (final AirspaceFactory factory : defaultAirspaceFactories) {
          JMenuItem item = new JMenuItem(factory.toString());
          item.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  controller.createNewEntry(factory);
                }
              });
          subMenu.add(item);
        }
        menu.add(subMenu);

        resizeNewShapesItem = new JCheckBoxMenuItem("Fit new shapes to viewport");
        resizeNewShapesItem.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT);
        resizeNewShapesItem.addActionListener(controller);
        resizeNewShapesItem.setState(controller.isResizeNewShapesToViewport());
        menu.add(resizeNewShapesItem);

        enableEditItem = new JCheckBoxMenuItem("Enable shape editing");
        enableEditItem.setActionCommand(ENABLE_EDIT);
        enableEditItem.addActionListener(controller);
        enableEditItem.setState(controller.isEnableEdit());
        menu.add(enableEditItem);
      }
      menuBar.add(menu);

      menu = new JMenu("Selection");
      {
        JMenuItem item = new JMenuItem("Deselect");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(CLEAR_SELECTION);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Delete");
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
        item.setActionCommand(REMOVE_SELECTED);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      frame.setJMenuBar(menuBar);

      controller.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals((e.getPropertyName()))) {
                resizeNewShapesItem.setSelected(controller.isResizeNewShapesToViewport());
              } else if (ENABLE_EDIT.equals(e.getPropertyName())) {
                enableEditItem.setSelected(controller.isEnableEdit());
              }
            }
          });
    }
Пример #16
0
  public EditorServer(String fileName, String name, String desc) {
    super();
    self = this;
    if (fileName == null || !loadDocument(fileName)) {
      clients = new Vector();
      document = new EditorDocument(name, desc, "", System.currentTimeMillis());

      try {
        // ascii code for first blue line...
        document.insertString(0, "·-·+·*=·x·\n", document.getStyle("line"));
      } catch (BadLocationException ble) {
        System.out.println("EditorServer->const: BadLocationException");
      }

      paragraphs = new Paragraphs(document);
      lockManager = new LockManager(clients, document, paragraphs);
      highlights = new Highlights(lockManager, document);

      nextClientId = 1;
    }

    isAudioOptionSelected = false;
    // to avoid unecessary Audio - Text participant matching

    documentPanel = new DocumentPanel();
    updateParagraphList();

    clientsPanel = new ClientsPanel();
    clientsPanel.updateClientList();

    Icon clockIcon = getImageIcon("images/clock.gif");

    Icon clockIcon2 = getImageIcon("images/clock2.gif");

    startRTPrecording = new JButton("START RTP Recording", clockIcon);

    startRTPrecording.setRolloverIcon(clockIcon2);

    RecordingHandler recHandler = new RecordingHandler(self);

    startRTPrecording.addActionListener(recHandler);

    Icon stopIcon = getImageIcon("images/stop.gif");

    stopRTPrecording = new JButton("STOP RTP recording", stopIcon);

    stopRTPrecording.setEnabled(false);

    stopRTPrecording.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            recorder.endRecording();

            stopRTPrecording.setEnabled(false);
            startRTPrecording.setEnabled(true);
          }
        });

    Container container = getContentPane();

    container.setLayout(new FlowLayout());

    container.add(startRTPrecording);
    container.add(stopRTPrecording);

    // JTabbedPane tabPane = new JTabbedPane() ;
    tabPane.add("Document", documentPanel);
    tabPane.add("Text Clients", clientsPanel);
    container.add(tabPane, BorderLayout.CENTER);

    setTitle("EditorServer");
    setSize(new Dimension(800, 600));

    addWindowListener(
        new WindowAdapter() {

          public void windowClosing(WindowEvent e) {
            lockManager.saveDocument(null, highlights, self);
            System.exit(0);
          }
        });

    JMenuItem mnuSave = new JMenuItem("Save");
    mnuSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser dialog = new JFileChooser();
            dialog.addChoosableFileFilter(
                new MyFileFilter("Collabortive Document File (*.cde)", ".cde"));
            dialog.setAcceptAllFileFilterUsed(false);

            if (dialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
              lockManager.saveDocument(dialog.getSelectedFile().getPath(), highlights, self);
            }
          }
        });

    JMenuItem mnuSaveXML = new JMenuItem("Save XML");
    mnuSaveXML.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser dialog = new JFileChooser();
            dialog.addChoosableFileFilter(new MyFileFilter("XML File (*.xml)", ".xml"));
            dialog.setAcceptAllFileFilterUsed(false);

            if (dialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
              lockManager.saveXML(dialog.getSelectedFile().getPath(), highlights, self);
            }
          }
        });

    JMenu mnuFile = new JMenu("File");
    mnuFile.add(mnuSave);
    mnuFile.add(mnuSaveXML);
    JMenuBar menu = new JMenuBar();
    menu.add(mnuFile);
    setJMenuBar(menu);

    Thread backupThread =
        new Thread() {
          public void run() {
            while (1 == 1) {
              yield();
              try {
                // sleep(1000) ;
                sleep(5 * 60 * 1000);
                lockManager.saveDocument(null, highlights, self);
              } catch (Exception e) {
                System.out.println("EditorServer: backupThread. error");
                e.printStackTrace();
              }
            }
          }
        };
    backupThread.setDaemon(true);
    backupThread.start();
  } // endof const WITHOUT audio profile maker