org.eclipse.core.expressions.Expression Java Examples

The following examples show how to use org.eclipse.core.expressions.Expression. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewInstanceDescriptor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public ViewInstanceDescriptor ( final String id, final String parentId, final ViewInstanceFactory factory, final URI uri, final String name, final int order, final boolean defaultInstance, final Boolean zooming, final Expression lazyExpression, final Expression visibleExpression, final Expression defaultInstanceExpression, final String summaryConnectionId, final String summaryItemId, final boolean mainView, final Map<String, String> properties )
{
    super ();
    this.id = id;
    this.parentId = parentId;
    this.factory = factory;
    this.uri = uri;
    this.name = name;
    this.properties = properties;
    this.order = order;
    this.defaultInstance = defaultInstance;
    this.zooming = zooming;
    this.lazyExpression = lazyExpression;
    this.visibleExpression = visibleExpression;
    this.defaultInstanceExpression = defaultInstanceExpression;
    this.summaryConnectionId = summaryConnectionId;
    this.summaryItemId = summaryItemId;
    this.mainView = mainView;
}
 
Example #2
Source File: ClasspathFixProcessorDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public boolean matches(IJavaProject javaProject) {
	if (fStatus != null) {
		return fStatus.booleanValue();
	}

	IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
	if (children.length == 1) {
		try {
			ExpressionConverter parser= ExpressionConverter.getDefault();
			Expression expression= parser.perform(children[0]);
			EvaluationContext evalContext= new EvaluationContext(null, javaProject);
			evalContext.addVariable("project", javaProject); //$NON-NLS-1$
			evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$
			return expression.evaluate(evalContext) == EvaluationResult.TRUE;
		} catch (CoreException e) {
			JavaPlugin.log(e);
		}
		return false;
	}
	fStatus= Boolean.FALSE;
	return false;
}
 
Example #3
Source File: EditpartExtensionManager.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public static EditPart createEditPart( EditPart context, Object model )
{
	EvaluationContext econtext = new EvaluationContext( null, model );
	for ( Iterator<Expression> iterator = extensionMap.keySet( ).iterator( ); iterator.hasNext( ); )
	{
		try
		{
			Expression expression = iterator.next( );
			if ( expression.evaluate( econtext ) == EvaluationResult.TRUE )
			{
				EditPart editPart = (EditPart) extensionMap.get( expression )
						.createExecutableExtension( "type" ); //$NON-NLS-1$
				editPart.setModel( model );
				return editPart;
			}
		}
		catch ( CoreException e )
		{
			logger.log( Level.SEVERE, e.getMessage( ), e );
		}
	}
	return null;
}
 
Example #4
Source File: BasePluginXmlTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/** Verify that a node is a valid expression. */
protected static Expression checkExpression(Element expression) {
  try {
    Expression converted = ExpressionConverter.getDefault().perform(expression);
    Assert.assertNotNull(converted);
    return converted;
  } catch (CoreException ex) {
    throw new AssertionError("failed to convert to core expression", ex);
  }
}
 
Example #5
Source File: PluginXmlTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testNavigatorContentTriggerExpression_normalProject() throws CoreException {
  Element triggerPoints =
      findElement(
          "//plugin/extension[@point='org.eclipse.ui.navigator.navigatorContent']"
              + "/navigatorContent[@id='com.google.cloud.tools.eclipse.appengine.navigator']"
              + "/triggerPoints/*");
  Expression triggerExpression = checkExpression(triggerPoints);
  assertEquals(
      EvaluationResult.FALSE,
      triggerExpression.evaluate(new EvaluationContext(null, projectCreator.getProject())));
}
 
Example #6
Source File: PluginXmlTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testNavigatorContentTriggerExpression_appEngineStandardJavaProject()
    throws CoreException {
  Element triggerPoints =
      findElement(
          "//plugin/extension[@point='org.eclipse.ui.navigator.navigatorContent']"
              + "/navigatorContent[@id='com.google.cloud.tools.eclipse.appengine.navigator']"
              + "/triggerPoints/*");
  Expression triggerExpression = checkExpression(triggerPoints);
  projectCreator.withFacets(
      AppEngineStandardFacet.JRE7, JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25);
  assertEquals(
      EvaluationResult.TRUE,
      triggerExpression.evaluate(new EvaluationContext(null, projectCreator.getProject())));
}
 
Example #7
Source File: PluginXmlTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testNavigatorContentTriggerExpression_appEngineFlexibleWarJavaProject()
    throws CoreException {
  Element triggerPoints =
      findElement(
          "//plugin/extension[@point='org.eclipse.ui.navigator.navigatorContent']"
              + "/navigatorContent[@id='com.google.cloud.tools.eclipse.appengine.navigator']"
              + "/triggerPoints/*");
  Expression triggerExpression = checkExpression(triggerPoints);
  projectCreator.withFacets(
      AppEngineFlexWarFacet.FACET_VERSION, JavaFacet.VERSION_1_8, WebFacetUtils.WEB_31);
  assertEquals(
      EvaluationResult.TRUE,
      triggerExpression.evaluate(new EvaluationContext(null, projectCreator.getProject())));
}
 
