/**
   * This method obtains the children of this Experiment Results folder.
   *
   * <p>TODO: Define what the experiment results folder contains to be able to finish this method
   * correctly, right now it only accepts .xml files as children
   *
   * @param iProject The project that contains this Experiment Results folder
   * @return ArrayList<Object> The children of this Experiment Results folder
   */
  @Override
  protected ArrayList<Object> initializeChildren(IProject iProject) {
    ArrayList<Object> children = new ArrayList<Object>();

    // get the Experiment Results folder from the project
    IProject project = getProject();
    IFolder folder = project.getFolder(name);
    // attempt to get the resources inside this Experiment Results folder
    IResource[] members = {};
    try {
      members = folder.members();
    } catch (CoreException e) {
      e.printStackTrace();
    }
    // check for .xml files and add them to the children ArrayList
    for (IResource r : members) {
      System.out.println(r.toString());
      if (r instanceof IFile) {
        if (r.getFileExtension() != null) {
          if (r.getFileExtension().equalsIgnoreCase("xml")
              || r.getFileExtension().equalsIgnoreCase("tlv")) children.add(r);
        }
      }
    }
    System.out.println();
    return children;
  }
 /**
  * Tells if the specified resource correspond to a supported workspace image.
  *
  * @param resource the specified resource
  * @return true if the specified resource correspond to a supported workspace image, false else
  */
 private boolean isWorkspaceImage(IResource resource) {
   boolean isWorkspaceImage =
       resource != null
           && resource.getType() == IResource.FILE
           && resource.getFileExtension() != null
           && isSupportedImageFormat(resource.getFileExtension());
   return isWorkspaceImage;
 }
  private String composeAllFileContents(IFolder folder) {
    String contents = "";
    try {
      int lineNumber = 0;
      for (IResource member : folder.members()) {
        if (member.getType() == IResource.FILE
            && DeltajComposer.FILE_EXT.equals("." + member.getFileExtension())) {
          DeltajFile file = new DeltajFile((IFile) member, lineNumber, 0);

          InputStream source = null;
          source = ((IFile) member).getContents();
          BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source));
          StringBuilder stringBuilder = new StringBuilder();
          String line = null;
          while ((line = bufferedReader.readLine()) != null) {
            stringBuilder.append(line + "\n");
            lineNumber++;
          }
          bufferedReader.close();
          contents += stringBuilder.toString() + "\n";
          file.setEndLine(lineNumber++);
          this.deltajFiles.add(file);
        } else if (member.getType() == IResource.FOLDER) {
          contents += composeAllFileContents((IFolder) member);
        }
      }
    } catch (CoreException e) {
      DeltajCorePlugin.getDefault().logError(e);
    } catch (IOException e) {
      DeltajCorePlugin.getDefault().logError(e);
    }
    return contents;
  }
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   ISelection selection =
       PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
   if (!(selection instanceof StructuredSelection)) return null;
   Object selected = ((StructuredSelection) selection).getFirstElement();
   IResource resource = null;
   String path = "";
   if (selected instanceof IFile) {
     resource = (IResource) Platform.getAdapterManager().getAdapter(selected, IResource.class);
     path = resource.getLocation().toString();
     new ResultGenerator().parser(path);
   } else if (selected instanceof PlatformObject) {
     resource = (IResource) Platform.getAdapterManager().getAdapter(selected, IResource.class);
     path = resource.getLocation().toString();
     if (resource.getFileExtension() != null && resource.getFileExtension().equals("jar")) {
       new ResultGenerator().parser(path);
     }
   }
   return null;
 }
 public boolean visit(IResourceDelta delta) {
   // only interested in changed resources (not added or removed)
   if (delta.getKind() != IResourceDelta.REMOVED) {
     return true;
   }
   IResource resource = delta.getResource();
   if (resource.getType() == IResource.FILE
       && CALSourcePathMapper.CAL_FILE_EXTENSION.equalsIgnoreCase(resource.getFileExtension())) {
     removedCalFileFound = true;
   }
   return true;
 }
