Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/aspectj/tools/ajde/jbuilder/JBuilderTaskListManager.java


1   
2   /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3    *
4    * This file is part of the IDE support for the AspectJ(tm)
5    * programming language; see http://aspectj.org
6    *
7    * The contents of this file are subject to the Mozilla Public License
8    * Version 1.1 (the "License"); you may not use this file except in
9    * compliance with the License. You may obtain a copy of the License at
10   * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11   *
12   * Software distributed under the License is distributed on an "AS IS" basis,
13   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14   * for the specific language governing rights and limitations under the
15   * License.
16   *
17   * The Original Code is AspectJ.
18   *
19   * The Initial Developer of the Original Code is Xerox Corporation. Portions
20   * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21   * All Rights Reserved.
22   *
23   * Contributor(s):
24   */
25  
26  package org.aspectj.tools.ajde.jbuilder;
27  
28  import javax.swing.Icon;
29  
30  import com.borland.primetime.ide.*;
31  import com.borland.primetime.util.*;
32  import org.aspectj.asm.*;
33  import org.aspectj.ajde.*;
34  
35  /**
36   * @author Mik Kersten
37   */
38  public class JBuilderTaskListManager implements TaskListManager {
39  
40      private static final String CATEGORY_NAME = "AspectJ Compiler Messages";
41      private MessageView messageView;
42      private MessageCategory messageCategory;
43  
44      /**
45       * Will remove any old categories with the same name.
46       */
47      public JBuilderTaskListManager() {
48        if (Browser.getActiveBrowser() != null) {
49            messageView = Browser.getActiveBrowser().getMessageView();
50            MessageCategory[] categories = messageView.getTabs();
51            for (int i = 0; i < categories.length; i++) {
52                if (categories[i].getTitle().equals(CATEGORY_NAME))  {
53                    try {
54                        messageView.removeTab(categories[i]);
55                    } catch (Exception e) { }
56                }
57            }
58        }
59          messageCategory = new MessageCategory(CATEGORY_NAME);
60      }
61  
62      public void addSourcelineTask(String message, SourceLocation sourceLocation, StructureMessage.Kind kind) {
63      String formattedMessage = "\"" + sourceLocation.getSourceFileName() + "\": " 
64        + message + " at line " 
65        + sourceLocation.getLineNumber() + ", column " 
66        + sourceLocation.getColumnNumber();
67      Icon icon = null;
68      if (kind.equals(StructureMessage.Kind.ERROR)) {
69        icon = BrowserIcons.ICON_ERROR;
70          } else if (kind.equals(StructureMessage.Kind.WARNING)) {
71            icon = BrowserIcons.ICON_WARNING;
72      } else {
73        icon = BrowserIcons.ICON_WATCH;  
74      }
75          Message jbMessage = new Message(  
76            formattedMessage,
77              icon,
78              new AJTaskListAction(sourceLocation));
79          if (kind.equals(StructureMessage.Kind.ERROR)) jbMessage.setForeground(java.awt.Color.red);
80          jbMessage.setSelectAction(new AJTaskListSelectAction(sourceLocation));
81          messageView.addMessage(messageCategory, jbMessage);
82      }
83  
84    public void addProjectTask(String message, StructureMessage.Kind kind) {
85      Icon icon = null;
86      if (kind.equals(StructureMessage.Kind.ERROR)) {
87        icon = BrowserIcons.ICON_ERROR;
88          } else if (kind.equals(StructureMessage.Kind.WARNING)) {
89            icon = BrowserIcons.ICON_WARNING;
90      } else {
91        icon = BrowserIcons.ICON_WATCH;  
92      }
93          Message jbMessage = new Message(message, icon);
94          if (kind.equals(StructureMessage.Kind.ERROR)) jbMessage.setForeground(java.awt.Color.red);
95          messageView.addMessage(messageCategory, jbMessage);
96    }
97  
98      public void clearTasks() {
99          try {
100             messageView.removeTab(messageCategory);
101         } catch (VetoException ve) {
102             Ajde.getDefault().getErrorHandler().handleError("Could not remove error messages tab.", ve);
103         }
104     }
105 }
106 
107 //    public JBuilderCompilerMessages(String categoryName) {
108 //        messageView = Browser.getActiveBrowser().getMessageView();
109 //        MessageCategory[] categories = messageView.getTabs();
110 //        for (int i = 0; i < categories.length; i++) {
111 //            if (categories[i].getTitle().equals(categoryName))  {
112 //                try {
113 //                    messageView.removeTab(categories[i]);
114 //                } catch (Exception e) {}
115 //            }
116 //        }
117 //        messageCategory = new MessageCategory(categoryName);
118 //    }
119 //
120 //    public void addCompilerMessages(CompileResult result) {
121 //    String[]  descriptions = result.getDescriptions();
122 //        String[]  files        = result.getfiles();
123 //        Integer[] lineNumbers  = result.getLineNumbers();
124 //        if (descriptions.length == 0 && result.getResult().trim() != "") {
125 //            messageView.addMessage(messageCategory, new Message(result.getResult(),
126 //                                                     BrowserIcons.ICON_ERROR));
127 //      return;
128 //        }
129 //    for ( int i = 0; i < descriptions.length &&
130 //             i < files.length &&
131 //             i < lineNumbers.length; i++ ) {
132 //            String message = "";
133 //            if (files[i] != "") {
134 //                message += "\"" + files[i] + "\": ";
135 //            }
136 //            if (lineNumbers[i].intValue() != -1 && lineNumbers[i].intValue() != 0) {
137 //                message += descriptions[i] + ", at line: " + lineNumbers[i];
138 //            } else {
139 //                message += descriptions[i];
140 //            }
141 //            boolean isWarning = false;
142 //            if (descriptions[i].endsWith("(warning)")) {
143 //                messageView.addMessage(messageCategory, new Message(message,
144 //                                                             BrowserIcons.ICON_WARNING,
145 //                                                             new CompilerMessageAction(files[i],
146 //                                                             lineNumbers[i].intValue(),
147 //                                                             JBuilderManager.getActiveManager().getIDEActions())));
148 //            } else {
149 //                messageView.addMessage(messageCategory, new Message(message,
150 //                                                 BrowserIcons.ICON_ERROR,
151 //                                                 new CompilerMessageAction(files[i],
152 //                                                    lineNumbers[i].intValue(),
153 //                                                    JBuilderManager.getActiveManager().getIDEActions())));
154 //            }
155 //    }
156 //    }