org.eclipse.core.runtime.QualifiedName Java Examples

The following examples show how to use org.eclipse.core.runtime.QualifiedName. 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: CpplintCheckSettings.java    From CppStyle with MIT License 6 votes vote down vote up
private static boolean enableCpplint(IResource resource) {
	boolean enable = CppStyle.getDefault().getPreferenceStore()
			.getBoolean(CppStyleConstants.ENABLE_CPPLINT_ON_SAVE);

	try {
		IProject project = resource.getProject();
		String enableProjectSpecific = project
				.getPersistentProperty(new QualifiedName("", CppStyleConstants.PROJECTS_PECIFIC_PROPERTY));

		if (enableProjectSpecific != null && Boolean.parseBoolean(enableProjectSpecific)) {
			String value = project
					.getPersistentProperty(new QualifiedName("", CppStyleConstants.ENABLE_CPPLINT_PROPERTY));
			if (value != null) {
				return Boolean.parseBoolean(value);
			}

			return false;
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}

	return enable;
}
 
Example #2
Source File: ResourceBasedPreferenceStore.java    From tlaplus with MIT License 6 votes vote down vote up
public String getString(String name)
{
    String value = null;
    try
    {
        value = resource.getPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, name));
        if (value == null) 
        {
            value = "";
        }
    } catch (CoreException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return value;
}
 
Example #3
Source File: ResourceUtils.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
public static String getAbsolutePathOfLinkedResource(IResource resource) {
  	try {
  		QualifiedName qn = ResourceUtils.createPersistentPropertyQualifiedName(IResourceAttributes.LINKED_RESOURCE_ORIGINAL_PATH_ATTR_NAME, resource.getFullPath().toOSString());
	IProject project = resource.getProject();
	if (project != null && project.isOpen()) {
		String path = project.getPersistentProperty(qn);
		if (path != null) {
			return getAbsolutePathAsInFS(path);
		}
	}
} catch (CoreException e) {
	LogHelper.logError(e);
}
  	
  	return null;
  }
 
Example #4
Source File: ReportPlugin.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Set the show cheatsheet preference in workspace root. Used by wizards
 */
public static void writeCheatSheetPreference( boolean value )
{
	IWorkspace workspace = ResourcesPlugin.getWorkspace( );
	try
	{
		workspace.getRoot( )
				.setPersistentProperty( new QualifiedName( "org.eclipse.birt.property", //$NON-NLS-1$
						"showCheatSheet" ), //$NON-NLS-1$
						String.valueOf( value ) );
	}
	catch ( CoreException e )
	{
		logger.log( Level.SEVERE, e.getMessage( ), e );
	}
}
 
Example #5
Source File: ResourceUtilTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void createCopyAndVerifyResource(String name, boolean isFile, boolean isAbsolute) throws CoreException {
    IResource resource = createAndVerifyResource(name, true);
    IPath newPath;
    if (isAbsolute) {
        newPath = resource.getParent().getFullPath().addTrailingSeparator().append(name + COPY_SUFFIX);
    } else {
        newPath = new Path ("..").append(resource.getParent().getName()).append(name + COPY_SUFFIX);
    }
    resource.setPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, PROPERTY_KEY), PROPERTY_VALUE);
    IResource copyResource = ResourceUtil.copyResource(resource, newPath, IResource.FORCE, new NullProgressMonitor());
    assertNotNull(copyResource);
    Map<QualifiedName, String> persistentProperties = copyResource.getPersistentProperties();
    assertEquals(1, persistentProperties.size());
    for (Map.Entry<QualifiedName, String> entry: persistentProperties.entrySet()) {
        assertEquals(PROPERTY_KEY, entry.getKey().getLocalName());
        assertEquals(Activator.PLUGIN_ID, entry.getKey().getQualifier());
        assertEquals(PROPERTY_VALUE, entry.getValue());
    }
    resource.delete(true, null);
    copyResource.delete(true, null);
}
 
Example #6
Source File: ReportPlugin.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return the cheat sheet property preference, stored in the workbench root
 */