Exemple #6
0
  public IRpcFuture startCompileErl(
      final IProject project,
      final BuildResource bres,
      final String outputDir0,
      final IBackend backend,
      final OtpErlangList compilerOptions,
      final boolean force) {
    final IPath projectPath = project.getLocation();
    final IResource res = bres.getResource();
    final String s = res.getFileExtension();
    if (!"erl".equals(s)) {
      ErlLogger.warn("trying to compile " + res.getName() + "?!?!");
    }

    MarkerUtils.deleteMarkers(res);

    String outputDir;
    outputDir = getRealOutputDir(bres, outputDir0, projectPath);

    final Collection<IPath> includeDirs = getAllIncludeDirs(project);

    // delete beam file
    final IPath beamPath = getBeamForErl(res);
    final IResource beam = project.findMember(beamPath);

    try {
      final boolean shouldCompile = force || shouldCompile(project, res, beam);

      if (shouldCompile) {
        if (beam != null) {
          try {
            beam.delete(true, null);
          } catch (final Exception e) {
            ErlLogger.warn(e);
          }
        }
        if (isDebugging()) {
          ErlLogger.debug("compiling %s", res.getName());
        }

        createTaskMarkers(project, res);
        return InternalErlideBuilder.compileErl(
            backend, res.getLocation(), outputDir, includeDirs, compilerOptions);

      } else {
        return null;
      }
    } catch (final Exception e) {
      ErlLogger.warn(e);
      return null;
    }
  }
 /**
  * Returns the editor being used to edit a PDA file, associated with the given part, or <code>null
  * </code> if none.
  *
  * @param part workbench part
  * @return the editor being used to edit a PDA file, associated with the given part, or <code>null
  *     </code> if none
  */
 private ITextEditor getEditor(IWorkbenchPart part) {
   if (part instanceof ITextEditor) {
     ITextEditor editorPart = (ITextEditor) part;
     IResource resource = editorPart.getEditorInput().getAdapter(IResource.class);
     if (resource != null) {
       String extension = resource.getFileExtension();
       if (extension != null && extension.equals("pda")) { // $NON-NLS-1$
         return editorPart;
       }
     }
   }
   return null;
 }
Exemple #8
0
 @Override
 public boolean visit(final IResource resource) throws CoreException {
   if (fName == null) {
     return false;
   }
   if (getResult() != null) {
     return false;
   }
   final IErlProject erlProject =
       ErlModelManager.getErlangModel().getErlangProject(resource.getProject());
   if (resource.getType() == IResource.FILE
       && resource.getFileExtension() != null
       && "erl".equals(resource.getFileExtension())
       && isInCodePath(resource, erlProject)) {
     final String[] p = resource.getName().split("\\.");
     if (p[0].equals(fName)) {
       setResult(resource);
       return false;
     }
   }
   return true;
 }
  /**
   * Extract service names / methods / screens etc. for faster searches
   *
   * @throws CoreException
   */
  private void scanOfbizProjectOrFolder(IContainer project, UIScanProgressHelper progressHelper)
      throws CoreException {
    List<IResource> resourceList =
        new ArrayList<IResource>(Arrays.asList(project.members(IContainer.EXCLUDE_DERIVED)));

    for (IResource resource : resourceList) {
      checkForCancel();

      if (resource.getType() == IResource.FOLDER) {
        progressHelper.showProgress();
        showStatus(resource);
        scanOfbizProjectOrFolder((IFolder) resource, progressHelper);
      } else if ("xml".equals(resource.getFileExtension())) {

        helper.extractDefinitionsFromXml(
            resource,
            serviceMethodToNameMap,
            serviceNameAndFilePathMap,
            referencedFtlList,
            referencedBshOrGroovyList,
            referencedServiceList,
            referencedViewList,
            viewDefinitionMap,
            referencedScreenList,
            screenNameAndFilePathMap);

      } else if ("ftl".equals(resource.getFileExtension())) {
        ftlList.add(new NonJavaIMember(resource));
        helper.searchForProgrammaticallyRenderedScreen(resource, referencedScreenList);
      } else if ("bsh".equals(resource.getFileExtension())) {
        bshOrGroovyList.add(new NonJavaIMember(resource));
        helper.searchForProgrammaticallyRenderedScreen(resource, referencedScreenList);
      } else if ("bsh".equals(resource.getFileExtension())) {
        helper.searchForProgrammaticallyRenderedScreen(resource, referencedScreenList);
      } else if ("groovy".equals(resource.getFileExtension())) {
        bshOrGroovyList.add(new NonJavaIMember(resource));
      }
    }
  }