Example #8
Source File: PluginXmlTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testNavigatorContentTriggerExpression_appEngineFlexibleJarJavaProject()
    throws CoreException {
  Element triggerPoints =
      findElement(
          "//plugin/extension[@point='org.eclipse.ui.navigator.navigatorContent']"
              + "/navigatorContent[@id='com.google.cloud.tools.eclipse.appengine.navigator']"
              + "/triggerPoints/*");
  Expression triggerExpression = checkExpression(triggerPoints);
  projectCreator.withFacets(AppEngineFlexJarFacet.FACET_VERSION, JavaFacet.VERSION_1_8);
  assertEquals(
      EvaluationResult.TRUE,
      triggerExpression.evaluate(new EvaluationContext(null, projectCreator.getProject())));
}
 
Example #9
Source File: PluginXmlTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testNavigatorContentActionProvider() throws CoreException {
  Element actionProvider =
      findElement(
          "//plugin/extension[@point='org.eclipse.ui.navigator.navigatorContent']"
              + "/navigatorContent[@id='com.google.cloud.tools.eclipse.appengine.navigator']"
              + "/actionProvider");
  assertEquals(AppEngineActionProvider.class.getName(), actionProvider.getAttribute("class"));
  assertEquals(
      "com.google.cloud.tools.eclipse.appengine.facets.ui.navigator.actions",
      actionProvider.getAttribute("id"));
  Element actionProviderEnablement = findElement("enablement/*", actionProvider);
  Expression enablementExpression = checkExpression(actionProviderEnablement);
  assertEquals(
      EvaluationResult.TRUE,
      enablementExpression.evaluate(
          new EvaluationContext(null, mock(AppEngineProjectElement.class))));
  assertEquals(
      EvaluationResult.TRUE,
      enablementExpression.evaluate(new EvaluationContext(null, mock(CronDescriptor.class))));
  assertEquals(
      EvaluationResult.TRUE,
      enablementExpression.evaluate(
          new EvaluationContext(null, mock(DenialOfServiceDescriptor.class))));
  assertEquals(
      EvaluationResult.TRUE,
      enablementExpression.evaluate(
          new EvaluationContext(null, mock(DispatchRoutingDescriptor.class))));
  assertEquals(
      EvaluationResult.TRUE,
      enablementExpression.evaluate(
          new EvaluationContext(null, mock(DatastoreIndexesDescriptor.class))));
  assertEquals(
      EvaluationResult.TRUE,
      enablementExpression.evaluate(
          new EvaluationContext(null, mock(TaskQueuesDescriptor.class))));
}
 
Example #10
Source File: ContributedProcessorDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean matches(ICompilationUnit cunit) {
	if (fRequiredSourceLevel != null) {
		String current= cunit.getJavaProject().getOption(JavaCore.COMPILER_SOURCE, true);
		if (JavaModelUtil.isVersionLessThan(current, fRequiredSourceLevel)) {
			return false;
		}
	}

	if (fStatus != null) {
		return fStatus.booleanValue();
	}

	IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
	if (children.length == 1) {
		try {
			ExpressionConverter parser= ExpressionConverter.getDefault();
			Expression expression= parser.perform(children[0]);
			EvaluationContext evalContext= new EvaluationContext(null, cunit);
			evalContext.addVariable("compilationUnit", cunit); //$NON-NLS-1$
			IJavaProject javaProject= cunit.getJavaProject();
			String[] natures= javaProject.getProject().getDescription().getNatureIds();
			evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$
			evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$
			return expression.evaluate(evalContext) == EvaluationResult.TRUE;
		} catch (CoreException e) {
			JavaPlugin.log(e);
		}
		return false;
	}
	fStatus= Boolean.FALSE;
	return false;
}
 
Example #11
Source File: ViewInstanceDescriptor.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public Expression getDefaultInstanceExpression ()
{
    return this.defaultInstanceExpression;
}
 
Example #12
Source File: ViewInstanceDescriptor.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public Expression getLazyExpression ()
{
    return this.lazyExpression;
}
 
Example #13
Source File: ViewInstanceDescriptor.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public Expression getVisibleExpression ()
{
    return this.visibleExpression;
}
 
Example #14
Source File: ElementAdapter.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Expression getExpression( )
{
	return expression;
}
 
Example #15
Source File: ElementAdapter.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void setExpression( Expression expression )
{
	this.expression = expression;
}
 
Example #16
Source File: CompletionProposalCategory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the enablement element of the described extension.
 * 
 * @return the enablement expression or <code>null</code> if it is not specified
 * @since 3.8.1
 */
Expression getEnablementExpression() {
	return fEnablementExpression;
}