public static boolean readCheatSheetPreference( )
{
	IWorkspace workspace = ResourcesPlugin.getWorkspace( );
	try
	{
		String property = workspace.getRoot( )
				.getPersistentProperty( new QualifiedName( "org.eclipse.birt.property", //$NON-NLS-1$
						"showCheatSheet" ) ); //$NON-NLS-1$
		if ( property != null )
			return Boolean.valueOf( property ).booleanValue( );
	}
	catch ( CoreException e )
	{
		logger.log( Level.SEVERE, e.getMessage( ), e );
	}
	return true;
}
 
Example #7
Source File: ClangFormatFormatter.java    From CppStyle with MIT License 6 votes vote down vote up
private boolean enableClangFormatOnSave(IResource resource) {
	boolean enable = CppStyle.getDefault().getPreferenceStore()
			.getBoolean(CppStyleConstants.ENABLE_CLANGFORMAT_ON_SAVE);

	try {
		IProject project = resource.getProject();
		String enableProjectSpecific = project
				.getPersistentProperty(new QualifiedName("", CppStyleConstants.PROJECTS_PECIFIC_PROPERTY));

		if (enableProjectSpecific != null && Boolean.parseBoolean(enableProjectSpecific)) {
			String value = project
					.getPersistentProperty(new QualifiedName("", CppStyleConstants.ENABLE_CLANGFORMAT_PROPERTY));
			if (value != null) {
				return Boolean.parseBoolean(value);
			}

			return false;
		}
	} catch (CoreException e) {
		CppStyle.log(e);
	}

	return enable;
}
 
Example #8
Source File: StandardProjectSREProviderTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	this.id = SARLRuntime.createUniqueIdentifier();
	this.project = mock(IProject.class);
	when(this.project.getPersistentProperty(ArgumentMatchers.any(QualifiedName.class))).thenAnswer(new Answer() {
	@Override
		public Object answer(InvocationOnMock invocation) throws Throwable {
			QualifiedName qn = (QualifiedName) invocation.getArguments()[0];
			String sqn = qn.toString();
			switch (sqn) {
			case "io.sarl.eclipse.launch.SRE:HAS_PROJECT_SPECIFIC":
				return Boolean.TRUE.toString();
			case "io.sarl.eclipse.launch.SRE:USE_SYSTEM_WIDE_SRE":
				return Boolean.FALSE.toString();
			case "io.sarl.eclipse.launch.SRE:SRE_INSTALL_ID":
				return StandardProjectSREProviderTest.this.id;
			}
			return null;
		}
	});
	this.provider = new StandardProjectSREProvider(this.project);
}
 
Example #9
Source File: AbstractProjectPreferencesPage.java    From uml2solidity with Eclipse Public License 1.0 6 votes vote down vote up
private void restoreOldSettings() {
	if (isPropertyPage()) {
		QualifiedName oldKey = new QualifiedName(preferencesId(), useProjectSettingsPreferenceName());
		try {
			String oldValue = project.getPersistentProperty(oldKey);
			if (oldValue != null) {
				// remove old entry
				project.setPersistentProperty(oldKey, null);
				// if were true - save copy into project settings
				if (Boolean.valueOf(oldValue)) {
					saveUseProjectSettings(true);
				}
			}
		} catch (Exception e) {
		}
	}

}
 
Example #10
Source File: AbstractPreferencePage.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private void restoreOldSettings() {
	if (isPropertyPage()) {
		QualifiedName oldKey = new QualifiedName(qualifiedName(), USE_PROJECT_SETTINGS);
		try {
			String oldValue = currentProject().getPersistentProperty(oldKey);
			if (oldValue != null) {
				//remove old entry
				currentProject().setPersistentProperty(oldKey, null);
				//if were true - save copy into project settings
				if (Boolean.valueOf(oldValue)) {
					saveUseProjectSettings(true);
				}
			}
		} catch (Exception e) {
			log.debug("Failed to read persistent property", e);
		}
	}

}
 
