Java Code Examples for org.eclipse.core.resources.IContainer

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Bio-PEPA, under directory /uk.ac.ed.inf.common/src/uk/ac/ed/inf/common/launching/.

Source file: LaunchingUtils.java

  22 
vote

/** 
 * Gets the output folder from the current configuration. Returns <code>null</code> if a valid folder cannot be calculated
 * @param configuration
 * @return
 */
public static IFolder getOutputFolder(ILaunchConfiguration configuration){
  String outputDirectory=null;
  try {
    outputDirectory=configuration.getAttribute(ILaunchingConstants.SRMC_OUTPUT_DIR,(String)null);
  }
 catch (  CoreException e) {
    return null;
  }
  if (outputDirectory == null)   return null;
  Path path=new Path(outputDirectory);
  IContainer container=ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
  if (container == null || container.getType() != IContainer.FOLDER)   return null;
  return (IFolder)container;
}
 

Example 2

From project bpelunit, under directory /tycho/net.bpelunit.toolsupport/editors/sections/.

Source file: PUTSection.java

  22 
vote

protected void handleChooseWSDLSelected(){
  String currentFile=fWSDLEntry.getValue();
  IProject currentProject=getEditor().getCurrentProject();
  IContainer currentDirectory=getEditor().getCurrentDirectory();
  String path=FileSelector.getFile(getShell(),currentFile,new WSDLFileValidator(getEditor()),new WSDLFileFilter(),currentProject,currentDirectory);
  if (path != null) {
    fWSDLEntry.setValue(path);
    getPUT().setWsdl(path);
    manageTargetNamespace(path);
    markDirty();
  }
}
 

Example 3

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/.

Source file: BPMN2DiagramCreator.java

  22 
vote

/** 
 * Delete the temporary diagram file. If the containing folder hierarchy is empty, it will also be deleted.
 * @param file - the temporary diagram file.
 */
public static void dispose(IFile file){
  try {
    IContainer container=file.getParent();
    file.delete(true,null);
    while (isEmptyFolder(container)) {
      container.delete(true,null);
      container=container.getParent();
    }
  }
 catch (  CoreException e) {
    e.printStackTrace();
  }
}
 

Example 4

From project bundlemaker, under directory /main/org.bundlemaker.core/src/org/bundlemaker/core/internal/.

Source file: BundleMakerProjectNature.java

  22 
vote

/** 
 * <p> </p>
 * @param folder
 * @throws CoreException
 */
private static void createFolder(IFolder folder) throws CoreException {
  IContainer parent=folder.getParent();
  if (parent instanceof IFolder) {
    createFolder((IFolder)parent);
  }
  if (!folder.exists()) {
    folder.create(false,true,null);
  }
}
 

Example 5

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/wizard/.

Source file: BuildPathsBlock.java

  22 
vote

private void buildPathChangeControlPressed(DialogField field){
  if (field == fJavaBuildPathDialogField) {
    IContainer container=chooseContainer(fJavaOutputLocationPath);
    if (container != null) {
      fJavaBuildPathDialogField.setText(container.getFullPath().makeRelative().toString());
    }
  }
}
 

Example 6

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/project/.

Source file: DawbResourcePage.java

  22 
vote

private String getContainerPath(IStructuredSelection selection){
  if (selection == null)   return null;
  final Object res=selection.getFirstElement();
  if (res instanceof IAdaptable) {
    final IContainer container=(IContainer)((IAdaptable)res).getAdapter(IContainer.class);
    if (container != null) {
      return container.getFullPath().toPortableString();
    }
  }
  return null;
}
 

Example 7

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model.ui/src/main/java/com/isencia/passerelle/workbench/model/ui/wizards/.

Source file: PasserelleNewModelWizardPage.java

  22 
vote

/** 
 * Tests if the current workbench selection is a suitable container to use.
 */
private void initialize(){
  IContainer container=null;
  if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) {
    IStructuredSelection ssel=(IStructuredSelection)selection;
    if (ssel.size() > 1)     return;
    Object obj=ssel.getFirstElement();
    if (obj instanceof IResource) {
      if (obj instanceof IContainer)       container=(IContainer)obj;
 else       container=((IResource)obj).getParent();
      containerText.setText(container.getFullPath().toString());
    }
  }
  fileText.setText(generateUniqueFileName(container));
}
 

Example 8

From project dawn-workflow, under directory /org.dawb.passerelle.actors/src/org/dawb/passerelle/actors/edna/.

Source file: AbstractEdnaPlugin.java

  22 
vote

private IFolder getEdnaXmlFolder() throws Exception {
  final IContainer cont=getProject();
  final IFolder edna=cont.getFolder(new Path("edna-xml"));
  if (!edna.exists()) {
    try {
      edna.create(true,true,new NullProgressMonitor());
    }
 catch (    Exception ne) {
      logger.error("Did not create new folder " + edna.getName(),ne);
    }
  }
  return edna;
}
 

