gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] fenfire/org/fenfire/loom Loom.java


From: Benja Fallenstein
Subject: [Gzz-commits] fenfire/org/fenfire/loom Loom.java
Date: Wed, 12 Mar 2003 11:54:03 -0500

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Changes by:     Benja Fallenstein <address@hidden>      03/03/12 11:54:03

Modified files:
        org/fenfire/loom: Loom.java 

Log message:
        First cut at jumping to a user-entered URI

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/loom/Loom.java.diff?tr1=1.27&tr2=1.28&r1=text&r2=text

Patches:
Index: fenfire/org/fenfire/loom/Loom.java
diff -u fenfire/org/fenfire/loom/Loom.java:1.27 
fenfire/org/fenfire/loom/Loom.java:1.28
--- fenfire/org/fenfire/loom/Loom.java:1.27     Tue Mar 11 17:52:22 2003
+++ fenfire/org/fenfire/loom/Loom.java  Wed Mar 12 11:54:02 2003
@@ -74,8 +74,9 @@
 
        Comparator compareByAbbrev = names.getComparator();
 
-       Set classes = new TreeSet(compareByAbbrev);
+       Collection classes = new TreeSet(compareByAbbrev);
        classes.addAll(ModelUtil.getClasses(model));
+       classes = new ArrayList(classes);
        
        properties = new ArrayList(ModelUtil.getProperties(model));
        Collections.sort(properties, compareByAbbrev);
@@ -110,10 +111,14 @@
 
        showClassMenu.removeAll();
        showClassBy.clear();
+       classes.add(null);
        for(Iterator j=classes.iterator(); j.hasNext();) {
            final Resource cls = (Resource)j.next();
-           Menu menu = 
-               new Menu(names.getAbbrev(cls.toString()));
+           Menu menu;
+           if(cls != null)
+               menu = new Menu(names.getAbbrev(cls.toString()));
+           else
+               menu = new Menu("All others");
            showClassMenu.add(menu);
            
            MenuItem byURI = new MenuItem("by URI"); menu.add(byURI);
@@ -129,7 +134,10 @@
                menu.add(mi);
                mi.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent _) {
-                           showClassBy.put(cls, prop);
+                           if(cls != null)
+                               showClassBy.put(cls, prop);
+                           else
+                               showNoClassBy = prop;
                            AbstractUpdateManager.chg();
                        }
                    });
@@ -144,6 +152,8 @@
     protected Frame propFrame = new Frame("Properties");
     protected java.awt.List propList = new java.awt.List();
 
+    protected Dialog goTo;
+
     public static void main(String[] args) throws RDFException, IOException,
                                                  org.xml.sax.SAXException {
        String file = null;
@@ -168,6 +178,7 @@
     protected FileDialog fileDialog;
 
     protected Map showClassBy = new HashMap();
+    protected Property showNoClassBy = null;
     protected Menu showClassMenu = new Menu("Show class");
 
     public Loom(String file, ColorScheme colors0) 
@@ -271,11 +282,17 @@
                        String t = s;
 
                        try {
-                           Statement typeStmt =
-                               ((Resource)node).getProperty(rdf.type);
+                           Property by;
+
+                           try {
+                               Statement typeStmt =
+                                   ((Resource)node).getProperty(rdf.type);
+                               RDFNode type = typeStmt.getObject();
+                               by = (Property)showClassBy.get(type);
+                           } catch(RDFException _) {
+                               by = showNoClassBy;
+                           }
 
-                           RDFNode type = typeStmt.getObject();
-                           Property by = (Property)showClassBy.get(type);
                            if(by != null) {
                                Statement byStmt = 
((Resource)node).getProperty(by);
                                if(byStmt.getObject() instanceof Literal)
@@ -363,7 +380,7 @@
                public void keystroke(String s) {
                    System.out.println("Keystroke: "+s);
                    if(model == null) return;
-                   
+
                    if(viewcur == 0) {
                        if(s.equals("u") || s.equals("o"))
                            s = "Up";
@@ -376,7 +393,9 @@
                            s = "Down";
                    }
 
-                   if(s.equals("i") || s.equals("Up"))
+                   if(s.equals("Ctrl-G"))
+                       goTo.setVisible(true);
+                   else if(s.equals("i") || s.equals("Up"))
                        cursor.rotate(-1);
                    else if(s.equals(",") || s.equals("Down"))
                        cursor.rotate(1);
@@ -444,6 +463,28 @@
                    Screen scr = new Screen(api.createWindow(), b, s);
                    frame = ((gzz.client.awt.FrameScreen)scr.window)
                        .getFrame();
+
+                   goTo = new Dialog(frame, "Go to URI");
+                   Panel goToP = new Panel(); goTo.add(goToP);
+                   Label goToLabel = new Label("Go to URI:");
+                   final TextField goToText = new TextField(25);
+                   goToP.add(goToLabel); goToP.add(goToText);
+                   Button ok = new Button("Go!"); goToP.add(ok);
+                   ok.addActionListener(new ActionListener() {
+                           public void actionPerformed(ActionEvent _) {
+                               goTo.setVisible(false);
+                               String uri = goToText.getText();
+                               try {
+                                   cursor.set(model.getResource(uri));
+                               } catch(RDFException e) {
+                                   e.printStackTrace();
+                               }
+                               AbstractUpdateManager.chg();
+                           }
+                       });
+                   goTo.setVisible(true);
+                   
+                   
                    fileDialog = new FileDialog(frame, "Open",
                                                FileDialog.LOAD);
                    frame.setMenuBar(mBar);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]