pl.edu.agh.cast.resources
Class ProjectUtil

java.lang.Object
  extended by pl.edu.agh.cast.resources.BaseProjectUtil
      extended by pl.edu.agh.cast.resources.ProjectUtil
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener

public class ProjectUtil
extends pl.edu.agh.cast.resources.BaseProjectUtil
implements java.beans.PropertyChangeListener

Utility methods for operating on projects

Author:
awos

Nested Class Summary
static class ProjectUtil.NewDiagramInfo
           
 
Field Summary
 int diagramCounter
           
static java.lang.String[] PROJECT_NAME_FORBIDDEN_CHARS
           
 
Fields inherited from class pl.edu.agh.cast.resources.BaseProjectUtil
PROJECT_DISPLAY_NAME_PROPERTY, PROJECT_ID_PROPERTY
 
Method Summary
 org.eclipse.core.resources.IProject changeProjectLocation(java.lang.String newLocation)
          Removes project from workspace and adds project pointed to by newLocation.
 boolean closeProject(org.eclipse.core.resources.IProject project)
          Closes a project, closing all editors as well.
 org.eclipse.core.resources.IProject createAndActivateProject(java.lang.String projectName, org.eclipse.core.runtime.IPath location)
          Create project of specified name if it does not exists and activates created project.
 org.eclipse.core.resources.IProject createProject(java.lang.String projectName, org.eclipse.core.runtime.IPath location)
          Create project of specified name if it does not exists.
 java.lang.String escapeName(java.lang.String name)
           
 java.lang.String generateProjectId()
          Create unique identifier for the project
 java.lang.String getDefaultDiagramName()
           
 java.util.List<java.lang.String> getDiagramNames()
          Returns list of names of diagrams contained in project identified by projectName
 java.lang.String getDisplayName(org.eclipse.core.resources.IProject project)
           
static ProjectUtil getInstance()
           
 ProjectUtil.NewDiagramInfo getNewDiagramInfo(org.eclipse.core.resources.IProject project)
          Returns new IFile for diagram.
 boolean handleExistingProjectAction(java.lang.String location)
           
 void handleMissingProjectFile(java.lang.String location)
           
 void handleNoProjectAction()
           
 void handleWrongProjectLocationAction(java.lang.String location)
           
 boolean openProject(java.lang.String location, boolean force)
          Opens existing project from specified directory
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Property change notification
 void setDisplayName(org.eclipse.core.resources.IProject project, java.lang.String name)
           
 boolean tryOpenRecentProject(MostRecentlyUsedProject mrup)
          Tries to open a project described by MostRecentlyUsedProject.
 
Methods inherited from class pl.edu.agh.cast.resources.BaseProjectUtil
getProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROJECT_NAME_FORBIDDEN_CHARS

public static final java.lang.String[] PROJECT_NAME_FORBIDDEN_CHARS

diagramCounter

public int diagramCounter
Method Detail

getInstance

public static ProjectUtil getInstance()

getDiagramNames

public java.util.List<java.lang.String> getDiagramNames()
                                                 throws org.eclipse.core.runtime.CoreException
Returns list of names of diagrams contained in project identified by projectName

Parameters:
projectName - is the name of the project to look in
Returns:
list of diagram names in this project
Throws:
org.eclipse.core.runtime.CoreException

getDisplayName

public java.lang.String getDisplayName(org.eclipse.core.resources.IProject project)

setDisplayName

public void setDisplayName(org.eclipse.core.resources.IProject project,
                           java.lang.String name)

escapeName

public java.lang.String escapeName(java.lang.String name)

createProject

public org.eclipse.core.resources.IProject createProject(java.lang.String projectName,
                                                         org.eclipse.core.runtime.IPath location)
                                                  throws org.eclipse.core.runtime.CoreException
Create project of specified name if it does not exists.

Parameters:
projectName -
Returns:
Throws:
org.eclipse.core.runtime.CoreException

createAndActivateProject

public org.eclipse.core.resources.IProject createAndActivateProject(java.lang.String projectName,
                                                                    org.eclipse.core.runtime.IPath location)
                                                             throws org.eclipse.core.runtime.CoreException
Create project of specified name if it does not exists and activates created project.

Parameters:
projectName -
location -
Returns:
Throws:
org.eclipse.core.runtime.CoreException

openProject

public boolean openProject(java.lang.String location,
                           boolean force)
                    throws java.io.FileNotFoundException,
                           org.eclipse.core.runtime.CoreException
Opens existing project from specified directory

Parameters:
location - project location which contains .project description file
force - if true opens project with the same name which exists in the workspace
Returns:
true if specified project has been opened; false otherwise: if the specified project exists already in the workspace and force flag has been set to false
Throws:
java.io.FileNotFoundException - if project description file (.project) is not found in specified location
org.eclipse.core.runtime.CoreException - if loading description failed. Reasons include:
  • The stream could not be read.
  • The stream does not contain a legal project description.

getNewDiagramInfo

public ProjectUtil.NewDiagramInfo getNewDiagramInfo(org.eclipse.core.resources.IProject project)
Returns new IFile for diagram.

Parameters:
project -
Returns:

getDefaultDiagramName

public java.lang.String getDefaultDiagramName()

changeProjectLocation

public org.eclipse.core.resources.IProject changeProjectLocation(java.lang.String newLocation)
Removes project from workspace and adds project pointed to by newLocation. Project name is taken from project description stored in newLocation.

Parameters:
newLocation -
Returns:
moved project

generateProjectId

public java.lang.String generateProjectId()
Create unique identifier for the project

Returns:
Unique project identifier.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Property change notification

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

tryOpenRecentProject

public boolean tryOpenRecentProject(MostRecentlyUsedProject mrup)
Tries to open a project described by MostRecentlyUsedProject.

Parameters:
mrup - project to open
Returns:
true if project was correctly opened, or if the operation was cancelled by the user when closing currently opened editors

closeProject

public boolean closeProject(org.eclipse.core.resources.IProject project)
Closes a project, closing all editors as well. Asks the user for confirmation to save dirty editors.

Returns:
true if all editors were closed

handleExistingProjectAction

public boolean handleExistingProjectAction(java.lang.String location)

handleNoProjectAction

public void handleNoProjectAction()

handleWrongProjectLocationAction

public void handleWrongProjectLocationAction(java.lang.String location)

handleMissingProjectFile

public void handleMissingProjectFile(java.lang.String location)


Copyright © 2007-2008 AGH University of Science and Technology. All Rights Reserved.