Beispiel #1
0
 /** Sets the Image for the page */
 private void setImage() {
   URL url = null;
   try {
     url =
         new URL(
             ReportPlugin.getDefault().getBundle().getEntry("/"), // $NON-NLS-1$
             "icons/wizban/dataset_wizard.gif"); //$NON-NLS-1$
   } catch (MalformedURLException e) {
     ExceptionHandler.handle(e);
   }
   ImageDescriptor desc = ImageDescriptor.createFromURL(url);
   this.setImageDescriptor(desc);
 }
  /** @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */
  public void run(IAction action) {
    if (!prePreview()) {
      return;
    }

    IFile file = getSelectedFile();
    if (file != null) {
      // String url = MessageFormat.format( PATTERN, new Object[]{
      // file.getLocation( ).toString( )
      // } );
      String url = file.getLocation().toString();
      Map options = new HashMap();
      options.put(WebViewer.FORMAT_KEY, WebViewer.HTML);
      options.put(
          WebViewer.RESOURCE_FOLDER_KEY,
          ReportPlugin.getDefault().getResourceFolder(file.getProject()));

      WebViewer.display(url, options);
    } else {
      action.setEnabled(false);
    }
  }
Beispiel #3
0
  /**
   * Creates the top level control for this dialog page under the given parent composite.
   *
   * <p>Implementors are responsible for ensuring that the created control can be accessed via
   * <code>getControl</code>
   *
   * @param parent the parent composite
   */
  public void createControl(Composite parent) {
    helper = new DataSetBasePageHelper();

    // initialize the dialog layout
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout();
    composite.setLayout(layout);

    final Group group = new Group(composite, SWT.NONE);
    group.setLayout(new GridLayout());
    group.setText(Messages.getString("DataSetBasePage.Group.DataSourceSelection")); // $NON-NLS-1$
    group.setLayoutData(
        new GridData(SWT.FILL, SWT.FILL, true, true, 1, 8)); // GridData.FILL_BOTH));

    wizardFilter = new WizardFilter();
    dataSourceFilteredTree =
        new FilteredTree(
            group,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL,
            this.wizardFilter,
            true);
    GridData treeData = new GridData(GridData.FILL_BOTH);
    treeData.grabExcessHorizontalSpace = true;
    treeData.grabExcessVerticalSpace = true;
    treeData.heightHint = 300;
    treeData.widthHint = 600;
    dataSourceFilteredTree.setLayoutData(treeData);
    SelectionListener listener =
        new SelectionListener() {
          TreeItem parent = null;

          public void widgetDefaultSelected(SelectionEvent arg0) {}

          public void widgetSelected(SelectionEvent event) {
            if (event.item.getData() instanceof DataSourceHandle) {
              dataSetTypeChooser.getCombo().setEnabled(true);
              if (parent == null || parent != ((TreeItem) event.item).getParentItem()) {
                parent = ((TreeItem) event.item).getParentItem();
                doDataSourceSelectionChanged(parent.getData());
              }
              setPageComplete(!hasWizard() && (getMessageType() != ERROR));
            } else {
              dataSetTypeChooser.getCombo().clearSelection();
              dataSetTypeChooser.getCombo().setEnabled(false);
              setPageComplete(false);
            }
            dataSourceFilteredTree.getViewer().getTree().setFocus();
          }
        };
    dataSourceFilteredTree.getViewer().getTree().addSelectionListener(listener);
    createDataSetTypeViewer(composite);

    setDataSourceTreeViewer();
    setPageStatus();

    // initialize name editor
    new Label(composite, SWT.RIGHT)
        .setText(Messages.getString("dataset.wizard.label.datasetName")); // $NON-NLS-1$
    nameEditor = new Text(composite, SWT.BORDER);
    String name = ReportPlugin.getDefault().getCustomName(ReportDesignConstants.DATA_SET_ELEMENT);
    if (name != null) {
      nameEditor.setText(Utility.getUniqueDataSetName(name));
    } else // can't get defaut name
    {
      nameEditor.setText(
          Utility.getUniqueDataSetName(
              Messages.getString("dataset.new.defaultName"))); // $NON-NLS-1$		
    }

    nameEditor.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    nameEditor.setToolTipText(Messages.getString("DataSetBasePage.tooltip")); // $NON-NLS-1$
    nameEditor.addModifyListener(
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {
            if (StringUtil.isBlank(nameEditor.getText().trim())) {
              setMessage(EMPTY_NAME, ERROR);
            } else if (isDuplicateName()) { // name is duplicated
              setMessage(DUPLICATE_NAME, ERROR);
            } else if (containInvalidCharactor(
                nameEditor.getText())) { // name contains invalid ".", "/", "\", "!", ";", ","
              // character
              String msg =
                  Messages.getFormattedString(
                      "error.invalidName", //$NON-NLS-1$
                      new Object[] {nameEditor.getText()});
              setMessage(msg, ERROR);
            } else { // everything is OK
              setMessage(CREATE_PROMPT);
            }

            setPageComplete(
                !hasWizard() && (getMessageType() != ERROR) && getSelectedDataSource() != null);

            nameEditor.setFocus();
          }
        });
    setControl(composite);

    Utility.setSystemHelp(getControl(), IHelpConstants.CONEXT_ID_DATASET_NEW);
  }