Example #11
Source File: ProjectUtils.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public static String formatProblem(IMarker problem) {
  StringBuilder sb = new StringBuilder();
  sb.append(problem.getResource().getFullPath());
  sb.append(':');
  sb.append(problem.getAttribute(IMarker.LINE_NUMBER, -1));
  sb.append(": ");
  sb.append(problem.getAttribute(IMarker.MESSAGE, ""));

  // Derived from
  // org.eclipse.wst.xml.ui.internal.validation.core.errorinfo.ReferencedFileErrorsHandler
  // ValidationMessage.ERROR_MESSAGE_MAP_QUALIFIED_NAME
  QualifiedName errorMessageMapName =
      new QualifiedName("org.eclipse.wst.xml.validation", "errorMessageMap");
  // map is list of file-URI -> ValidationMessage objects
  try {
    Map<?, ?> map = (Map<?, ?>) problem.getResource().getSessionProperty(errorMessageMapName);
    if (map != null) {
      for (Entry<?, ?> entry : map.entrySet()) {
        // show == false as the top message object is in the marker message
        appendValidationMessage(sb, entry.getValue(), 0, /* show */ false);
      }
    }
  } catch (CoreException ex) {
    /* ignore: not a validation problem */
  }
  return sb.toString();
}
 
Example #12
Source File: TexlipseProperties.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Read a session property.
 * 
 * @param project the current project
 * @param property the name of the property
 * @return the value of session property or null if the property is not found
 */
public static Object getSessionProperty(IResource project, String property) {
    Object value = null;
    try {
        value = project.getSessionProperty(new QualifiedName(TexlipseProperties.PACKAGE_NAME, property));
    } catch (CoreException e) {
        // do nothing
    }
    return value;
}
 
Example #13
Source File: ProjectStub2.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String getPersistentProperty(QualifiedName key) throws CoreException {
    if (key.getLocalName().equals("PYTHON_PROJECT_VERSION")) {
        // TODO the comment below says "always the latests", but it isn't!
        return IPythonNature.PYTHON_VERSION_2_5;//for tests, always the latest version
    }
    //this is just for backward-compatibility
    if (key.getLocalName().equals("PROJECT_SOURCE_PATH")) {
        return "/test";
    }
    if (key.getLocalName().equals("PROJECT_EXTERNAL_SOURCE_PATH")) {
        return "";
    }
    throw new RuntimeException(key.getLocalName());
}
 
Example #14
Source File: TexlipseProperties.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Read a project property.
 * 
 * @param project the current project
 * @param property the name of the property
 * @return the value of the named project property or null if the property is not found
 */
public static String getProjectProperty(IResource project, String property) {
    String value = null;
    try {
        value = project.getPersistentProperty(new QualifiedName(TexlipseProperties.PACKAGE_NAME, property));
    } catch (CoreException e) {
        // do nothing
    }
    return value;
}
 
Example #15
Source File: ProjectStub2.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
    if (value == null) {
        return;
    }
    throw new RuntimeException("not expected");
}
 
Example #16
Source File: DerbyProperties.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void save(IProject project) throws CoreException {
		
		project.setPersistentProperty(new QualifiedName (
			CommonNames.UI_PATH, DSPORT), Integer.toString(port));
		project.setPersistentProperty(new QualifiedName (
			CommonNames.UI_PATH, DSHOST), host);
		project.setPersistentProperty(new QualifiedName (
			CommonNames.UI_PATH, DS_SYS_HOME), systemHome);
//		project.setPersistentProperty(new QualifiedName (
//				CommonNames.UI_PATH, DS_RUNNING_PORT), Integer.toString(runningPort));
	}
 
Example #17
Source File: CDEpropertyPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the import by default.
 *
 * @param project the project
 * @return the import by default
 */
public static String getImportByDefault(IProject project) {
  String byDefault;
  try {
    byDefault = project.getPersistentProperty(new QualifiedName("", BY_DEFAULT_PROPERTY_KEY));
  } catch (CoreException e) {
    byDefault = "";
  }
  if (null == byDefault)
    byDefault = "";
  return byDefault;
}
 
Example #18
Source File: DerbyProperties.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void load(IProject project) throws CoreException {
		
		String property = project.getPersistentProperty(new QualifiedName (
				CommonNames.UI_PATH, DSPORT));
		port = (property != null && property.length() > 0) ? Integer.parseInt(property) : port;
		property = project.getPersistentProperty(new QualifiedName (
				CommonNames.UI_PATH, DSHOST));
		host = (property != null && property.length() > 0) ? property : host;
		property = project.getPersistentProperty(new QualifiedName (
				CommonNames.UI_PATH, DS_SYS_HOME));
		systemHome = (property != null && property.length() > 0) ? property : systemHome;
//		property = project.getPersistentProperty(new QualifiedName (
//				CommonNames.UI_PATH, DS_RUNNING_PORT));
//		runningPort = (property != null && property.length() > 0) ? Integer.parseInt(property) : runningPort;
	}
 
