Changeset 97
- Timestamp:
- 04/17/06 15:03:28 (3 years ago)
- Files:
-
- trunk/src/org/thestaticvoid/iriverter/Converter.java (modified) (7 diffs)
- trunk/src/org/thestaticvoid/iriverter/ConverterUI.java (modified) (2 diffs)
- trunk/src/org/thestaticvoid/iriverter/LogViewer.java (modified) (5 diffs)
- trunk/src/org/thestaticvoid/iriverter/Logger.java (modified) (2 diffs)
- trunk/src/org/thestaticvoid/iriverter/MPlayerInfo.java (modified) (2 diffs)
- trunk/src/org/thestaticvoid/iriverter/MencoderStreamParser.java (modified) (1 diff)
- trunk/src/org/thestaticvoid/iriverter/ProgressDialog.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/org/thestaticvoid/iriverter/Converter.java
r96 r97 255 255 256 256 public void convertSingleVideo(SingleVideoInfo singleVideoInfo) { 257 Logger.logMessage("Single Video: " + singleVideoInfo.getInputVideo(), Logger.INFO); 258 257 259 progressDialogInfo.setInputVideo(new File(singleVideoInfo.getInputVideo()).getName()); 258 progressDialogInfo.setOutputVideo(new File(singleVideoInfo.get InputVideo()).getName());260 progressDialogInfo.setOutputVideo(new File(singleVideoInfo.getOutputVideo()).getName()); 259 261 progressDialogInfo.setStatus("Gathering information about the input video..."); 260 262 261 263 MPlayerInfo info = new MPlayerInfo(singleVideoInfo.getInputVideo()); 264 if (!info.videoSupported()) { 265 Logger.logMessage("Unsupported video", Logger.ERROR); 266 return; 267 } 262 268 263 269 List commandList = prepareBaseCommandList(singleVideoInfo.getInputVideo(), singleVideoInfo.getOutputVideo(), info); … … 274 280 } 275 281 276 public void convertDVD(DVDInfo dvdInfo) { 282 public void convertDVD(DVDInfo dvdInfo) { 277 283 String inputVideo = "Title " + dvdInfo.getTitle() + " of the DVD at " + dvdInfo.getDrive(); 278 284 … … 285 291 } 286 292 293 Logger.logMessage("DVD: " + inputVideo, Logger.INFO); 294 287 295 progressDialogInfo.setInputVideo(inputVideo); 288 296 progressDialogInfo.setOutputVideo(new File(dvdInfo.getOutputVideo()).getName()); … … 323 331 324 332 public void manuallySplitVideo(ManualSplitInfo manualSplitInfo) { 333 Logger.logMessage("Manual Split: " + manualSplitInfo.getVideo(), Logger.INFO); 334 325 335 String outputVideo = manualSplitInfo.getVideo().substring(0, manualSplitInfo.getVideo().lastIndexOf('.')) + ".part" + manualSplitInfo.getPart() + ".avi"; 326 336 … … 358 368 tempFile.deleteOnExit(); 359 369 370 Logger.logMessage("Join Videos: " + tempFile, Logger.INFO); 371 360 372 progressDialogInfo.setOutputVideo(tempFile.getName()); 361 373 progressDialogInfo.setStatus("Concatenating videos to a temporary file..."); … … 373 385 374 386 if (!isCanceled) { 387 Logger.logMessage("Writing header...", Logger.INFO); 388 375 389 progressDialogInfo.setInputVideo(tempFile.getName()); 376 390 progressDialogInfo.setOutputVideo(new File(joinVideosInfo.getOutputVideo()).getName()); … … 390 404 for (int i = 0; i < command.length; i++) 391 405 commandStr += command[i] + " "; 392 Logger.logMessage(commandStr );406 Logger.logMessage(commandStr, Logger.INFO); 393 407 394 408 try { trunk/src/org/thestaticvoid/iriverter/ConverterUI.java
r96 r97 668 668 try { 669 669 ConverterUI ui = new ConverterUI(); 670 } catch ( Exceptione) {670 } catch (Throwable e) { 671 671 String message = "An unhandled exception occured: " + e.getMessage() + "\n\n"; 672 672 StackTraceElement[] st = e.getStackTrace(); … … 674 674 message += st[i] + "\n"; 675 675 676 Logger.logMessage(message, Logger.ERROR); 677 676 678 MessageBox messageBox = new MessageBox(new Shell(Display.getDefault()), SWT.ICON_ERROR | SWT.OK); 677 679 messageBox.setText("Error"); trunk/src/org/thestaticvoid/iriverter/LogViewer.java
r96 r97 1 1 package org.thestaticvoid.iriverter; 2 3 import java.util.*; 2 4 3 5 import org.eclipse.swt.*; … … 6 8 import org.eclipse.swt.graphics.*; 7 9 import org.eclipse.swt.layout.*; 10 import org.eclipse.swt.custom.*; 8 11 9 12 public class LogViewer { 10 13 private static LogViewer singleton; 11 14 private Shell shell; 12 private Text text; 15 private StyledText text; 16 private java.util.List lineColors; 13 17 14 18 public LogViewer() { 15 19 if (singleton != null) 16 20 return; 21 22 lineColors = new ArrayList(); 17 23 18 24 Display display = Display.getDefault(); … … 22 28 shell.setLayout(new GridLayout()); 23 29 24 text = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); 25 text.setEditable(false); 26 text.setText(Logger.getLogText()); 30 text = new StyledText(shell, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY); 27 31 text.setFont(new Font(display, new FontData("monospace", 10, SWT.NORMAL))); 28 32 text.setLayoutData(new GridData(GridData.FILL_BOTH)); 29 33 34 String[] lines = Logger.getLogText().split("\n"); 35 for (int i = 0; i < lines.length; i++) 36 logMessage(lines[i]); 37 30 38 shell.open(); 31 39 … … 46 54 public void logMessage(final String message) { 47 55 Display.getDefault().syncExec(new Runnable() { 48 public void run() { 56 public void run() { 49 57 text.append(message + "\n"); 58 text.setCaretOffset(text.getCharCount()); 59 60 if (message.charAt(0) == Logger.PREFIX[Logger.INFO].charAt(0)) 61 lineColors.add(new Color(Display.getDefault(), 240, 255, 126)); // light yellow 62 else if (message.charAt(0) == Logger.PREFIX[Logger.ERROR].charAt(0)) 63 lineColors.add(new Color(Display.getDefault(), 255, 137, 126)); // light red 64 else if (message.charAt(0) == Logger.PREFIX[Logger.MPLAYER].charAt(0)) 65 lineColors.add(new Color(Display.getDefault(), 126, 160, 255)); // light blue 66 else 67 lineColors.add(new Color(Display.getDefault(), 255, 255, 255)); // white 68 69 for (int i = 0; i < lineColors.size(); i++) 70 text.setLineBackground(i, 1, (Color) lineColors.get(i)); 50 71 } 51 72 }); … … 56 77 public void run() { 57 78 text.setText(""); 79 lineColors.clear(); 58 80 } 59 81 }); trunk/src/org/thestaticvoid/iriverter/Logger.java
r96 r97 4 4 5 5 public class Logger { 6 public static final int INFO = 0, ERROR = 1, MPLAYER = 2; 7 public static final String[] PREFIX = {"--- ", "!!! ", ">>> "}; 8 6 9 private static PrintWriter output; 7 10 … … 17 20 } 18 21 19 public static void logMessage(String message) { 22 public static void logMessage(String message, int type) { 23 String[] messageLines = message.split("\n"); 24 message = ""; 25 for (int i = 0; i < messageLines.length; i++) 26 message += PREFIX[type] + messageLines[i] + (i == messageLines.length - 1 ? "" : "\n"); 27 20 28 System.out.println(message); 21 29 trunk/src/org/thestaticvoid/iriverter/MPlayerInfo.java
r96 r97 36 36 while ((line = input.readLine()) != null) { 37 37 mplayerOutput.append(line + "\n"); 38 Logger.logMessage(line );38 Logger.logMessage(line, Logger.MPLAYER); 39 39 } 40 40 … … 52 52 String line; 53 53 while ((line = input.readLine()) != null) 54 Logger.logMessage(line );54 Logger.logMessage(line, Logger.MPLAYER); 55 55 56 56 input.close(); trunk/src/org/thestaticvoid/iriverter/MencoderStreamParser.java
r96 r97 28 28 while ((inputLine = input.readLine()) != null) { 29 29 if (inputLine.indexOf("Pos:") == -1) 30 Logger.logMessage(inputLine );30 Logger.logMessage(inputLine, Logger.MPLAYER); 31 31 32 32 if (inputLine.indexOf("Video stream:") > -1) trunk/src/org/thestaticvoid/iriverter/ProgressDialog.java
r32 r97 13 13 private String syncInputVideo, syncOutputVideo, syncStatus; 14 14 private int currentJob, totalJobs, syncPercentComplete; 15 private boolean syncSuccess;16 15 17 16 public ProgressDialog(Shell parent, int style) { … … 101 100 } 102 101 103 public synchronized void complete(boolean success) { 104 syncSuccess = success; 105 106 Display.getDefault().syncExec(new Runnable() { 107 public void run() { 108 if (!syncSuccess) { 102 public synchronized void complete(final boolean success) { 103 Display.getDefault().syncExec(new Runnable() { 104 public void run() { 105 if (!success) { 109 106 MessageBox dialog = new MessageBox(getParent().getShell(), SWT.ICON_ERROR); 110 107 dialog.setText("There Was an Error While Converting");
