Exemplo n.º 1
0
 public void update() {
   String[] namespaces = InferredSchemaManager.getInferredSchema(service).getNamespaces();
   for (int i = 0; i < namespaces.length; i++)
     if (namespaces[i].equals("")) namespaces[i] = NO_NAMESPACE;
   schemaList.setListData(namespaces);
   if (schemaList.isSelectionEmpty()) {
     xsd.setText("");
   } else {
     xsd.setText(
         XmlUtils.prettyPrintXml(
             InferredSchemaManager.getInferredSchema(service)
                 .getXsdForNamespace((String) schemaList.getSelectedValue())));
     xsd.scrollTo(0, 0);
   }
 }
Exemplo n.º 2
0
 public void afterSubmit(Submit submit, SubmitContext context) {
   if (submit.getResponse() == null) return;
   HttpResponse httpResponse = (HttpResponse) submit.getResponse();
   String content = httpResponse.getContentAsXml();
   if (content == null || content.equals("<xml/>")) return;
   XmlObject xml;
   try {
     URL url = httpResponse.getURL();
     String defaultNamespace = url.getProtocol() + "://" + url.getHost();
     XmlOptions options =
         new XmlOptions()
             .setLoadSubstituteNamespaces(Collections.singletonMap("", defaultNamespace));
     xml = XmlObject.Factory.parse(content, options);
   } catch (XmlException e) {
     e.printStackTrace();
     return;
   }
   if (!submit.getStatus().equals(Status.CANCELED)
       && !InferredSchemaManager.getInferredSchema(service).validate(xml)) {
     setTitle("Schema (conflicts)");
     if (thread != null && thread.isAlive()) {
       handler.kill();
       try {
         thread.join();
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
     handler = new Handler(tabs, xml);
     thread = new Thread(handler);
     thread.start();
   }
 }
Exemplo n.º 3
0
  public JComponent getComponent() {
    if (tabs == null) {
      tabs = new SchemaTabs();
      InferredSchemaManager.addPropertyChangeListener(service, tabs);
    }

    return tabs;
  }
Exemplo n.º 4
0
 public synchronized void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals("resolve")) {
     resolveButton.setEnabled(false);
     handler.go();
   } else if (e.getActionCommand().equals("save")) {
     InferredSchemaManager.save(service);
   }
 }
Exemplo n.º 5
0
 public synchronized void run() {
   try {
     if (panel.awaitButton(this)) {
       try {
         wait();
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     } else yesToAll = true;
     if (kill) return;
     InferredSchemaManager.getInferredSchema(service).learningValidate(xml, this);
     panel.update();
     setTitle("Schema");
     InferredSchemaManager.save(service);
   } catch (XmlException e) {
     setTitle("Schema (invalid)");
   }
 }
Exemplo n.º 6
0
 public void actionPerformed(ActionEvent e) {
   if (!schemaList.isSelectionEmpty()) {
     String ns = (String) schemaList.getSelectedValue();
     if (UISupport.confirm("Remove inferred namespace '" + ns + "'?", "Remove namespace")) {
       if (ns.equals(NO_NAMESPACE)) ns = "";
       InferredSchemaManager.deleteNamespace(service, ns);
     }
   }
 }
Exemplo n.º 7
0
 public void valueChanged(ListSelectionEvent e) {
   if (e.getValueIsAdjusting() == false) {
     if (!schemaList.isSelectionEmpty()) {
       String namespace = (String) schemaList.getSelectedValue();
       if (namespace.equals(NO_NAMESPACE)) namespace = "";
       xsd.setText(
           XmlUtils.prettyPrintXml(
               InferredSchemaManager.getInferredSchema(service).getXsdForNamespace(namespace)));
       xsd.scrollTo(0, 0);
     }
   }
 }
Exemplo n.º 8
0
    public SchemaTabs() {
      super();
      conflicts = new JPanel();
      conflicts.setLayout(new BorderLayout());
      auto = new JCheckBox("Auto-Resolve");
      auto.setToolTipText("Automatically modify inferred schema from received Responses");
      auto.setOpaque(false);
      UISupport.setFixedSize(auto, 120, 20);
      XmlBeansSettingsImpl settings = getRequest().getSettings();
      if (settings.isSet(AUTO_INFER_SCHEMAS)) {
        auto.setSelected(settings.getBoolean(AUTO_INFER_SCHEMAS));
      }
      auto.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              getRequest().getSettings().setBoolean(AUTO_INFER_SCHEMAS, auto.isSelected());
            }
          });
      resolveButton = new JButton("Resolve conflicts");
      resolveButton.setEnabled(false);
      resolveButton.setActionCommand("resolve");
      resolveButton.addActionListener(this);

      JXToolBar toolbar = UISupport.createToolbar();
      toolbar.addFixed(auto);
      toolbar.addFixed(resolveButton);

      log = new JLogList("Schema log");
      conflicts.add(toolbar, BorderLayout.NORTH);
      conflicts.add(log, BorderLayout.CENTER);
      addTab("Conflicts", conflicts);

      schemaList = new JList(InferredSchemaManager.getInferredSchema(service).getNamespaces());
      schemaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      schemaList.addListSelectionListener(this);

      toolbar = UISupport.createToolbar();
      toolbar.addFixed(UISupport.createToolbarButton(new RemoveNamespaceAction()));

      JPanel listPanel = new JPanel();
      listPanel.setLayout(new BorderLayout());
      listPanel.add(toolbar, BorderLayout.NORTH);
      listPanel.add(new JScrollPane(schemaList), BorderLayout.CENTER);
      xsd = JXEditTextArea.createXmlEditor(false);
      xsd.setEditable(false);
      update();
      addTab(
          "Schemas", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listPanel, new JScrollPane(xsd)));
    }
Exemplo n.º 9
0
 public void release() {
   InferredSchemaManager.removePropertyChangeListener(service, tabs);
 }