Example #19
Source File: DerbyServerUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void setRunning(IProject proj, Boolean value) throws CoreException {
	try{
		if (value != null && value.equals(Boolean.FALSE)){
			value = null;
		}
		if(proj.isOpen()){
			proj.setSessionProperty(new QualifiedName(CommonNames.UI_PATH,CommonNames.ISRUNNING ),value);
		}
	}catch(Exception e){
		Logger.log("DerbyServerUtils.setRunning() error: "+e, IStatus.ERROR);	
		
	}
	DerbyIsRunningDecorator.performUpdateDecor(proj);
}
 
Example #20
Source File: PythonNatureStore.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public synchronized String getPropertyFromXml(QualifiedName key) {
    if (this.project == null) {
        return "";
    }

    traceFunc("getPropertyFromXml - ", key);
    synchronized (this) {
        checkLoad("getPropertyFromXml");
        try {
            Object object = cache.get(key);
            if (object == NULL_VALUE_IN_CACHE) {
                return null;
            }
            if (object instanceof String) {
                return (String) object;
            }

            Node propertyNode = findPropertyNodeInXml("pydev_property", key);

            if (propertyNode != null) {
                String ret = getTextContent(propertyNode);
                traceFunc("END getPropertyFromXml -- ", ret);
                cache.put(key, ret == null ? NULL_VALUE_IN_CACHE : ret);
                return ret;
            } else {
                cache.put(key, NULL_VALUE_IN_CACHE);
            }

            traceFunc("END getPropertyFromXml (null)");
            return null;
        } catch (Exception e) {
            traceFunc("END getPropertyFromXml (EXCEPTION)");
            throw new RuntimeException("Error on document:" + document + " project:" + project, e);
        }
    }
}
 
Example #21
Source File: PythonNatureStore.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Finds a property node as a direct child of the root node with the specified type and key.
 *
 * @param type
 * @param key
 * @return The property node or null if a node with the supplied key and type cannot be found.
 * @throws MisconfigurationException
 * @throws CoreException
 */
private synchronized Node findPropertyNodeInXml(String type, QualifiedName key) throws MisconfigurationException {
    traceFunc("findPropertyNodeInXml");
    Node root = getRootNodeInXml();
    NodeList childNodes = root.getChildNodes();
    if (childNodes != null && childNodes.getLength() > 0) {
        String keyString = getKeyString(key);
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node child = childNodes.item(i);
            if (child.getNodeName().equals(type)) {
                NamedNodeMap attrs = child.getAttributes();
                if (attrs != null && attrs.getLength() > 0) {
                    Node namedItem = attrs.getNamedItem("name");
                    if (namedItem != null) {
                        String name = namedItem.getNodeValue();
                        if (name != null && name.equals(keyString)) {
                            traceFunc("END findPropertyNodeInXml - ", child);
                            return child;
                        }
                    }
                }
            }
        }
    }
    traceFunc("END findPropertyNodeInXml (null)");
    return null;
}
 
Example #22
Source File: CDEpropertyPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the add to flow.
 *
 * @param project the project
 * @param byDefault the by default
 */
public static void setAddToFlow(IProject project, String byDefault) {
  try {
    project.setPersistentProperty(new QualifiedName("", ADD_TO_FLOW_PROPERTY_KEY), byDefault);
  } catch (CoreException e) {
    throw new InternalErrorCDE("unhandled exception", e);
  }
}
 
Example #23
Source File: CDEpropertyPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public boolean performOk() {
  // store the value in the owner text field
  try {
    ((IResource) getElement()).setPersistentProperty(
            new QualifiedName("", DATAPATH_PROPERTY_KEY), dataPathUI.getText());
  } catch (CoreException e) {
    return false;
  }
  return true;
}
 
