/** * Configures a {@link Job} instance using the configuration data held in * this {@link JobOptions}. * * @param job * a {@link Job} to configure (must not be <code>null</code>) */ public void configure(final Job job) { Check.notNull(job, "job"); //$NON-NLS-1$ job.setPriority(priority); job.setSystem(system); job.setUser(user); job.setRule(schedulingRule); for (final Iterator it = properties.keySet().iterator(); it.hasNext();) { final QualifiedName key = (QualifiedName) it.next(); final Object value = properties.get(key); job.setProperty(key, value); } }
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) { } } }
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; }
private void addSecondSection(Composite parent) { Composite composite = createDefaultComposite(parent); // Label for owner field Label ownerLabel = new Label(composite, SWT.NONE); ownerLabel.setText(OWNER_TITLE); // Owner text field ownerText = new Text(composite, SWT.SINGLE | SWT.BORDER); GridData gd = new GridData(); gd.widthHint = convertWidthInCharsToPixels(TEXT_FIELD_WIDTH); ownerText.setLayoutData(gd); // Populate owner text field try { String owner = ((IResource) getElement()).getPersistentProperty( new QualifiedName("", OWNER_PROPERTY)); ownerText.setText((owner != null) ? owner : DEFAULT_OWNER); } catch (CoreException e) { ownerText.setText(DEFAULT_OWNER); } }
@Override public boolean performOk() { boolean retVal = super.performOk(); if (retVal && isPropertyPage()) { try { currentProject().setPersistentProperty(new QualifiedName(qualifiedName(), USE_PROJECT_SETTINGS), String.valueOf(useProjectSettingsButton.getSelection())); ((IPersistentPreferenceStore) getPreferenceStore()).save(); } catch (Exception e) { log.error("Error", e); //$NON-NLS-1$ retVal = false; } } return retVal; }
public static void createEDK2ProjectFromExistingModule(Edk2Module module, IProgressMonitor monitor) throws CoreException { IProject newProjectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(module.getName()); IProjectDescription projDesc; newProjectHandle.create(monitor); newProjectHandle.open(monitor); projDesc = ResourcesPlugin.getWorkspace().newProjectDescription(newProjectHandle.getName()); IPath newProjectPath = newProjectHandle.getLocation(); projDesc.setLocation(newProjectPath); newProjectHandle.setPersistentProperty(new QualifiedName("Uefi_EDK2_Wizards", "EDK2_WORKSPACE"), module.getWorkspacePath()); newProjectHandle.setPersistentProperty(new QualifiedName("Uefi_EDK2_Wizards", "MODULE_ROOT_PATH"), new Path(module.getElementPath()).removeLastSegments(1).toString()); monitor.beginTask("Adding C nature to project", 25); CCorePlugin.getDefault().createCDTProject(projDesc, newProjectHandle, null); ExistingEdk2ModuleProjectCreator.ConfigureProjectNature(newProjectHandle); monitor.beginTask("Creating project structure", 45); ProjectStructureUpdater.UpdateProjectStructureFromModule(newProjectHandle, module); monitor.beginTask("Parsing include paths", 65); ProjectStructureUpdater.updateIncludePaths(newProjectHandle, module); monitor.beginTask("Saving EDK2 project properties", 95); ProjectStructureUpdater.setResourceChangeListeners(newProjectHandle); }
public static void setSyncTimestamp(IResource paramIResource) { if ((paramIResource == null) || (!paramIResource.exists())) { return; } try { if (paramIResource.getType() == 1) { paramIResource.refreshLocal(1, new NullProgressMonitor()); } if (paramIResource.exists()) { long l = paramIResource.getLocalTimeStamp(); QualifiedName localQualifiedName = getSyncModifiedQualifiedName(paramIResource); paramIResource.getProject().setPersistentProperty(localQualifiedName, String.valueOf(l)); } } catch (CoreException localCoreException) { localCoreException.printStackTrace(); } }
/** * We override the performOk method. In case of property pages we copy the values in the * overlay store into the property values of the selected project. * We also save the state of the radio buttons. * * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ public boolean performOk() { boolean result = super.performOk(); if (result && isPropertyPage()) { // Save state of radiobuttons in project properties IResource resource = (IResource) getElement(); try { String value = (useProjectSettingsButton.getSelection()) ? TRUE : FALSE; resource.setPersistentProperty( new QualifiedName(pageId, USEPROJECTSETTINGS), value); } catch (CoreException e) { } } return result; }
/** * We override the performOk method. In case of property pages * we save the state of the radio buttons. * * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ public boolean performOk() { boolean result = super.performOk(); if (result && isPropertyPage()) { // Save state of radiobuttons in project properties IResource resource = (IResource) getElement(); try { String value = (useProjectSettingsButton.getSelection()) ? TRUE : FALSE; resource.setPersistentProperty( new QualifiedName(pageId, USEPROJECTSETTINGS), value); } catch (CoreException e) { } } return result; }
public static void savePreferences(IFile ifile, List<MResource> files) throws CoreException { Map<QualifiedName, String> pmap = ifile.getPersistentProperties(); for (QualifiedName key : pmap.keySet()) { if (key.equals(JrxmlExporter.KEY_REPORT_ISMAIN)) continue; ifile.setPersistentProperty(key, null); } for (MResource f : files) { PublishOptions popt = f.getPublishOptions(); String prefix = f.getValue().getName(); ifile.setPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, prefix + ".overwrite"), Boolean.toString(popt.isOverwrite())); ifile.setPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, prefix + ".reference"), popt.getPublishMethod().toString()); if (popt.getReferencedResource() != null) ifile.setPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, prefix + ".refPATH"), popt.getReferencedResource().getUriString()); else ifile.setPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, prefix + ".refPATH"), null); } }
public static void loadPreferences(IProgressMonitor monitor, IFile ifile, MResource f) { PublishOptions popt = f.getPublishOptions(); String prefix = f.getValue().getName(); try { String ovw = ifile.getPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, prefix + ".overwrite")); if (ovw != null) popt.setOverwrite(Boolean.parseBoolean(ovw)); String ref = ifile.getPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, prefix + ".reference")); if (ref != null) { popt.setPublishMethod(ResourcePublishMethod.valueOf(ref)); String path = ifile.getPersistentProperty(new QualifiedName(Activator.PLUGIN_ID, prefix + ".refPATH")); if (path != null) { ResourceDescriptor rd = new ResourceDescriptor(); rd.setParentFolder(RDUtil.getParentFolder(path)); rd.setUriString(path); rd.setWsType(f.getValue().getWsType()); popt.setReferencedResource(WSClientHelper.getResource(monitor, f, rd, FileUtils.createTempFile("tmp", ""))); } else popt.setPublishMethod(ResourcePublishMethod.LOCAL); } } catch (Exception e) { popt.setPublishMethod(ResourcePublishMethod.LOCAL); e.printStackTrace(); } }
public static Properties loadPreferences(IFile f) throws CoreException { int PLENGHT = PREFIX.length(); Properties props = new Properties(); String p = ""; Map<QualifiedName, String> map = f.getPersistentProperties(); for (QualifiedName qn : map.keySet()) { String key = qn.getLocalName(); String value = map.get(qn); if (key.startsWith(PREFIX)) p += key.substring(PLENGHT) + "=" + value + "\n"; else props.put(key, value); } if (!p.isEmpty()) props.put(NET_SF_JASPERREPORTS_JRPROPERTIES, p); return props; }
private void addFirstSection(Composite parent) { Composite composite = createDefaultComposite(parent); //Label for path field Label pathLabel = new Label(composite, SWT.NONE); pathLabel.setText(PATH_TITLE); // Path text field pathValueText = new FileChooser(composite, true); GridData gd = new GridData(); gd.widthHint = convertWidthInCharsToPixels(TEXT_FIELD_WIDTH); pathValueText.setLayoutData(gd); try { pathValueText.setText(((IResource) getElement()).getPersistentProperty(new QualifiedName("", "OF_ROOT")).toString()); } catch (Exception e) { pathValueText.setText(Activator.getDefault().getPreferenceStore().getString("OF_ROOT")); } }
private static void writeProp(final IResource resource, final String key, final Option<String> optValue) throws CoreException { final IFile propFile = propFile(resource, key); final QualifiedName qnKey = new QualifiedName(QUALIFIER, key); if (optValue.isSome()) { final String value = optValue.some(); final InputStream in = IOUtils.toInputStream(value); if (!propFile.exists()) { mkdirs(propFile); propFile.create(in, true, null); } else propFile.setContents(in, true, true, null); resource.setPersistentProperty(qnKey, value); } else if (propFile.exists()) { propFile.delete(true, null); resource.setPersistentProperty(qnKey, null); } resource.touch(null); }
private void createKarafPlatformResources(final IProgressMonitor monitor) throws CoreException { newKarafProject.getProjectHandle().getFolder(".bin").create(true, true, monitor); newKarafProject.getProjectHandle().getFolder(".bin/platform").create(true, true, monitor); newKarafProject.getProjectHandle().getFolder(".bin/platform/etc").createLink(workingPlatformModel.getParentKarafModel().getConfigurationDirectory(), 0, monitor); newKarafProject.getProjectHandle().getFolder(".bin/platform/deploy").createLink(workingPlatformModel.getParentKarafModel().getUserDeployedDirectory(), 0, monitor); newKarafProject.getProjectHandle().getFolder(".bin/platform/lib").createLink(workingPlatformModel.getParentKarafModel().getRootDirectory().append("lib"), 0, monitor); newKarafProject.getProjectHandle().getFolder(".bin/platform/system").createLink(workingPlatformModel.getParentKarafModel().getPluginRootDirectory(), 0, monitor); newKarafProject.getProjectHandle().getFolder(".bin/runtime").create(true, true, monitor); // TODO: Is this the right way to add the current installation? final IDynamicVariable eclipseHomeVariable = VariablesPlugin.getDefault().getStringVariableManager().getDynamicVariable("eclipse_home"); final String eclipseHome = eclipseHomeVariable.getValue(""); newKarafProject.getProjectHandle().getFolder(".bin/platform/eclipse").create(true, true, monitor); newKarafProject.getProjectHandle().getFolder(".bin/platform/eclipse/dropins").createLink(new Path(eclipseHome).append("dropins"), 0, monitor); newKarafProject.getProjectHandle().getFolder(".bin/platform/eclipse/plugins").createLink(new Path(eclipseHome).append("plugins"), 0, monitor); newKarafProject.getProjectHandle().setPersistentProperty( new QualifiedName(KarafUIPluginActivator.PLUGIN_ID, "karafProject"), "true"); newKarafProject.getProjectHandle().setPersistentProperty( new QualifiedName(KarafUIPluginActivator.PLUGIN_ID, "karafModel"), karafPlatformModel.getRootDirectory().toString()); }
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; }
public boolean performOk() { try { ((IResource) getElement()).setPersistentProperty(new QualifiedName( "", CppStyleConstants.PROJECTS_PECIFIC_PROPERTY), new Boolean(projectSpecificButton.getSelection()) .toString()); ((IResource) getElement()).setPersistentProperty(new QualifiedName( "", CppStyleConstants.ENABLE_CPPLINT_PROPERTY), new Boolean(enableCpplintOnSaveButton.getSelection()) .toString()); ((IResource) getElement()).setPersistentProperty(new QualifiedName( "", CppStyleConstants.ENABLE_CLANGFORMAT_PROPERTY), new Boolean(enableClangFormatOnSaveButton.getSelection()) .toString()); ((IResource) getElement()).setPersistentProperty(new QualifiedName( "", CppStyleConstants.CPPLINT_PROJECT_ROOT), projectRoot .getStringValue()); } catch (CoreException e) { return false; } return true; }
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; }
/** * @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; }
/** * 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 ); } }
/** * Returns the given property's Eclipse value converted to EMF's corresponding basic value. * @param qualifiedName the name of the property for which this value applies. * @param value the value to convert. * @return the given property's Eclipse value converted to EMF's corresponding basic value. */ protected Object getDescriptionValue(QualifiedName qualifiedName, Object value) { if (value == null) { return null; } else if (IContentDescription.BYTE_ORDER_MARK.equals(qualifiedName)) { for (ByteOrderMark byteOrderMarker : ContentHandler.ByteOrderMark.values()) { if (value == byteOrderMarker.bytes()) { return byteOrderMarker; } } return null; } else { return value; } }
/** * Returns the given property's basic EMF value converted to the corresponding Eclipse value. * @param qualifiedName the name of the property for which this value applies. * @param value the value to convert. * @return the given property's basic EMF value converted to the corresponding Eclipse value. */ protected Object getDescriptionValue(QualifiedName qualifiedName, Object value) { if (value == null) { return null; } else if (IContentDescription.BYTE_ORDER_MARK.equals(qualifiedName)) { return ((ContentHandler.ByteOrderMark)value).bytes(); } else { return value; } }
@Override public synchronized String getPropertyFromXml(QualifiedName key) { if (this.project == null) { return ""; } traceFunc("getPropertyFromXml - ", key); synchronized (this) { checkLoad("getPropertyFromXml"); try { Node propertyNode = findPropertyNodeInXml("pydev_property", key); if (propertyNode != null) { String ret = getTextContent(propertyNode); traceFunc("END getPropertyFromXml -- ", ret); return ret; } traceFunc("END getPropertyFromXml (null)"); return null; } catch (Exception e) { traceFunc("END getPropertyFromXml (EXCEPTION)"); throw new RuntimeException("Error on document:" + document + " project:" + project, e); } } }
/** * Retrieve the value of a path property from the Xml representation. If the property is not found in the Xml document, the eclipse persistent property of the same key is read and migrated to the * xml representation. * * @param key * @return the array of strings representing paths * @throws CoreException */ private String[] getPathPropertyFromXml(QualifiedName key) throws CoreException { traceFunc("getPathPropertyFromXml"); synchronized (this) { try { Node propertyNode = findPropertyNodeInXml("pydev_pathproperty", key); if (propertyNode != null) { traceFunc("END getPathPropertyFromXml"); return getChildValuesWithType(propertyNode, "path"); } traceFunc("END getPathPropertyFromXml (null)"); return null; } catch (Exception e) { traceFunc("END getPathPropertyFromXml (EXCEPTION)"); IStatus status = new Status(IStatus.ERROR, "PythonNatureStore", -1, e.toString(), e); throw new CoreException(status); } } }
private String readProperty(String key) { String result = null; try { result = FileUtil.readPropertyInXMLFile(getPropertiesFile(), key); } catch (IOException e) { try { result = getJavaProject().getCorrespondingResource().getPersistentProperty(new QualifiedName("TomcatProject", key)); } catch (Exception e2) { TomcatLauncherPlugin.log(e2); } } if(result == null) { result = ""; } return result; }
/** * Removes all persistent properties previously stored by this class from the * associated .xtp/.itp file resource. */ public void clear() { if (!bPersistent || iFile==null || !iFile.exists()) return; try { Set<?> iKeys = iFile.getPersistentProperties().keySet(); Iterator<?> i = iKeys.iterator(); while (i.hasNext()) { QualifiedName iKey = (QualifiedName)i.next(); if (iKey.getQualifier().equals(DLabProPlugin.PLUGIN_NAME)) iFile.setPersistentProperty(iKey,null); } } catch (CoreException e) { e.printStackTrace(); } }
/** * Convenience method. Gets one persistent property of the associated resource. * * @param sKey * the key * @return the value or <code>null</code> if no such property exists */ private String getPersistentProperty(String sKey) { if (iFile==null || !iFile.exists()) return null; try { QualifiedName iQn = new QualifiedName(DLabProPlugin.PLUGIN_NAME,sKey); return iFile.getPersistentProperty(iQn); } catch (CoreException e) { e.printStackTrace(); return null; } }
static public String getProperty(IResource resource, String qualifiedProperyName) throws PropertyNotFoundException { int index = qualifiedProperyName.lastIndexOf("."); String qualifer = qualifiedProperyName.substring(0, index); String localName = qualifiedProperyName.substring(index+1); QualifiedName key = new QualifiedName(qualifer, localName); String result = ""; try { result = resource.getPersistentProperty(key); if ( result == null ) throw new PropertyNotFoundException(resource, qualifiedProperyName); } catch (CoreException e) {} return result; }
static public void setProperty(IResource resource, String qualifiedProperyName, boolean value) { int index = qualifiedProperyName.lastIndexOf("."); String qualifer = qualifiedProperyName.substring(0, index); String localName = qualifiedProperyName.substring(index+1); QualifiedName key = new QualifiedName(qualifer, localName); try { resource.setPersistentProperty(key, String.valueOf(value)); } catch (CoreException e) { e.printStackTrace(); } }
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)); }
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; }
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); }
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(); }
/** * 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; }
/** * Write a project property. This value will be stored to the project settings file on disk. * * @param project the current project * @param property the name of the property * @param value new value for the property */ public static void setProjectProperty(IResource project, String property, String value) { try { project.setPersistentProperty(new QualifiedName(TexlipseProperties.PACKAGE_NAME, property), value); } catch (CoreException e) { // do nothing } }
/** * 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; }
/** * Write a session property. This value will be stored only in memory as long as Eclipse is still running. * * @param project the current project * @param property the name of the property * @param value new value for the session property */ public static void setSessionProperty(IResource project, String property, Object value) { try { project.setSessionProperty(new QualifiedName(TexlipseProperties.PACKAGE_NAME, property), value); } catch (CoreException e) { // do nothing } }