コード例 #1
0
 void createPage0() {
   try {
     xmlEditor = new XMLEditor();
     int index = addPage(xmlEditor, getEditorInput());
     setPageText(index, xmlEditor.getTitle() + " (Xml View)");
     IDocument inputDocument =
         xmlEditor.getDocumentProvider().getDocument(xmlEditor.getEditorInput());
     String documentContent = inputDocument.get();
     if (documentContent.isEmpty()) {
       documentContent = "";
       Bundle bundle = Platform.getBundle("reprotool.ide.txtspec");
       URL url = bundle.getResource("schema/default.txtspec.xml");
       try {
         InputStream ir = url.openStream();
         InputStreamReader isr = new InputStreamReader(ir);
         BufferedReader br = new BufferedReader(isr);
         String append;
         if ((documentContent = (br.readLine())) != null) ;
         while ((append = (br.readLine())) != null) documentContent += ("\n" + append);
         br.close();
       } catch (Exception e) {
         System.err.println(e.getMessage() + " " + e.getCause().toString());
       }
       documentContent = documentContent.trim();
       xmlEditor.setDocument(documentContent);
     }
   } catch (PartInitException e) {
     ErrorDialog.openError(
         getSite().getShell(), "Error creating xml text editor", null, e.getStatus());
   }
 }
コード例 #2
0
 /** Calculates the contents of page 2 when the it is activated. */
 protected void pageChange(int newPageIndex) {
   super.pageChange(newPageIndex);
   if (newPageIndex == 1) {
     IDocument inputDocument =
         xmlEditor.getDocumentProvider().getDocument(xmlEditor.getEditorInput());
     String documentContent = inputDocument.get();
     TSEditor.setDocument(documentContent);
   } else if (newPageIndex == 0) {
     IDocument inputDocument =
         xmlEditor.getDocumentProvider().getDocument(xmlEditor.getEditorInput());
     String documentContent = inputDocument.get();
     if (documentContent.isEmpty()) {
       documentContent = "";
       Bundle bundle = Platform.getBundle("reprotool.ide.txtspec");
       URL url = bundle.getResource("schema/default.txtspec.xml");
       try {
         InputStream ir = url.openStream();
         InputStreamReader isr = new InputStreamReader(ir);
         BufferedReader br = new BufferedReader(isr);
         String append;
         if ((documentContent = (br.readLine())) != null) ;
         while ((append = (br.readLine())) != null) documentContent += ("\n" + append);
         br.close();
       } catch (Exception e) {
         System.err.println(e.getMessage() + " " + e.getCause().toString());
       }
       documentContent = documentContent.trim();
     }
     xmlEditor.setDocument(documentContent);
   }
 }
コード例 #3
0
  /**
   * Set the major UI features of this basic view composite
   *
   * @param textEditor
   * @param parentComposite
   * @param styleBit
   */
  public Transition(final XMLEditor textEditor, final Composite parentComposite, int styleBit) {
    super(parentComposite, SWT.BORDER);
    setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_MAGENTA));
    this.textEditor = textEditor;
    addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            toolkit.dispose();
          }
        });
    toolkit.adapt(this);
    toolkit.paintBordersFor(this);
    setLayout(new FormLayout());
    setLayoutData(new GridData(GridData.FILL_BOTH));

    final ScrolledComposite parentScrolledComposite =
        new ScrolledComposite(this, SWT.BORDER | SWT.V_SCROLL);
    parentScrolledComposite.setAlwaysShowScrollBars(true);
    parentScrolledComposite.setExpandHorizontal(true);
    parentScrolledComposite.setExpandVertical(true);
    FormData parentScrolledCompositeFormLayoutData = new FormData();
    parentScrolledCompositeFormLayoutData.right = new FormAttachment(100);
    parentScrolledCompositeFormLayoutData.bottom = new FormAttachment(100);
    parentScrolledCompositeFormLayoutData.top = new FormAttachment(0, 5);
    parentScrolledCompositeFormLayoutData.left = new FormAttachment(0, 5);
    parentScrolledComposite.setLayoutData(parentScrolledCompositeFormLayoutData);
    this.setData(parentScrolledComposite);

    baseContainer = new Composite(parentScrolledComposite, SWT.NONE);
    baseContainer.setBackground(SWTResourceManager.getColor(204, 153, 255));
    parentScrolledComposite.setContent(baseContainer);

    baseContainer.setLayout(new GridLayout(1, true));
    try {
      CentralUtils centralUtils = CentralUtils.getCentralUtils(textEditor);
      centralUtils.setBasicUI(parentScrolledComposite, baseContainer);
      centralUtils.unmarshal(textEditor);
    } catch (JAXBException e) {
      LOG.info(e.getMessage());
    }

    // create a THumanInteractions object if humanInteractions variable is
    // null
    if (textEditor.getRootElement() == null) {
      humanInteractions = new THumanInteractions();
      textEditor.setRootElement(humanInteractions);
    }
    try {
      // create the biggest xml element- UI section
      humanInteractionsUI =
          new THumanInteractionsUI(
              textEditor, baseContainer, this, SWT.NONE, textEditor.getRootElement(), 0, 0);
    } catch (JAXBException e1) {
      LOG.info(e1.getMessage());
    }
  }
コード例 #4
0
 public void refreshLogic(XMLEditor editor) throws JAXBException {
   if (humanInteractions != null) {
     humanInteractionsUI.dispose();
     humanInteractionsUI =
         new THumanInteractionsUI(
             textEditor, baseContainer, this, SWT.NONE, textEditor.getRootElement(), 0, 0);
     humanInteractionsUI.initialize(editor);
   }
 }
コード例 #5
0
 void createPage1() {
   try {
     TSEditor = new TxtSpecEditor(xmlEditor.getDocument());
     int index = addPage(TSEditor, getEditorInput());
     setPageText(index, TSEditor.getTitle() + " (TextSpec View)");
   } catch (PartInitException e) {
     ErrorDialog.openError(
         getSite().getShell(), "Error creating TextSpec Editor", null, e.getStatus());
   }
 }