Ejemplo n.º 1
0
 /** @since 2.0 */
 @Override
 public void delete(boolean force, IProgressMonitor monitor) {
   // Remove correction for this module from all places.
   final IScriptProject scriptProject = getScriptProject();
   final IEnvironment environment = EnvironmentManager.getEnvironment(scriptProject);
   TclProjectInfo project = TclPackagesManager.getTclProject(scriptProject.getElementName());
   EList<TclModuleInfo> modules = project.getModules();
   String path = environment.convertPathToString(getFullPath()).toString();
   for (TclModuleInfo tclModuleInfo : modules) {
     EList<UserCorrection> corrections = tclModuleInfo.getSourceCorrections();
     EList<TclSourceEntry> sourced = tclModuleInfo.getSourced();
     EList<UserCorrection> sourceCorrections = tclModuleInfo.getSourceCorrections();
     for (TclSourceEntry tclSourceEntry : sourced) {
       String value = tclSourceEntry.getValue();
       if (value.contains("$") && value.equals(getOriginalName())) {
         for (UserCorrection userCorrection : sourceCorrections) {
           if (userCorrection.getOriginalValue().equals(value)) {
             userCorrection.getUserValue().remove(path);
           }
         }
       }
     }
   }
   TclPackagesManager.save();
   // Do delta refresh
   try {
     ModelManager.getModelManager()
         .getDeltaProcessor()
         .checkExternalChanges(
             new IModelElement[] {getScriptProject()}, new NullProgressMonitor());
   } catch (ModelException e) {
     DLTKCore.error("Failed to call for model update:", e);
   }
 }
Ejemplo n.º 2
0
 public IPath getBufferPath() {
   IEnvironment environment = EnvironmentManager.getEnvironment(this);
   if (environment != null) {
     return EnvironmentPathUtils.getFullPath(environment, getStorage().getFullPath());
   } else {
     return getStorage().getFullPath();
   }
 }
Ejemplo n.º 3
0
 private void closeEditor(IWorkbenchPage page, IEditorPart editor) {
   IModelElement modelElement = EditorUtility.getEditorInputModelElement(editor, false);
   if (modelElement != null) {
     IEnvironment environment = EnvironmentManager.getEnvironment(modelElement);
     if (environment != null && !environment.isLocal()) {
       page.closeEditor(editor, false);
     }
   }
 }
Ejemplo n.º 4
0
 public IFileHandle getFile(URI locationURI) {
   if (RSEEnvironmentProvider.RSE_SCHEME.equalsIgnoreCase(locationURI.getScheme())
       && locationURI.getHost().equals(host.getAliasName())) {
     return new RSEFileHandle(this, locationURI);
   } else {
     final URI[] resolved = EnvironmentManager.resolve(locationURI);
     for (int i = 0; i < resolved.length; ++i) {
       final URI newLocation = resolved[i];
       if (RSEEnvironmentProvider.RSE_SCHEME.equalsIgnoreCase(newLocation.getScheme())
           && newLocation.getHost().equals(host.getAliasName())) {
         return new RSEFileHandle(this, newLocation);
       }
     }
     return null;
   }
 }
Ejemplo n.º 5
0
    public void update(Observable o, Object arg) {
      final IWorkspace workspace = DLTKUIPlugin.getWorkspace();
      final String name = fNameGroup.getName();
      // check whether the project name field is empty
      if (name.length() == 0) {
        setErrorMessage(null);
        setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterProjectName);
        setPageComplete(false);
        return;
      }
      // check whether the project name is valid
      final IStatus nameStatus = workspace.validateName(name, IResource.PROJECT);
      if (!nameStatus.isOK()) {
        setErrorMessage(nameStatus.getMessage());
        setPageComplete(false);
        return;
      }
      // check whether project already exists
      final IProject handle = getProjectHandle();

      if (!isInLocalServer()) {
        if (handle.exists()) {
          setErrorMessage(
              NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists);
          setPageComplete(false);
          return;
        }
      }

      IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
      String newProjectNameLowerCase = name.toLowerCase();
      for (IProject currentProject : projects) {
        String existingProjectName = currentProject.getName();
        if (existingProjectName.toLowerCase().equals(newProjectNameLowerCase)) {
          setErrorMessage(
              NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists);
          setPageComplete(false);
          return;
        }
      }

      final String location = fPHPLocationGroup.getLocation().toOSString();
      // check whether location is empty
      if (location.length() == 0) {
        setErrorMessage(null);
        setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterLocation);
        setPageComplete(false);
        return;
      }
      // check whether the location is a syntactically correct path
      if (!Path.EMPTY.isValidPath(location)) {
        setErrorMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory);
        setPageComplete(false);
        return;
      }
      // check whether the location has the workspace as prefix
      IPath projectPath = Path.fromOSString(location);
      if (!fPHPLocationGroup.isInWorkspace() && Platform.getLocation().isPrefixOf(projectPath)) {
        setErrorMessage(
            NewWizardMessages.ScriptProjectWizardFirstPage_Message_cannotCreateInWorkspace);
        setPageComplete(false);
        return;
      }
      // If we do not place the contents in the workspace validate the
      // location.
      if (!fPHPLocationGroup.isInWorkspace()) {
        IEnvironment environment = getEnvironment();
        if (EnvironmentManager.isLocal(environment)) {
          final IStatus locationStatus = workspace.validateProjectLocation(handle, projectPath);
          File file = projectPath.toFile();
          if (!locationStatus.isOK()) {
            setErrorMessage(locationStatus.getMessage());
            setPageComplete(false);
            return;
          }

          if (!canCreate(projectPath.toFile())) {
            setErrorMessage(
                NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory);
            setPageComplete(false);
            return;
          }
        }
      }

      if (fragment != null) {
        fragment.getWizardModel().putObject("ProjectName", fNameGroup.getName());
        if (!fragment.isComplete()) {
          setErrorMessage((String) fragment.getWizardModel().getObject(ERROR_MESSAGE));
          setPageComplete(false);
          return;
        }
      }

      setPageComplete(true);
      setErrorMessage(null);
      setMessage(null);
    }