Example 9

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/project/.

Source file: NewDroolsProjectWizard.java

  22 
vote

private void createFolder(IFolder folder,IProgressMonitor monitor) throws CoreException {
  IContainer container=folder.getParent();
  if (container != null && !container.exists() && (container instanceof IFolder))   createFolder((IFolder)container,monitor);
  if (!folder.exists()) {
    folder.create(true,true,monitor);
  }
}
 

Example 10

From project Eclipse, under directory /com.mobilesorcery.sdk.core/src/com/mobilesorcery/sdk/core/templates/.

Source file: ProjectTemplate.java

  22 
vote

private void mkParents(IResource resource) throws CoreException {
  IContainer parent=resource.getParent();
  if (!parent.exists() && parent != null) {
    mkParents(parent);
    if (parent.getType() == IResource.FOLDER) {
      ((IFolder)parent).create(true,true,new NullProgressMonitor());
    }
  }
}
 

Example 11

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.core/src/org/springsource/ide/eclipse/commons/core/.

Source file: SpringCoreUtils.java

  22 
vote

/** 
 * Creates given folder and (if necessary) all of it's parents.
 */
public static void createFolder(IFolder folder,IProgressMonitor monitor) throws CoreException {
  if (!folder.exists()) {
    IContainer parent=folder.getParent();
    if (parent instanceof IFolder) {
      createFolder((IFolder)parent,monitor);
    }
    folder.create(true,true,monitor);
  }
}
 

Example 12

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.core.test/src/org/springsource/ide/eclipse/gradle/core/test/.

Source file: GradleTest.java

  22 
vote

private static void create(IFolder folder) throws Exception {
  IContainer parent=folder.getParent();
  if (parent instanceof IFolder && !parent.exists()) {
    create(((IFolder)parent));
  }
  folder.create(true,true,new NullProgressMonitor());
}
 

Example 13

From project eclipsefp, under directory /net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/builder/.

Source file: CleanOutFoldersOperation.java

  22 
vote

private void shrubOutFolder(final IProgressMonitor mon) throws CoreException {
  mon.subTask(CoreTexts.cleanOutFoldersOperation_shrubbingOut);
  IContainer outFolder=ResourceUtil.getOutFolder(project);
  if (outFolder != null && !outFolder.equals(project)) {
    outFolder.accept(folderCleaner,IContainer.INCLUDE_PHANTOMS);
  }
  mon.worked(12);
}
 

Example 14

From project edna-rcp, under directory /org.edna.plugingenerator/src/org/edna/plugingenerator/wizards/.

Source file: NewEDNAPluginWizard.java

  22 
vote

private void getEdnaHome(){
  IContainer temp=this.folder;
  IContainer old=null;
  while (temp != null) {
    if (temp.getName().equals("edna")) {
      edna_home=temp;
      edna_project=old;
    }
    old=temp;
    temp=temp.getParent();
  }
}
 

Example 15

From project grails-ide, under directory /org.grails.ide.eclipse.test.ui/src/org/grails/ide/eclipse/ui/test/.

Source file: GrailsJUnitIntegrationTests.java

  22 
vote

/** 
 * Typically called before creating a File to ensure that all the parents in the path leading to the file are created if necessary
 * @throws CoreException 
 */
private void createParents(IResource fileOrFolder) throws CoreException {
  IContainer parent=fileOrFolder.getParent();
  if (parent != null && !parent.exists()) {
    IFolder folder=(IFolder)parent;
    createParents(folder);
    folder.create(true,true,null);
  }
}
 

Example 16

From project iee, under directory /org.eclipse.iee.editor.wizard/src/org/eclipse/iee/editor/wizard/wizards/.

Source file: GeneralIEEWizardPage.java

  22 
vote

/** 
 * 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();
    if (obj instanceof IResource) {
      IContainer container;
      if (obj instanceof IContainer)       container=(IContainer)obj;
 else       container=((IResource)obj).getParent();
      containerText.setText(container.getFullPath().toString());
    }
  }
  fileText.setText("iee.java");
}
 

Example 17

From project libra, under directory /plugins/org.eclipse.libra.facet/src/org/eclipse/libra/facet/.

Source file: OSGiBundleFacetUninstallDelegate.java

  22 
vote

private void cleanUpManifest(IProject project,IProgressMonitor monitor) throws CoreException {
  IResource manifestFile=findResource(project,MANIFEST_URI);
  manifestFile.delete(IResource.KEEP_HISTORY,monitor);
  IContainer metaInfFolder=manifestFile.getParent();
  if (metaInfFolder.members().length == 0) {
    metaInfFolder.delete(IResource.KEEP_HISTORY,monitor);
  }
}
 

Example 18

From project m2eclipse-tycho, under directory /org.sonatype.tycho.m2e/src/org/sonatype/tycho/m2e/internal/.

Source file: PDEProjectHelper.java

  22 
vote

/** 
 * Returns bundle manifest as known to PDE project metadata. Returned file may not exist in the workspace or on the filesystem. Never returns null.
 */
