private void fix(IMarker marker, IProgressMonitor monitor) { MarkerResolutionGenerator.printAttributes (marker); try { String filepath = (String) marker.getAttribute(BuildPolicyConfigurationException.JAVAFILENAME); int start = (int) marker.getAttribute(IMarker.CHAR_START); int end = (int) marker.getAttribute(IMarker.CHAR_END); IFile ifile = (IFile) ResourceManager.toResource(new Path(filepath)); ICompilationUnit cu = JavaCore.createCompilationUnitFrom(ifile); String source = cu.getBuffer().getContents(); String part1 = source.substring(0,start); String part2 = source.substring(end); source = part1 + "value=\"" + resolutionMarkerDescription.getGenerator() + "\"" + part2; final Document document = new Document(source); cu.getBuffer().setContents(document.get()); cu.save(monitor, false); } catch (Exception e) { ResourceManager.logException(e); } }
@Override public IEditorInput getEditorInput(Object element) { if (element instanceof ILineBreakpoint) { return new FileEditorInput((IFile) ((ILineBreakpoint) element).getMarker().getResource()); } IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(element.toString())); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile[] files = root.findFilesForLocationURI(fileStore.toURI()); if (files != null) { for (IFile file : files) { if (file.exists()) { return new FileEditorInput(file); } } } return new FileStoreEditorInput(fileStore); }
private boolean process(Object element, RenameArguments arguments) { if (element instanceof IFile) { originalFile = (IFile) element; newName = arguments.getNewName(); if (!acceptFile(originalFile)) return false; RenameChange operation = new RenameGraphFileChange(originalFile.getProject(),originalFile.getFullPath(), newName); renameOperations.add(operation); return true; } if (element instanceof IFolder) { IFolder folder = (IFolder) element; MoveGraphParticipant mgp = new MoveGraphParticipant(); moveOperations.addAll(mgp.create(folder,(folder.getParent().getFolder(new Path(arguments.getNewName()))))); return moveOperations.size()>0; } return false; }
public ExportCommand(String containerName, String fileName, String fileType, String content) { super(); this.containerName = containerName; this.fileName = fileName; this.fileType = fileType; this.content = content; wsRoot = ResourcesPlugin.getWorkspace().getRoot(); names = StringUtils.split(containerName, "/"); wsRootRes = wsRoot.findMember(new Path("/" + names[0])); prj = wsRootRes.getProject(); target = prj.getFolder("target"); steps = prj.getFolder("target/Steps"); types = prj.getFolder("target/Steps/0-Types"); srvcs = prj.getFolder("target/Steps/1-Services"); cdef = prj.getFolder("target/Steps/2-ComponentDefinitions"); iassm = prj.getFolder("target/Steps/3-InitialAssembly"); cimpl = prj.getFolder("target/Steps/4-ComponentImplementations"); intgr = prj.getFolder("target/Steps/5-Integration"); }
/** * @param projectname * @param folder * @param filename * @return whether the file exists in the specified project & folder * @throws CoreException */ public static File getFile(String projectname, String folder, String pkg, String filename) throws CoreException { IProject project = getProject(projectname); IFolder destFolder = project.getFolder(new Path(folder)); IFolder container = destFolder; if (pkg != null) { StringTokenizer st = new StringTokenizer(pkg, "/"); while (st.hasMoreTokens()) { String dir = st.nextToken(); IFolder f = container.getFolder(new Path(dir)); if (!f.exists()) { f.create(true, true, null); } container = f; } } IFile file = container.getFile(new Path(filename)); return file.getRawLocation().makeAbsolute().toFile(); }
/** * Check nested subjob to collect external files. * @param externalFilesPathList * @param subJobPath * @param tranformComponentList */ private void checkSubJobForExternalFiles(List<String> externalFilesPathList,String subJobPath, List<String> tranformComponentList) { Object obj=null; try { obj = CanvasUtils.INSTANCE.fromXMLToObject(new FileInputStream(new File(JobManager.getAbsolutePathFromFile(new Path(subJobPath))))); } catch (FileNotFoundException e) { logger.error("subjob xml not found "+e); } if(obj!=null && obj instanceof Container){ Container container = (Container) obj; for (Component component : container.getUIComponentList()){ addExternalTransformFiles(externalFilesPathList, component, tranformComponentList); Schema schema = (Schema) component.getProperties().get(Constants.SCHEMA_PROPERTY_NAME); if(schema!=null && schema.getIsExternal()){ externalFilesPathList.add(schema.getExternalSchemaPath()); } if(Constants.SUBJOB_COMPONENT.equals(component.getComponentName())){ String subJob=(String) component.getProperties().get(Constants.PATH_PROPERTY_NAME); checkSubJobForExternalFiles(externalFilesPathList, subJob,tranformComponentList); } } } }
/** * Open the dialog to select a module specifier * * @param shell * The Shell to open the dialog in */ public void openModuleSpecifierDialog(Shell shell) { ModuleSpecifierSelectionDialog dialog = new ModuleSpecifierSelectionDialog(shell, model.getProject().append(model.getSourceFolder())); if (!model.getModuleSpecifier().isEmpty()) { String initialSelectionSpecifier = model.getModuleSpecifier(); dialog.setInitialSelection(initialSelectionSpecifier); } dialog.open(); Object result = dialog.getFirstResult(); if (result instanceof String) { IPath specifierPath = new Path((String) result); model.setModuleSpecifier(specifierPath.removeFileExtension().toString()); } }
/** * Performance tests for search: Indexing entire workspace * * First wait that already started indexing jobs ends before performing test and measure. * Consider this initial indexing jobs as warm-up for this test. */ public void testIndexing() throws CoreException { // Wait for indexing end (we use initial indexing as warm-up) AbstractJavaModelTests.waitUntilIndexesReady(); // Remove project previous indexing INDEX_MANAGER.removeIndexFamily(new Path("")); INDEX_MANAGER.reset(); // Restart brand new indexing INDEX_MANAGER.request(new Measuring(true)); for (int j=0, length=ALL_PROJECTS.length; j<length; j++) { if (DACAPO_PRINT) System.out.print("."); INDEX_MANAGER.indexAll(ALL_PROJECTS[j].getProject()); } waitUntilIndexesReady(); }
private void checkIfXPathIsDuplicate( ) { Text loopXpathQueryTextBox=(Text)table.getData(); String loopXPathQuery=loopXpathQueryTextBox.getText(); Set<Path> setToCheckDuplicates= new HashSet<Path>(); Set<String> uniqueName=new HashSet<>(); for(TableItem tableItem:table.getItems()){ Path xPathColumn=makeXPathAbsoluteIfNot(tableItem.getText(2), loopXPathQuery); if(!uniqueName.add(tableItem.getText(0))){ tableItem.setData(Constants.ERROR_MESSAGE,FIELD_IS_DUPLICATE); setRedColor(tableItem); } else if(!setToCheckDuplicates.add(xPathColumn)){ tableItem.setData(Constants.ERROR_MESSAGE,Messages.X_PATH_IS_DUPLICATE); setRedColor(tableItem); } else{ tableItem.setData(Constants.ERROR_MESSAGE,""); setBlackColor(tableItem); } } }
/** * Getting an IFile from an EMF Resource * * @param eObject * @return */ public static IFile getIFile(Resource res) { URI uri = res.getURI(); String filePath = uri.toPlatformString(true); IFile ifile = ResourcesPlugin.getWorkspace().getRoot() .getFile(new Path(filePath)); return ifile; }
@Override public Set<String> getParentRepos() { String parents; try { parents = prefs.get(JPFClasspathPlugin.PREF_PARENT_REGISTRIES, ""); } catch( IllegalStateException ise ) { refreshPrefs(); parents = prefs.get(JPFClasspathPlugin.PREF_PARENT_REGISTRIES, ""); } Path path = new Path(parents); Set<String> parentSet = new HashSet<>(); for( String parentStr : path.segments() ) { if( parentStr.length() > 0 ) { parentSet.add(parentStr); } } return parentSet; }
@Test public void testUpdatePathGeneratorInSourceFile () throws CoreException, FileNotFoundException { System.out.println("XXXXXXXXXXXXXXXXXXXX testUpdatePathGeneratorInSourceFile"); String expectedNewGenerator = "random(vertex_coverage(50))"; PetClinicProject.create (bot,gwproject); // At this step the generator is "random(edge_coverage(100))" IFile veterinarien = PetClinicProject.getVeterinariensSharedStateImplFile(gwproject); ICompilationUnit cu = JavaCore.createCompilationUnitFrom(veterinarien); String oldGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu); SourceHelper.updatePathGenerator(veterinarien, oldGenerator, expectedNewGenerator); cu = JavaCore.createCompilationUnitFrom(veterinarien); String newGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu); assertEquals(newGenerator,expectedNewGenerator); String location = JDTManager.getGW4EGeneratedAnnotationValue(cu,"value"); IPath path = new Path (gwproject).append(location); IFile graphModel = (IFile)ResourceManager.getResource(path.toString()); IPath buildPolicyPath = ResourceManager.getBuildPoliciesPathForGraphModel(graphModel); IFile buildPolicyFile = (IFile)ResourceManager.getResource(buildPolicyPath.toString()); PropertyValueCondition condition = new PropertyValueCondition(buildPolicyFile,graphModel.getName(),"random(edge_coverage(100));I;random(vertex_coverage(50));I;"); bot.waitUntil(condition); }
/** * The framework calls this to see if the file is correct. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected boolean validatePage () { if ( super.validatePage () ) { String extension = new Path ( getFileName () ).getFileExtension (); if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) ) { String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$ setErrorMessage ( NextGenerationProtocolEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) ); return false; } return true; } return false; }
/** * The framework calls this to see if the file is correct. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override protected boolean validatePage () { if ( super.validatePage () ) { final String extension = new Path ( getFileName () ).getFileExtension (); if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) ) { final String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$ setErrorMessage ( ChartEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) ); return false; } return true; } return false; }
public static TestResourceGeneration get (IFile file) throws CoreException, FileNotFoundException { String targetFolder = GraphWalkerContextManager.getTargetFolderForTestImplementation(file); IPath pkgFragmentRootPath = file.getProject().getFullPath().append(new Path(targetFolder)); IPackageFragmentRoot implementationFragmentRoot = JDTManager.getPackageFragmentRoot(file.getProject(), pkgFragmentRootPath); String classname = file.getName().split("\\.")[0]; classname = classname + PreferenceManager.suffixForTestImplementation(implementationFragmentRoot.getJavaProject().getProject().getName()) + ".java"; ClassExtension ce = PreferenceManager.getDefaultClassExtension(file); IPath p = ResourceManager.getPathWithinPackageFragment(file).removeLastSegments(1); p = implementationFragmentRoot.getPath().append(p); ResourceContext context = new ResourceContext(p, classname, file, true, false, false, ce); TestResourceGeneration trg = new TestResourceGeneration(context); return trg; }
/** ** * This methods loads schema from external schema file * * @param externalSchemaFilePath * @param schemaType * @return */ public List<GridRow> loadSchemaFromExternalFile(String externalSchemaFilePath,String schemaType) { IPath filePath=new Path(externalSchemaFilePath); IPath copyOfFilePath=filePath; if (!filePath.isAbsolute()) { filePath = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath).getRawLocation(); } if(filePath!=null && filePath.toFile().exists()){ GridRowLoader gridRowLoader=new GridRowLoader(schemaType, filePath.toFile()); return gridRowLoader.importGridRowsFromXML(); }else{ MessageBox messageBox=new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_ERROR); messageBox.setMessage(Messages.FAILED_TO_IMPORT_SCHEMA_FILE+"\n"+copyOfFilePath.toString()); messageBox.setText(Messages.ERROR); messageBox.open(); } return null; }
private IPath getParameterFileIPath(){ if(getEditorInput() instanceof IFileEditorInput){ IFileEditorInput input = (IFileEditorInput)getEditorInput() ; IFile file = input.getFile(); IProject activeProject = file.getProject(); String activeProjectName = activeProject.getName(); IPath parameterFileIPath =new Path("/"+activeProjectName+"/param/"+ getPartName().replace(".job", ".properties")); activeProjectName.concat("_").concat(getPartName().replace(".job", "_")); return parameterFileIPath; }else{ return null; } }
/** * The framework calls this to see if the file is correct. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected boolean validatePage () { if ( super.validatePage () ) { String extension = new Path ( getFileName () ).getFileExtension (); if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) ) { String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$ setErrorMessage ( WorldEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) ); return false; } return true; } return false; }
/** * The framework calls this to see if the file is correct. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override protected boolean validatePage () { if ( super.validatePage () ) { final String extension = new Path ( getFileName () ).getFileExtension (); if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) ) { final String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$ setErrorMessage ( MemoryEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) ); return false; } return true; } return false; }
/** * The framework calls this to see if the file is correct. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected boolean validatePage () { if ( super.validatePage () ) { String extension = new Path ( getFileName () ).getFileExtension (); if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) ) { String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$ setErrorMessage ( SecurityEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) ); return false; } return true; } return false; }
private ModelData[] getModels(ILaunchConfiguration config) throws CoreException { List<ModelData> temp = new ArrayList<ModelData>(); String paths = config.getAttribute(CONFIG_GRAPH_MODEL_PATHS, ""); if (paths == null || paths.trim().length() == 0) return new ModelData[0]; StringTokenizer st = new StringTokenizer(paths, ";"); st.nextToken(); // the main model path st.nextToken(); // main model : Always "1" st.nextToken(); // the main path generator while (st.hasMoreTokens()) { String path = st.nextToken(); IFile file = (IFile) ResourceManager .getResource(new Path(path).toString()); if (file==null) continue; ModelData data = new ModelData(file); boolean selected = st.nextToken().equalsIgnoreCase("1"); String pathGenerator = st.nextToken(); data.setSelected(selected); data.setSelectedPolicy(pathGenerator); if (selected) temp.add(data); } ModelData[] ret = new ModelData[temp.size()]; temp.toArray(ret); return ret; }
@Override public void run() { if (GenerationUtils.validate(containerName)) { Shell shell = Display.getDefault().getActiveShell(); boolean confirm = MessageDialog.openQuestion(shell, "Confirm Create", "Existing Files will be cleared. Do you wish to continue?"); if (confirm) { wsRoot = ResourcesPlugin.getWorkspace().getRoot(); names = StringUtils.split(containerName, "/"); wsRootRes = wsRoot.findMember(new Path("/" + names[0])); prj = wsRootRes.getProject(); steps = prj.getFolder("target/Steps"); File root = new File(steps.getLocation().toOSString()); if (root.exists()) { GenerationUtils.clearCreatedFolders(root); } for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { try { project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException e) { } } } } }
/** * The framework calls this to see if the file is correct. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected boolean validatePage () { if ( super.validatePage () ) { String extension = new Path ( getFileName () ).getFileExtension (); if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) ) { String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$ setErrorMessage ( ExecEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) ); return false; } return true; } return false; }
public void openXslEditor(IProject project) { Sheet sheet = getObject(); String projectName = sheet.getProject().getName(); String parentStyleSheet = sheet.getUrl(); Path filePath = new Path(sheet.getUrl()); IFile file = project.getFile(filePath); IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { try { activePage.openEditor(new XslFileEditorInput(file, projectName, sheet), "com.twinsoft.convertigo.eclipse.editors.xsl.XslRuleEditor"); } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while loading the xsl editor '" + parentStyleSheet + "'"); } } }
@Override public void run(IIntroSite site, Properties params) { WorkspaceModifyOperation op = new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IProject project = createProject(monitor); createExample(project); } }; try { PlatformUI.getWorkbench().getProgressService().run(true, true, op); final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager(); IIntroPart part = introManager.getIntro(); introManager.closeIntro(part); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IDE.openEditor(page, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("hello-world/greeter.sol"))); } catch (Exception e) { e.printStackTrace(); } }
/** * Uses the standard container selection dialog to * choose the new value for the container field. */ private void handleBrowse() { ContainerSelectionDialog dialog = new ContainerSelectionDialog( getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, "Select new file container"); if (dialog.open() == ContainerSelectionDialog.OK) { Object[] result = dialog.getResult(); if (result.length == 1) { containerText.setText(((Path)result[0]).toOSString()); } } }
/** * @see PreferencePage#performOk */ @Override public boolean performOk() { if( !modified ) { return true; } IPath path = Path.EMPTY; Object[] checked = listViewer.getCheckedElements(); for( Object elements : checked ) { path = path.append(((IProject) elements).getName()); } IPreferenceStore prefs = getPreferenceStore(); prefs.setValue(JPFClasspathPlugin.PREF_PARENT_REGISTRIES, path.toString()); try { ((IPersistentPreferenceStore) prefs).save(); } catch( IOException e ) { JPFClasspathLog.logError(e); } return true; }
/** * Create from scratch a build policy file if it does not exists * * @param resource * @return the build file * @throws CoreException * @throws InterruptedException */ public static IFile createBuildPoliciesFile(IFile resource, IProgressMonitor monitor) throws CoreException, InterruptedException { String buildPolicyFilename = PreferenceManager.getBuildPoliciesFileName(resource.getProject().getName()); IFile buildfile = (IFile) ResourceManager.resfreshFileInContainer(resource.getParent(), buildPolicyFilename); if (buildfile == null || !buildfile.exists()) { byte[] bytes = getDefaultBuildFileComment().getBytes(); InputStream source = new ByteArrayInputStream(bytes); buildfile = resource.getParent().getFile(new Path(buildPolicyFilename)); buildfile.create(source, IResource.NONE, null); buildfile.refreshLocal(IResource.DEPTH_INFINITE, monitor); } return buildfile; }
/** * @param file * @return * @throws CoreException */ public static AbstractPostConversion getDefaultGraphConversion(IFile file,boolean generateOnlyInterface) throws CoreException { AbstractPostConversion converter = null; boolean canBeConverted = PreferenceManager.isGraphModelFile(file); if (canBeConverted) { String targetFolder = GraphWalkerContextManager.getTargetFolderForTestImplementation(file); IPath pkgFragmentRootPath = file.getProject().getFullPath().append(new Path(targetFolder)); IPackageFragmentRoot implementationFragmentRoot = JDTManager.getPackageFragmentRoot(file.getProject(), pkgFragmentRootPath); String classname = file.getName().split("\\.")[0]; classname = classname + PreferenceManager.suffixForTestImplementation( implementationFragmentRoot.getJavaProject().getProject().getName()) + ".java"; ClassExtension ce = PreferenceManager.getDefaultClassExtension(file); IPath p = ResourceManager.getPathWithinPackageFragment(file).removeLastSegments(1); p = implementationFragmentRoot.getPath().append(p); ResourceContext context = new ResourceContext(p, classname, file, true, false, generateOnlyInterface, ce); converter = new JavaTestBasedPostConversionImpl(context); } return converter; }
public ArrayList<String> getResourcesWithExtension(String ext, String containerName) { ArrayList<String> ret = new ArrayList<String>(); if (containerName != null) { String[] names = StringUtils.split(containerName, "/"); IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = wsRoot.findMember(new Path("/" + names[0])); IPath loc = resource.getLocation(); File prjLoc = new File(loc.toString()); Collection<File> res = FileUtils.listFiles(prjLoc, FileFilterUtils.suffixFileFilter(ext, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE); for (File file : res) ret.add(file.getAbsolutePath()); } return ret; }
@Test public void testGetPackageFragment() throws Exception { IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, true, false); ResourceManager.createFile(project.getProject().getName(), "src/test/resources", "mypkg/subpkg", "test.java", ""); IPackageFragment pf = ResourceManager.getPackageFragment(project.getProject(), new Path("src/test/resources/mypkg/subpkg")); assertNotNull(pf); IPackageFragment frag = (IPackageFragment) project.findElement(new Path("mypkg/subpkg")); IPackageFragmentRoot pfr = ResourceManager.getPackageFragmentRoot(project.getProject(), frag); pf = ResourceManager.getPackageFragment(project.getProject(), pfr.getPath().removeFirstSegments(1)); assertNotNull(pf); }
private void fix(IMarker marker, IProgressMonitor monitor) { try { IPath graphModelPath = new Path ((String)marker.getAttribute(BuildPolicyConfigurationException.GRAPHMODELPATH)); IFile ifile = (IFile) ResourceManager.toResource(graphModelPath); BuildPolicyManager.addDefaultPolicies(ifile,monitor); marker.delete(); } catch (Exception e) { ResourceManager.logException(e); } }
private IFile updateGraphAndConvertToTargetXML(String newUniiqueJobId, IFile jobFile, Container container) { IPath xmlFileIPath = new Path(jobFile.getFullPath().toOSString()); xmlFileIPath = xmlFileIPath.removeFileExtension().addFileExtension(Constants.XML_EXTENSION_FOR_IPATH); IFile fileXml = ResourcesPlugin.getWorkspace().getRoot().getFile(xmlFileIPath); try { ConverterUtil.INSTANCE.convertToXML(container, false, fileXml, null); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException exception) { MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_ERROR); messageBox.setMessage("Exception occurred while creating XML file. Please check logs."); messageBox.open(); LOGGER.error("Exception while converting into xml",exception); } return fileXml; }
/** * The framework calls this to see if the file is correct. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected boolean validatePage() { if (super.validatePage()) { String extension = new Path(getFileName()).getFileExtension(); if (extension == null || !FILE_EXTENSIONS.contains(extension)) { String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; setErrorMessage(ConstraintsEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS })); return false; } return true; } return false; }
/** * Module specifier specifier property constraints */ @Override protected void validateModuleSpecifier() throws ValidationException { String effectiveModuleSpecifier = getModel().getEffectiveModuleSpecifier(); // Invoke super validation procedure on full effective module specifier doValidateModuleSpecifier(effectiveModuleSpecifier); /* Check for potential file collisions */ if (isFileSpecifyingModuleSpecifier(effectiveModuleSpecifier)) { IProject moduleProject = ResourcesPlugin.getWorkspace().getRoot() .getProject(getModel().getProject().toString()); IPath effectiveModulePath = new Path(getModel().getEffectiveModuleSpecifier()); IPath n4jsdPath = getModel().getSourceFolder() .append(effectiveModulePath.addFileExtension(N4JSGlobals.N4JSD_FILE_EXTENSION)); IPath n4jsPath = getModel().getSourceFolder() .append(effectiveModulePath.addFileExtension(N4JSGlobals.N4JS_FILE_EXTENSION)); if (getModel().isDefinitionFile() && moduleProject.exists(n4jsPath)) { throw new ValidationException( String.format(ErrorMessages.THE_NEW_DEFINITION_MODULE_COLLIDES_WITH_THE_SOURCE_FILE, moduleProject.getFullPath().append(n4jsPath))); } else if (!getModel().isDefinitionFile() && moduleProject.exists(n4jsdPath)) { throw new ValidationException(String .format(ErrorMessages.THE_NEW_SOURCE_MODULE_COLLIDES_WITH_THE_DEFINITION_FILE, moduleProject.getFullPath().append(n4jsdPath))); } } }
private IJavaProject createJavaProject(String name) throws CoreException { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); if (project.exists()) project.delete(true, null); project.create(null); project.open(null); IProjectDescription description = project.getDescription(); description.setNatureIds(new String[] { JavaCore.NATURE_ID }); project.setDescription(description, null); IJavaProject javaProject = JavaCore.create(project); javaProject.setRawClasspath(new IClasspathEntry[] { JavaCore.newVariableEntry(new Path("JRE_LIB"), null, null) }, null); return javaProject; }
@Override public Object convert(Object fromObject) { if (fromObject instanceof String) { return new Path(((String) fromObject)); } return null; }
/** * The framework calls this to see if the file is correct. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected boolean validatePage() { if (super.validatePage()) { String extension = new Path(getFileName()).getFileExtension(); if (extension == null || !FILE_EXTENSIONS.contains(extension)) { String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; setErrorMessage(LibraryEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS })); return false; } return true; } return false; }
@Override public URI getLocation(URI projectURI, ProjectReference projectReference, N4JSSourceContainerType expectedN4JSSourceContainerType) { if (projectURI.segmentCount() >= DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) { String expectedProjectName = projectReference.getProject().getProjectId(); if (expectedProjectName != null && expectedProjectName.length() > 0) { IProject existingProject = workspace.getProject(expectedProjectName); if (existingProject.isAccessible()) { if (expectedN4JSSourceContainerType == N4JSSourceContainerType.ARCHIVE) { return null; } else { return URI.createPlatformResourceURI(expectedProjectName, true); } } else if (expectedN4JSSourceContainerType == N4JSSourceContainerType.ARCHIVE) { for (String libFolder : getLibraryFolders(projectURI)) { IFile archiveFile = workspace.getFile(new Path(projectURI.segment(1) + "/" + libFolder + "/" + expectedProjectName + IN4JSArchive.NFAR_FILE_EXTENSION_WITH_DOT)); if (archiveFile.exists()) { return URI.createPlatformResourceURI(archiveFile.getFullPath().toString(), true); } } } } } return null; }