コード例 #1
0
 public boolean semanticEventAfter(SemanticEvent se, String msg) {
   Object arg = se.getArg();
   String winclass = getAttr("winclass");
   if (MSG_NEW == msg && this == arg && winclass != null) {
     Map<String, Object> attrs = (Map) CHashMap.getInstance(getAttr("attrs"));
     Browser br = getBrowser();
     Layer layer =
         (getAttr("doc") == null ? br.getRoot() : br.getCurDocument())
             .getLayer(getAttr("layer", Layer.SCRATCH));
     // System.out.println("system layer behaviors\n\t");
     //		for (Iterator<> i=systemLayer.behaviorIterator(); i.hasNext(); )
     // System.out.println(((Behavior)i.next()).getName()+" ");
     Behavior.getInstance(winclass /*for now -- getName() not right*/, winclass, attrs, layer);
     // if (win.getTitle()==null) win.setTitle(getAttr("title"));    // share TITLE attribute with
     // target VFrame, if it doesn't have one
     // if (lastbbox_==null) lastbbox_=win.getBounds(); else {
     // win.setLocation(lastbbox_.x,lastbbox_.y); win.setSize(lastbbox_.width,lastbbox_.height); }
     // getBrowser().eventq(VFrame.SHOWEVENT, win); -- part of VFrame restore()
   }
   // if (VFrame.SHOWEVENT==msg && this==arg) System.out.println("SHOW on "+winclass);
   return super.semanticEventAfter(se, msg);
 }
コード例 #2
0
  public AnnotationSidePanel(final Browser br, final Fab4 f) {
    super(new BorderLayout(5, 3));
    bro = br;
    fab = f;
    final PersonalAnnos bu = (PersonalAnnos) Fab4utils.getBe("Personal", br.getRoot().getLayers());
    // JPanel icos = new JPanel(new FlowLayout(FlowLayout.CENTER,3,2));
    setBorder(new LineBorder(AnnotationSidePanel.publicColor, 2));
    JPanel topp = new JPanel(new BorderLayout(4, 1));
    annotationPaneLabel = new JComboBox(new String[] {"Public notes", "Private notes"});
    annotationPaneLabel.setToolTipText("Choose if public or private");
    annotationPaneLabel.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) loadRemoteCombo();
          }
        });
    annotationPaneLabel.setFont(annotationPaneLabel.getFont().deriveFont(Font.BOLD));

    topp.add(BorderLayout.NORTH, annotationPaneLabel);
    JPanel south = new JPanel(new FlowLayout(FlowLayout.CENTER, 1, 1));
    final JTextField tt = new JTextField("type search");
    tt.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == java.awt.event.MouseEvent.BUTTON1) tt.selectAll();
          }
        });
    tt.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent arg0) {
            if (arg0.getKeyChar() == '\n') {
              String txt = ((JTextField) arg0.getSource()).getText();
              search(txt);
            }
          }
        });
    JButton lb = new JButton(FabIcons.getIcons().ICOLIGHT);
    lb.setToolTipText("Search in the annotations");
    lb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            search(tt.getText());
          }
        });
    south.add(tt);
    south.add(lb);

    // TODO: do a better search, separate window
    JComboBox cb = new JComboBox(new String[] {"Date", "Author", "Trust", "Position"});
    cb.setToolTipText("Sort notes by:");
    cb.setEditable(false);
    JPanel t = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 1));
    t.add(new JLabel("sort"));
    t.add(cb);
    topp.add(BorderLayout.SOUTH, t);

    // int wi = bHideAnno.getPreferredSize().width*3+20;
    // wi = Math.max(wi,annotationPaneLabel.getPreferredSize().width);
    int hei =
        annotationPaneLabel.getPreferredSize().height + /*
		 * bHideAnno.getPreferredSize
		 * ().height
		 */ +10 + tt.getPreferredSize().height;
    Dimension dim = new Dimension(annotationPaneLabel.getPreferredSize().width, hei);
    topp.setPreferredSize(dim);
    topp.setMinimumSize(dim);
    topp.setMaximumSize(dim);

    annoUserList = new JList();
    annoUserList.setAutoscrolls(true);
    annoUserList.setBackground(new Color(255, 255, 230));
    annoUserList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    bdeleAnno = new JButton("Delete", FabIcons.getIcons().ICODEL);
    bdeleAnno.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (int i : annoUserList.getSelectedIndices())
              br.eventq(PersonalAnnos.MSG_DELETE, bu.user.get(i));
          }
        });
    bdeleAnno.setToolTipText("Delete selected notes");
    if (bu != null) {
      annoUserList.setModel(bu.user);
      Component[] t1 = new Component[1];
      t1[0] = bdeleAnno;
      bu.addUIElementsToFab4List(annoUserList, t1, cb);
    }
    bdeleAnno.setEnabled(false);
    add(topp, BorderLayout.NORTH);
    JScrollPane scrollPane = new JScrollPane(annoUserList);
    add(scrollPane, BorderLayout.CENTER);
    annoUserList.addListSelectionListener(
        new ListSelectionListener() {

          public void valueChanged(ListSelectionEvent e) {
            Object[] index = annoUserList.getSelectedValues();
            if (index.length > 0) bCopy.setEnabled(true);
            else bCopy.setEnabled(false);
            nsel.setText("" + index.length);
          }
        });

    JPanel ppp = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 1));
    bCopy = new JButton("Copy  ", FabIcons.getIcons().ICOPUB);
    Font nf = bCopy.getFont();
    nf.deriveFont((float) (nf.getSize2D() * 0.8));
    bCopy.setFont(nf);
    bCopy.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            br.eventq(PersonalAnnos.MSG_COPY, "");
          }
        });
    bCopy.setToolTipText("Copies the selected notes to the server or local database");
    ppp.add(bCopy);
    bCopy.setEnabled(false);

    bdeleAnno.setFont(nf);

    ppp.add(bdeleAnno);
    ppp.setPreferredSize(
        new Dimension(ppp.getPreferredSize().width, bdeleAnno.getPreferredSize().height * 2 + 3));

    nsel = new JLabel(" ");
    nsel.setFont(nf);
    ppp.add(nsel);
    add(ppp, BorderLayout.SOUTH);
  }