/** * file color changed. reevaluate everything affected by this file TODO: for now only reevaluate * checks in this file */ public void fileColorChanged(FileColorChangedEvent event) { final HashSet<ColoredSourceFile> toCheck = new HashSet<ColoredSourceFile>(); for (IContainer folder : event.getAffectedFolders()) { try { if (folder.exists()) folder.accept( new IResourceVisitor() { public boolean visit(IResource resource) throws CoreException { if (resource instanceof IFile) try { toCheck.add(ColoredSourceFile.getColoredSourceFile((IFile) resource)); } catch (FeatureModelNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; } }); } catch (CoreException e) { e.printStackTrace(); } } reevaluateFileChecks(toCheck); }
/** * get a string status indicator for the modelName status label, given the modelName * * @param modelName the model name to test * @return the status of the supplied model name */ private String getModelNameStatus(String sModelName) { // Check for null or zero-length if (sModelName == null || sModelName.length() == 0) { return MODEL_CREATE_ERROR_NO_NAME; // Check for valid model name } String fileNameMessage = ModelUtilities.validateModelName(sModelName, FILE_EXT); if (fileNameMessage != null) { return MODEL_CREATE_ERROR_INVALID_NAME; } // Check if already exists String sFileName = getFileName(sModelName); IPath modelFullPath = null; IPath modelRelativePath = null; if (newModelParent != null) { modelFullPath = newModelParent.getFullPath().append(sFileName); modelRelativePath = newModelParent.getProjectRelativePath().append(sFileName); } if (newModelParent != null && newModelParent.getProject().exists(modelRelativePath)) { return MODEL_CREATE_ERROR_ALREADY_EXISTS; } if (targetFilePath != null && targetFilePath.equals(modelFullPath)) { return MODEL_CREATE_ERROR_SAME_NAME_AS; } // success return MODEL_CREATE_ERROR_IS_VALID; }
/** * Retrieves all .class files from the output path * * @return The .class files list */ protected void getAllClassFiles( final IContainer aContainer, final List<IResource> aClassFileList) { if (aContainer == null) { return; } IResource[] members; try { members = aContainer.members(); } catch (final CoreException e) { Activator.logError( aContainer.getProject(), MessageFormat.format( "Error listing members in : {0}", aContainer.getFullPath().toOSString()), e); return; } for (final IResource member : members) { if (member.getType() == IResource.FOLDER) { getAllClassFiles((IContainer) member, aClassFileList); } else if (member.getType() == IResource.FILE && member.getName().endsWith(".class")) { aClassFileList.add(member); } } }
protected final Object getSingleElementFromSelection(ISelection selection) { if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) return null; Iterator<?> iter = ((IStructuredSelection) selection).iterator(); Object firstElement = iter.next(); if (!(firstElement instanceof IJavaElement)) { if (firstElement instanceof IMarker) firstElement = ((IMarker) firstElement).getResource(); if (firstElement instanceof IAdaptable) { IJavaElement je = ((IAdaptable) firstElement).getAdapter(IJavaElement.class); if (je == null && firstElement instanceof IFile) { IContainer parent = ((IFile) firstElement).getParent(); if (parent != null) return parent.getAdapter(IJavaElement.class); else return null; } else return je; } else return firstElement; } Object currentInput = getViewer().getInput(); if (currentInput == null || !currentInput.equals(findInputForJavaElement((IJavaElement) firstElement))) if (iter.hasNext()) // multi-selection and view is empty return null; else // OK: single selection and view is empty return firstElement; // be nice to multi-selection while (iter.hasNext()) { Object element = iter.next(); if (!(element instanceof IJavaElement)) return null; if (!currentInput.equals(findInputForJavaElement((IJavaElement) element))) return null; } return firstElement; }
/** * Starts pub serve for a given launch configuration. Checks if the current pub serve is for the * same pubspec.yaml, if not then starts up pub serve. * * @param wrapper - the launch config wrapper * @return - true if pub serve starts */ public boolean startPubServe(DartLaunchConfigWrapper wrapper) { // TODO(keertip): output to process console console = DartCore.getConsole(); if (currentLaunch != null) { IResource resource = currentLaunch.getApplicationResource(); if (resource != null) { // check if previous launch and new launch share the same pubspec. If so, and pub serve is // running, then current pub serve can be used. IContainer appDir = DartCore.getApplicationDirectory(resource); if (appDir.equals(DartCore.getApplicationDirectory(wrapper.getApplicationResource()))) { // TODO(keertip): make this separate checks so that new connection can be started without // starting new process if (process != null && !isTerminated() && pubConnection != null && pubConnection.isConnected()) { console.printSeparator("Starting pub serve : " + resource.getProject().getName()); // make sure pub is serving the directory, send serve directory command boolean isServed = serveDirectory(wrapper.getApplicationResource()); if (isServed) { currentLaunch = wrapper; return true; } } } } } // terminate existing pub serve if any dispose(); return runPubServe(wrapper); }
/** * The worker method. It will find the container, create the file if missing or just replace its * contents, and open the editor on the newly created file. */ private void doFinish( String containerName, String fileName, String name, String description, IProgressMonitor monitor) throws CoreException { // create a sample file monitor.beginTask("Creating " + fileName, 2); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(new Path(containerName)); if (!resource.exists() || !(resource instanceof IContainer)) { throwCoreException("Container \"" + containerName + "\" does not exist."); } IContainer container = (IContainer) resource; final IFile file = container.getFile(new Path(fileName)); try { Test emptyTest = createEmptyTest(name, description); String xml = new CubicTestXStream().toXML(emptyTest); FileUtils.writeStringToFile(file.getLocation().toFile(), xml, "ISO-8859-1"); file.getParent().refreshLocal(IResource.DEPTH_INFINITE, null); } catch (IOException e) { ErrorHandler.logAndRethrow(e); } monitor.worked(1); if (openCreatedTestOnFinish) { openFileForEditing(monitor, file); } }
/** * Launches the generation. * * @param monitor This will be used to display progress information to the user. * @throws IOException Thrown when the output cannot be saved. * @generated */ public void doGenerate(IProgressMonitor monitor) throws IOException { if (!targetFolder.getLocation().toFile().exists()) { targetFolder.getLocation().toFile().mkdirs(); } // final URI template0 = getTemplateURI("org.earthsystemcurator.cupid.esmf2fortran", new // Path("/esmf2fortran/main/generate.emtl")); // esmf2fortran.main.Generate gen0 = new esmf2fortran.main.Generate(modelURI, // targetFolder.getLocation().toFile(), arguments) { // protected URI createTemplateURI(String entry) { // return template0; // } // }; // gen0.doGenerate(BasicMonitor.toMonitor(monitor)); monitor.subTask("Loading..."); esmf2fortran.main.Generate gen0 = new esmf2fortran.main.Generate(modelURI, targetFolder.getLocation().toFile(), arguments); monitor.worked(1); String generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID( "org.earthsystemcurator.cupid.esmf2fortran", "esmf2fortran.main.Generate", modelURI.toString(), targetFolder.getFullPath().toString(), new ArrayList<String>()); gen0.setGenerationID(generationID); gen0.doGenerate(BasicMonitor.toMonitor(monitor)); }
/** * Launches the generation. * * @param monitor This will be used to display progress information to the user. * @throws IOException Thrown when the output cannot be saved. * @generated */ public void doGenerate(IProgressMonitor monitor) throws IOException { if (!targetFolder.getLocation().toFile().exists()) { targetFolder.getLocation().toFile().mkdirs(); } // final URI template0 = // getTemplateURI("org.eclipse.papyrus.robotml.generators.intempora.rtmaps", new // Path("/org/eclipse/robotml/generators/acceleo/rtmaps/main/generate_rtmaps.emtl")); // org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps gen0 = new // org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps(modelURI, // targetFolder.getLocation().toFile(), arguments) { // protected URI createTemplateURI(String entry) { // return template0; // } // }; // gen0.doGenerate(BasicMonitor.toMonitor(monitor)); monitor.subTask("Loading..."); Generate_rtmaps gen0 = new Generate_rtmaps(modelURI, targetFolder.getLocation().toFile(), arguments); monitor.worked(1); String generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID( "org.eclipse.papyrus.robotml.generators.intempora.rtmaps", "org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps", modelURI.toString(), targetFolder.getFullPath().toString(), new ArrayList<String>()); gen0.setGenerationID(generationID); gen0.doGenerate(BasicMonitor.toMonitor(monitor)); }
private void setSelectionFromEditor(IWorkbenchPart part, ISelection selection) { if (part instanceof IEditorPart) { IModelElement element = null; if (selection instanceof IStructuredSelection) { Object obj = getSingleElementFromSelection(selection); if (obj instanceof IModelElement) element = (IModelElement) obj; } IEditorInput ei = ((IEditorPart) part).getEditorInput(); if (selection instanceof ITextSelection) { int offset = ((ITextSelection) selection).getOffset(); element = getElementAt(ei, offset); } if (element != null) { adjustInputAndSetSelection(element); return; } if (ei instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) ei).getFile(); IModelElement je = (IModelElement) file.getAdapter(IModelElement.class); if (je == null) { IContainer container = ((IFileEditorInput) ei).getFile().getParent(); if (container != null) je = (IModelElement) container.getAdapter(IModelElement.class); } if (je == null) { setSelection(null, false); return; } adjustInputAndSetSelection(je); } /* * else if (ei instanceof IClassFileEditorInput) { IClassFile cf = * ((IClassFileEditorInput) ei).getClassFile(); * adjustInputAndSetSelection(cf); } */ } }
public void refreshUiFromManager() { this.refreshing = true; IContainer sourceLocation = this.importManager.getSourceModelLocation(); if (sourceLocation != null) { this.sourceModelContainerText.setText(sourceLocation.getFullPath().makeRelative().toString()); } if (this.importManager.getSourceModelName() != null) { if (!this.sourceModelFileText.getText().equals(this.importManager.getSourceModelName())) { this.sourceModelFileText.setText(this.importManager.getSourceModelName()); } } IContainer viewLocation = this.importManager.getViewModelLocation(); if (viewLocation != null) { this.viewModelContainerText.setText(viewLocation.getFullPath().makeRelative().toString()); } if (this.importManager.getViewModelName() != null) { if (!this.viewModelFileText.getText().equals(this.importManager.getViewModelName())) { this.viewModelFileText.setText(this.importManager.getViewModelName()); } } // // source model info is complete so go ahead and set message for user setSourceModelHelpMessage(); // source model info is complete so go ahead and set message for user setViewModelHelpMessage(); updateDesignerProperties(); this.refreshing = false; }
public Object getSourceElement(IStackFrame stackFrame) { if (stackFrame instanceof ScriptStackFrame) { ScriptStackFrame sf = (ScriptStackFrame) stackFrame; URI uri = sf.getFileName(); String pathname = uri.getPath(); if (Platform.getOS().equals(Platform.OS_WIN32)) { pathname = pathname.substring(1); } File file = new File(pathname); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IContainer container = root.getContainerForLocation(new Path(file.getParent())); if (container != null) { IResource resource = container.findMember(file.getName()); if (resource instanceof IFile) { return (IFile) resource; } } else { return file; } } return null; }
/** * Final check before the actual refactoring * * @return status * @throws OperationCanceledException */ public RefactoringStatus checkFinalConditions() throws OperationCanceledException { RefactoringStatus status = new RefactoringStatus(); IContainer destination = fProcessor.getDestination(); IProject sourceProject = fProcessor.getSourceSelection()[0].getProject(); IProject destinationProject = destination.getProject(); if (sourceProject != destinationProject) status.merge(MoveUtils.checkMove(phpFiles, sourceProject, destination)); // Checks if one of the resources already exists with the same name in // the destination IPath dest = fProcessor.getDestination().getFullPath(); IResource[] sourceResources = fProcessor.getSourceSelection(); for (IResource element : sourceResources) { String newFilePath = dest.toOSString() + File.separatorChar + element.getName(); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(newFilePath)); if (resource != null && resource.exists()) { status.merge( RefactoringStatus.createFatalErrorStatus( NLS.bind( PhpRefactoringCoreMessages.getString("MoveDelegate.6"), element.getName(), dest.toOSString()))); // $NON-NLS-1$ } } return status; }
/* * (non-Javadoc) * * @see core.resources.ICoreResource#seek(core.resources.IResourceLocationRequestor) */ public void lookup(IResourceAcceptor requestor, LookupDepth depth) { String packageName = fRoot.toPackageName(this); IPackageFragment[] fragments = fRoot.getAllPackageFragments(packageName); for (int i = 0; i < fragments.length; i++) { Object[] nonJavaResources = null; try { if (fragments[i].isReadOnly()) { // TODO - is this the correct check for a package in a jar file? nonJavaResources = fragments[i].getNonJavaResources(); } else { IContainer container = (IContainer) fragments[i].getUnderlyingResource(); if (container != null && container.exists()) { IResource[] members = container.members(false); ArrayList<IResource> resultList = new ArrayList<IResource>(); for (int j = 0; j < members.length; j++) { if (members[j] instanceof IFile) resultList.add(members[j]); } nonJavaResources = resultList.toArray(); } } } catch (CoreException e) { TapestryCore.log(e); } if (nonJavaResources == null) continue; for (int j = 0; j < nonJavaResources.length; j++) { IStorage storage = (IStorage) nonJavaResources[j]; ICoreResource loc = new ClasspathResource(fRoot, getPath() + storage.getName()); if (!requestor.accept(loc)) break; } } }
@Override public void doRun( IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) { instrumentation.metric("command", command); if (!selection.isEmpty() && selection.getFirstElement() instanceof IResource) { Object object = selection.getFirstElement(); if (object instanceof IFile) { object = ((IFile) object).getParent(); } while (object != null && ((IContainer) object).findMember(DartCore.PUBSPEC_FILE_NAME) == null) { object = ((IContainer) object).getParent(); } if (object instanceof IContainer) { IContainer container = (IContainer) object; instrumentation.data("name", container.getName()); savePubspecFile(container); runPubJob(container); return; } else { instrumentation.metric("Problem", "Object was null").log(); } } instrumentation.metric("Problem", "pubspec.yaml file not selected, showing dialog"); MessageDialog.openError( getShell(), ActionMessages.RunPubAction_fail, ActionMessages.RunPubAction_fileNotFound); instrumentation.log(); }
/** * Creates the complete package path given by the user (all filled with __init__) and returns the * last __init__ module created. */ public static IFile createPackage( IProgressMonitor monitor, IContainer validatedSourceFolder, String packageName) throws CoreException { IFile lastFile = null; if (validatedSourceFolder == null) { return null; } IContainer parent = validatedSourceFolder; for (String packagePart : StringUtils.dotSplit(packageName)) { IFolder folder = parent.getFolder(new Path(packagePart)); if (!folder.exists()) { folder.create(true, true, monitor); } parent = folder; IFile file = parent.getFile( new Path("__init__" + FileTypesPreferencesPage.getDefaultDottedPythonExtension())); if (!file.exists()) { file.create(new ByteArrayInputStream(new byte[0]), true, monitor); } lastFile = file; } return lastFile; }
/** * Possible failures: * * <ul> * <li>NO_ELEMENTS_TO_PROCESS - the root supplied to the operation is <code>null</code>. * <li>INVALID_NAME - the name provided to the operation is <code>null</code> or is not a valid * script folder name. * <li>READ_ONLY - the root provided to this operation is read only. * <li>NAME_COLLISION - there is a pre-existing resource (file) with the same name as a folder * in the script folder's hierarchy. * <li>ELEMENT_NOT_PRESENT - the underlying resource for the root is missing * </ul> * * @see IScriptModelStatus * @see ScriptConventions */ @Override public IModelStatus verify() { if (getParentElement() == null) { return new ModelStatus(IModelStatusConstants.NO_ELEMENTS_TO_PROCESS); } IPath packageName = this.pkgName == null ? null : this.pkgName.append("."); // $NON-NLS-1$ String packageNameValue = null; if (packageName != null) { packageNameValue = packageName.toOSString(); } if (this.pkgName == null || (this.pkgName.segmentCount() > 0 && !Util.isValidFolderNameForPackage( (IContainer) getParentElement().getResource(), packageName.toString()))) { return new ModelStatus(IModelStatusConstants.INVALID_NAME, packageNameValue); } IProjectFragment root = (IProjectFragment) getParentElement(); if (root.isReadOnly()) { return new ModelStatus(IModelStatusConstants.READ_ONLY, root); } IContainer parentFolder = (IContainer) root.getResource(); int i; for (i = 0; i < this.pkgName.segmentCount(); i++) { IResource subFolder = parentFolder.findMember(this.pkgName.segment(i)); if (subFolder != null) { if (subFolder.getType() != IResource.FOLDER) { return new ModelStatus( IModelStatusConstants.NAME_COLLISION, Messages.bind(Messages.status_nameCollision, subFolder.getFullPath().toString())); } parentFolder = (IContainer) subFolder; } } return ModelStatus.VERIFIED_OK; }
/** * test whether the supplied modelName is valid * * @param modelName the model name to test * @return 'true' if the name is valid, 'false' if not. */ private boolean isValidModelName(String sModelName) { // Check for null or zero-length if (sModelName == null || sModelName.length() == 0) { return false; } // Check for valid model name String fileNameMessage = ModelUtilities.validateModelName(sModelName, FILE_EXT); if (fileNameMessage != null) { return false; } // Check if already exists String sFileName = getFileName(sModelName); IPath modelFullPath = null; IPath modelRelativePath = null; if (newModelParent != null) { modelFullPath = newModelParent.getFullPath().append(sFileName); modelRelativePath = newModelParent.getProjectRelativePath().append(sFileName); } if (newModelParent != null && newModelParent.getProject().exists(modelRelativePath)) { return false; } // Check if it is the same path as the relational model being generated if (targetFilePath != null && targetFilePath.equals(modelFullPath)) { return false; } // success return true; }
/** * Deletes a set of files from the file system, and also their parent folders if those become * empty during this process. * * @param nameSet set of file paths * @param monitor progress monitor * @throws CoreException if an error occurs */ private void deleteFiles(final Set<IPath> nameSet, IProgressMonitor monitor) throws CoreException { if (nameSet == null || nameSet.isEmpty()) { return; } Set<IContainer> subFolders = new HashSet<IContainer>(); for (IPath filePath : nameSet) { // Generate new path IFile currentFile = project.getFile(filePath); if (currentFile.exists()) { // Retrieve parent folder and store for deletion IContainer folder = currentFile.getParent(); subFolders.add(folder); currentFile.delete(true, monitor); } monitor.worked(1); } // Delete parent folders, if they are empty for (IContainer folder : subFolders) { if (folder.exists() && folder.members().length == 0) { folder.delete(true, monitor); } monitor.worked(1); } }
@Override public boolean performFinish() { IContainer c = Project.findContainerByPath(null, page.getContainerFullPath()); if (c != null) { try { final IFile sorFile = c.getFile(new Path(page.getFileName())); IOAdapter io = new IOAdapter(); SortSetXMLSaver r = new SortSetXMLSaver().setModel(new SortSet()); r.setFile(new EclipseFileWrapper(sorFile)) .setOutputStream(io.getOutputStream()) .exportObject(); Project.setContents( sorFile, io.getInputStream(), new Callback() { @Override public void onSuccess() { try { UI.openInEditor(sorFile); } catch (PartInitException pie) { /* ? */ pie.printStackTrace(); } } }); return true; } catch (SaveFailedException e) { page.setErrorMessage(e.getLocalizedMessage()); } } return false; }
public static IPath[] chooseExclusionPattern( Shell shell, IContainer currentSourceFolder, String title, String message, IPath initialPath, boolean multiSelection) { Class[] acceptedClasses = new Class[] {IFolder.class, IFile.class}; ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, multiSelection); ViewerFilter filter = new TypedViewerFilter(acceptedClasses); ILabelProvider lp = new WorkbenchLabelProvider(); ITreeContentProvider cp = new WorkbenchContentProvider(); IResource initialElement = null; if (initialPath != null) { IContainer curr = currentSourceFolder; int nSegments = initialPath.segmentCount(); for (int i = 0; i < nSegments; i++) { IResource elem = curr.findMember(initialPath.segment(i)); if (elem != null) { initialElement = elem; } if (elem instanceof IContainer) { curr = (IContainer) elem; } else { break; } } } ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, lp, cp); dialog.setTitle(title); dialog.setValidator(validator); dialog.setMessage(message); dialog.addFilter(filter); dialog.setInput(currentSourceFolder); dialog.setInitialSelection(initialElement); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { Object[] objects = dialog.getResult(); int existingSegments = currentSourceFolder.getFullPath().segmentCount(); IPath[] resArr = new IPath[objects.length]; for (int i = 0; i < objects.length; i++) { IResource currRes = (IResource) objects[i]; IPath path = currRes.getFullPath().removeFirstSegments(existingSegments).makeRelative(); if (currRes instanceof IContainer) { path = path.addTrailingSeparator(); } resArr[i] = path; } return resArr; } return null; }
/** * Creates a compilation unit. * * @exception ModelException if unable to create the compilation unit. */ protected void executeOperation() throws ModelException { try { // beginTask(Messages.operation_createUnitProgress, 2); ModelElementDelta delta = newModelElementDelta(); ISourceModule unit = getSourceModule(); IScriptFolder pkg = (IScriptFolder) getParentElement(); IContainer folder = (IContainer) pkg.getResource(); worked(1); IFile compilationUnitFile = folder.getFile(new Path(fName)); if (compilationUnitFile.exists()) { // update the contents of the existing unit if fForce is true if (force) { IBuffer buffer = unit.getBuffer(); if (buffer == null) return; buffer.setContents(fSource); unit.save(new NullProgressMonitor(), false); resultElements = new IModelElement[] {unit}; if (!Util.isExcluded(unit) && unit.getParent().exists()) { for (int i = 0; i < resultElements.length; i++) { delta.changed(resultElements[i], IModelElementDelta.F_CONTENT); } addDelta(delta); } } else { throw new ModelException( new ModelStatus( IModelStatusConstants.NAME_COLLISION, Messages.bind( Messages.status_nameCollision, compilationUnitFile.getFullPath().toString()))); } } else { try { String encoding = null; try { encoding = folder.getDefaultCharset(); // get folder encoding as file is not accessible } catch (CoreException ce) { // use no encoding } InputStream stream = new ByteArrayInputStream( encoding == null ? fSource.getBytes() : fSource.getBytes(encoding)); createFile(folder, unit.getElementName(), stream, force); resultElements = new IModelElement[] {unit}; if (!Util.isExcluded(unit) && unit.getParent().exists()) { for (int i = 0; i < resultElements.length; i++) { delta.added(resultElements[i]); } addDelta(delta); } } catch (IOException e) { throw new ModelException(e, IModelStatusConstants.IO_EXCEPTION); } } worked(1); } finally { done(); } }
protected void createFolder(IContainer parent) throws CoreException { if (!parent.exists()) { if (!(parent instanceof IFolder)) throw new RuntimeException("IContainer " + notNull(parent) + " does not exist"); createFolder(parent.getParent()); ((IFolder) parent).create(true, false, new NullProgressMonitor()); } }
protected void deleteEmptyParent(IProgressMonitor monitor, IContainer container) throws CoreException { final IContainer parent = container.getParent(); if (container.members().length == 0) { container.delete(true, monitor); deleteEmptyParent(monitor, parent); } }
public Object getModelPropertyValue(String key) { Object modelPropertyValue = super.getModelPropertyValue(key); if (modelPropertyValue == null) { if (key.equals(PsArtifactConstants.WIZARD_OPTION_PS_TYPE)) { modelPropertyValue = getSelectedTemplate(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_SAVE_LOCATION)) { IContainer container = getProxyServiceSaveLocation(); if (container != null && container instanceof IFolder) { IFolder proxyFolder = container .getProject() .getFolder("src") .getFolder("main") .getFolder("synapse-config") .getFolder("proxy-services"); modelPropertyValue = proxyFolder; } else { modelPropertyValue = container; } } else if (key.equals("proxy.target.ep.type")) { modelPropertyValue = getTargetEPType(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_COMMON_PS_EPURL)) { modelPropertyValue = getEndPointUrl(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_COMMON_PS_EPKEY)) { modelPropertyValue = getEndPointkey(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_SECURE_PS_SECPOLICY)) { modelPropertyValue = getSecPolicy(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_WSDL_PS_WSDLURL)) { modelPropertyValue = getWsdlUri(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_WSDL_PS_WSDLSERVICE)) { modelPropertyValue = getWsdlService(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_WSDL_PS_WSDLPORT)) { modelPropertyValue = getWsdlPort(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_WSDL_PS_PUBLISHSAME)) { modelPropertyValue = isPublishSameService(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_LOGGING_PS_REQLOGLEVEL)) { modelPropertyValue = getRequestLogLevel(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_LOGGING_PS_RESLOGLEVEL)) { modelPropertyValue = getResponseLogLevel(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_TRANSFORMER_PS_XSLT)) { modelPropertyValue = getRequestXSLT(); } else if (key.equals( PsArtifactConstants.WIZARD_OPTION_TEMPL_TRANSFORMER_PS_TRANSFORMRESPONSES)) { modelPropertyValue = isTransformResponses(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_TRANSFORMER_PS_RESXSLT)) { modelPropertyValue = getResponseXSLT(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_COMMON_PS_PREDEFINED)) { modelPropertyValue = predefinedEP; } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_COMMON_PS_EPLIST)) { modelPropertyValue = getPredefinedEndPoint(); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_AVAILABLE_PS)) { if (selectedProxyList != null) { modelPropertyValue = selectedProxyList.toArray(); } } } return modelPropertyValue; }
/** Ensures that controls are correctly set. */ private void dialogChanged() { IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName())); if (resource == null) { updateStatus("File container must be specified"); return; } IContainer container = (IContainer) resource; String fileName = getFileName(); String author = getAuthor(); String titleName = getModelName(); final IFile modelfile = container.getFile(new Path("models/" + fileName)); final IFile htmlfile = container.getFile(new Path("doc/" + titleName + ".html")); if (getContainerName().length() == 0) { updateStatus("File container must be specified"); return; } if ((resource.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { updateStatus("File container must exist"); return; } if (!resource.isAccessible()) { updateStatus("Project must be writable"); return; } if (fileName.length() == 0) { updateStatus("File name must be specified"); return; } if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { updateStatus("File name must be valid"); return; } if (!fileName.endsWith(".gaml")) { updateStatus("File extension must be \".gaml\""); return; } if (author.length() == 0) { updateStatus("Author name must be specified"); return; } if (modelfile.exists()) { updateStatus("File already exists"); return; } if (htmlfile.exists()) { updateStatus("Model name already defined"); return; } if (titleName.length() == 0) { updateStatus("Model name must be specified"); return; } updateStatus(null); }
private void shrubOutFolder(final IProgressMonitor mon) throws CoreException { mon.subTask(CoreTexts.cleanOutFoldersOperation_shrubbingOut); IContainer outFolder = project.getFolder(ScionPlugin.DIST_FOLDER); // ResourceUtil.getOutFolder( project ); if (outFolder != null && !outFolder.equals(project)) { outFolder.accept(folderCleaner, IContainer.INCLUDE_PHANTOMS); } mon.worked(12); }
public void add(IResource resource) { IContainer container; if (resource instanceof IContainer) { container = (IContainer) resource; } else { container = resource.getParent(); } containers.put(container.getFullPath().toString(), container); }
private void map(final RepositoryMapping m) { final IResource r; final File git; final IResource dotGit; IContainer c = null; m.clear(); r = getProject().findMember(m.getContainerPath()); if (r instanceof IContainer) { c = (IContainer) r; } else if (r != null) { c = Utils.getAdapter(r, IContainer.class); } if (c == null) { logAndUnmapGoneMappedResource(m); return; } m.setContainer(c); IPath absolutePath = m.getGitDirAbsolutePath(); if (absolutePath == null) { logAndUnmapGoneMappedResource(m); return; } git = absolutePath.toFile(); if (!git.isDirectory() || !new File(git, "config").isFile()) { // $NON-NLS-1$ logAndUnmapGoneMappedResource(m); return; } try { m.setRepository(Activator.getDefault().getRepositoryCache().lookupRepository(git)); } catch (IOException ioe) { logAndUnmapGoneMappedResource(m); return; } m.fireRepositoryChanged(); trace( "map " //$NON-NLS-1$ + c + " -> " //$NON-NLS-1$ + m.getRepository()); try { c.setSessionProperty(MAPPING_KEY, m); } catch (CoreException err) { Activator.logError(CoreText.GitProjectData_failedToCacheRepoMapping, err); } dotGit = c.findMember(Constants.DOT_GIT); if (dotGit != null && dotGit.getLocation().toFile().equals(git)) { protect(dotGit); } }
/** * Creates new folder from project root. The folder name can include relative path as a part of * the name. Nonexistent parent directories are being created. * * @param project - project where to create the folder. * @param name - folder name. * @return folder handle. * @throws CoreException if something goes wrong. */ public static IFolder createFolder(IProject project, String name) throws CoreException { final IPath p = new Path(name); IContainer folder = project; for (String seg : p.segments()) { folder = folder.getFolder(new Path(seg)); if (!folder.exists()) ((IFolder) folder).create(true, true, NULL_MONITOR); } resourcesCreated.add(folder); return (IFolder) folder; }
protected static AssemblyInstance loadnewICM(String filename) { // There may be other ways of loading the file IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(new Path(filename)); IContainer container = (IContainer) resource; IFile ifile = container.getFile(new Path(filename)); // This is the method provided by the ReasoningFramework API AssemblyInstance assembly = ReasoningFramework.loadConstructiveAssembly(ifile); return (assembly); }