コード例 #1
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
  */
 protected Control createDialogArea(Composite parent) {
   getShell().setText(Messages.getString("dialogs.OrganizeTestTextDialog.title")); // $NON-NLS-1$
   // create a composite with standard margins and spacing
   Composite composite = new Composite(parent, SWT.NONE | SWT.RESIZE);
   GridLayout layout = new GridLayout();
   layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
   layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
   layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
   layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
   layout.numColumns = 2;
   composite.setLayout(layout);
   composite.setLayoutData(new GridData(GridData.FILL_BOTH));
   applyDialogFont(composite);
   switch (type) {
     case TYPE_SAVE:
       return createDialogAreaContentsForSave(composite);
     case TYPE_LOAD:
       return createDialogAreaContentsForLoad(composite);
     case TYPE_ORGANIZE:
       return createDialogAreaContentsForOrganize(composite);
     default:
       throw new IllegalStateException(
           Messages.getString("dialogs.OrganizeTestTextDialog.errror.message1")
               + type); //$NON-NLS-1$
   }
 }
コード例 #2
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.dialogs.Dialog#okPressed()
  */
 protected void okPressed() {
   okPressed = true;
   if (type == TYPE_SAVE) {
     if (nameText.getText() == null || nameText.getText().trim().length() == 0) {
       messageLabel.setText(
           Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text7")); // $NON-NLS-1$
       messageLabel.redraw();
       return;
     } else {
       this.nameToSave = nameText.getText();
     }
   } else if (type == TYPE_LOAD) {
     if (this.selectedPath != null) {
       try {
         this.selectedText = getFileContents(this.selectedPath);
       } catch (Exception e) {
         messageLabel.setText(e.getMessage());
         messageLabel.redraw();
         return;
       }
     } else if (nameList.getSelection() == null || nameList.getSelection().length == 0) {
       messageLabel.setText(
           Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text8")); // $NON-NLS-1$
       messageLabel.redraw();
       return;
     } else {
       this.selectedText =
           QuickRExPlugin.getDefault().getTestTextByName(nameList.getSelection()[0]);
     }
   }
   this.close();
 }
コード例 #3
0
 public LoadTestTextAction() {
   super(""); // $NON-NLS-1$
   this.setText(Messages.getString("views.QuickRExView.loadTextAction.text")); // $NON-NLS-1$
   this.setToolTipText(
       Messages.getString("views.QuickRExView.loadTextAction.tooltip")); // $NON-NLS-1$
   this.setImageDescriptor(
       ((PluginImageRegistry) QuickRExPlugin.getDefault().getImageRegistry())
           .getImageDescriptor(PluginImageRegistry.IMG_LOAD_TT));
   this.setId("de.babe.eclipse.plugins.quickREx.actions.LoadTestTextAction"); // $NON-NLS-1$
 }
コード例 #4
0
  private Control createDialogAreaContentsForLoad(Composite p_composite) {
    messageLabel = new Label(p_composite, SWT.NULL);
    messageLabel.setText(
        Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text1")); // $NON-NLS-1$
    GridData gd = new GridData(GridData.VERTICAL_ALIGN_FILL);
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    gd.widthHint = 400;
    messageLabel.setLayoutData(gd);
    Label nameLabel = new Label(p_composite, SWT.NULL);
    nameLabel.setText(
        Messages.getString("dialogs.OrganizeTestTextDialog.nameLabel.text2")); // $NON-NLS-1$
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    gd.grabExcessHorizontalSpace = false;
    nameLabel.setLayoutData(gd);
    nameList = new List(p_composite, SWT.V_SCROLL);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.grabExcessHorizontalSpace = true;
    gd.heightHint = 100;
    nameList.setLayoutData(gd);
    nameList.setItems(QuickRExPlugin.getDefault().getTestTextNames());
    nameList.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            if (nameList.getSelection() != null && nameList.getSelection().length > 0) {
              testTextField.setText(
                  QuickRExPlugin.getDefault()
                      .getTestTextByName(nameList.getSelection()[0])
                      .getText());
              selectedPath = null;
            }
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    Label textLabel = new Label(p_composite, SWT.NULL);
    textLabel.setText(
        Messages.getString("dialogs.OrganizeTestTextDialog.textLabel.text2")); // $NON-NLS-1$
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    gd.grabExcessHorizontalSpace = false;
    textLabel.setLayoutData(gd);
    testTextField =
        new Text(
            p_composite,
            SWT.READ_ONLY | SWT.LEAD | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.RESIZE);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 250;
    gd.widthHint = 400;
    testTextField.setLayoutData(gd);
    testTextField.setBackground(new Color(getShell().getDisplay(), new RGB(255, 255, 255)));
    return p_composite;
  }
コード例 #5
0
 private void createButtonsForOrganize(Composite parent) {
   createButton(
       parent,
       DELETE_BUTTON_ID,
       Messages.getString("dialogs.OrganizeTestTextDialog.button.delete"),
       false); //$NON-NLS-1$
   createButton(
       parent,
       IDialogConstants.CANCEL_ID,
       Messages.getString("dialogs.OrganizeTestTextDialog.button.close"),
       true); //$NON-NLS-1$
 }
コード例 #6
0
 private void handleNameTextModified() {
   getButton(IDialogConstants.OK_ID)
       .setEnabled((nameText.getText() != null && nameText.getText().trim().length() > 0));
   if (QuickRExPlugin.getDefault().testTextNameExists(nameText.getText())) {
     messageLabel.setText(
         Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text3")); // $NON-NLS-1$
   } else if (nameText.getText() == null || nameText.getText().trim().length() == 0) {
     messageLabel.setText(
         Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text4")); // $NON-NLS-1$
   } else {
     messageLabel.setText(""); // $NON-NLS-1$
   }
 }
コード例 #7
0
 private void deletePressed() {
   if (nameList.getSelection() == null || nameList.getSelection().length == 0) {
     messageLabel.setText(
         Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text5")); // $NON-NLS-1$
     messageLabel.redraw();
     return;
   } else {
     QuickRExPlugin.getDefault().deleteTestTextByName(nameList.getSelection()[0]);
     testTextField.setText(""); // $NON-NLS-1$
     nameList.setItems(QuickRExPlugin.getDefault().getTestTextNames());
     messageLabel.setText(
         Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text6")); // $NON-NLS-1$
     messageLabel.redraw();
   }
 }
コード例 #8
0
 private void createButtonsForLoad(Composite parent) {
   createButton(
       parent,
       BROWSE_BUTTON_ID,
       Messages.getString("dialogs.OrganizeTestTextDialog.button.browse"),
       false); //$NON-NLS-1$
   createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
   createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
 }
コード例 #9
0
 private Control createDialogAreaContentsForSave(Composite p_composite) {
   messageLabel = new Label(p_composite, SWT.NULL);
   messageLabel.setText(""); // $NON-NLS-1$
   GridData gd = new GridData(GridData.VERTICAL_ALIGN_FILL);
   gd.grabExcessHorizontalSpace = true;
   gd.horizontalSpan = 2;
   gd.widthHint = 400;
   messageLabel.setLayoutData(gd);
   Label nameLabel = new Label(p_composite, SWT.NULL);
   nameLabel.setText(
       Messages.getString("dialogs.OrganizeTestTextDialog.nameLabel.text3")); // $NON-NLS-1$
   gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
   gd.grabExcessHorizontalSpace = false;
   nameLabel.setLayoutData(gd);
   nameText = new Text(p_composite, SWT.BORDER);
   gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
   gd.grabExcessHorizontalSpace = true;
   nameText.setLayoutData(gd);
   nameText.addModifyListener(
       new ModifyListener() {
         public void modifyText(ModifyEvent p_e) {
           handleNameTextModified();
         }
       });
   Label textLabel = new Label(p_composite, SWT.NULL);
   textLabel.setText(
       Messages.getString("dialogs.OrganizeTestTextDialog.textLabel.text3")); // $NON-NLS-1$
   gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
   gd.grabExcessHorizontalSpace = false;
   textLabel.setLayoutData(gd);
   testTextField =
       new Text(
           p_composite,
           SWT.READ_ONLY | SWT.LEAD | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.RESIZE);
   gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
   gd.grabExcessHorizontalSpace = true;
   gd.grabExcessVerticalSpace = true;
   gd.heightHint = 250;
   gd.widthHint = 400;
   testTextField.setLayoutData(gd);
   testTextField.setBackground(new Color(getShell().getDisplay(), new RGB(255, 255, 255)));
   testTextField.setText(this.textToSave);
   return p_composite;
 }
コード例 #10
0
 /**
  * Gets all possible flags for a specific regex-flavour.
  *
  * @param flavour The flavour
  * @return A collection of the type de.babe.eclipse.plugins.quickREx.regexp.Flag
  * @see de.babe.eclipse.plugins.quickREx.regexp.Flag
  */
 public static Collection getAllFlags(int flavour) {
   switch (flavour) {
     case JAVA_FLAVOUR:
       return JavaMatchSet.getAllFlags();
     case ORO_PERL_FLAVOUR:
       return OROPerlMatchSet.getAllFlags();
     case ORO_AWK_FLAVOUR:
       return OROAwkMatchSet.getAllFlags();
     default:
       throw new IllegalArgumentException(
           Messages.getString("regexp.MatchSetFactory.error.message2") + flavour); // $NON-NLS-1$
   }
 }
コード例 #11
0
 /**
  * Factory-Method to create a MatchSet for the passed details.
  *
  * @param flavour one of the Flavour-Flags defined in this class
  * @param regExp the regular expression
  * @param text the text to match against the reg.exp.
  * @param flags a Collection of flags to pass to the Compiler. This may contain more flags than
  *     are applicable to the requested flavour. In this case, only those flags wich are applicable
  *     are taken into account when creating the MatchSet
  * @return a MatchSet as requested
  */
 public static MatchSet createMatchSet(int flavour, String regExp, String text, Collection flags) {
   Vector flavourFlags = new Vector(flags);
   flavourFlags.retainAll(MatchSetFactory.getAllFlags(flavour));
   switch (flavour) {
     case JAVA_FLAVOUR:
       return new JavaMatchSet(regExp, text, flavourFlags);
     case ORO_PERL_FLAVOUR:
       return new OROPerlMatchSet(regExp, text, flavourFlags);
     case ORO_AWK_FLAVOUR:
       return new OROAwkMatchSet(regExp, text, flavourFlags);
     default:
       throw new IllegalArgumentException(
           Messages.getString("regexp.MatchSetFactory.error.message1") + flavour); // $NON-NLS-1$
   }
 }
コード例 #12
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
  */
 protected void createButtonsForButtonBar(Composite parent) {
   switch (type) {
     case TYPE_SAVE:
       super.createButtonsForButtonBar(parent);
       return;
     case TYPE_LOAD:
       createButtonsForLoad(parent);
       return;
     case TYPE_ORGANIZE:
       createButtonsForOrganize(parent);
       return;
     default:
       throw new IllegalStateException(
           Messages.getString("dialogs.OrganizeTestTextDialog.error.message2")
               + type); //$NON-NLS-1$
   }
 }
コード例 #13
0
 private NamedText getFileContents(String p_filePath) throws Exception {
   StringBuffer contents = new StringBuffer();
   File file = new File(p_filePath);
   if (!(file.exists() && file.canRead()) || file.isDirectory()) {
     throw new Exception(
         Messages.getString("dialogs.OrganizeTestTextDialog.error.message3")); // $NON-NLS-1$
   } else {
     FileInputStream fis = null;
     try {
       fis = new FileInputStream(file);
       int read = 0;
       while ((read = fis.read()) != -1) {
         contents.append((char) read);
       }
       fis.close();
     } catch (Exception e) {
       throw e;
     }
   }
   return new NamedText(p_filePath, contents.toString());
 }