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); } }
private void copyBuildFile(String source, IProject project) throws CoreException { File sourceFileLocation = new File(source); File[] listFiles = sourceFileLocation.listFiles(); if(listFiles != null){ for(File sourceFile : listFiles){ IFile destinationFile = project.getFile(sourceFile.getName()); try(InputStream fileInputStream = new FileInputStream(sourceFile)) { if(!destinationFile.exists()){ //used while importing a project destinationFile.create(fileInputStream, true, null); } } catch (IOException | CoreException exception) { logger.debug("Copy build file operation failed"); throw new CoreException(new MultiStatus(Activator.PLUGIN_ID, 100, "Copy build file operation failed", exception)); } } } }
private boolean deleteCorrospondingJobAndPropertyFileifUserDeleteXmlFile(IProject iProject) { if (modifiedResource.getProjectRelativePath()!=null && StringUtils.equalsIgnoreCase(modifiedResource.getProjectRelativePath().segment(0), CustomMessages.ProjectSupport_JOBS)) { IFile propertyFileName = null; IFolder jobsFolder = iProject.getFolder(CustomMessages.ProjectSupport_JOBS); IFolder propertiesFolder = iProject.getFolder(Messages.PARAM); if (jobsFolder != null) { jobIFile=jobsFolder.getFile(modifiedResource.getFullPath().removeFirstSegments(2).removeFileExtension().addFileExtension(Constants.JOB_EXTENSION_FOR_IPATH)); } if (propertiesFolder != null) { propertyFileName = propertiesFolder.getFile(modifiedResource.getFullPath().removeFileExtension() .addFileExtension(Constants.PROPERTIES).toFile().getName()); } String message = getErrorMessageIfUserDeleteXmlRelatedFiles(jobIFile, propertyFileName); showErrorMessage(jobIFile, propertyFileName, Messages.bind(message, modifiedResource.getName())); } else { flag = true; } return flag; }
/** * Create a Message Box displays a currentJob UniqueId and a message to * generate new Unique Id. * @param container * @param jobFile * @param isSubjob * @return {@link Integer} */ private int showMessageForGeneratingUniqueJobId(Container container, IFile jobFile, boolean isSubJob) { int buttonId = SWT.NO; if(StringUtils.isBlank(container.getUniqueJobId())){ return SWT.YES; } MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO); messageBox.setText("Question"); String previousUniqueJobId = container.getUniqueJobId(); if (isSubJob) { messageBox.setMessage(Messages.bind(Messages.GENERATE_NEW_UNIQUE_JOB_ID_FOR_SUB_JOB, jobFile.getName(), previousUniqueJobId)); } else { messageBox.setMessage( Messages.bind(Messages.GENERATE_NEW_UNIQUE_JOB_ID_FOR_JOB, jobFile.getName(), previousUniqueJobId)); } buttonId = messageBox.open(); return buttonId; }
/** * Open the only solution if only one file has the correct extension * Otherwise invite to select the file to open * @param project * @param fileExtension */ public static void openPossibleFileWithExtensionInProject(IProject project, String fileExtension) { FileFinderVisitor finder = new FileFinderVisitor(fileExtension); try { project.accept(finder); List<IFile> list =finder.getFiles(); if(list.size() == 1) { openIFile(list.get(0)); } else{ openPossibleFileInProject(project,"*."+fileExtension); } } catch (CoreException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
@Override public IFile getActiveFile() { IProject projectWithGenmodel = this.getProject(this.gemocLanguageProject); FileFinderVisitor genmodelFinder = new FileFinderVisitor("genmodel"); try { projectWithGenmodel.accept(genmodelFinder); } catch (CoreException e) { Activator.error(e.getMessage(), e); } if(genmodelFinder.getFiles().size() > 0){ return genmodelFinder.getFiles().get(0); } else { return null; } }
@Test public void testCloseEditor() throws Exception { IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, true, true); IFile impl = (IFile) ResourceManager .getResource(project.getProject().getFullPath().append("src/test/java/SimpleImpl.java").toString()); Display.getDefault().syncExec(() -> { try { IWorkbenchWindow iww = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ResourceManager.closeEditor(impl, iww); } catch (PartInitException e) { ResourceManager.logException(e); }}); Waiter.waitUntil(new EditorClosedCondition("SimpleImpl.java")); }
private void buildIncrement(IResourceDelta delta, PgDbParser parser, IProgressMonitor monitor) throws CoreException, InterruptedException, IOException { List<IFile> files = new ArrayList<>(); delta.accept(d -> { if (PgUIDumpLoader.isInProject(d)) { IResource res = d.getResource(); if (res.getType() == IResource.FILE) { switch (d.getKind()) { case IResourceDelta.REMOVED: case IResourceDelta.REMOVED_PHANTOM: parser.removePathFromRefs(res.getLocation().toOSString()); break; default: files.add((IFile) res); break; } } } return true; }); parser.getObjFromProjFiles(files, monitor); }
@Override public void activateEditor(final IWorkbenchPage page, final IStructuredSelection selection) { if (null != selection && !selection.isEmpty()) { final Object firstElement = selection.getFirstElement(); if (firstElement instanceof ResourceNode) { final File fileResource = ((ResourceNode) firstElement).getResource(); if (fileResource.exists() && fileResource.isFile()) { final URI uri = URI.createFileURI(fileResource.getAbsolutePath()); final IResource resource = externalLibraryWorkspace.getResource(uri); if (resource instanceof IFile) { final IEditorInput editorInput = EditorUtils.createEditorInput(new URIBasedStorage(uri)); final IEditorPart editor = page.findEditor(editorInput); if (null != editor) { page.bringToTop(editor); return; } } } } } super.activateEditor(page, selection); }
/** * Check if index is populated with external project content and workspace project content when the external * location with single project is registered and workspace contains project with different name. */ @Test public void testWorkspaceProjectAndExternalProject() throws Exception { IProject createJSProject = ProjectUtils.createJSProject("LibFoo2"); IFolder src = configureProjectWithXtext(createJSProject); IFile manifest = createJSProject.getProject().getFile("manifest.n4mf"); assertMarkers("manifest of first project should have no errors", manifest, 0); createTestFile(src, "Foo", "console.log('hi')"); copyProjectsToLocation(externalLibrariesRoot); waitForAutoBuild(); setExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot); Collection<String> expectedExternal = collectIndexableFiles(externalLibrariesRoot); Collection<String> expectedWorkspace = collectIndexableFiles(ResourcesPlugin.getWorkspace()); Collection<String> expected = new HashSet<>(); expected.addAll(expectedExternal); expected.addAll(expectedWorkspace); assertResourceDescriptions(expected, BuilderUtil.getAllResourceDescriptions()); removeExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot); }
private boolean isFilteredByParent() { if ((linkedResourceGroup == null) || linkedResourceGroup.isEnabled()) return false; IPath containerPath = resourceGroup.getContainerFullPath(); if (containerPath == null) return false; String resourceName = resourceGroup.getResource(); if (resourceName == null) return false; if (resourceName.length() > 0) { IPath newFolderPath = containerPath.append(resourceName); IFile newFileHandle = createFileHandle(newFolderPath); IWorkspace workspace = newFileHandle.getWorkspace(); return !workspace.validateFiltered(newFileHandle).isOK(); } return false; }
private void loadClassesFromSettingsFolder() { Properties properties = new Properties(); IFolder folder=getCurrentProject().getFolder(PathConstant.PROJECT_RESOURCES_FOLDER); IFile file = folder.getFile(PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES); try { LOGGER.debug("Loading property file"); if (file.getLocation().toFile().exists()) { FileInputStream inStream = new FileInputStream(file.getLocation().toString()); properties.load(inStream); for(Object key:properties.keySet()){ String packageName=StringUtils.remove((String)key,Constants.DOT+Constants.ASTERISK); if(StringUtils.isNotBlank(properties.getProperty((String)key)) && StringUtils.isNotBlank(packageName)){ loadUserDefinedClassesInClassRepo(properties.getProperty((String)key),packageName); } } } } catch (IOException |RuntimeException exception) { LOGGER.error("Exception occurred while loading jar files from projects setting folder",exception); } }
/** * This also changes the editor's input. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void doSaveAs () { SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () ); saveAsDialog.open (); IPath path = saveAsDialog.getResult (); if ( path != null ) { IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path ); if ( file != null ) { doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) ); } } }
@Test public void testOfflineAppendMode() throws Exception { GW4EProject project = new GW4EProject(bot, gwproject); FileParameters fp = project.createSimpleProject (); fp.setTargetFilename("SimpleOffLineImpl"); OfflineTestUIPageTest page = walkToToOfflinePage(gwproject,fp); page.selectAppendMode("com.company.SimpleImpl.java - gwproject/src/main/java"); page.selectGenerators(new String [] {"random(edge_coverage(100))"}); page.finish(); ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { IFile resource = (IFile) ResourceManager.getResource("gwproject/src/main/java/com/company/SimpleImpl.java"); boolean methodAppended = IOHelper.findInFile(resource, "Generated with : random(edge_coverage(100))"); return methodAppended; } @Override public String getFailureMessage() { return "method not generated "; } }; bot.waitUntil(condition, 3 * 6 * SWTBotPreferences.TIMEOUT); //3mn closeWizard (); }
public static IFile createFile(IProject project, IFile file, InputStream contentStream, IProgressMonitor monitor) throws CoreException { if (!file.exists()) { IPath path = file.getProjectRelativePath(); if (path.segmentCount() > 1) { IPath currentFolderPath = new Path(""); for (int i=0; i<path.segmentCount()-1; i++) { currentFolderPath = currentFolderPath.append(path.segment(i)); createFolder(project, currentFolderPath, monitor); } } try { file.create(contentStream, true, monitor); } finally { try { contentStream.close(); } catch (IOException e) { throw new CoreException(new Status(Status.ERROR, "", "Could not close stream for file " + file.getFullPath(), e)); } } } return file; }
/** * Launch a file, using the file information, which means using default launch configurations. */ protected void launchFile(IFile originalFileToRun, String mode) { final String runnerId = getRunnerId(); final String path = originalFileToRun.getFullPath().toOSString(); final URI moduleToRun = URI.createPlatformResourceURI(path, true); final String implementationId = chooseImplHelper.chooseImplementationIfRequired(runnerId, moduleToRun); if (implementationId == ChooseImplementationHelper.CANCEL) return; RunConfiguration runConfig = runnerFrontEnd.createConfiguration(runnerId, implementationId, moduleToRun); ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(getLaunchConfigTypeID()); DebugUITools.launch(runConfigConverter.toLaunchConfiguration(type, runConfig), mode); // execution dispatched to proper delegate LaunchConfigurationDelegate }
@Override public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); if (resource == null) { return false; } switch (resource.getType()) { case IResource.ROOT: case IResource.PROJECT: case IResource.FOLDER: return true; case IResource.FILE: IFile file = (IFile) resource; if (EditorConfigConstants.EDITORCONFIG.equals(file.getName()) && delta.getKind() == IResourceDelta.CHANGED) { entries.remove(new FileResource(file)); } } return false; }
public static void copyFiles(File srcFolder, IContainer destFolder) throws CoreException, FileNotFoundException { for (File f : srcFolder.listFiles()) { if (f.isDirectory()) { IFolder newFolder = destFolder.getFolder(new Path(f.getName())); newFolder.create(true, true, null); copyFiles(f, newFolder); } else { IFile newFile = destFolder.getFile(new Path(f.getName())); InputStream in = new FileInputStream(f); try { newFile.create(in, true, null); } finally { try { if (in != null) in.close(); } catch (IOException e) { } } } } }
public GccMinifier(MinifyBuilder builder, IFile srcFile, IFile destFile, OutputStream out, IEclipsePreferences prefs) throws IOException, CoreException { super(builder); this.srcFile = srcFile; this.out = out; this.outCharset = destFile.exists() ? destFile.getCharset() : "ascii"; console = builder.minifierConsole(); String optLevel = prefs.get(PrefsAccess.preferenceKey( srcFile, MinifyBuilder.GCC_OPTIMIZATION), MinifyBuilder.GCC_OPT_WHITESPACE_ONLY); switch (optLevel) { case MinifyBuilder.GCC_OPT_ADVANCED: compilationLevel = CompilationLevel.ADVANCED_OPTIMIZATIONS; break; case MinifyBuilder.GCC_OPT_SIMPLE: compilationLevel = CompilationLevel.SIMPLE_OPTIMIZATIONS; break; default: compilationLevel = CompilationLevel.WHITESPACE_ONLY; } }
/** * @param file * @return The build policies file located in the same folder as the graph * file * @throws FileNotFoundException */ public static IFile getBuildPoliciesForGraph(IFile file) throws FileNotFoundException { String name = PreferenceManager.getBuildPoliciesFileName(file.getProject().getName()); IFolder folder = (IFolder) file.getParent(); IFile policiesFile = folder.getFile(name); if (policiesFile == null || !policiesFile.exists()) throw new FileNotFoundException(folder.getFullPath().append(name).toString()); return policiesFile; }
/** * Is the passed file a GW3 file ? * * @param resource * @return */ public static boolean isGW3ModelFile(IFile resource) { if (resource == null) return false; String extension = resource.getFileExtension(); if (Constant.GW3_FILE.equalsIgnoreCase(extension) && allowedFolder(resource)) { return true; } return false; }
/** * @param buildPolicy * @param graphModelFile * @return */ private static IPath graphModelExists(IFile buildPolicy, String graphModelFile) throws FileNotFoundException { IPath path = null; try { path = buildPolicy.getFullPath().removeLastSegments(1).append(graphModelFile); if (ResourceManager.fileExists(buildPolicy.getProject(), path.toString())) return path; } catch (CoreException e) { ResourceManager.logException(e); } throw new FileNotFoundException(path.toString()); }
/***/ @SuppressWarnings("resource") protected IFile doCreateTestFile(IFolder folder, String fullName, CharSequence content) throws CoreException { IFile file = folder.getFile(fullName); file.create(new StringInputStream(content.toString()), true, monitor()); waitForAutoBuild(); return file; }
public void getObjFromProjFile(IFile file, IProgressMonitor monitor) throws InterruptedException, IOException, CoreException { PgDiffArguments args = new PgDiffArguments(); args.setInCharsetName(file.getCharset()); try (PgUIDumpLoader loader = new PgUIDumpLoader(file, args, monitor)) { loader.setLoadSchema(false); loader.setLoadReferences(true); PgDatabase db = loader.loadFile(new PgDatabase()); objDefinitions.putAll(db.getObjDefinitions()); objReferences.putAll(db.getObjReferences()); fillFunctionBodies(loader.getFuncBodyReferences()); } notifyListeners(); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { List<IFile> jobFiles = new ArrayList<>(); List<IFile> pastedFileList = new ArrayList<>(); IWorkbenchPart part = HandlerUtil.getActivePart(event); if(part instanceof CommonNavigator){ PasteAction action = new PasteAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite()); action.run(); IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IProject project = workSpaceRoot.getProject(JobCopyParticipant.getCopyToPath().split("/")[1]); IFolder jobFolder = project.getFolder( JobCopyParticipant.getCopyToPath().substring(JobCopyParticipant.getCopyToPath().indexOf('/', 2))); IFolder paramFolder = project.getFolder(PARAMETER_FOLDER_NAME); try { createCurrentJobFileList(jobFolder, jobFiles); pastedFileList=getPastedFileList(jobFiles); generateUniqueJobIdForPastedFiles(pastedFileList); createXmlFilesForPastedJobFiles(pastedFileList); List<String> copiedPropertiesList = getCopiedPropertiesList(); createPropertiesFilesForPastedFiles(paramFolder, pastedFileList, copiedPropertiesList); JobCopyParticipant.cleanUpStaticResourcesAfterPasteOperation(); } catch (CoreException coreException) { logger.warn("Error while copy paste jobFiles",coreException.getMessage() ); } } else if(part instanceof ELTGraphicalEditor){ IEditorPart editor = HandlerUtil.getActiveEditor(event); ((ELTGraphicalEditor)editor).pasteSelection(); } return null; }
private ZipInputStream getArchiveStream(final URI archiveLocation) throws CoreException, IOException { if (archiveLocation.isPlatformResource()) { IFile workspaceFile = workspace.getFile(new Path(archiveLocation.toPlatformString(true))); return new ZipInputStream(workspaceFile.getContents()); } else { return new ZipInputStream(new URL(archiveLocation.toString()).openStream()); } }
@Test public void testFindIContainerString() throws Exception { IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, true, true); IFile impl = (IFile) ResourceManager .getResource(project.getProject().getFullPath().append("src/test/java/SimpleImpl.java").toString()); IPath p = ResourceManager.find(project.getProject(), impl.getFullPath().toString()); assertNotNull(p); }
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> adapter) { if (BashEditor.class.equals(adapter)) { return (T) this; } if (IContentOutlinePage.class.equals(adapter)) { return (T) getOutlinePage(); } if (ColorManager.class.equals(adapter)) { return (T) getColorManager(); } if (IFile.class.equals(adapter)) { IEditorInput input = getEditorInput(); if (input instanceof IFileEditorInput) { IFileEditorInput feditorInput = (IFileEditorInput) input; return (T) feditorInput.getFile(); } return null; } if (ISourceViewer.class.equals(adapter)) { return (T) getSourceViewer(); } if (StatusMessageSupport.class.equals(adapter)) { return (T) this; } if (ITreeContentProvider.class.equals(adapter) || BashEditorTreeContentProvider.class.equals(adapter)) { if (outlinePage == null) { return null; } return (T) outlinePage.getContentProvider(); } return super.getAdapter(adapter); }
/** * Is this file a graphml model file ? * * @param resource * @return */ public static boolean isGraphModelFile(IFile resource) { String extension = resource.getFileExtension(); if (Constant.GRAPHML_FILE.equalsIgnoreCase(extension) && allowedFolder(resource)) { return true; } if (Constant.GRAPH_JSON_FILE.equalsIgnoreCase(extension) && allowedFolder(resource)) { return true; } if (Constant.GRAPH_GW4E_FILE.equalsIgnoreCase(extension) && allowedFolder(resource)) { return true; } return false; }
@Test public void testReorganizeImport() throws Exception { IJavaProject pj = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME,true,false); IFile impl = ProjectHelper.createDummyClass (pj); ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(impl); int line = IOHelper.findLocationLineInFile((IFile) compilationUnit.getResource(), "import"); assertTrue(line!=-1); JDTManager.reorganizeImport(compilationUnit); line = IOHelper.findLocationLineInFile((IFile) compilationUnit.getResource(), "import"); assertEquals (-1,line); }
private void fix(IMarker marker, IProgressMonitor monitor) { try { IPath graphModelPath = new Path ((String)marker.getAttribute(BuildPolicyConfigurationException.GRAPHMODELPATH)); IFile ifile = (IFile) ResourceManager.toResource(graphModelPath); BuildPolicyManager.addSyncPolicies(ifile,monitor); marker.delete(); } catch (Exception e) { ResourceManager.logException(e); } }
/** * @see IActionDelegate#run(IAction) */ public void run(IAction action) { //System.out.println("OcciRegistry" + OcciRegistry.getInstance().getRegisteredExtensions()) ; //System.out.println(" selection "+selection); Iterator<?> it = ((IStructuredSelection) selection).iterator(); int i= 0; String message="\n"; while (it.hasNext()) { IProject selectedProject = (IProject)it.next(); if(selectedProject instanceof IProject) { // Generate plugin.xml IFile pluginXML = PDEProject.getPluginXml(selectedProject); if(pluginXML.exists()) { if (!(getExtensionScheme(pluginXML).equals("") || getExtensionURI(pluginXML).equals(""))) { //System.out.println(" selectedElement "+selectedProject +" "+selectedProject.getClass()); //System.out.println(" selectedElement "+getExtensionScheme(pluginXML)); //System.out.println(" selectedElement "+getExtensionURI(pluginXML)); OcciRegistry.getInstance().registerExtension(getExtensionScheme(pluginXML), getExtensionURI(pluginXML)); closeOtherSessions(selectedProject); i++; message = message.concat(getExtensionScheme(pluginXML)).concat("\n"); } } } } if(i>0) MessageDialog.openInformation(shell, Messages.RegisterExtensionAction_ExtRegistration, Messages.RegisterExtensionAction_RegisteredExtension +message); }
/** * This also changes the editor's input. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void doSaveAs() { SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); saveAsDialog.open(); IPath path = saveAsDialog.getResult(); if (path != null) { IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file != null) { doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); } } }
/** * Obtains the contents of source code appearing in an editor. * @param file the file * @return the contents of the source code, or <code>null</code> if the source code is not valid */ public static String getSourceCode(IFile file) { IDocument doc = getDocument(file); if (doc != null) { return doc.get(); } return null; }
private void sendInput(OutputStream stream, Set<IResource> filesToCompile) { try (OutputStreamWriter writer = new OutputStreamWriter(stream, Charset.forName("UTF-8"));) { ParameterBuilder builder = new ParameterBuilder(); if (prefs.isWriteBINFile()) { builder.addOutput(CompileOutputType.BIN.outputKey()); } if (prefs.isWriteABIFile()) { builder.addOutput(CompileOutputType.ABI.outputKey()); } if (prefs.isWriteASTFile()) { builder.addOutput(CompileOutputType.AST.outputKey()); } if (prefs.isWriteASMFile()) { builder.addOutput(CompileOutputType.ASM.outputKey()); } for (IResource resource : filesToCompile) { if (resource instanceof IFile) { IFile file = (IFile) resource; builder.addSource(file.getLocation().lastSegment(), new Source(file)); } } writer.write(builder.buildJson()); writer.flush(); } catch (IOException e) { e.printStackTrace(); } }
private void refreshParameterFileInProjectExplorer() { IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(getParameterFileIPath()); try { file.refreshLocal(IResource.DEPTH_ZERO, null); } catch (CoreException e) { logger.error("Error in refreshing the parameters in file", e); } }
/** * @param factory * @param file * @throws IOException */ private static List<IPath> write(ContextFactory factory, SourceFile file, boolean erase, IProgressMonitor monitor) throws IOException { List<IPath> ret = new ArrayList<IPath>(); List<Context> contexts = factory.create(file.getInputPath()); for (Context context : contexts) { try { RuntimeModel model = context.getModel(); File outfile = file.getOutputPath().toFile(); if (erase) { IFile ifileTodelete = ResourceManager.toIFile(outfile); if (ifileTodelete.exists()) { ifileTodelete.delete(true, monitor); } } String source = new CodeGenerator().generate(file, model); File f = file.getOutputPath().getParent().toFile(); IFolder ifolder = ResourceManager.toIFolder(f); ResourceManager.ensureFolder((IFolder) ifolder); IFile ifile = ResourceManager.createFileDeleteIfExists(file.getOutputPath().toFile(), source, monitor); ret.add(ifile.getFullPath()); } catch (Throwable t) { ResourceManager.logException(t); } } return ret; }
/** * Opens the model selection dialog. * * @param parent * the parent {@link Composite} */ private void openSiriusModelSelection(final Composite parent) { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent.getShell(), new WorkbenchLabelProvider(), new FilteredFileContentProvider(new String[] { SiriusUtil.SESSION_RESOURCE_EXTENSION })); dialog.setTitle("Select model file"); dialog.setMessage("Select the model file to execute:"); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); if (dialog.open() == Window.OK) { siriusResourceURIText.setText(((IFile)dialog.getFirstResult()).getFullPath().toString()); } }