Example #24
Source File: PythonNatureStore.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public synchronized Map<String, String> getMapProperty(QualifiedName key) throws CoreException {
    if (this.project == null) {
        return null;
    }
    checkLoad("getMapProperty");

    String[] keyAndValues;
    synchronized (this) {
        Object object = cache.get(key);
        if (object == NULL_VALUE_IN_CACHE) {
            keyAndValues = null;

        } else if (object instanceof String[]) {
            keyAndValues = (String[]) object;

        } else {
            keyAndValues = null;
            try {
                Node propertyNode = findPropertyNodeInXml("pydev_variables_property", key);
                if (propertyNode != null) {
                    keyAndValues = getChildValuesWithType(propertyNode, "key", "value");
                }
            } catch (Exception e) {
                traceFunc("END getMapProperty (EXCEPTION)");
                IStatus status = new Status(IStatus.ERROR, "PythonNatureStore", -1, e.toString(), e);
                throw new CoreException(status);
            }
            cache.put(key, keyAndValues == null ? NULL_VALUE_IN_CACHE : keyAndValues);
        }
    }

    Map<String, String> ret = null;
    if (keyAndValues != null) {
        ret = getMapStringFromArray(keyAndValues);
    }
    traceFunc("END getMapProperty - ", key, ret);
    return ret;
}
 
Example #25
Source File: TypeSystemLocationPropertyPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public boolean performOk() {
  
  // have check, so performOk is only done when ts file is a valid file string
  
  // store the value in the owner text field
  try {
    ((IResource) getElement()).setPersistentProperty(
            new QualifiedName("", TYPE_SYSTEM_PROPERTY), typeSystemText.getText());
  } catch (CoreException e) {
    return false;
  }
  return true;
}
 
Example #26
Source File: CDEpropertyPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the data path.
 *
 * @param project the project
 * @return the data path
 */
public static String getDataPath(IProject project) {
  String dataPath;
  try {
    dataPath = project.getPersistentProperty(new QualifiedName("", DATAPATH_PROPERTY_KEY));
  } catch (CoreException e) {
    dataPath = "";
  }
  if (null == dataPath)
    dataPath = "";
  return dataPath;
}
 
Example #27
Source File: DerbyProperties.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void save(IProject project) throws CoreException {
		
		project.setPersistentProperty(new QualifiedName (
			CommonNames.UI_PATH, DSPORT), Integer.toString(port));
		project.setPersistentProperty(new QualifiedName (
			CommonNames.UI_PATH, DSHOST), host);
		project.setPersistentProperty(new QualifiedName (
			CommonNames.UI_PATH, DS_SYS_HOME), systemHome);
//		project.setPersistentProperty(new QualifiedName (
//				CommonNames.UI_PATH, DS_RUNNING_PORT), Integer.toString(runningPort));
	}
 
Example #28
Source File: CppStylePropertyPage.java    From CppStyle with MIT License 5 votes vote down vote up
public String getPropertyValueString(String key) {
	String value;
	try {
		value = ((IResource) getElement())
				.getPersistentProperty(new QualifiedName("", key));
		if (value == null) {
			return "";
		}

	} catch (CoreException e) {
		return "";
	}

	return value;
}
 
Example #29
Source File: TypeSystemLocationPropertyPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public static void setTypeSystemLocation(IProject project, String typeSystemLocation) {
  
  try {
    project.setPersistentProperty(new QualifiedName("", TYPE_SYSTEM_PROPERTY), typeSystemLocation);
  } catch (CoreException e) {
    CasEditorPlugin.log(e);
  }
}
 
Example #30
Source File: CpplintCheckSettings.java    From CppStyle with MIT License 5 votes vote down vote up
public static String getCpplintRoot(IFile file) {
	IProject project = file.getProject();
	String rootSpec;
	try {
		rootSpec = project.getPersistentProperty(new QualifiedName("", CppStyleConstants.CPPLINT_PROJECT_ROOT));

		if (rootSpec == null || rootSpec.isEmpty()) {
			return null;
		}
	} catch (CoreException e) {
		return null;
	}

	String rootVc = getVersionControlRoot(file);

	if (rootVc == null) {
		return null;
	}

	String relative = new File(rootVc).toURI().relativize(new File(rootSpec).toURI()).getPath();

	if (relative.endsWith("" + Path.SEPARATOR)) {
		return relative.substring(0, relative.length() - 1);
	}

	return relative;
}