home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xa;
-
- import com.extensibility.app.BaseAction;
- import com.extensibility.app.BaseDocument;
- import com.extensibility.app.BaseWindow;
- import com.extensibility.app.UI;
- import com.extensibility.rock.BaseMenu;
- import com.extensibility.rock.RAction;
- import com.extensibility.xml.ParserException;
- import java.awt.BorderLayout;
- import java.awt.Component;
- import java.text.MessageFormat;
- import java.util.Enumeration;
- import java.util.Vector;
- import javax.swing.JFrame;
- import javax.swing.JList;
- import javax.swing.JMenuBar;
- import javax.swing.JScrollPane;
- import javax.swing.JSplitPane;
- import javax.swing.JTextArea;
-
- public class ErrorWindow extends BaseWindow {
- static final String LARGE_STRING = ">< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< ";
- static final String WRITE_BREAK = ">< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< ";
- JScrollPane scroller;
- JList list;
- Vector errors;
- JSplitPane split;
- JTextArea details;
- JScrollPane detailScroll;
- static final MessageFormat mf1 = new MessageFormat(UI.getString("err.encounter.pe"));
- static final MessageFormat mf2 = new MessageFormat(UI.getString("err.encounter.uri"));
- static final MessageFormat mf3 = new MessageFormat(UI.getString("err.encounter.pe.within"));
- static final MessageFormat mf4 = new MessageFormat(UI.getString("err.encounter.uri.within"));
-
- public static boolean available(SchemaDoc var0) {
- return !var0.getParseErrors().isEmpty();
- }
-
- public String getText() {
- return "PRINTING NOT SUPPORTED";
- }
-
- public ErrorWindow(SchemaDoc var1) {
- super(var1);
- ((Component)this).setVisible(false);
- ((JFrame)this).getContentPane().setLayout(new BorderLayout());
- this.errors = var1.getParseErrors();
- this.details = new JTextArea();
- this.details.setEditable(false);
- this.details.setLineWrap(true);
- this.details.setWrapStyleWord(true);
- this.detailScroll = new JScrollPane(this.details);
- this.list = new JList(this.errors);
- if (this.errors.size() > 0) {
- this.list.addListSelectionListener(new 1(this));
- }
-
- this.list.setPrototypeCellValue(new ParserException(101, ">< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< >< "));
- this.list.setCellRenderer(new ErrorCell(((BaseDocument)var1).getURI()));
- JScrollPane var2 = new JScrollPane(this.list);
- this.split = new JSplitPane(0, var2, this.detailScroll);
- ((JFrame)this).getContentPane().add(this.split, "Center");
- ((JFrame)this).setJMenuBar(this.createMenuBar());
- this.list.setSelectedIndex(0);
- this.list.requestFocus();
- }
-
- public String getClassName() {
- return "com.extensibility.xa.ErrorWindow";
- }
-
- public String formatDetails(ParserException var1) {
- StringBuffer var2 = new StringBuffer();
- var2.append(var1.getMessage());
- boolean var3 = true;
- Enumeration var4 = var1.getContext();
- var2.append(" ");
-
- while(var4.hasMoreElements()) {
- ParserException.Context var5 = (ParserException.Context)var4.nextElement();
- if (var3) {
- if (var5.isInternal()) {
- var2.append(mf1.format(new String[]{var5.getName()}));
- } else if (!var5.getURI().hasPersistence()) {
- var2.append(UI.getString("err.recurse", "pe."));
- } else {
- var2.append(mf2.format(new String[]{(new Integer(var5.getColumn())).toString(), (new Integer(var5.getLine())).toString(), var5.getURI().getFullName()}));
- }
-
- var3 = false;
- } else if (var5.isInternal()) {
- var2.append(mf3.format(new String[]{var5.getName()}));
- } else if (var5.getURI().hasPersistence()) {
- String var6 = var5.getURI().getFullName();
- var2.append(mf4.format(new String[]{(new Integer(var5.getLine())).toString(), var6}));
- }
- }
-
- var2.append(UI.getString("err.decl.source"));
- var2.append(System.getProperty("line.separator"));
- var2.append(System.getProperty("line.separator"));
- var2.append(var1.getSource());
- return var2.toString();
- }
-
- protected JMenuBar createMenuBar() {
- JMenuBar var1 = new JMenuBar();
- super.muFile = (BaseMenu)var1.add(new BaseMenu(UI.getString("menu.file")));
- super.muFile.setMnemonic(UI.getMnemonic("menu.file"));
- this.createCloseAction().addToMenu(super.muFile);
- super.muFile.addSeparator();
- this.createSaveAsAction().addToMenu(super.muFile);
- super.muFile.addSeparator();
- this.createPrintSetupAction().addToMenu(super.muFile);
- this.createPrintAction().addToMenu(super.muFile);
- super.muFile.addSeparator();
- ((BaseWindow)this).createExitAction().addToMenu(super.muFile);
- return var1;
- }
-
- protected BaseAction createCloseAction() {
- return new 2(this, "file.item.close", 'W');
- }
-
- protected RAction createSaveAsAction() {
- return new 3(this, "file.item.save.as");
- }
-
- protected RAction createPrintSetupAction() {
- return new 4((ErrorWindow)null, "file.item.print.setup");
- }
-
- protected RAction createPrintAction() {
- return new 5((ErrorWindow)null, "file.item.print", 'P');
- }
- }
-