public static IFile getBundleManifest(IProject project) throws CoreException {
  IContainer metainf=PDEProject.getBundleRoot(project);
  if (metainf == null || metainf instanceof IProject) {
    metainf=project.getFolder("META-INF");
  }
 else {
    metainf=metainf.getFolder(new Path("META-INF"));
  }
  return metainf.getFile(new Path("MANIFEST.MF"));
}
 

Example 19

From project m2eclipse-wtp, under directory /org.maven.ide.eclipse.wtp/src/org/maven/ide/eclipse/wtp/filtering/.

Source file: ResourceFilteringBuildParticipant.java

  22 
vote

private void deleteFilteredResources(IProject project,IPath targetFolderPath) throws CoreException {
  IFolder targetFolder=project.getFolder(targetFolderPath);
  if (targetFolder.exists()) {
    IContainer parent=targetFolder.getParent();
    LOG.info("Cleaning filtered folder for " + project.getName());
    IProgressMonitor monitor=new NullProgressMonitor();
    targetFolder.delete(true,monitor);
    if (parent != null) {
      parent.refreshLocal(IResource.DEPTH_INFINITE,monitor);
    }
  }
}
 

Example 20

From project mylyn.context, under directory /org.eclipse.mylyn.resources.ui/src/org/eclipse/mylyn/internal/resources/ui/.

Source file: ResourceStructureBridge.java

  22 
vote

@Override public String getParentHandle(String handle,boolean allowChildBridgeHandles){
  if (allowChildBridgeHandles) {
    return getParentHandle(handle);
  }
 else {
    IResource resource=(IResource)getObjectForHandle(handle);
    if (resource != null) {
      IContainer parent=resource.getParent();
      return getHandleIdentifier(parent);
    }
  }
  return null;
}
 

Example 21

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/explorer/s3/dnd/.

Source file: S3ObjectSummaryDropAction.java

  21 
vote

public boolean run(Object source,Object target){
  BucketAndKey bk=new BucketAndKey((byte[])source);
  IContainer dropFolder;
  if (target instanceof IContainer) {
    dropFolder=(IContainer)target;
  }
 else   if (target instanceof IFile) {
    dropFolder=((IFile)target).getParent();
  }
 else   if (target instanceof IJavaProject) {
    dropFolder=((IJavaProject)target).getProject();
  }
 else   if (target instanceof IJavaElement) {
    IJavaElement j=(IJavaElement)target;
    try {
      return run(source,j.getUnderlyingResource());
    }
 catch (    JavaModelException e) {
      AwsToolkitCore.getDefault().logException("Couldn't determine java resource",e);
      return false;
    }
  }
 else {
    return false;
  }
  final File f=dropFolder.getLocation().toFile();
  if (!f.exists())   return false;
  String fileName=getOutputFileName(bk.key,f);
  if (fileName == null || fileName.length() == 0) {
    return false;
  }
  final File outputFile=new File(fileName);
  new DownloadObjectJob("Downloading " + bk.key,bk.bucket,bk.key,dropFolder,outputFile).schedule();
  return true;
}
 

Example 22

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/actions/.

Source file: SjsFileContentProvider.java

  21 
vote

public Object[] getChildren(Object parentElement){
  ArrayList<IResource> childElements=new ArrayList<IResource>();
  if (parentElement instanceof IContainer && ((IContainer)parentElement).isAccessible()) {
    IContainer container=(IContainer)parentElement;
    try {
      for (int i=0; i < container.members().length; i++) {
        IResource resource=container.members()[i];
        if (resource instanceof IFile && isSjs((IFile)resource)) {
          childElements.add(resource);
        }
 else         if (resource instanceof IContainer && resource.isAccessible() && containsMolecules((IContainer)resource)) {
          childElements.add(resource);
        }
      }
    }
 catch (    CoreException e) {
      LogUtils.handleException(e,logger,net.bioclipse.chemoinformatics.Activator.PLUGIN_ID);
    }
catch (    IOException e) {
      LogUtils.handleException(e,logger,net.bioclipse.chemoinformatics.Activator.PLUGIN_ID);
    }
  }
  return childElements.toArray();
}
 

Example 23

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.nmrshiftdb/src/net/bioclipse/nmrshiftdb/wizards/.

Source file: CloneWizard.java

  21 
vote

