/jEdit/trunk/macros/Misc/Make_Bug_Report.bsh
# · Unknown · 129 lines · 118 code · 11 blank · 0 comment · 0 complexity · efb311284d86cc460835af02a3b7575e MD5 · raw file
- /*
- * Make_Bug_Report.bsh - a BeanShell macro script for the
- * jEdit text editor - creates a new buffer with installation and
- * error information extracted from jEdit's Activity Log.
- * Copyright (C) 2001 John Gellene
- * jgellene@nyc.rr.com
- * http://community.jedit.org
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id: Make_Bug_Report.bsh 21353 2012-03-14 09:46:51Z jojaba_67 $
- *
- * Checked for jEdit 4.0 API
- *
- */
- // Localization
- final static String OpeningActivityLogError = jEdit.getProperty("macro.rs.MakeBugReport.OpeningActivityLog.error", "Error opening Activity Log.");
- final static String UsefulEntriesForReportLabel = jEdit.getProperty("macro.rs.MakeBugReport.UsefulEntriesForReport.label", "Activity log entries that might be useful in a bug report:\n\n.");
- final static String MessagejEditLabel = jEdit.getProperty("macro.rs.MakeBugReport.MessagejEdit.label", "[message] jEdit:");
- final static String NoticejEditLabel = jEdit.getProperty("macro.rs.MakeBugReport.NoticejEdit.label", "[notice] jEdit:");
- final static String NoticeJarClassLoaderLabel = jEdit.getProperty("macro.rs.MakeBugReport.NoticeJarClassLoader.label", "[notice] JARClassLoader:");
- final static String MessagejEditStartupCompleteLabel = jEdit.getProperty("macro.rs.MakeBugReport.MessagejEditStartupComplete.label", "[message] jEdit: Startup complete");
- final static String ErrorLabel = jEdit.getProperty("macro.rs.MakeBugReport.Error.label", "[error]");
- final static String ReadingActivityLogError = jEdit.getProperty("macro.rs.MakeBugReport.ReadingActivityLog.error", "Error reading Activity Log");
- // Process
- makeBugReport()
- {
- Log.flushStream();
- path = jEdit.getSettingsDirectory() + File.separator
- + "activity.log";
- try
- {
- file = new FileInputStream(path);
- reader = new BufferedReader(new InputStreamReader(file));
- }
- catch(IOException e)
- {
- Macros.error(view, OpeningActivityLogError);
- return;
- }
- report = new StringBuffer();
- report.append(UsefulEntriesForReportLabel);
- lastError = new StringBuffer();
- insideError = false;
- startupDone = false;
- activityLogHeaderLines = 250;
- try
- {
- for(i = 0; i < activityLogHeaderLines; ++i)
- {
- report.append(reader.readLine()).append('\n');
- }
- while((line = reader.readLine()) != null)
- {
- if(!startupDone &&
- (line.startsWith(MessagejEditLabel)
- || line.startsWith(NoticejEditLabel)
- || line.startsWith(NoticeJarClassLoaderLabel)))
- {
- report.append(line).append('\n');
- if(line.equals(MessagejEditStartupCompleteLabel))
- {
- startupDone = true;
- }
- }
- else if(line.startsWith(ErrorLabel))
- {
- if(!insideError)
- {
- lastError.setLength(0);
- insideError = true;
- }
- lastError.append(line).append('\n');
- }
- else
- insideError = false;
- }
- reader.close();
- }
- catch(IOException e)
- {
- Macros.error(view, ReadingActivityLogError);
- }
- report.append(lastError.toString());
- newBuffer = jEdit.newFile(view);
- newBuffer.insert(0, report.toString());
- }
- makeBugReport();
- /*
- jEdit macro index data (DocBook format)
- <listitem>
- <para><filename>Make_Bug_Report.bsh</filename></para>
- <abstract><para>
- Creates a new buffer with installation and error information
- extracted from the Activity Log.
- </para></abstract>
- <para>
- The macro extracts initial messages written to the Activity Log
- describing the user's operating system, JDK, jEdit version and
- installed plugins. It then appends the last set of error messages
- written to the Activity Log. The new text buffer can be saved and
- attached to an email message or a bug report made on SourceForge.
- </para>
- </listitem>
- */
- // end Make_Bug_Report.bsh