private IContainer findPomXmlBasedir(IContainer dir) { if (dir == null) { return null; } try { // loop upwards through the parents as long as we do not cross the project boundary while (dir.exists() && dir.getProject() != null && dir.getProject() != dir) { // see if pom.xml exists if (dir.getType() == IResource.FOLDER) { IFolder folder = (IFolder) dir; if (folder.findMember(IMavenConstants.POM_FILE_NAME) != null) { return folder; } } else if (dir.getType() == IResource.FILE) { if (((IFile) dir).getName().equals(IMavenConstants.POM_FILE_NAME)) { return dir.getParent(); } } dir = dir.getParent(); } } catch (Exception e) { return dir; } return dir; }
/** * Copy/move one make target to the specified container. * * @param makeTarget - make target. * @param container - container to copy/move to. * @param operation - copying operation. Should be one of {@link org.eclipse.swt.dnd.DND} * operations. * @param shell - shell to display user warnings. * @param offerOverwriteDialog - whether overwrite dialog is provided. * @throws CoreException on the failure of {@link IMakeTargetManager} or {@link IMakeTarget} * operation. * @see DND#DROP_NONE * @see DND#DROP_COPY * @see DND#DROP_MOVE * @see DND#DROP_LINK * @see DND#DROP_DEFAULT */ public static void copyOneTarget( IMakeTarget makeTarget, IContainer container, final int operation, Shell shell, boolean offerOverwriteDialog) throws CoreException { IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager(); IMakeTarget exists = makeTargetManager.findTarget(container, makeTarget.getName()); if (exists != null) { int userAnswer = IDialogConstants.CANCEL_ID; if (offerOverwriteDialog) { userAnswer = overwriteMakeTargetDialog(makeTarget.getName(), shell); } else { userAnswer = RENAME_ID; } if (userAnswer == IDialogConstants.YES_ID || userAnswer == IDialogConstants.YES_TO_ALL_ID) { copyTargetData(makeTarget, exists); if (operation == DND.DROP_MOVE) { makeTargetManager.removeTarget(makeTarget); } } else if (userAnswer == RENAME_ID || userAnswer == RENAME_TO_ALL_ID) { String name = generateUniqueName(makeTarget.getName(), container); IMakeTarget newMakeTarget = cloneTarget(name, makeTarget, container.getProject()); newMakeTarget.setContainer(container); int dialogReturnCode = Window.OK; if (userAnswer == RENAME_ID) { MakeTargetDialog dialog; try { dialog = new MakeTargetDialog(shell, newMakeTarget); dialogReturnCode = dialog.open(); } catch (CoreException e) { MakeUIPlugin.errorDialog( shell, MakeUIPlugin.getResourceString("AddBuildTargetAction.exception.internal"), e.toString(), e); //$NON-NLS-1$ } } else if (userAnswer == RENAME_TO_ALL_ID) { makeTargetManager.addTarget(container, newMakeTarget); } if (operation == DND.DROP_MOVE && dialogReturnCode != Window.CANCEL) { makeTargetManager.removeTarget(makeTarget); } } } else { makeTargetManager.addTarget( container, cloneTarget(makeTarget.getName(), makeTarget, container.getProject())); if (operation == DND.DROP_MOVE) { makeTargetManager.removeTarget(makeTarget); } } }
/** * 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); } } }
/** * 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; }
/** * Create {@code MakeTarget} from basic data elements available during copy/paste or drag/drop * operations. The other data will be set to default. * * @param name - name of make target being created. * @param targetStr - build target. * @param command - make command. ("make" by default). * @param container - container where to place the target. * @return newly created {@link IMakeTarget}. * @throws CoreException if there was a problem creating new make target. */ public static IMakeTarget createMakeTarget( String name, String targetStr, String command, IContainer container) throws CoreException { IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager(); IProject project = container.getProject(); String[] ids = makeTargetManager.getTargetBuilders(project); String builderId = ids[0]; // IMakeTarget attributes IMakeTarget newMakeTarget = makeTargetManager.createTarget(project, name, builderId); if (targetStr != null) { newMakeTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET, targetStr); } // IMakeCommonBuildInfo attributes String projectBuildCommand = getProjectBuildCommand(project); if (command != null && command.length() > 0 && !command.equals(projectBuildCommand)) { newMakeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, command); newMakeTarget.setUseDefaultBuildCmd(false); } else { newMakeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, projectBuildCommand); newMakeTarget.setUseDefaultBuildCmd(true); } return newMakeTarget; }
/** * 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; }
/** * Convert multiline text to array of {@code IMakeTarget}s. Each line is interpreted as one * separate make command. * * @param multilineText - input text. * @param container - container where the targets will belong. * @return resulting array of {@code IMakeTarget}s. */ private static IMakeTarget[] prepareMakeTargetsFromString( String multilineText, IContainer container) { if (container != null) { String[] lines = multilineText.split("[\n\r]"); // $NON-NLS-1$ List<IMakeTarget> makeTargets = new ArrayList<IMakeTarget>(lines.length); for (String command : lines) { command = command.trim(); if (command.length() > 0) { String name = command; String buildCommand = command; String buildTarget = null; String defaultBuildCommand = MakeTargetDndUtil.getProjectBuildCommand(container.getProject()); if (command.startsWith(defaultBuildCommand + " ")) { // $NON-NLS-1$ buildCommand = defaultBuildCommand; buildTarget = command.substring(defaultBuildCommand.length() + 1).trim(); name = buildTarget; } try { makeTargets.add( MakeTargetDndUtil.createMakeTarget(name, buildTarget, buildCommand, container)); } catch (CoreException e) { // Ignore failed targets MakeUIPlugin.log(e); } } } return makeTargets.toArray(new IMakeTarget[makeTargets.size()]); } return null; }
/** * 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; }
public void selectionChanged(IAction action, ISelection selection) { boolean enabled = false; if (selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; Object obj = sel.getFirstElement(); if (obj instanceof ICElement) { if (obj instanceof ICContainer || obj instanceof ICProject) { fContainer = (IContainer) ((ICElement) obj).getUnderlyingResource(); } else { obj = ((ICElement) obj).getResource(); if (obj != null) { fContainer = ((IResource) obj).getParent(); } } } else if (obj instanceof IResource) { if (obj instanceof IContainer) { fContainer = (IContainer) obj; } else { fContainer = ((IResource) obj).getParent(); } } else { fContainer = null; } if (fContainer != null && AutotoolsPlugin.hasTargetBuilder(fContainer.getProject())) { enabled = true; } } action.setEnabled(enabled); }
public void copyImportFile(IContainer importLocation, boolean isNewAritfact, String groupId) throws IOException { File importFile = getModel().getImportFile(); File destFile = null; List<OMElement> selectedSeqList = ((TemplateModel) getModel()).getSelectedTempSequenceList(); if (selectedSeqList != null && selectedSeqList.size() > 0) { for (OMElement element : selectedSeqList) { String name = element.getAttributeValue(new QName("name")); destFile = new File(importLocation.getLocation().toFile(), name + ".xml"); FileUtils.createFile(destFile, element.toString()); fileLst.add(destFile); if (isNewAritfact) { ESBArtifact artifact = new ESBArtifact(); artifact.setName(name); artifact.setVersion(version); artifact.setType("synapse/template"); artifact.setServerRole("EnterpriseServiceBus"); artifact.setGroupId(groupId); artifact.setFile( FileUtils.getRelativePath( importLocation.getProject().getLocation().toFile(), new File(importLocation.getLocation().toFile(), name + ".xml")) .replaceAll(Pattern.quote(File.separator), "/")); esbProjectArtifact.addESBArtifact(artifact); } } } else { destFile = new File(importLocation.getLocation().toFile(), importFile.getName()); FileUtils.copy(importFile, destFile); fileLst.add(destFile); String name = importFile.getName().replaceAll(".xml$", ""); if (isNewAritfact) { ESBArtifact artifact = new ESBArtifact(); artifact.setName(name); artifact.setVersion(version); artifact.setType("synapse/template"); artifact.setServerRole("EnterpriseServiceBus"); artifact.setGroupId(groupId); artifact.setFile( FileUtils.getRelativePath( importLocation.getProject().getLocation().toFile(), new File(importLocation.getLocation().toFile(), name + ".xml")) .replaceAll(Pattern.quote(File.separator), "/")); esbProjectArtifact.addESBArtifact(artifact); } } }
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; }
protected IProject findDestProject() { IContainer c = SVFileUtils.getWorkspaceFolder(getOption(SOURCE_FOLDER, "")); if (c == null) { return null; } else if (c instanceof IProject) { return (IProject) c; } else { return c.getProject(); } }
// TODO ideally it should use MavenProject, but it is faster to scan IJavaProjects protected IPath getJREContainerPath(IContainer basedir) throws CoreException { IProject project = basedir.getProject(); if (project != null && project.hasNature(JavaCore.NATURE_ID)) { IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] entries = javaProject.getRawClasspath(); for (IClasspathEntry entry : entries) { if (JavaRuntime.JRE_CONTAINER.equals(entry.getPath().segment(0))) { return entry.getPath(); } } } return null; }
protected IProject getProject() { URI root = _index.getRoot(); IPath containerPath = org.eclipse.core.filesystem.URIUtil.toPath(root); if (containerPath == null) { return null; } IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(containerPath); if (container == null) { return null; } return container.getProject(); }
/* (non-Javadoc) * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) */ public Object getParent(Object obj) { if (obj instanceof IMakeTarget) { // this is ambiguous as make target can sit in 2 places, in its container // or source folder represented by TargetSourceContainer return ((IMakeTarget) obj).getContainer(); } else if (obj instanceof IContainer) { return ((IContainer) obj).getParent(); } else if (obj instanceof TargetSourceContainer) { IContainer container = ((TargetSourceContainer) obj).getContainer(); // TargetSourceContainer sits at project root return container.getProject(); } return null; }
@Override protected boolean initialize(Object element) { if (element instanceof IContainer) { container = (IContainer) element; project = container.getProject(); // 只处理ARESProject if (ARESProject.hasARESNature(project)) { String newName = getArguments().getNewName(); newPath = container.getFullPath().removeLastSegments(1).append(newName); return true; } } return false; }
@Override public boolean visit(IResourceProxy proxy) throws CoreException { try { if (proxy.getType() != IResource.FOLDER && proxy.getType() != IResource.PROJECT) { return false; } IContainer container = (IContainer) proxy.requestResource(); monitor.subTask(container.getProjectRelativePath().toString()); QualifiedName qName = new QualifiedName("org.eclipse.cdt.make", "goals"); // $NON-NLS-1$ //$NON-NLS-2$ String goal = container.getPersistentProperty(qName); if (goal != null) { goal = goal.trim(); IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager(); String[] builder = manager.getTargetBuilders(container.getProject()); IMakeTarget target = manager.createTarget(container.getProject(), goal, builder[0]); target.setBuildAttribute(IMakeTarget.BUILD_TARGET, goal); manager.addTarget(container, target); container.setPersistentProperty(qName, null); } return true; } finally { if (--nextProgress <= 0) { // we have exhausted the current increment, so report progress monitor.worked(1); worked++; if (worked >= halfWay) { // we have passed the current halfway point, so double the // increment and reset the halfway point. currentIncrement *= 2; halfWay += (TOTAL_WORK - halfWay) / 2; } // reset the progress counter to another full increment nextProgress = currentIncrement; } } }
/** Writes the given contents to a file with the given fileName in the specified project. */ public void writeContent() { String contents = generateSpecfile(); InputStream contentInputStream = new ByteArrayInputStream(contents.getBytes()); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(new Path(projectName)); if (!resource.exists() || !(resource instanceof IContainer)) { IStatus status = new Status( IStatus.ERROR, StubbyPlugin.PLUGIN_ID, IStatus.OK, "Project \"" + projectName + "\" does not exist.", null); StubbyLog.logError(new CoreException(status)); } IContainer container = (IContainer) resource; IResource specsFolder = container.getProject().findMember("SPECS"); // $NON-NLS-1$ IFile file = container.getFile(new Path(specfileName)); if (specsFolder != null) { file = ((IFolder) specsFolder).getFile(new Path(specfileName)); } final IFile openFile = file; try { InputStream stream = contentInputStream; if (file.exists()) { file.setContents(stream, true, true, null); } else { file.create(stream, true, null); } stream.close(); } catch (IOException e) { StubbyLog.logError(e); } catch (CoreException e) { StubbyLog.logError(e); } Display.getCurrent() .asyncExec( new Runnable() { public void run() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditor(page, openFile, true); } catch (PartInitException e) { StubbyLog.logError(e); } } }); }
public VirtualContainer(IContainer container1, boolean countResourceBundles) { this.container = container1; rbmanager = ResourceBundleManager.getManager(container.getProject()); if (countResourceBundles) { rbCount = 1; new Job("count ResourceBundles") { @Override protected IStatus run(IProgressMonitor monitor) { recount(); return Status.OK_STATUS; } }.schedule(); } else { rbCount = 0; } }
/** * validates the local shared config file location * * @return true if the local shared file exists, false otherwise */ private boolean validateLocalShared() { if (isShared()) { String path = fSharedLocationText.getText().trim(); IContainer container = getContainer(path); if (container == null || container.equals(ResourcesPlugin.getWorkspace().getRoot())) { setErrorMessage( LaunchConfigurationsMessages.CommonTab_Invalid_shared_configuration_location_14); return false; } else if (!container.getProject().isOpen()) { setErrorMessage( LaunchConfigurationsMessages .CommonTab_Cannot_save_launch_configuration_in_a_closed_project__1); return false; } } return true; }
/** * Creates make targets array from filenames array. These will be loose targets not connected to * global make target list managed by MakeTargetManager * * @param filenames - array of filenames. Each filename expected to be an actual file otherwise a * user gets a warning popup. * @param dropContainer - a container where the targets are being created. * @param shell - a shell to display warnings to user. If null, no warnings are displayed. * @return array of make targets. */ private static IMakeTarget[] prepareMakeTargetsFromFiles( String[] filenames, IContainer dropContainer, Shell shell) { List<IMakeTarget> makeTargetsList = new ArrayList<IMakeTarget>(filenames.length); int errorCount = 0; int nonFileCount = 0; for (String filepath : filenames) { IPath path = new Path(filepath); File file = path.toFile(); if (file.isFile()) { String name = path.lastSegment(); try { String buildCommand = MakeTargetDndUtil.getProjectBuildCommand(dropContainer.getProject()); makeTargetsList.add( MakeTargetDndUtil.createMakeTarget(name, filepath, buildCommand, dropContainer)); } catch (CoreException e) { errorCount++; MakeUIPlugin.log(e); } } else { nonFileCount++; } } if (shell != null) { if (errorCount > 0) { MessageDialog.openError( shell, MakeUIPlugin.getResourceString("MakeTargetDnD.title.createError"), // $NON-NLS-1$ MakeUIPlugin.getResourceString("MakeTargetDnD.message.createError")); // $NON-NLS-1$ } if (nonFileCount > 0) { MessageDialog.openInformation( shell, MakeUIPlugin.getResourceString("MakeTargetDnD.title.createInfo"), // $NON-NLS-1$ MakeUIPlugin.getResourceString( "MakeTargetDnD.message.createNonFileTargetAttempt")); //$NON-NLS-1$ } } return makeTargetsList.toArray(new IMakeTarget[makeTargetsList.size()]); }
/** Tests if the current workbench selection is a suitable container to use. */ private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) { return; } Object obj = ssel.getFirstElement(); IContainer container = null; if (obj instanceof IResource) { if (obj instanceof IContainer) { container = (IContainer) obj; } else { container = ((IResource) obj).getParent(); } } else if (obj instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) obj; IResource res = (IResource) adaptable.getAdapter(IResource.class); if (res == null) { return; } if (res instanceof IContainer) { container = (IContainer) res; } else { container = res.getParent(); } } if (container != null) { projectText.setText(container.getProject().getName()); projectText.setEditable(false); projectBrowse.setEnabled(false); containerText.setText(container.getFullPath().toString()); } } if (getProjectName().isEmpty()) { containerText.setEditable(false); containerBrowse.setEnabled(false); fileText.setEditable(false); } }
/** * Check if the file exists within the current project. It will first check the root of the * project and then the sources. If the file cannot be found in either, return false. An empty * file name would immediately return false. * * @return True if the file exists. */ public static boolean fileExistsInSources(IFile original, String fileName) { if (fileName.trim().isEmpty()) { return false; } IContainer container = original.getParent(); IResource resourceToOpen = container.findMember(fileName); IFile file = null; if (resourceToOpen == null) { IResource sourcesFolder = container.getProject().findMember("SOURCES"); // $NON-NLS-1$ file = container.getFile(new Path(fileName)); if (sourcesFolder != null) { file = ((IFolder) sourcesFolder).getFile(new Path(fileName)); } if (!file.exists()) { return false; } } return true; }
public ResourceBundleManager getResourceBundleManager() { if (rbmanager == null) { rbmanager = ResourceBundleManager.getManager(container.getProject()); } return rbmanager; }
public void createControl(Composite parent) { Composite topLevel = new Composite(parent, SWT.NONE); GridLayout topLayout = new GridLayout(); topLayout.verticalSpacing = 0; topLevel.setLayout(topLayout); topLevel.setFont(parent.getFont()); // Show description on opening setErrorMessage(null); setMessage(null); setControl(topLevel); boolean fail = false; if (getSelection().size() == 1) { Object sel = getSelection().getFirstElement(); if (sel instanceof IPackageFragmentRoot) { dest = (IContainer) ((IPackageFragmentRoot) sel).getResource(); } else if (sel instanceof IPackageFragment) { dest = (IContainer) ((IPackageFragment) sel).getResource(); packageName = ((IPackageFragment) sel).getElementName(); } else { final String JAVA_SOURCE_ERROR = "Cannot create Clojure namespace outside a java source folder"; CCWPlugin.logError("Wrong selection type: " + sel.getClass() + ". " + JAVA_SOURCE_ERROR); mainPage.setErrorMessage(JAVA_SOURCE_ERROR); fail = true; } if (dest != null) { setDescription( "Create new Clojure " + kind(true) + " in \"" + dest.getFullPath().toString() + "\" of project \"" + dest.getProject().getName() + "\""); } } else { IProject project = null; for (Iterator i = getSelection().iterator(); i.hasNext(); ) { IResource res; Object e = i.next(); if (e instanceof IResource) res = (IResource) e; else if (e instanceof IAdaptable) res = (IResource) ((IAdaptable) e).getAdapter(IResource.class); else res = null; if (res == null) continue; if (res.getProject() == null) continue; if (project == null) project = res.getProject(); else { project = null; break; } } if (project != null) { dest = project; setDescription("Create new top-level Clojure " + kind(true) + "."); } else if (project == null) { mainPage.setErrorMessage( "Cannot create top-level Clojure " + kind(true) + " without project selection."); fail = true; } } if (!fail) { Group group = label(topLevel, kind() + " name:"); text = new Text(group, SWT.LEFT + SWT.BORDER); addToGroup(group, text); } }
public boolean setModelPropertyValue(String key, Object data) throws ObserverFailedException { boolean returnResult = super.setModelPropertyValue(key, data); if (key.equals(PsArtifactConstants.WIZARD_OPTION_IMPORT_FILE)) { if (getImportFile() != null && !getImportFile().toString().equals("")) { try { List<OMElement> availableProxies = new ArrayList<OMElement>(); if (SynapseFileUtils.isSynapseConfGiven( getImportFile(), SynapseEntryType.PROXY_SERVICE)) { availableProxies = SynapseFileUtils.synapseFileProcessing( getImportFile().getPath(), SynapseEntryType.PROXY_SERVICE); setAvailablePSList(availableProxies); } else { setAvailablePSList(new ArrayList<OMElement>()); } returnResult = false; } catch (OMException e) { log.error("Error reading object model", e); } catch (XMLStreamException e) { log.error("XML stream error", e); } catch (IOException e) { log.error("I/O error has occurred", e); } catch (Exception e) { log.error("An unexpected error has occurred", e); } } } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_PS_TYPE)) { ArtifactTemplate template = (ArtifactTemplate) data; setSelectedTemplate(template); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_SAVE_LOCATION)) { IContainer container = (IContainer) data; if (container != null && container instanceof IFolder) { IFolder proxyFolder = container .getProject() .getFolder("src") .getFolder("main") .getFolder("synapse-config") .getFolder("proxy-services"); setProxyServiceSaveLocation(proxyFolder); } else { setProxyServiceSaveLocation(container); } } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_CREATE_ESB_PROJECT)) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); IProject esbProject = ESBProjectUtils.createESBProject(shell, getLocation()); if (esbProject != null) { setProxyServiceSaveLocation(esbProject); } } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_PS_NAME)) { setProxyServiceName(data.toString()); } else if (key.equals("proxy.target.ep.type")) { setTargetEPType((TargetEPType) data); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_COMMON_PS_EPURL)) { setEndPointUrl(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_COMMON_PS_EPKEY)) { setEndPointKey(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_SECURE_PS_SECPOLICY)) { setSecPolicy(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_WSDL_PS_WSDLURL)) { setWsdlUri(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_WSDL_PS_WSDLSERVICE)) { setWsdlService(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_WSDL_PS_WSDLPORT)) { setWsdlPort(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_WSDL_PS_PUBLISHSAME)) { setPublishSameService((Boolean) data); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_LOGGING_PS_REQLOGLEVEL)) { setRequestLogLevel(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_LOGGING_PS_RESLOGLEVEL)) { setResponseLogLevel(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_TRANSFORMER_PS_XSLT)) { setRequestXSLT(data.toString()); } else if (key.equals( PsArtifactConstants.WIZARD_OPTION_TEMPL_TRANSFORMER_PS_TRANSFORMRESPONSES)) { setTransformResponses((Boolean) data); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_TRANSFORMER_PS_RESXSLT)) { setResponseXSLT(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_TEMPL_COMMON_PS_EPLIST)) { setPredefinedEndPoint(data.toString()); } else if (key.equals(PsArtifactConstants.WIZARD_OPTION_AVAILABLE_PS)) { Object[] selectedEPs = (Object[]) data; if (selectedProxyList != null) selectedProxyList.clear(); for (Object object : selectedEPs) { if (object instanceof OMElement) { selectedProxyList.add((OMElement) object); } } setSelectedProxyList(selectedProxyList); } return returnResult; }