Commits

ianl...@think-ahead.jp  committed 17b3284

Fixed some error reporting to use jEdit error message dialogs.

  • Participants
  • Parent commits e42700a

Comments (0)

Files changed (4)

File SnipplrPlugin.props

 snipplr-search.no.results.msg=Search returned 0 results
 snipplr-search.no.apikey.error=Please enter your API key in the Plugin Options.
 
+snipplr.request.error=Snipplr Error
+
 snipplr-snippet.title.label=Title:
 snipplr-snippet.tags.label=Tags:
 snipplr-snippet.url.label=URL:

File src/snipplr/SnipplrPlugin.java

 
 //{{{ Imports
 import org.gjt.sp.jedit.*;
+import org.gjt.sp.util.Log;
+import org.gjt.sp.jedit.io.VFSManager;
 import org.gjt.sp.util.WorkThreadPool;
 import org.apache.xmlrpc.XmlRpcException;
 import javax.swing.JOptionPane;
         try {
             LanguageMapper.buildLanguageCache();
         } catch (XmlRpcException e) {
-            //TODO: use a jEdit error dialog
-            JOptionPane.showMessageDialog(null, e);
+            Log.log(Log.ERROR, this, e);
+            VFSManager.error(null,"snipplr.request.error", new String[] { e.toString() });
         }
     }
     
         Snippet snippet = new Snippet();
         
         //TODO: get the right language based on the buffer mode.
-        // String lang = LanguageMapper.languageSearch(buffer.getMode().getName());
-        // if (lang == null) {
-            
-        // }
+        Language lang = LanguageMapper.languageSearch(buffer.getMode().getName());
+        
         
         //TODO: Get the current selection and set it as the source code.
         

File src/snipplr/SnipplrSearchPanel.java

 //{{{ Imports
 import org.gjt.sp.jedit.*;
 import org.gjt.sp.jedit.textarea.JEditTextArea;
+import org.gjt.sp.jedit.io.VFSManager;
 
 import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
         if (message instanceof SnipplrListUpdate) {
             SnipplrListUpdate update = (SnipplrListUpdate)message;
             if (update.isError()) {
-                JOptionPane.showMessageDialog(null, update.getError().getMessage());
+                VFSManager.error(null,"snipplr.request.error", new String[] { update.getError().getMessage() });
                 m_results.setModel(new SnippetListModel(new ArrayList<Snippet>()));
             } else {
                 //update the result list.

File src/snipplr/SnipplrService.java

 
 //{{{ Imports
 import org.gjt.sp.jedit.*;
+import org.gjt.sp.jedit.io.VFSManager;
 
 import java.util.List;
 import java.util.ArrayList;
             }
         } catch (MalformedURLException e) {
             Log.log(Log.ERROR, SnipplrService.class, e);
+            VFSManager.error(null,"snipplr.request.error", new String[] { e.toString() });
             return null;
         }
     }//}}}
                 Object[] params = new Object[]{apiKey, title, code, tags, language};
                 client.execute("snippet.post", params);
             } else {
-                m_error.add(0, new RuntimeException(jEdit.getProperty("snipplr-search.no.apikey.error")));
+                VFSManager.error(null,"snipplr.request.error", new String[] { jEdit.getProperty("snipplr-search.no.apikey.error") });
             }
         } catch (MalformedURLException e) {
             Log.log(Log.ERROR, SnipplrService.class, e);
+            VFSManager.error(null,"snipplr.request.error", new String[] { e.toString() });
         }
     }//}}}
     
             }
         } catch (MalformedURLException e) {
             Log.log(Log.ERROR, SnipplrService.class, e);
+            VFSManager.error(null,"snipplr.request.error", new String[] { e.toString() });
             return null;
         }
     }//}}}
                 return false;
             }
         } catch (MalformedURLException e) {
-            //TODO: log entry.
+            Log.log(Log.ERROR, SnipplrService.class, e);
+            VFSManager.error(null,"snipplr.request.error", new String[] { e.toString() });
             return false;
         }
     }//}}}
                 }
             } catch (MalformedURLException e) {
                 Log.log(Log.ERROR, SnipplrService.class, e);
+                VFSManager.error(null,"snipplr.request.error", new String[] { e.toString() });
             } catch (XmlRpcException e) {
                 //Error code 1 means that we didn't match any snippets
                 //this isn't really an error.