Java Code Examples for org.eclipse.core.runtime.IProgressMonitor

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 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: ScalaEditor.java

  18 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs(URI uri,IEditorInput editorInput){
  (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
  setInputWithNotify(editorInput);
  setPartName(editorInput.getName());
  IProgressMonitor progressMonitor=getActionBars().getStatusLineManager() != null ? getActionBars().getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
  doSave(progressMonitor);
}
 

Example 2

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

Source file: WebappEditor.java

  18 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs(URI uri,IEditorInput editorInput){
  (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
  setInputWithNotify(editorInput);
  setPartName(editorInput.getName());
  IProgressMonitor progressMonitor=getActionBars().getStatusLineManager() != null ? getActionBars().getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
  doSave(progressMonitor);
}
 

Example 3

From project acceleo-webapp-generator, under directory /plugins/org.obeonetwork.pim.gen.backbone.model.editor/src-gen/org/obeonetwork/pim/gen/backbone/model/backbone/presentation/.

Source file: BackboneEditor.java

  18 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs(URI uri,IEditorInput editorInput){
  (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
  setInputWithNotify(editorInput);
  setPartName(editorInput.getName());
  IProgressMonitor progressMonitor=getActionBars().getStatusLineManager() != null ? getActionBars().getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
  doSave(progressMonitor);
}
 

Example 4

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.specmol/src/net/bioclipse/specmol/business/.

Source file: SpecmolManager.java

  17 
vote

public void saveSpecmol(IJumboSpecmol specmol,IFile target) throws BioclipseException, CoreException, UnsupportedEncodingException {
  IProgressMonitor monitor=new NullProgressMonitor();
  try {
    int ticks=10000;
    monitor.beginTask("Writing file",ticks);
    CMLSerializer ser=new CMLSerializer();
    ser.setIndent(2);
    String towrite=ser.getXML(specmol.getJumboObject());
    if (target.exists()) {
      target.setContents(new ByteArrayInputStream(towrite.getBytes("US-ASCII")),false,true,monitor);
    }
 else {
      target.create(new ByteArrayInputStream(towrite.getBytes("US-ASCII")),false,monitor);
    }
    monitor.worked(ticks);
  }
  finally {
    monitor.done();
  }
}
 

Example 5

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/net/bioclipse/spectrum/business/.

Source file: SpectrumManager.java

  17 
vote

public void saveSpectrum(IJumboSpectrum spectrum,IFile target,String filetype) throws BioclipseException, CoreException {
  IProgressMonitor monitor=new NullProgressMonitor();
  try {
    int ticks=10000;
    monitor.beginTask("Writing file",ticks);
    String towrite;
    if (filetype.equals(SpectrumEditor.JCAMP_TYPE)) {
      Spectrum jdxspectrum=CMLToJcampSpectrumMapper.mapCMLSpectrumToJcamp(spectrum.getJumboObject());
      JCAMPWriter jcamp=JCAMPWriter.getInstance();
      String jcampString;
      try {
        jcampString=jcamp.toJCAMP(jdxspectrum);
      }
 catch (      JCAMPException e) {
        throw new BioclipseException(e.getMessage());
      }
      towrite=jcampString;
    }
 else     if (filetype.equals(SpectrumEditor.CML_TYPE)) {
      CMLSerializer ser=new CMLSerializer();
      ser.setIndent(2);
      String xml=ser.getXML(spectrum.getJumboObject());
      towrite=xml;
    }
 else {
      throw new BioclipseException("Filetype " + filetype + " not supported!");
    }
    if (target.exists()) {
      target.setContents(new StringBufferInputStream(towrite),false,true,monitor);
    }
 else {
      target.create(new StringBufferInputStream(towrite),false,monitor);
    }
    monitor.worked(ticks);
  }
  finally {
    monitor.done();
  }
}
 

Example 6

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: ScalaEditor.java

  15 
vote

/** 
 * This is for implementing  {@link IEditorPart} and simply saves the model file.<!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void doSave(IProgressMonitor progressMonitor){
  final Map<Object,Object> saveOptions=new HashMap<Object,Object>();
  saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
  WorkspaceModifyOperation operation=new WorkspaceModifyOperation(){
    @Override public void execute(    IProgressMonitor monitor){
      boolean first=true;
      for (      Resource resource : editingDomain.getResourceSet().getResources()) {
        if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
          try {
            long timeStamp=resource.getTimeStamp();
            resource.save(saveOptions);
            if (resource.getTimeStamp() != timeStamp) {
              savedResources.add(resource);
            }
          }
 catch (          Exception exception) {
            resourceToDiagnosticMap.put(resource,analyzeResourceProblems(resource,exception));
          }
          first=false;
        }
      }
    }
  }
;
  updateProblemIndication=false;
  try {
    new ProgressMonitorDialog(getSite().getShell()).run(true,false,operation);
    ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
    firePropertyChange(IEditorPart.PROP_DIRTY);
  }
 catch (  Exception exception) {
    ScalaEditorPlugin.INSTANCE.log(exception);
  }
  updateProblemIndication=true;
  updateProblemIndication();
}
 

Example 7

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/build/.

Source file: NDKCommandLauncher.java

  15 
vote

@Override public Process execute(IPath commandPath,String[] args,String[] env,IPath changeToDirectory,IProgressMonitor monitor) throws CoreException {
  if (Platform.getOS().equals(Platform.OS_WIN32) || Platform.getOS().equals(Platform.OS_MACOSX)) {
    String command=commandPath.toString();
    for (    String arg : args)     command+=" " + arg;
    commandPath=new Path("sh");
    args=new String[]{"-c",command};
  }
  return super.execute(commandPath,args,env,changeToDirectory,monitor);
}
 

Example 8

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/discovery/.

Source file: NDKDiscoveredPathInfo.java

  15 
vote

public void update(IProgressMonitor monitor) throws CoreException {
  if (!needUpdating())   return;
  new NDKDiscoveryUpdater(this).runUpdate(monitor);
  if (includePaths != null && symbols != null) {
    recordUpdate();
    save();
  }
}
 

Example 9

From project Archimedes, under directory /br.org.archimedes.orto/src/br/org/archimedes/orto/.

Source file: Activator.java

  15 
vote

public void earlyStartup(){
  UIJob job=new UIJob("InitCommandsWorkaround"){
    public IStatus runInUIThread(    IProgressMonitor monitor){
      ICommandService commandService=(ICommandService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
      Command command=commandService.getCommand(ORTO_COMMAND_ID);
      State state=command.getState(ORTO_STATE);
      state.setValue(false);
      if (command.getHandler().isEnabled()) {
        commandService.refreshElements(ORTO_COMMAND_ID,null);
      }
      return new Status(IStatus.OK,PLUGIN_ID,"Init commands workaround performed succesfully");
    }
  }
;
  job.schedule();
}
 

Example 10

From project Archimedes, under directory /br.org.archimedes.snap/src/br/org/archimedes/snap/.

Source file: Activator.java

  15 
vote

private void earlyStartup(){
  UIJob job=new UIJob("InitCommandsWorkaround"){
    public IStatus runInUIThread(    IProgressMonitor monitor){
      ICommandService commandService=(ICommandService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
      Command command=commandService.getCommand(SNAP_COMMAND_ID);
      State state=command.getState(SNAP_STATE);
      state.setValue(true);
      if (command.getHandler().isEnabled()) {
        commandService.refreshElements(SNAP_COMMAND_ID,null);
      }
      return new Status(IStatus.OK,PLUGIN_ID,"Init commands workaround performed succesfully");
    }
  }
;
  job.schedule();
}
 

Example 11

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

Source file: AccountInfoMonitor.java

  15 
vote

protected IStatus run(IProgressMonitor monitor){
  for (  AccountInfoChangeListener listener : listeners) {
    try {
      listener.currentAccountChanged();
    }
 catch (    Exception e) {
      AwsToolkitCore.getDefault().logException("Couldn't notify listener of account change: " + listener.getClass(),e);
    }
  }
  return Status.OK_STATUS;
}
 

Example 12

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

Source file: DeleteBucketAction.java

  15 
vote

@Override public void run(){
  Dialog dialog=newConfirmationDialog(getText() + "?","Are you sure you want to delete the selected buckets?");
  if (dialog.open() <= 0)   return;
  new Job("Deleting Buckets"){
    @Override protected IStatus run(    IProgressMonitor monitor){
      try {
        AmazonS3 s3=AwsToolkitCore.getClientFactory().getS3Client();
        ObjectUtils objectUtils=new ObjectUtils(s3);
        for (        Bucket bucket : buckets) {
          objectUtils.deleteBucketAndAllVersions(bucket.getName());
        }
        Display.getDefault().asyncExec(new Runnable(){
          public void run(){
            S3ContentProvider.getInstance().refresh();
          }
        }
);
        return Status.OK_STATUS;
      }
 catch (      Exception e) {
        return new Status(IStatus.ERROR,AwsToolkitCore.PLUGIN_ID,"Unable to delete buckets: " + e.getMessage(),e);
      }
    }
  }
.schedule();
}
 

Example 13

From project bel-editor, under directory /org.openbel.editor.core/src/org/openbel/editor/core/builder/.

Source file: BELCompileBuilder.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override @SuppressWarnings("rawtypes") protected IProject[] build(int kind,Map args,IProgressMonitor monitor) throws CoreException {
  if (kind == FULL_BUILD) {
    fullBuild(monitor);
  }
 else {
    IResourceDelta delta=getDelta(getProject());
    if (delta == null) {
      fullBuild(monitor);
    }
 else {
      incrementalBuild(delta,monitor);
    }
  }
  return null;
}
 

Example 14

From project bel-editor, under directory /org.openbel.editor.core/src/org/openbel/editor/core/builder/.

Source file: BELCompileBuilder.java

  15 
vote

protected void fullBuild(final IProgressMonitor monitor){
  try {
    getProject().accept(new SampleResourceVisitor());
  }
 catch (  CoreException e) {
  }
}
 

Example 15

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/src/de/bht/fpa/mail/s000000/common/mail/imapsync/.

Source file: ImapHelper.java

  15 
vote

/** 
 * Synchronizes all folders of an IMAP  {@link Account} with a database usingthe  {@link EntityManager}. The current implementation is only able to add new messages, but NOT deleted or moved messages.
 * @param account the  {@link Account} to use to connect
 * @param debug enable/disable IMAP debugging
 * @param protocol the protocol to create the  {@link Store} from. See{@link Session#getStore(String)}
 * @param properties a key-value Map to override properties (i.e. for another port).
 * @throws SynchronizationException
 */
public static void syncAllFoldersToAccount(final Account account,IProgressMonitor monitor,Dictionary<String,String> properties,String protocol) throws SynchronizationException {
  try {
    Properties props=combineProperties(properties);
    Session session=Session.getInstance(props);
    Store store=session.getStore(protocol);
    try {
      store.connect(account.getHost(),account.getUsername(),account.getPassword());
      debug(store.toString());
      IMAPFolder imapFolder=(IMAPFolder)store.getDefaultFolder();
      int totalNumberOfFolders=caculateTotalNumberOfFolders(imapFolder);
      monitor.beginTask("Syncing " + totalNumberOfFolders + " IMAP Folders",totalNumberOfFolders);
      for (      javax.mail.Folder subFolder : imapFolder.list()) {
        if (monitor.isCanceled()) {
          break;
        }
        Folder syncedFolder=syncFolderInternal(account,monitor,(IMAPFolder)subFolder,null);
        if (!account.getFolders().contains(syncedFolder)) {
          account.getFolders().add(syncedFolder);
          syncedFolder.setAccount(account);
        }
      }
      merge(account);
    }
  finally {
      monitor.done();
      store.close();
    }
  }
 catch (  final Exception e) {
    Display.getDefault().syncExec(new Runnable(){
      @Override public void run(){
        Status status=new Status(Status.ERROR,Activator.PLUGIN_ID,"Synchronization of Account '" + account.getName() + "' failed",e.getCause());
        ExceptionDetailsErrorDialog.openError(Display.getDefault().getActiveShell(),status.getMessage(),null,status);
      }
    }
);
  }
}
 

Example 16

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/wizards/export/.

Source file: CompRelationsWizard.java

  15 
vote

@Override protected IStatus run(IProgressMonitor monitor){
  inferer.computeComponentRelations();
  Runnable runnable=new Runnable(){
    public void run(){
      BioPEPACompRelationsView invview=BioPEPACompRelationsView.getDefault();
      invview.setRelationsTree(inferer.getRelationsTree());
      invview.refreshTree();
    }
  }
;
  Display.getDefault().syncExec(runnable);
  return Status.OK_STATUS;
}
 

Example 17

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

Source file: BaseRunner.java

  15 
vote

public final void run(final IProgressMonitor monitor) throws CoreException {
  IResourceRuleFactory factory=ResourcesPlugin.getWorkspace().getRuleFactory();
  ISchedulingRule createRule=factory.createRule(fResultFolder);
  ISchedulingRule modifyRule=factory.modifyRule(fResultFolder);
  ISchedulingRule multiRule=MultiRule.combine(createRule,modifyRule);
  ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable(){
    public void run(    IProgressMonitor aMonitor) throws CoreException {
      SubMonitor subMonitor=SubMonitor.convert(aMonitor,100);
      if (fResultFolder.exists()) {
        fResultFolder.delete(true,subMonitor.newChild(15));
      }
      subMonitor.setWorkRemaining(85);
      fResultFolder.create(false,true,subMonitor.newChild(5));
      try {
        _run(subMonitor.newChild(75));
      }
 catch (      CoreException e) {
        try {
          fResultFolder.delete(true,subMonitor.newChild(5));
        }
 catch (        CoreException deleteException) {
          throw new CoreException(StatusFactory.newCannotRollback(fResultFolder.getFullPath(),deleteException));
        }
        throw e;
      }
 finally {
        subMonitor.setWorkRemaining(5);
        _updateFolder(subMonitor.newChild(5));
        if (aMonitor != null)         aMonitor.done();
      }
    }
  }
,multiRule,IWorkspace.AVOID_UPDATE,monitor);
}
 

Example 18

From project bioclipse.opentox, under directory /plugins/net.bioclipse.opentox/src/net/bioclipse/opentox/api/.

Source file: Dataset.java

  15 
vote

public static String createNewDataset(String service,List<IMolecule> molecules,IProgressMonitor monitor) throws Exception {
  StringWriter strWriter=new StringWriter();
  SDFWriter writer=new SDFWriter(strWriter);
  for (  IMolecule mol : molecules) {
    writer.write(cdk.asCDKMolecule(mol).getAtomContainer());
  }
  writer.close();
  return createNewDataset(normalizeURI(service),strWriter.toString(),monitor);
}
 

Example 19

From project bioclipse.opentox, under directory /plugins/net.bioclipse.opentox/src/net/bioclipse/opentox/api/.

Source file: Dataset.java

  15 
vote

public static String createNewDataset(String service,IMolecule mol,IProgressMonitor monitor) throws Exception {
  StringWriter strWriter=new StringWriter();
  SDFWriter writer=new SDFWriter(strWriter);
  writer.write(cdk.asCDKMolecule(mol).getAtomContainer());
  writer.close();
  return createNewDataset(service,strWriter.toString(),monitor);
}
 

Example 20

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

Source file: SenecaManager.java

  15 
vote

public boolean saveSenecaJob(IFile file,SenecaJobSpecification specification,IProgressMonitor monitor) throws CoreException {
  InputStream source=specification.getSource();
  boolean force=true;
  boolean keepHistory=false;
  if (file.exists()) {
    file.setContents(source,force,keepHistory,monitor);
  }
 else {
    file.create(source,force,monitor);
  }
  return true;
}
 

Example 21

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

Source file: JudgePage.java

  15 
vote

public void doSave(IProgressMonitor monitor){
  if (specification == null) {
    return;
  }
  Iterator<IJudge> judgeFactories=Activator.getDefault().getJudgeExtensions().iterator();
  while (judgeFactories.hasNext()) {
    IJudge judge=judges.get(judgeFactories.next().getName());
    specification.setJudgeEnabled(judge.getClass().getName(),judge.getEnabled());
    specification.setWeight(judge.getClass().getName(),judge.getWeight());
    if (judge.getEnabled() && judge.getData() != null)     specification.setJudgeData(judge.getClass().getName(),judge.getData().toFile().getName());
 else     specification.setJudgeEnabled(judge.getClass().getName(),false);
  }
  this.setDirty(false);
}
 

Example 22

From project bndtools, under directory /bndtools.core/src/bndtools/builder/.

Source file: BndProjectNature.java

  15 
vote

private void updateProject(final IProjectDescription desc,final boolean adding) throws CoreException {
  IWorkspaceRunnable runnable=new IWorkspaceRunnable(){
    public void run(    IProgressMonitor monitor) throws CoreException {
      project.setDescription(desc,monitor);
      if (adding) {
        ensureBndBndExists();
        installBndClasspath();
      }
 else {
        removeBndClasspath();
      }
    }
  }
;
  project.getWorkspace().run(runnable,null);
}
 

Example 23

From project bndtools, under directory /bndtools.core/src/bndtools/builder/.

Source file: NewBuilder.java

  15 
vote

@Override protected void clean(IProgressMonitor monitor) throws CoreException {
  try {
    IProject myProject=getProject();
    Project model=Workspace.getProject(myProject.getLocation().toFile());
    if (model == null)     return;
    File target=model.getTarget();
    if (target.isDirectory() && target.getParentFile() != null) {
      IO.delete(target);
      if (!target.exists() && !target.mkdirs()) {
        throw new IOException("Could not create directory " + target);
      }
    }
    IFolder targetFolder=myProject.getFolder(calculateTargetDirPath(model));
    targetFolder.refreshLocal(IResource.DEPTH_INFINITE,monitor);
  }
 catch (  Exception e) {
    throw new CoreException(new Status(IStatus.ERROR,Plugin.PLUGIN_ID,0,"Build Error!",e));
  }
}
 

Example 24

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

Source file: BPELUnitEditor.java

  15 
vote

@Override public void doSave(IProgressMonitor monitor){
  this.preSave();
  this.fXmlEditorPage.doSave(monitor);
  this.postSave();
  super.editorDirtyStateChanged();
}
 

Example 25

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

Source file: BPELUnitEditor.java

  15 
vote

@Override public void doSave(IProgressMonitor monitor){
  this.preSave();
  this.fXmlEditorPage.doSave(monitor);
  this.postSave();
  super.editorDirtyStateChanged();
}
 

Example 26

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

Source file: BPMN2DiagramWizard.java

  15 
vote

/** 
 * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context.
 */
@Override public boolean performFinish(){
  final String fileName=page.getFileName();
  final IResource container=page.getDiagramContainer();
  IRunnableWithProgress op=new IRunnableWithProgress(){
    @Override public void run(    IProgressMonitor monitor) throws InvocationTargetException {
      try {
        IPath path=container.getFullPath().append(fileName);
        IFolder folder=null;
        BPMN2DiagramCreator factory=new BPMN2DiagramCreator();
        folder=BPMN2DiagramCreator.getTempFolder(path);
        factory.setDiagramFile(BPMN2DiagramCreator.getTempFile(path,folder));
        factory.setDiagramFolder(folder);
        factory.createDiagram();
      }
 catch (      CoreException e) {
        throw new InvocationTargetException(e);
      }
 finally {
        monitor.done();
      }
    }
  }
;
  try {
    getContainer().run(true,false,op);
  }
 catch (  InterruptedException e) {
    return false;
  }
catch (  InvocationTargetException e) {
    Throwable realException=e.getTargetException();
    MessageDialog.openError(getShell(),"Error",realException.getMessage());
    return false;
  }
  return true;
}
 

Example 27

From project bundlemaker, under directory /integrationtest/org.bundlemaker.itest.spring/src/org/bundlemaker/itest/spring/.

Source file: DeleteModuleTransformation.java

  15 
vote

/** 
 * {@inheritDoc}
 */
public void apply(IModifiableModularizedSystem modularizedSystem,IProgressMonitor progressMonitor){
  Set<IResource> sourceResources=modularizedSystem.getModifiableResourceModule(_moduleIdentifier).getResources(ContentType.SOURCE);
  System.out.println("Unassigned sources:");
  for (  IResource resource : getSortedResources(sourceResources)) {
    System.out.println(" - " + resource.getRoot() + "\\"+ resource.getPath().replace('/','\\'));
  }
  Set<IResource> binaryResources=modularizedSystem.getModifiableResourceModule(_moduleIdentifier).getResources(ContentType.BINARY);
  System.out.println("Unassigned classes:");
  for (  IResource resource : getSortedResources(binaryResources)) {
    System.out.println(" - " + resource.getRoot() + "\\"+ resource.getPath().replace('/','\\'));
  }
  modularizedSystem.removeModule(_moduleIdentifier);
}
 

Example 28

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

Source file: BundleMakerCore.java

  15 
vote

/** 
 * <p> Creates a bundle maker project for the given  {@link IProject}. The specified project must have the bundle maker nature. </p> <p> You can use  {@link #isBundleMakerProject(IProject)} to check if the project is BundleMaker project
 * @param project
 * @return
 * @throws CoreException
 */
public static IBundleMakerProject getBundleMakerProject(IProject project,IProgressMonitor progressMonitor) throws CoreException {
  Assert.isNotNull(project);
  if (!project.exists()) {
    throw new CoreException(new Status(IStatus.ERROR,BundleMakerCore.BUNDLE_ID,"Project '" + project.getName() + "' has to exist."));
  }
  if (!project.hasNature(NATURE_ID)) {
    throw new CoreException(new Status(IStatus.ERROR,BundleMakerCore.BUNDLE_ID,"Project '" + project.getName() + "' must have nature '"+ NATURE_ID+ "'."));
  }
  IBundleMakerProject bundleMakerProject=(IBundleMakerProject)Activator.getDefault().getBundleMakerProject(project);
  if (bundleMakerProject == null) {
    bundleMakerProject=new BundleMakerProject(project);
    Activator.getDefault().cacheBundleMakerProject(project,bundleMakerProject);
  }
  return bundleMakerProject;
}