public void loadRemoteCombo() { int i = annotationPaneLabel.getSelectedIndex(); if (i == 0) { // fab.loadRemote.setSelected(true); setBorder(new LineBorder(AnnotationSidePanel.publicColor, 2)); // bPubAnno.setText("Publish"); // bPubAnno.setIcon(FabIcons.getIcons().ICOPUB); fab.mpublish.setText("Save public"); bCopy.setText("Copy to private"); local = false; if (!PersonalAnnos.useRemoteServer) { bro.eventq(PersonalAnnos.MSG_GO_REMOTE, null); bro.eventq(PersonalAnnos.MSG_REFRESH_LIST, null); } } else if (i == 1) { // fab.loadRemote.setSelected(false); setBorder(new LineBorder(AnnotationSidePanel.privateColor, 2)); // bPubAnno.setText("Save"); bCopy.setText("Copy to public"); fab.mpublish.setText("Save private"); local = true; // bPubAnno.setIcon(FabIcons.getIcons().ICOSAVE); if (PersonalAnnos.useRemoteServer) { bro.eventq(PersonalAnnos.MSG_GO_LOCAL, null); bro.eventq(PersonalAnnos.MSG_REFRESH_LIST, null); } } }
/** "Return" invokes smart scroll, which closes up current section, and opens next. */ public boolean eventAfter(AWTEvent e, Point scrn, Node obsn) { int eid = e.getID(); // System.out.println("Outliner eventBefore "+eid+", outActive_="+outActive_); if (outActive_ != null && outActive_.isSet() && outActive_.isOpen() /*always true?*/ /* && outSects_.indexOf(outActive_)==-1*/ && /*active_ &&*/ eid == KeyEvent.KEY_PRESSED && ((KeyEvent) e).getKeyChar() == ' ' // ).getKeyCode()==KeyEvent.VK_ENTER ) { Browser br = getBrowser(); // find next OutlineSpan next = nextSection(outActive_.getStart().leaf); Node outn = outActive_.getStart().leaf; IScrollPane isp = outn.getIScrollPane(); VScrollbar vsb = isp.getVsb(); int y = vsb.getValue(), h = isp.bbox.height; if (next != null) { Leaf l = (Leaf) next.getStart().leaf; Point rel = l.getRelLocation(isp); // if next on screen open next, closing up previous of <= level // System.out.println(y+" .. "+l.getNextLeaf()+"/"+rel.y+" .. "+(y+h)); if (y < rel.y && rel.y < y + h) { // close up current and previous while <= level int level = Integers.parseInt(next.getAttr(OutlineSpan.ATTR_LEVEL), 1); for (OutlineSpan prev = outActive_; prev != null; prev = prevSection(prev.getStart().leaf)) { br.eventq(OutlineSpan.MSG_CLOSE, prev); if (Integers.parseInt(prev.getAttr(OutlineSpan.ATTR_LEVEL), Integer.MIN_VALUE) <= level) break; // stop after first at same level as next/new current } outActive_ = next; br.eventq(OutlineSpan.MSG_OPEN, outActive_); // includes l.scrollTo(0,0, true); // System.out.println("open "+outActive_); } // else fall through to scroll return true; } else if (y + h >= vsb.getMax()) { // at end, just close up // System.out.println("couldn't find next OutlineSpan"); -- at end br.eventq(OutlineSpan.MSG_CLOSE, outActive_); outActive_ = null; } // close current and open next // br.setGrab(this); // get key release // return true; } return false; }
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); }
public boolean semanticEventAfter(SemanticEvent se, String msg) { // System.out.println("outlineOpen on active_="+active_+", msg="+msg); if (Outliner.MSG_MADE == msg) { Object o = se.getArg(); if (o instanceof Node) { active_ = true; ((Node) o).addObserver(this); Browser br = getBrowser(); br.eventq(new SemanticEvent(br, Executive.MSG_SUMMARY, "ON")); } } else if (!active_) { // nothing -- page fully on screen } else if (DocumentPopup.MSG_CREATE_DOCPOPUP == msg && se.getIn() != getBrowser().getSelectionSpan()) { // null)) { -- just plain-doc popup // System.out.println("**** f/b createMenu "+super.toString()+", in="+se.getIn()); INode menu = (INode) se.getOut(); createUI( "button", "Fully Collapse Outline", "event " + OutlineSpan.MSG_CLOSE_ALL, menu, "SPECIFIC", false); createUI( "button", "Fully Open (or Space to smart scroll)", "event " + Executive.MSG_SUMMARY + " OFF; event outlineOpenAll", menu, "SPECIFIC", false); /* } else if (msg.startsWith("outline")) { //if (first_/* && false* /) { CLGeneral gs = (CLGeneral)getDocument().getStyleSheet().get("excerpt"); if (gs.getSize()!=CLGeneral.INVALID) { gs.setElide(CLGeneral.BOOLINVALID); gs.setSize(CLGeneral.INVALID); for (Iterator<> i=excerptSpans_.iterator(); i.hasNext(); ) ((Span)i.next()).markDirty(); // Span class only marks dirty if set } //} */ } else if (OutlineSpan.MSG_OPEN == msg) { Object o = se.getArg(); if (o instanceof OutlineSpan) outActive_ = (OutlineSpan) o; // System.out.println("outlineOpen on "+o+" / "+outActive_.getStart().leaf.getNextLeaf()); } else if (Executive.MSG_SUMMARY == msg) { Object o = se.getArg(); if (o instanceof String) { // CLGeneral gs = (CLGeneral)getDocument().getStyleSheet().get("excerpt"); /* if ("ON".equalsIgnoreCase((String)o)) { gs.setElide(CLGeneral.FALSE); gs.setSize(10); outActive_=null; } else { gs.setElide(CLGeneral.BOOLINVALID); gs.setSize(CLGeneral.INVALID); }*/ StyleSheet ss = getDocument().getStyleSheet(); if (ssl_ == null) { ssl_ = new ArrayList<Object>(6); for (StyleSheet ssn = ss; ssn != null; ssn = ssn.getCascade()) { Object sse = ssn.get("excerpt"); if (sse != null) { ssl_.add(ssn); ssl_.add(sse); } } // if (excerpt_==null) excerpt_ = (CLGeneral)ss.get("excerpt"); } // System.out.println(ss.getName()+" => excerpt "+excerpt_); if ("ON".equalsIgnoreCase((String) o)) { for (int i = 0, imax = ssl_.size(); i < imax; i += 2) ((StyleSheet) ssl_.get(i)).put("excerpt", (ContextListener) ssl_.get(i + 1)); // ss.put("excerpt", excerpt_); outActive_ = null; // System.out.println("putting excerpt in "+getDocument().getFirstLeaf()+" // "+excerpt_.getSize()+" / "+excerpt_.getElide()); } else { // ss.remove("excerpt"); for (int i = 0, imax = ssl_.size(); i < imax; i += 2) ((StyleSheet) ssl_.get(i)).remove("excerpt"); } // for (Iterator<> i=excerptSpans_.iterator(); i.hasNext(); ) ((Span)i.next()).markDirty(); // -- execsum already reformats whole tree } } else if (Document.MSG_CLOSE == msg) { for (int i = 0, imax = ssl_.size(); i < imax; i += 2) ((StyleSheet) ssl_.get(i)).put("excerpt", (ContextListener) ssl_.get(i + 1)); // getDocument().getStyleSheet().put("excerpt", excerpt_); // stylesheet shared, so // restore! } return super.semanticEventAfter(se, msg); }
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); }
private void search(String txt) { bro.eventq(PersonalAnnos.MSG_SEARCH_ANNO, txt); setBorder(new LineBorder(AnnotationSidePanel.searchColor, 2)); }