@Override
  public boolean matches(IEditorReference editorRef, IEditorInput input) {
    IQ7Element inputElement = getElement(input);
    if (inputElement != null && editorRef.getId().startsWith("org.eclipse.rcptt.ui.editors")) {
      IWorkbenchPart part = editorRef.getPart(false);
      if (part instanceof EclEditor) {
        IQ7NamedElement model = ((EclEditor) part).getModel();
        if (model != null) {
          return inputElement.equals(model);
        }
      } else if (part instanceof NamedElementEditor) {
        IQ7NamedElement model = ((NamedElementEditor) part).getModel();
        if (model != null) {
          return inputElement.equals(model);
        }
      }

      // try figure out using ref editor input
      IEditorInput editRefInput;
      try {
        editRefInput = editorRef.getEditorInput();
        if (editRefInput != null) {
          IQ7Element refElement = getElement(editRefInput);
          return inputElement.equals(refElement);
        }
      } catch (PartInitException e) {
        RcpttPlugin.log(e.getMessage(), e);
      }
    }
    return false;
  }
Beispiel #2
0
 private boolean saveAs() {
   IQ7Folder folder = null;
   if (getModel() != null) {
     IQ7Element parent = getModel().getParent();
     if (parent != null && parent.exists() && parent instanceof IQ7Folder) {
       folder = (IQ7Folder) parent;
     }
   }
   ITestCase newScenario = DialogUtil.openNewScenarioDialog(getShell(), false, folder);
   if (newScenario == null) return false;
   IFile file = (IFile) newScenario.getResource();
   if (file == null) return false;
   IQ7Element newModel = RcpttCore.create(file);
   if (newModel == null) return false;
   setModel((ITestCase) newModel);
   save();
   return true;
 }