public TagsRegistry getTags() { if (tagsWatcher == null) { tagsWatcher = new TagsWatcher(tags); RcpttCore.addElementChangedListener(tagsWatcher); } return this.tags; }
private IQ7Element getElement(IEditorInput input) { IQ7Element inputElement = null; if (input instanceof IFileEditorInput) { inputElement = RcpttCore.create(((IFileEditorInput) input).getFile()); } else if (input instanceof EclEditorInput) { inputElement = ((EclEditorInput) input).getElement(); } return inputElement; }
/* * (non-Javadoc) * * @see * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext * ) */ @Override public void stop(BundleContext context) throws Exception { if (tagsWatcher != null) { RcpttCore.removeElementChangedListener(tagsWatcher); } tagsWatcher = null; tags = null; plugin = null; super.stop(context); }
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; }
private static IContext[] getReferencedContexts(IQ7NamedElement element) { if (element == null) { return new IContext[0]; } try { List<IContext> result = new ArrayList<IContext>(); if (element instanceof Q7InternalTestCase) { Scenario scenario = ((Q7InternalTestCase) element).getNamedElement(); for (String id : scenario.getContexts()) { IQ7NamedElement ref = Q7SearchCore.findById(id); if (!(ref instanceof IContext)) { continue; } result.add((IContext) ref); } return result.toArray(new IContext[result.size()]); } if (element instanceof ITestCase) { String[] ids = ((ITestCase) element).getContexts(); return RcpttCore.getInstance() .getContexts((ITestCase) element, Arrays.asList(ids), null, true); } IQ7ProjectMetadata metadata = element.getQ7Project().getMetadata(); if (metadata.exists()) { String[] ids = metadata.getContexts(); for (String id : ids) { IQ7NamedElement ref = Q7SearchCore.findById(id); if (!(ref instanceof IContext)) { continue; } result.add((IContext) ref); } } return result.toArray(new IContext[result.size()]); } catch (ModelException e) { return new IContext[0]; } }
public static void initializeProjectContextUpdateJob() { RcpttCore.addElementChangedListener( new IElementChangedListener() { public void elementChanged(Q7ElementChangedEvent event) { IQ7ElementDelta delta = event.getDelta(); IQ7NamedElement[] namedElements = delta.getNamedElements(); for (final IQ7NamedElement e : namedElements) { IQ7ElementDelta childDelta = delta.getChildBy(e); switch (childDelta.getKind()) { case IQ7ElementDelta.REMOVED: case IQ7ElementDelta.CHANGED: if (e instanceof Q7ProjectMetadata) { ProjectContextReferencesUpdateJob job = new ProjectContextReferencesUpdateJob(e.getQ7Project()); Job.getJobManager().cancel(job.getFamily()); job.setRule(e.getQ7Project().getProject()); job.schedule(); } break; } } } }); }