Changeset 835

Show
Ignore:
Timestamp:
09/04/10 09:06:26 (17 months ago)
Author:
stefan
Message:

added error popup

Location:
trunk/src/jlatexeditor
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/gui/MessagePopup.java

    r744 r835  
    1414 
    1515  private JLabel label; 
     16  private Color backgroundColor = new Color(192, 239, 192); 
     17  private Color strokeColor = new Color(0, 128, 0); 
    1618 
    17   public MessagePopup(String message, JFrame invoker) { 
     19  public MessagePopup(Color color, String message, JFrame invoker) { 
    1820    super(message); 
    1921 
    2022    label = new JLabel(getLabel()); 
    2123    label.setMaximumSize(new Dimension(800, 600)); 
     24 
     25    backgroundColor = mix(Color.WHITE, color, 0.75); 
     26    strokeColor = mix(Color.BLACK, color, 0.33); 
    2227 
    2328    Dimension preferred = label.getPreferredSize(); 
     
    3439    addMouseListener(this); 
    3540  } 
     41 
     42  private Color mix(Color c1, Color c2, double c1ratio) { 
     43    return new Color( 
     44      (int) (c1.getRed()*c1ratio + c2.getRed()*(1-c1ratio)), 
     45      (int) (c1.getGreen()*c1ratio + c2.getGreen()*(1-c1ratio)), 
     46      (int) (c1.getBlue()*c1ratio + c2.getBlue()*(1-c1ratio))); 
     47  } 
    3648 
    3749  public void setVisible(boolean b) { 
     
    5466    // green rectangle 
    5567    g2D.clearRect(0, 0, getWidth(), getHeight()); 
    56     g2D.setColor(new Color(192, 239, 192)); // 217, 231, 194 
     68    g2D.setColor(backgroundColor); // 217, 231, 194 
    5769    g2D.fillRoundRect(2, 2, getWidth() - 4, getHeight() - 4, 15, 15); 
    58     g2D.setColor(new Color(0, 128, 0)); 
     70    g2D.setColor(strokeColor); 
    5971    g2D.setStroke(new BasicStroke(2)); 
    6072    g2D.drawRoundRect(2, 2, getWidth() - 4, getHeight() - 4, 15, 15); 
  • trunk/src/jlatexeditor/gui/StatusBar.java

    r744 r835  
    3030  private CheckForUpdates updateChecker = new CheckForUpdates(); 
    3131 
    32   private ArrayList<String> messges = new ArrayList<String>(); 
     32  private ArrayList<String> messages = new ArrayList<String>(); 
    3333 
    3434  public StatusBar(JLatexEditorJFrame jLatexEditor) { 
     
    5858 
    5959  public synchronized void showMessage(String shortMessage, String message) { 
    60     messges.add(message); 
    61     new MessagePopup(message, jLatexEditor); 
     60    messages.add(message); 
     61    new MessagePopup(new Color(0, 192, 0), message, jLatexEditor); 
    6262  } 
    6363 
     
    112112  } 
    113113 
    114   public static class MemoryUsage extends JPanel implements ActionListener { 
     114  public void showTextError(String shortMessage, String textMessage) { 
     115    String message = "<html>" + textMessage.replaceAll("\\n", "<br>") + "</html>"; 
     116    messages.add(message); 
     117    new MessagePopup(new Color(192, 0, 0), message, jLatexEditor); 
     118  } 
     119 
     120  public static class MemoryUsage extends JPanel implements ActionListener { 
    115121    public static Color COLOR_BAR = new Color(163, 201, 247); 
    116122    public static Color COLOR_BACKGROUND = ColorUtil.mix(COLOR_BAR, 0.5, Color.WHITE); 
  • trunk/src/jlatexeditor/JLatexEditorJFrame.java

    r834 r835  
    10171017        results = SVN.getInstance().update(getMainEditor().getFile().getParentFile()); 
    10181018      } catch (Exception exception) { 
    1019         statusBar.showMessage("SVN update failed", "SVN update failed: " + exception.getMessage()); 
     1019        exception.printStackTrace(); 
     1020        statusBar.showTextError("SVN update failed", "SVN update failed: " + exception.getMessage()); 
    10201021        return; 
    10211022      } 
     
    10501051          result = SVN.getInstance().commit(getMainEditor().getFile().getParentFile(), message); 
    10511052        } catch (Exception exception) { 
     1053          exception.printStackTrace(); 
    10521054          statusBar.showMessage("SVN update failed", "SVN update failed: " + exception.getMessage()); 
    10531055          return; 
  • trunk/src/jlatexeditor/tools/SVN.java

    r834 r835  
    2626 
    2727    Process svn; 
    28     try { 
    29       svn = ProcessUtil.exec(new String[]{"svn", "--non-interactive", "update"}, dir); 
    30     } catch (Exception e) { 
    31       e.printStackTrace(); 
    32       throw new Exception("SVN update failed!", e); 
    33     } 
     28    svn = ProcessUtil.exec(new String[]{"svn", "--non-interactive", "update"}, dir); 
    3429 
    3530    BufferedReader in = new BufferedReader(new InputStreamReader(svn.getInputStream()), 100000); 
     
    6762  } 
    6863 
    69   /** 
    70    * Check if the return code of the svn process is OK. 
    71    * 
    72    * @param process svn process 
    73    */ 
    74   private void checkProcessResult(Process process, String action) throws Exception { 
    75  
    76     try { 
    77       String errorString = new String(StreamUtils.readBytesFromInputStream(process.getErrorStream())); 
    78       throw new Exception(action + " failed due to the following error:\n" + errorString); 
    79     } catch (IOException e) { 
    80       e.printStackTrace(); 
    81       throw new Exception(action + " failed!", e); 
    82     } 
    83   } 
    84  
    8564  public synchronized Pair<Boolean, String> commit(File dir, String message) throws Exception { 
    8665    message = message.replace('"', ' '); 
    8766    message = message.replace('\\', ' '); 
    8867 
    89     Process svn; 
    90     try { 
    91       svn = ProcessUtil.exec(new String[]{"svn", "--non-interactive", "commit", "-m", message}, dir); 
    92     } catch (Exception e) { 
    93       e.printStackTrace(); 
    94       throw new Exception("SVN update failed!", e); 
    95 //      return new Pair<Boolean, String>(false, "<font color=red><b>Exception: " + e.getMessage() + "</b></font>"); 
    96     } 
    97  
    98     boolean success = true; 
     68    Process svn = ProcessUtil.exec(new String[]{"svn", "--non-interactive", "commit", "-m", message}, dir); 
     69 
     70    boolean success = true; 
    9971 
    10072    StringBuilder builder = new StringBuilder(); 
     
    181153  } 
    182154 
     155  /** 
     156   * Check if the return code of the svn process is OK. 
     157   * 
     158   * @param process svn process 
     159   */ 
     160  private void checkProcessResult(Process process, String action) throws Exception { 
     161    String errorString = new String(StreamUtils.readBytesFromInputStream(process.getErrorStream())); 
     162    if (!errorString.equals("")) { 
     163      throw new Exception(action + " failed due to the following error:\n" + errorString); 
     164    } 
     165  } 
     166 
    183167  public static class UpdateResult { 
    184168    public static final int TYPE_UPDATE = 0;