Пример #1
0
 public void observe(nsIConsoleMessage message) {
   nsIScriptError error =
       (nsIScriptError) message.queryInterface(nsIScriptError.NS_ISCRIPTERROR_IID);
   if (error == null) {
     return;
   }
   if (browser == null || browser.isDisposed()) {
     return;
   }
   long flag = error.getFlags();
   if ((flag == nsIScriptError.errorFlag || flag == nsIScriptError.exceptionFlag)
       && error.getSourceName().equals(internalGetUrl())) {
     errorCount++;
     if (errorCount == 1) {
       String errorMessage =
           MessageFormat.format(
               Messages.getString("FirefoxBrowser.Error"),
               new Object[] {errorCount}); // $NON-NLS-1$
       errorIcon.setImage(Activator.getDefault().getImage(Activator.ERRORS_IMG_ID));
       errorLabel.setText(errorMessage);
       errorLabel.setToolTipText(
           Messages.getString("FirefoxBrowser.Errors_In_Page")); // $NON-NLS-1$
       errorIcon.setToolTipText(errorLabel.getToolTipText());
     } else {
       String errorMessage =
           MessageFormat.format(
               Messages.getString("FirefoxBrowser.Errors"),
               new Object[] {errorCount}); // $NON-NLS-1$
       errorLabel.setText(errorMessage);
     }
     errors.layout(true, true);
     errors.getParent().layout(true, true);
   }
 }
Пример #2
0
  private void createPage(Composite parent) {
    _page = new Composite(parent, SWT.NONE);
    setControl(_page);
    GridLayout layout = new GridLayout(3, false);
    layout.marginRight = 5;
    layout.horizontalSpacing = 10;
    _page.setLayout(layout);

    // Create file path widgets
    Label label;
    if (isSourcePage()) {
      label = createLabel(_page, "Source Class:", "The source Java class for the transformation.");
    } else {
      label = createLabel(_page, "Target Class:", "The target Java class for the transformation.");
    }

    _javaClassText = new Text(_page, SWT.BORDER | SWT.READ_ONLY);
    _javaClassText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    _javaClassText.setToolTipText(label.getToolTipText());

    final Button javaClassBrowseButton = new Button(_page, SWT.NONE);
    javaClassBrowseButton.setLayoutData(new GridData());
    javaClassBrowseButton.setText("...");
    javaClassBrowseButton.setToolTipText("Browse to specify the selected class.");

    javaClassBrowseButton.addSelectionListener(
        new SelectionAdapter() {

          @SuppressWarnings("static-access")
          @Override
          public void widgetSelected(final SelectionEvent event) {
            try {
              final IType selected =
                  selectType(_page.getShell(), "java.lang.Object", null); // $NON-NLS-1$
              if (selected != null) {
                _javaClassText.setText(selected.getFullyQualifiedName());
                if (isSourcePage()) {
                  model.setSourceType(ModelType.CLASS);
                  model.setSourceFilePath(selected.getFullyQualifiedName());
                } else {
                  model.setTargetType(ModelType.CLASS);
                  model.setTargetFilePath(selected.getFullyQualifiedName());
                }

                UIJob uiJob =
                    new UIJob("open error") {
                      @Override
                      public IStatus runInUIThread(IProgressMonitor monitor) {
                        NewTransformationWizard wizard = (NewTransformationWizard) getWizard();
                        try {
                          Class<?> tempClass =
                              wizard.getLoader().loadClass(selected.getFullyQualifiedName());
                          _javaModel = _builder.fromJavaClass(tempClass);
                          _modelViewer.setModel(_javaModel);
                        } catch (ClassNotFoundException e) {
                          e.printStackTrace();
                        }
                        return Status.OK_STATUS;
                      }
                    };
                uiJob.setSystem(true);
                uiJob.schedule();
                _javaClassText.notifyListeners(SWT.Modify, new Event());
              }
            } catch (JavaModelException e1) {
              e1.printStackTrace();
            }
          }
        });

    Group group = new Group(_page, SWT.SHADOW_ETCHED_IN);
    group.setText("Class Structure Preview");
    group.setLayout(new GridLayout(3, false));
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 3));

    _modelViewer = new ModelViewer(null, group, _javaModel, null);
    _modelViewer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    _modelViewer.layout();

    bindControls();
    validatePage();
  }