@Override public boolean performFinish(){
  try {
    IContainer parent=biores.getParent();
    CMLCml cmlcml=Activator.getDefault().getJavaSpecmolManager().loadSpecmol(biores).getJumboObject();
    Elements spectra=cmlcml.getChildCMLElements("spectrum");
    for (int h=0; h < spectra.size(); h++) {
      Elements metadatalists=((CMLSpectrum)spectra.get(h)).getChildElements();
      for (int l=0; l < metadatalists.size(); l++) {
        if (metadatalists.get(l) instanceof CMLMetadataList) {
          List<CMLMetadata> mds=MetadataUtils.getMetadataDescendantsByName(((CMLMetadataList)metadatalists.get(l)).getMetadataDescendants(),"nmr:nmrshiftdbid");
          for (int i=0; i < mds.size(); i++) {
            ((CMLMetadataList)metadatalists.get(l)).removeChild(mds.get(i));
          }
        }
      }
    }
    Activator.getDefault().getJavaSpecmolManager().saveSpecmol(new JumboSpecmol(cmlcml),parent.getFile(new Path(clonePage.text.getText())));
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  return true;
}
 

Example 24

From project bndtools, under directory /bndtools.core/src/bndtools/editor/workspace/.

Source file: WorkspaceMainPart.java

  21 
vote

@Override public void initialize(IManagedForm form){
  super.initialize(form);
  try {
    Composite container=(Composite)getSection().getClient();
    IFile buildFile=Central.getWorkspaceBuildFile();
    if (buildFile == null)     return;
    if (!mainFile) {
      ImageHyperlink link=form.getToolkit().createImageHyperlink(container,SWT.CENTER);
      link.setText("Open main build.bnd file.");
      link.setImage(bndFileImg);
      link.addHyperlinkListener(new FileOpenLinkListener(buildFile.getFullPath()));
    }
 else {
      IResource[] extFiles;
      IContainer cnfDir=buildFile.getParent();
      IFolder extDir=cnfDir.getFolder(new Path("ext"));
      if (extDir.exists())       extFiles=extDir.members();
 else       extFiles=new IResource[0];
      if (extFiles.length > 0) {
        for (        IResource extFile : extFiles) {
          if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
            ImageHyperlink link=form.getToolkit().createImageHyperlink(container,SWT.CENTER);
            link.setText("Open " + extFile.getName());
            link.setImage(extFileImg);
            link.addHyperlinkListener(new FileOpenLinkListener(extFile.getFullPath()));
          }
        }
      }
 else {
        createMissingExtsWarningPanel(container,form.getToolkit(),extDir.getFullPath());
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 25

From project dawn-tango, under directory /org.dawb.passerelle.actors.tango/src/org/dawb/passerelle/actors/hardware/.

Source file: TangoCommandTransformer.java

  21 
vote

protected IResource getResource(final boolean setParameterValue) throws Exception {
  String path=specFileParam.getExpression();
  IFile file=null;
  if (path == null || "".equals(path)) {
    final IProject project=getProject();
    final IContainer src=project.getFolder("src");
    file=IFileUtils.getUniqueIFile(src,"macro","mac");
    path=file.getFullPath().toOSString();
    path=StringUtil.replace(path,"/" + file.getProject().getName() + "/","/${project_name}/",true);
    if (setParameterValue)     specFileParam.setExpression(path);
  }
  if (ResourcesPlugin.getWorkspace().getRoot().findMember(path) != null)   if (ResourcesPlugin.getWorkspace().getRoot().findMember(path).exists()) {
    file=(IFile)ResourcesPlugin.getWorkspace().getRoot().findMember(path);
  }
  if (file == null) {
    path=ParameterUtils.substitute(path,this);
    final IProject project=getProject();
    final String srcP=IFileUtils.getPathWithoutProject(path.substring(0,path.lastIndexOf('/')));
    IContainer specDir=(IContainer)project.findMember(srcP);
    if (specDir == null) {
      try {
        IFolder srcf=project.getFolder(srcP);
        specDir=srcf;
      }
 catch (      Exception ne) {
        logger.error("Cannot create folder " + srcP,ne);
      }
    }
    final String fileName=path.substring(path.lastIndexOf('/'));
    file=(IFile)specDir.findMember(fileName);
    if (file == null && specDir instanceof IProject) {
      file=((IProject)specDir).getFile(fileName);
    }
    if (file == null && specDir instanceof IFolder) {
      file=((IFolder)specDir).getFile(fileName);
    }
  }
  return file;
}
 

Example 26

From project dawn-third, under directory /org.dawb.org.csstudio.swt.xygraph/src/org/csstudio/swt/xygraph/toolbar/.

Source file: TraceConfigPage.java

  21 
vote

/** 
 * Gets a unique file. The file must have a parent of IFolder.
 * @param file
 * @return new file, not created.
 */
public static IFile getUniqueFile(IFile file,final String conjunctive,final String extension){
  final String name=file.getName();
  final Matcher matcher=Pattern.compile("(.+)(\\d+)\\." + extension,Pattern.CASE_INSENSITIVE).matcher(name);
  int start=0;
  String frag=name;
  try {
    frag=name.substring(0,name.lastIndexOf("."));
  }
 catch (  Throwable ignored) {
  }
  if (matcher.matches()) {
    frag=matcher.group(1);
    start=Integer.parseInt(matcher.group(2));
  }
  if (conjunctive != null) {
    frag=frag + conjunctive;
  }
  final IContainer parent=file.getParent();
  final IFile newFile;
  if (parent instanceof IFolder) {
    newFile=((IFolder)parent).getFile(frag + "." + extension);
  }
 else   if (parent instanceof IProject) {
    newFile=((IProject)parent).getFile(frag + "." + extension);
  }
 else {
    newFile=null;
  }
  if (newFile != null && !newFile.exists())   return newFile;
  return getUniqueFile(parent,frag,++start,extension);
}
 

Example 27

From project gda-common-rcp, under directory /uk.ac.gda.common.rcp/src/uk/ac/gda/common/rcp/util/.

Source file: EclipseUtils.java

  21 
vote

/** 
 * Gets a unique file. The file must have a parent of IFolder.
 * @param file
 * @return new file, not created.
 */
public static IFile getUniqueFile(IFile file,final String conjunctive,final String extension){
  final String name=file.getName();
  final Matcher matcher=Pattern.compile("(.+)(\\d+)\\." + extension,Pattern.CASE_INSENSITIVE).matcher(name);
  int start=0;
  String frag=name.substring(0,name.lastIndexOf("."));
  if (matcher.matches()) {
    frag=matcher.group(1);
    start=Integer.parseInt(matcher.group(2));
  }
  if (conjunctive != null) {
    frag=frag + conjunctive;
  }
  final IContainer parent=file.getParent();
  final IFile newFile;
  if (parent instanceof IFolder) {
    newFile=((IFolder)parent).getFile(frag + "." + extension);
  }
 else   if (parent instanceof IProject) {
    newFile=((IProject)parent).getFile(frag + "." + extension);
  }
 else {
    newFile=null;
  }
  if (newFile != null && !newFile.exists())   return newFile;
  return getUniqueFile(parent,frag,++start,extension);
}
 

Example 28

From project ivyde, under directory /org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/wizards/.

Source file: IvyNewWizardPage.java

  21 
vote

/** 
 * Tests if the current workbench selection is a suitable container to use.
 */
private void initialize(){
  if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
    IStructuredSelection ssel=(IStructuredSelection)selection;
    if (ssel.size() > 1) {
      return;
    }
    Object obj=ssel.getFirstElement();
    if (obj instanceof IResource) {
      IContainer container;
      if (obj instanceof IContainer) {
        container=(IContainer)obj;
      }
 else {
        container=((IResource)obj).getParent();
      }
      containerText.setText(container.getFullPath().toString());
      moduleText.setText(container.getProject().getName());
    }
  }
  fileText.setText("ivy.xml");
  statusText.select(0);
  orgText.setText(IvyPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.ORGANISATION));
}
 

Example 29

From project JGit, under directory /org.spearce.egit.core/src/org/spearce/egit/core/.

Source file: ContainerTreeIterator.java

  21 
vote

ResourceEntry(final IResource f){
  rsrc=f;
switch (f.getType()) {
case IResource.FILE:
    if (FS.INSTANCE.canExecute(asFile()))     mode=FileMode.EXECUTABLE_FILE;
 else     mode=FileMode.REGULAR_FILE;
  break;
case IResource.PROJECT:
case IResource.FOLDER:
{
  final IContainer c=(IContainer)f;
  if (c.findMember(".git") != null)   mode=FileMode.GITLINK;
 else   mode=FileMode.TREE;
  break;
}
default :
mode=FileMode.MISSING;
break;
}
}
 

Example 30

From project m2eclipse-webby, under directory /org.sonatype.m2e.webby/src/org/sonatype/m2e/webby/internal/launch/ui/.

Source file: WebbyLaunchShortcut.java

  21 
vote

public void launch(ISelection selection,String mode){
  if (selection instanceof IStructuredSelection) {
    IStructuredSelection structuredSelection=(IStructuredSelection)selection;
    Object object=structuredSelection.getFirstElement();
    IContainer container=null;
    if (object instanceof IProject || object instanceof IFolder) {
      container=(IContainer)object;
    }
 else     if (object instanceof IFile) {
      container=((IFile)object).getParent();
    }
 else     if (object instanceof IAdaptable) {
      IAdaptable adaptable=(IAdaptable)object;
      Object adapter=adaptable.getAdapter(IProject.class);
      if (adapter != null) {
        container=(IContainer)adapter;
      }
 else {
        adapter=adaptable.getAdapter(IFolder.class);
        if (adapter != null) {
          container=(IContainer)adapter;
        }
 else {
          adapter=adaptable.getAdapter(IFile.class);
          if (adapter != null) {
            container=((IFile)object).getParent();
          }
        }
      }
    }
    launch(container,mode);
  }
}
 

Example 31

From project Mura-Tools-for-Eclipse-Core, under directory /src/com/muratools/eclipse/.

Source file: MuraToolsAction.java

  21 
vote

public String getTargetDirectory(){
  String targetPath="";
  String containerPath="";
  if (getSelection() != null && getSelection().isEmpty() == false && getSelection() instanceof IStructuredSelection) {
    IStructuredSelection ssel=(IStructuredSelection)getSelection();
    if (ssel.size() > 1) {
      return targetPath;
    }
    Object obj=ssel.getFirstElement();
    if (obj instanceof IResource) {
      IContainer container=(IContainer)obj;
      containerPath=container.getFullPath().toString();
      IWorkspaceRoot root=ResourcesPlugin.getWorkspace().getRoot();
      IResource resource=root.findMember(new Path(containerPath));
      if (resource != null) {
        IPath path=container.getLocation();
        targetPath=path.toOSString();
      }
    }
  }
  return targetPath;
}
 

Example 32

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaModelWizard.java

  19 
vote

/** 
 * The framework calls this to create the contents of the wizard. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void addPages(){
  newFileCreationPage=new ScalaModelWizardNewFileCreationPage("Whatever",selection);
  newFileCreationPage.setTitle(ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaModelWizard_label"));
  newFileCreationPage.setDescription(ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaModelWizard_description"));
  newFileCreationPage.setFileName(ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
  addPage(newFileCreationPage);
  if (selection != null && !selection.isEmpty()) {
    Object selectedElement=selection.iterator().next();
    if (selectedElement instanceof IResource) {
      IResource selectedResource=(IResource)selectedElement;
      if (selectedResource.getType() == IResource.FILE) {
        selectedResource=selectedResource.getParent();
      }
      if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
        newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
        String defaultModelBaseFilename=ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaEditorFilenameDefaultBase");
        String defaultModelFilenameExtension=FILE_EXTENSIONS.get(0);
        String modelFilename=defaultModelBaseFilename + "." + defaultModelFilenameExtension;
        for (int i=1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
          modelFilename=defaultModelBaseFilename + i + "."+ defaultModelFilenameExtension;
        }
        newFileCreationPage.setFileName(modelFilename);
      }
    }
  }
  initialObjectCreationPage=new ScalaModelWizardInitialObjectCreationPage("Whatever2");
  initialObjectCreationPage.setTitle(ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaModelWizard_label"));
  initialObjectCreationPage.setDescription(ScalaEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
  addPage(initialObjectCreationPage);
}
 

Example 33

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappModelWizard.java

  19 
vote

/** 
 * The framework calls this to create the contents of the wizard. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void addPages(){
  newFileCreationPage=new WebappModelWizardNewFileCreationPage("Whatever",selection);
  newFileCreationPage.setTitle(WebappEditorPlugin.INSTANCE.getString("_UI_WebappModelWizard_label"));
  newFileCreationPage.setDescription(WebappEditorPlugin.INSTANCE.getString("_UI_WebappModelWizard_description"));
  newFileCreationPage.setFileName(WebappEditorPlugin.INSTANCE.getString("_UI_WebappEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
  addPage(newFileCreationPage);
  if (selection != null && !selection.isEmpty()) {
    Object selectedElement=selection.iterator().next();
    if (selectedElement instanceof IResource) {
      IResource selectedResource=(IResource)selectedElement;
      if (selectedResource.getType() == IResource.FILE) {
        selectedResource=selectedResource.getParent();
      }
      if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
        newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
        String defaultModelBaseFilename=WebappEditorPlugin.INSTANCE.getString("_UI_WebappEditorFilenameDefaultBase");
        String defaultModelFilenameExtension=FILE_EXTENSIONS.get(0);
        String modelFilename=defaultModelBaseFilename + "." + defaultModelFilenameExtension;
        for (int i=1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
          modelFilename=defaultModelBaseFilename + i + "."+ defaultModelFilenameExtension;
        }
        newFileCreationPage.setFileName(modelFilename);
      }
    }
  }
  initialObjectCreationPage=new WebappModelWizardInitialObjectCreationPage("Whatever2");
  initialObjectCreationPage.setTitle(WebappEditorPlugin.INSTANCE.getString("_UI_WebappModelWizard_label"));
  initialObjectCreationPage.setDescription(WebappEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
  addPage(initialObjectCreationPage);
}
 

Example 34

From project CIShell, under directory /templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/.

Source file: BasicTemplate.java

  19 
vote

private void copyFile(String fileName,InputStream inputStream,IContainer destinationContainer,boolean isBinary,boolean shouldProcessSubFileAsTemplate,IProgressMonitor progressMonitor) throws CoreException {
  String targetFileName;
  if (shouldProcessSubFileAsTemplate) {
    targetFileName=getProcessedString(fileName,fileName);
  }
 else {
    targetFileName=fileName;
  }
  progressMonitor.subTask(targetFileName);
  IFile destinationFile=destinationContainer.getFile(new Path(targetFileName));
  try {
    InputStream processedInputStream;
    if (shouldProcessSubFileAsTemplate) {
      processedInputStream=getProcessedStream(fileName,inputStream,isBinary);
    }
 else {
      processedInputStream=inputStream;
    }
    if (destinationFile.exists()) {
      destinationFile.setContents(processedInputStream,true,true,progressMonitor);
    }
 else {
      destinationFile.create(processedInputStream,true,progressMonitor);
    }
    processedInputStream.close();
  }
 catch (  IOException ioException) {
  }
}
 

Example 35

From project Database-Designer, under directory /plugins/org.obeonetwork.dsl.database.editor/src/org/obeonetwork/dsl/database/presentation/.

Source file: DatabaseModelWizard.java

  19 
vote

/** 
 * The framework calls this to create the contents of the wizard. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void addPages(){
  newFileCreationPage=new DatabaseModelWizardNewFileCreationPage("Whatever",selection);
  newFileCreationPage.setTitle(DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseModelWizard_label"));
  newFileCreationPage.setDescription(DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseModelWizard_description"));
  newFileCreationPage.setFileName(DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
  addPage(newFileCreationPage);
  if (selection != null && !selection.isEmpty()) {
    Object selectedElement=selection.iterator().next();
    if (selectedElement instanceof IResource) {
      IResource selectedResource=(IResource)selectedElement;
      if (selectedResource.getType() == IResource.FILE) {
        selectedResource=selectedResource.getParent();
      }
      if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
        newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
        String defaultModelBaseFilename=DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseEditorFilenameDefaultBase");
        String defaultModelFilenameExtension=FILE_EXTENSIONS.get(0);
        String modelFilename=defaultModelBaseFilename + "." + defaultModelFilenameExtension;
        for (int i=1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
          modelFilename=defaultModelBaseFilename + i + "."+ defaultModelFilenameExtension;
        }
        newFileCreationPage.setFileName(modelFilename);
      }
    }
  }
  initialObjectCreationPage=new DatabaseModelWizardInitialObjectCreationPage("Whatever2");
  initialObjectCreationPage.setTitle(DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseModelWizard_label"));
  initialObjectCreationPage.setDescription(DatabaseEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
  addPage(initialObjectCreationPage);
}
 

Example 36

From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/launching/internal/.

Source file: FolderSelectionDialog.java

  19 
vote

@Override public Object[] getChildren(Object parentElement){
  Object[] children=proxy.getChildren(parentElement);
  ArrayList<Object> result=new ArrayList<Object>();
  for (  Object o : children) {
    if (o instanceof IContainer) {
      result.add(o);
    }
  }
  return result.toArray();
}
 

Example 37

From project eclipse-instasearch, under directory /instasearch/src/it/unibz/instasearch/indexing/.

Source file: ResourceCollector.java

  19 
vote

public boolean visit(IResource resource) throws CoreException {
  if (!(resource instanceof IContainer))   return false;
  if (isResourceExcluded(resource,excludedPatterns))   return false;
switch (resource.getType()) {
case IResource.FOLDER:
    containers.add((IContainer)resource);
  break;
case IResource.PROJECT:
return visit((IProject)resource);
}
return true;
}
 

Example 38

From project EMF-IncQuery, under directory /plugins/org.eclipse.viatra2.emf.incquery.tooling.core/src/org/eclipse/viatra2/emf/incquery/core/project/.

Source file: ProjectGenerationHelper.java

  19 
vote

/** 
 * Adds a file to a container.
 * @param container the container to add the file to
 * @param path the path of the newly created file
 * @param contentStream the file will be filled with this stream's contents
 * @param monitor
 * @throws CoreException
 */
public static void addFileToProject(IContainer container,Path path,InputStream contentStream,IProgressMonitor monitor) throws CoreException {
  final IFile file=container.getFile(path);
  if (file.exists()) {
    file.setContents(contentStream,true,true,monitor);
  }
 else {
    file.create(contentStream,true,monitor);
  }
}
 

Example 39

From project fr.obeo.performance, under directory /fr.obeo.performance.editor/src-gen/fr/obeo/performance/presentation/.

Source file: PerformanceModelWizard.java

  19 
vote

/** 
 * The framework calls this to create the contents of the wizard. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void addPages(){
  newFileCreationPage=new PerformanceModelWizardNewFileCreationPage("Whatever",selection);
  newFileCreationPage.setTitle(PerformanceEditorPlugin.INSTANCE.getString("_UI_PerformanceModelWizard_label"));
  newFileCreationPage.setDescription(PerformanceEditorPlugin.INSTANCE.getString("_UI_PerformanceModelWizard_description"));
  newFileCreationPage.setFileName(PerformanceEditorPlugin.INSTANCE.getString("_UI_PerformanceEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
  addPage(newFileCreationPage);
  if (selection != null && !selection.isEmpty()) {
    Object selectedElement=selection.iterator().next();
    if (selectedElement instanceof IResource) {
      IResource selectedResource=(IResource)selectedElement;
      if (selectedResource.getType() == IResource.FILE) {
        selectedResource=selectedResource.getParent();
      }
      if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
        newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
        String defaultModelBaseFilename=PerformanceEditorPlugin.INSTANCE.getString("_UI_PerformanceEditorFilenameDefaultBase");
        String defaultModelFilenameExtension=FILE_EXTENSIONS.get(0);
        String modelFilename=defaultModelBaseFilename + "." + defaultModelFilenameExtension;
        for (int i=1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
          modelFilename=defaultModelBaseFilename + i + "."+ defaultModelFilenameExtension;
        }
        newFileCreationPage.setFileName(modelFilename);
      }
    }
  }
  initialObjectCreationPage=new PerformanceModelWizardInitialObjectCreationPage("Whatever2");
  initialObjectCreationPage.setTitle(PerformanceEditorPlugin.INSTANCE.getString("_UI_PerformanceModelWizard_label"));
  initialObjectCreationPage.setDescription(PerformanceEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
  addPage(initialObjectCreationPage);
}
 

Example 40

From project gted, under directory /net.sf.gted.tools/src/net/sf/gted/tools/properties/.

Source file: FolderSelectionDialog.java

  19 
vote

private void updateNewFolderButtonState(){
  final IStructuredSelection selection=(IStructuredSelection)this.getTreeViewer().getSelection();
  this.fSelectedContainer=null;
  if (selection.size() == 1) {
    final Object first=selection.getFirstElement();
    if (first instanceof IContainer) {
      this.fSelectedContainer=(IContainer)first;
    }
  }
  this.fNewFolderButton.setEnabled(this.fSelectedContainer != null);
}
 

Example 41

From project js4emf, under directory /org.eclipse.emf.js4emf.ui/src/org/eclipse/emf/js4emf/builders/.

Source file: JavascriptBuilder.java

  19 
vote

public boolean visit(IResource resource) throws CoreException {
  if (resource instanceof IContainer) {
    return true;
  }
 else   if (resource instanceof IFile && changeShouldTriggerBuild((IFile)resource)) {
    build((IFile)resource);
  }
  return false;
}
 

Example 42

From project koneki.ldt, under directory /plugins/org.eclipse.koneki.ldt.debug.ui/src/org/eclipse/koneki/ldt/debug/ui/internal/launchconfiguration/local/.

Source file: LuaApplicationLaunchShortcut.java

  19 
vote

private ILaunchConfiguration findLaunchConfiguration(IContainer container) throws CoreException, InterruptedException {
  List<ILaunchConfiguration> candidateConfigs=retreiveLaunchConfiguration();
  candidateConfigs=filterConfig(container,candidateConfigs);
  if (!candidateConfigs.isEmpty()) {
    return candidateConfigs.get(0);
  }
  return null;
}
 

Example 43

From project mwe, under directory /plugins/org.eclipse.emf.mwe.ewm.editor/src/org/eclipse/emf/mwe/ewm/presentation/.

Source file: WorkflowModelWizard.java

  19 
vote

/** 
 * The framework calls this to create the contents of the wizard. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void addPages(){
  newFileCreationPage=new WorkflowModelWizardNewFileCreationPage("Whatever",selection);
  newFileCreationPage.setTitle(WorkflowEditorPlugin.INSTANCE.getString("_UI_WorkflowModelWizard_label"));
  newFileCreationPage.setDescription(WorkflowEditorPlugin.INSTANCE.getString("_UI_WorkflowModelWizard_description"));
  newFileCreationPage.setFileName(WorkflowEditorPlugin.INSTANCE.getString("_UI_WorkflowEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
  addPage(newFileCreationPage);
  if (selection != null && !selection.isEmpty()) {
    Object selectedElement=selection.iterator().next();
    if (selectedElement instanceof IResource) {
      IResource selectedResource=(IResource)selectedElement;
      if (selectedResource.getType() == IResource.FILE) {
        selectedResource=selectedResource.getParent();
      }
      if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
        newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
        String defaultModelBaseFilename=WorkflowEditorPlugin.INSTANCE.getString("_UI_WorkflowEditorFilenameDefaultBase");
        String defaultModelFilenameExtension=FILE_EXTENSIONS.get(0);
        String modelFilename=defaultModelBaseFilename + "." + defaultModelFilenameExtension;
        for (int i=1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
          modelFilename=defaultModelBaseFilename + i + "."+ defaultModelFilenameExtension;
        }
        newFileCreationPage.setFileName(modelFilename);
      }
    }
  }
  initialObjectCreationPage=new WorkflowModelWizardInitialObjectCreationPage("Whatever2");
  initialObjectCreationPage.setTitle(WorkflowEditorPlugin.INSTANCE.getString("_UI_WorkflowModelWizard_label"));
  initialObjectCreationPage.setDescription(WorkflowEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
  addPage(initialObjectCreationPage);
}