Exemple #10
0
  @Override
  protected void clean(final IProgressMonitor monitor) throws CoreException {
    final IProject currentProject = getProject();
    if (currentProject == null || !currentProject.isAccessible()) {
      return;
    }

    if (BuilderHelper.isDebugging()) {
      ErlLogger.debug(
          "Cleaning "
              + currentProject.getName() // $NON-NLS-1$
              + " @ "
              + new Date(System.currentTimeMillis()));
    }

    try {
      initializeBuilder(monitor);
      MarkerUtils.removeProblemsAndTasksFor(currentProject);
      final IErlProject erlProject = CoreScope.getModel().getErlangProject(currentProject);
      final IFolder bf = currentProject.getFolder(erlProject.getOutputLocation());
      if (bf.exists()) {
        final IResource[] beams = bf.members();
        monitor.beginTask("Cleaning Erlang files", beams.length);
        if (beams.length > 0) {
          final float delta = 1.0f / beams.length;
          for (final IResource element : beams) {
            if ("beam".equals(element.getFileExtension())) {
              element.delete(true, monitor);
              notifier.updateProgressDelta(delta);
            }
          }
        }
      }

    } catch (final Exception e) {
      ErlLogger.error(e);
      final String msg =
          NLS.bind(BuilderMessages.build_inconsistentProject, e.getLocalizedMessage());
      MarkerUtils.addProblemMarker(currentProject, null, null, msg, 0, IMarker.SEVERITY_ERROR);
    } finally {
      cleanup();
      if (BuilderHelper.isDebugging()) {
        ErlLogger.debug(
            "Finished cleaning "
                + currentProject.getName() // $NON-NLS-1$
                + " @ "
                + new Date(System.currentTimeMillis()));
      }
    }
  }
 /* (non-Javadoc)
  * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
  */
 @SuppressWarnings("rawtypes")
 @Override
 public Object getAdapter(Object adaptableObject, Class adapterType) {
   if (adaptableObject instanceof ITextEditor) {
     ITextEditor editorPart = (ITextEditor) adaptableObject;
     IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
     if (resource != null) {
       String extension = resource.getFileExtension();
       if (extension != null && extension.equals("m4scp")) {
         return new SCPLineBreakpointAdapter();
       }
     }
   }
   return null;
 }
 /**
  * Finds all the jar files inside a project's libs folder.
  *
  * @param project
  * @param jarFiles
  */
 private static void getJarListFromLibsFolder(IProject project, Set<File> jarFiles) {
   IFolder libsFolder = project.getFolder(SdkConstants.FD_NATIVE_LIBS);
   if (libsFolder.exists()) {
     try {
       IResource[] members = libsFolder.members();
       for (IResource member : members) {
         if (member.getType() == IResource.FILE
             && SdkConstants.EXT_JAR.equalsIgnoreCase(member.getFileExtension())) {
           IPath location = member.getLocation();
           if (location != null) {
             jarFiles.add(location.toFile());
           }
         }
       }
     } catch (CoreException e) {
       // can't get the list? ignore this folder.
     }
   }
 }
  public static boolean isCljFile(IEditorPart editorPart) {
    IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
    if (resource != null && resource.getFileExtension().equals("clj")) {
      return true;
    }

    if (editorPart.getEditorInput() instanceof IStorageEditorInput) {
      try {
        IStorageEditorInput input = (IStorageEditorInput) editorPart.getEditorInput();
        if (input.getStorage().getName().endsWith(".clj")) {
          return true;
        }
      } catch (CoreException e) {
        // Nothing more to do :-(
      }
    }

    return false;
  }
  /** Check if a given {@link IResource} representing a class file has structural changes. */
  public boolean hasStructuralChanges(IResource resource, int flags) {
    try {
      r.lock();
      if (!hasRecordedTypeStructures(resource.getProject())) {
        return true;
      }

      Map<String, TypeStructure> typeStructures =
          typeStructuresByProject.get(resource.getProject());

      if (resource != null
          && resource.getFileExtension() != null
          && resource.getFileExtension().equals("java")) {
        IJavaElement element = JavaCore.create(resource);
        if (element instanceof ICompilationUnit && ((ICompilationUnit) element).isOpen()) {
          try {
            IType[] types = ((ICompilationUnit) element).getAllTypes();
            for (IType type : types) {
              String fqn = type.getFullyQualifiedName();
              TypeStructure typeStructure = typeStructures.get(fqn);
              if (typeStructure == null) {
                return true;
              }
              ClassFileReader reader =
                  getClassFileReaderForClassName(
                      type.getFullyQualifiedName(), resource.getProject());
              if (reader != null && hasStructuralChanges(reader, typeStructure, flags)) {
                return true;
              }
            }
            return false;
          } catch (JavaModelException e) {
            SpringCore.log(e);
          } catch (MalformedURLException e) {
            SpringCore.log(e);
          }
        }
      }
      return true;
    } finally {
      r.unlock();
    }
  }
Exemple #15
0
  private static void recursivelyFindFilesWithExtension(
      ArrayList<IResource> allFiles, IPath path, IWorkspaceRoot wsRoot, String extension) {
    IContainer container = wsRoot.getContainerForLocation(path);

    try {
      IResource[] resources = container.members();
      for (IResource resource : resources) {
        if (extension.equalsIgnoreCase(resource.getFileExtension())) {
          allFiles.add(resource);
        }
        if (resource.getType() == IResource.FOLDER) {
          IPath tempPath = resource.getLocation();
          recursivelyFindFilesWithExtension(allFiles, tempPath, wsRoot, extension);
        }
      }
    } catch (CoreException e) {
      // eat the exception, but throw it in the console
      e.printStackTrace();
    }
  }
  public static boolean isCljFile(IEditorPart editorPart) {
    IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
    if (resource != null && isCljExtension(resource.getFileExtension())) {
      return true;
    }

    if (editorPart.getEditorInput() instanceof IStorageEditorInput) {
      try {
        IStorageEditorInput input = (IStorageEditorInput) editorPart.getEditorInput();
        final String name = input.getStorage().getName();
        final int extDotIdx = name.lastIndexOf('.');
        final String ext = (extDotIdx < 0) ? "" : name.substring(extDotIdx + 1);
        if (isCljExtension(ext)) {
          return true;
        }
      } catch (CoreException e) {
        // Nothing more to do :-(
      }
    }

    return false;
  }
 /**
  * Collects all class files with the selected extension at the selected package.
  *
  * @param folder The folder to look at.
  * @return A list of all class file names.
  */
 private LinkedList<String> getClasses(IFolder folder) {
   LinkedList<String> classes = new LinkedList<String>();
   for (String packageName : comboPackage.getText().split("[.]")) {
     folder = folder.getFolder(packageName);
   }
   if (!folder.exists()) {
     return classes;
   }
   try {
     for (IResource res : folder.members()) {
       if (res instanceof IFile) {
         String fileExtension = res.getFileExtension();
         if (fileExtension != null && fileExtension.equals(getExtension())) {
           String resourceName = res.getName();
           classes.add(resourceName.substring(0, resourceName.lastIndexOf('.')));
         }
       }
     }
   } catch (CoreException e) {
     UIPlugin.getDefault().logError(e);
   }
   return classes;
 }
  /** Record {@link TypeStructure} instances of the given <code>resources</code>. */
  public void recordTypeStructures(IProject project, IResource... resources) {
    try {
      w.lock();
      Map<String, TypeStructure> typeStructures = null;
      if (!typeStructuresByProject.containsKey(project)) {
        typeStructures = new ConcurrentHashMap<String, TypeStructure>();
        typeStructuresByProject.put(project, typeStructures);
      } else {
        typeStructures = typeStructuresByProject.get(project);
      }

      for (IResource resource : resources) {
        if (resource.getFileExtension().equals("class") && resource instanceof IFile) {
          InputStream input = null;
          try {
            input = ((IFile) resource).getContents();
            ClassFileReader reader = ClassFileReader.read(input, resource.getName());
            TypeStructure typeStructure = new TypeStructure(reader);
            typeStructures.put(new String(reader.getName()).replace('/', '.'), typeStructure);
          } catch (CoreException e) {
          } catch (ClassFormatException e) {
          } catch (IOException e) {
          } finally {
            if (input != null) {
              try {
                input.close();
              } catch (IOException e) {
              }
            }
          }
        }
      }
    } finally {
      w.unlock();
    }
  }
 /**
  * Clear cache if necessary and return true if a refresh of figure of opened editors must be done,
  * false otherwise.
  *
  * @param delta , resource delta
  * @return boolean
  */
 private boolean needClearCache(IResource resource) {
   boolean cacheUpdated = false;
   String resourceExtension = resource.getFileExtension();
   if (WorkspaceImageFigure.isSvgImage(resourceExtension)) {
     String svgUri = resource.getFullPath().toString();
     Option<String> removed = SVGWorkspaceImageFigure.removeFromCache(svgUri);
     if (removed.some()) {
       cacheUpdated = true;
     }
   } else {
     URL url;
     try {
       url =
           new File(
                   ResourcesPlugin.getWorkspace()
                       .getRoot()
                       .getLocation()
                       .append(resource.getFullPath())
                       .toOSString())
               .toURI()
               .toURL();
     } catch (MalformedURLException e) {
       DiagramPlugin.getDefault().logError("Invalid uri : " + e.getMessage());
       return false;
     }
     ImageDescriptor bundledImageDescriptor = ImageDescriptor.createFromURL(url);
     boolean removed = DiagramUIPlugin.getPlugin().removeCacheImage(bundledImageDescriptor);
     // If a removed cache action is do, a refresh opened editors
     // is
     // required
     if (removed) {
       cacheUpdated = true;
     }
   }
   return cacheUpdated;
 }
Exemple #20
0
 public static boolean isHTMLFile(IResource resource) {
   return HTML_EXTENSIONS.contains(resource.getFileExtension());
 }
 /**
  * Returns the extension portion of the given resource.
  *
  * @param resource the resource
  * @return the file extension, possibily the empty string
  */
 private String getExtensionFor(IResource resource) {
   String ext = resource.getFileExtension();
   return ext == null ? "" : ext; // $NON-NLS-1$
 }
 protected boolean isAJarResource(final IResource resource) {
   return "jar".equals(resource.getFileExtension());
 }
Exemple #23
0
 void componentACanDeclareOnlyCompontB(
     AbstractComponent componentA,
     Restriction restriction,
     List<ComponentsBinRestrictionDeclareation> componentsBinRestrictionDeclareations) {
   //		AbstractComponent componentA = (AbstractComponent) restriction.eContainer();
   Set<ComponentInstance> allInstancesOfA = componentA.getInstances();
   String fullyQualifiedName = "";
   for (ComponentInstance componentInstanceA : allInstancesOfA) {
     IResource resource = componentInstanceA.getResource();
     if ((resource.getFileExtension() + "").equals("java")) {
       Set<ComponentInstanceReference> references =
           componentInstanceA.getDependencies(RelactionType.DECLARE);
       for (ComponentInstanceReference reference : references) {
         if (reference.isVerified(CanDeclareOnly.class.getName())) continue;
         boolean isViolataion = true;
         ComponentInstance componentInstanceReferenced =
             reference.getComponentInstanceReferenced();
         if (componentInstanceReferenced == null) {
           continue; // TODO - Resolver problema componentInstanceReferenced sem
                     // componenteInstancia
         }
         AbstractComponent component = componentInstanceReferenced.getComponent();
         if (component == null) continue;
         if (component.isChild(componentA)) continue;
         // EList<ComponentsBinRestrictionDeclareation> componentesB = restriction.getComponentB();
         fullyQualifiedName = componentInstanceReferenced.getType().getFullyQualifiedName();
         componenteB:
         for (ComponentsBinRestrictionDeclareation componentsBinRestrictionDeclareation :
             componentsBinRestrictionDeclareations) {
           if (componentsBinRestrictionDeclareation.getWildcard().equals(WildCard.PACKAGE)
               || componentsBinRestrictionDeclareation.getWildcard() == null) {
             if (componentsBinRestrictionDeclareation
                 .getComponentB()
                 .containsType(fullyQualifiedName)) {
               isViolataion = false;
               break componenteB;
             }
           } else if (componentsBinRestrictionDeclareation
               .getWildcard()
               .equals(WildCard.PACKAGE_AND_SUB_PACKAGE)) {
             if (componentsBinRestrictionDeclareation
                 .getComponentB()
                 .fullContainsType(fullyQualifiedName)) {
               isViolataion = false;
               break componenteB;
             }
           }
         }
         if (isViolataion) {
           String defaultMessage =
               "Classes  do componente  "
                   + componentA.getName()
                   + " não podem declarar "
                   + fullyQualifiedName
                   + ".";
           if (!reference
               .getComponentInstanceDependent()
               .isSubClasse(reference.getComponentInstanceReferenced()))
             addViolation(
                 restriction,
                 reference.getLineNumber(),
                 reference.getComponentInstanceDependent(),
                 defaultMessage,
                 IMarker.SEVERITY_ERROR,
                 DependecyType.COMPILE,
                 "CAN_DECLARE_ONLY");
         }
         reference.verified(CanDeclareOnly.class.getName());
       }
     }
   }
 }
  @SuppressWarnings("rawtypes")
  public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (adaptableObject instanceof org.eclipse.ui.texteditor.ITextEditor) {
      org.eclipse.ui.texteditor.ITextEditor editorPart =
          (org.eclipse.ui.texteditor.ITextEditor) adaptableObject;
      org.eclipse.core.resources.IResource resource =
          (org.eclipse.core.resources.IResource)
              editorPart.getEditorInput().getAdapter(org.eclipse.core.resources.IResource.class);
      if (resource != null) {
        String extension = resource.getFileExtension();
        if (extension != null
            && extension.equals(
                new org.feature.multi.perspective.mapping.viewmapping.resource.mtext.mopp
                        .MtextMetaInformation()
                    .getSyntaxName())) {
          return new org.feature.multi.perspective.mapping.viewmapping.resource.mtext.ui.debug
              .MtextLineBreakpointAdapter();
        }
      }
    }
    if (adapterType
            == org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider.class
        && adaptableObject
            instanceof
            org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug
                .MtextDebugVariable) {
      final org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug
              .MtextDebugVariable
          variable =
              (org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug
                      .MtextDebugVariable)
                  adaptableObject;
      return new org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider() {

        public void update(
            org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate[] updates) {
          for (org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate update :
              updates) {
            try {
              update.setLabel(variable.getName(), 0);
              update.setLabel(variable.getValue().getValueString(), 1);
              update.done();
            } catch (org.eclipse.debug.core.DebugException e) {
            }
          }
        }
      };
    }
    if (adapterType
            == org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider.class
        && adaptableObject
            instanceof
            org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug
                .MtextDebugVariable) {
      final org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug
              .MtextDebugVariable
          variable =
              (org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug
                      .MtextDebugVariable)
                  adaptableObject;
      return new org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider() {

        public void update(
            org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate[]
                updates) {
          try {
            for (org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate
                update : updates) {
              org.eclipse.debug.core.model.IValue value = variable.getValue();
              org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug.MtextDebugValue
                  castedValue =
                      (org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug
                              .MtextDebugValue)
                          value;
              update.setChildCount(castedValue.getVariableCount());
              update.done();
            }
          } catch (org.eclipse.debug.core.DebugException e) {
            e.printStackTrace();
          }
        }

        public void update(
            org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate[] updates) {
          try {
            org.eclipse.debug.core.model.IValue value = variable.getValue();
            org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug.MtextDebugValue
                castedValue =
                    (org.feature.multi.perspective.mapping.viewmapping.resource.mtext.debug
                            .MtextDebugValue)
                        value;
            for (org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate update :
                updates) {
              int offset = update.getOffset();
              int length = update.getLength();
              for (int i = offset; i < offset + length; i++) {
                org.eclipse.debug.core.model.IVariable variable = castedValue.getChild(i);
                update.setChild(variable, i);
              }
              update.done();
            }
          } catch (org.eclipse.debug.core.DebugException e) {
            e.printStackTrace();
          }
        }

        public void update(
            org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate[] updates) {
          for (org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate update :
              updates) {
            try {
              update.setHasChilren(variable.getValue().hasVariables());
              update.done();
            } catch (org.eclipse.debug.core.DebugException e) {
              e.printStackTrace();
            }
          }
        }
      };
    }
    return null;
  }
  @SuppressWarnings("rawtypes")
  public Object getAdapter(Object adaptableObject, Class adapterType) {

    if (adaptableObject instanceof ITextEditor) {
      ITextEditor editorPart = (ITextEditor) adaptableObject;
      IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
      if (resource != null) {
        String extension = resource.getFileExtension();
        if (extension != null && extension.equals(new OclMetaInformation().getSyntaxName())) {
          return new OclLineBreakpointAdapter();
        }
      }
    }
    if (adapterType == IElementLabelProvider.class && adaptableObject instanceof OclDebugVariable) {
      final OclDebugVariable variable = (OclDebugVariable) adaptableObject;
      return new IElementLabelProvider() {

        public void update(ILabelUpdate[] updates) {

          for (ILabelUpdate update : updates) {
            try {
              update.setLabel(variable.getName(), 0);
              update.setLabel(variable.getValue().getValueString(), 1);
              update.done();
            } catch (DebugException e) {
            }
          }
        }
      };
    }
    if (adapterType == IElementContentProvider.class
        && adaptableObject instanceof OclDebugVariable) {
      final OclDebugVariable variable = (OclDebugVariable) adaptableObject;
      return new IElementContentProvider() {

        public void update(IChildrenCountUpdate[] updates) {

          try {
            for (IChildrenCountUpdate update : updates) {
              IValue value = variable.getValue();
              OclDebugValue castedValue = (OclDebugValue) value;
              update.setChildCount(castedValue.getVariableCount());
              update.done();
            }
          } catch (DebugException e) {
            e.printStackTrace();
          }
        }

        public void update(IChildrenUpdate[] updates) {

          try {
            IValue value = variable.getValue();
            OclDebugValue castedValue = (OclDebugValue) value;
            for (IChildrenUpdate update : updates) {
              int offset = update.getOffset();
              int length = update.getLength();
              for (int i = offset; i < offset + length; i++) {
                IVariable variable = castedValue.getChild(i);
                update.setChild(variable, i);
              }
              update.done();
            }
          } catch (DebugException e) {
            e.printStackTrace();
          }
        }

        public void update(IHasChildrenUpdate[] updates) {

          for (IHasChildrenUpdate update : updates) {
            try {
              update.setHasChilren(variable.getValue().hasVariables());
              update.done();
            } catch (org.eclipse.debug.core.DebugException e) {
              e.printStackTrace();
            }
          }
        }
      };
    }
    return null;
  }
Exemple #26
0
 public static boolean isJSFile(IResource resource) {
   return JS_EXTENSION.equals(resource.getFileExtension());
 }