Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IFile


    synchronized (_wgaConfigLock) {

      FileOutputStream wgaxmlstream = null;
      try {
          IFile wgaConfig = getWGABase().getFile(new Path("wgaconfig.xml"));
          if (wgaConfig.exists() && wgaConfig.isReadOnly()) {
                    ResourceAttributes attributes = wgaConfig.getResourceAttributes();
                    attributes.setReadOnly(false);
                    wgaConfig.setResourceAttributes(attributes);               
          }
        wgaxmlstream = new FileOutputStream(wgaConfig.getLocation().toFile());
        WGAConfiguration.write(config, wgaxmlstream);
        _wgaBase.refreshLocal(IResource.DEPTH_ONE, null);
      } catch (Exception e) {
        IOException ioe = new IOException("Unable to save wga configuration.");
        ioe.setStackTrace(e.getStackTrace());
View Full Code Here


  }

  public void flushConfig() throws CoreException {
    FileOutputStream configFileStream = null;
    try {
      IFile configFile = getConfigFile();
      if (configFile.isReadOnly()) {
        ResourceAttributes attributes = configFile.getResourceAttributes(); // ResourceAttributes.fromFile(configFile.getLocation().toFile());
        attributes.setReadOnly(false);
        configFile.setResourceAttributes(attributes);
      }

      // we might have to update root url bc. of distribution changes
      if (getRootURL() != null) {
        WGAConfiguration wgaConfig = retrieveWGAConfig(false);
        if (wgaConfig != null) {
          wgaConfig.getServerOptions().put(WGAConfiguration.SERVEROPTION_ROOT_URL, getRootURL().toString());
          saveWGAConfig(wgaConfig);
        }
      }
      configFileStream = new FileOutputStream(configFile.getLocation().toFile());
      WGARuntimeConfiguration.write(_config, configFileStream);

      _project.refreshLocal(IResource.DEPTH_ONE, null);
    } catch (Exception e) {
      WGADesignerPlugin.getDefault().logError("Unable to save config of runtime '" + getName() + "'.", e);
View Full Code Here

    super.finalize();
  }

  public void resourceChanged(IResourceChangeEvent event) {
    if (event.getDelta() != null) {
      IFile wgaconfig = getWGAConfigFile();
      if (wgaconfig != null && wgaconfig.isAccessible()) {
        IResourceDelta delta = event.getDelta().findMember(getWGAConfigFile().getFullPath());
        if (delta != null) {
          // wga config changed
          fireWGAConfigurationChanged();
        }
View Full Code Here

    }

    public void apply(IDocument document) {
      IResource resource = _markerAnnotation.getMarker().getResource();
      if (resource instanceof IFile) {
        IFile referer = (IFile) resource;
        IFolder tmlFolder = new WGADesignStructureHelper(referer).getTmlRoot();
        IFile fileToCreate = tmlFolder.getFile(new Path(_refPath));
        if (!fileToCreate.exists()) {
          try {
            // mkdir
            IContainer parent = fileToCreate.getParent();
            List<IFolder> foldersToCreate = new ArrayList<IFolder>();
            while (!parent.exists()) {
              if (parent instanceof IFolder) {
                foldersToCreate.add((IFolder)parent);
              }
              parent = parent.getParent();
            }
            for (int i=foldersToCreate.size() - 1; i >= 0; i--) {
              foldersToCreate.get(i).create(false, true, new NullProgressMonitor());
            }           
            // create tml file           
                  String header = Plugin.getDefault().getHeaderFileMap().get(Plugin.HEADER_TML_MODUL).getHeaderForProject(fileToCreate.getProject())
                  fileToCreate.create(new ByteArrayInputStream(header.getBytes()), true, new NullProgressMonitor());             
            // open editor
            WorkbenchUtils.openEditor(Plugin.getDefault().getWorkbench(), fileToCreate, ResourceIDs.EDITOR_TML);
          } catch (CoreException e) {
          }       
        }
View Full Code Here

    }

    public void apply(IDocument document) {
      IResource resource = _markerAnnotation.getMarker().getResource();
      if (resource instanceof IFile) {
        IFile referer = (IFile) resource;
        WGADesignStructureHelper helper = new WGADesignStructureHelper(referer);
        IFolder scriptFolder = helper.getScriptsRoot();
        IFile fileToCreate = scriptFolder.getFile(new Path(_refPath));
        if (!fileToCreate.exists()) {
          try {
            // mkdir
            IContainer parent = fileToCreate.getParent();
            List<IFolder> foldersToCreate = new ArrayList<IFolder>();
            while (!parent.exists()) {
              if (parent instanceof IFolder) {
                foldersToCreate.add((IFolder)parent);
              }
              parent = parent.getParent();
            }
            for (int i=foldersToCreate.size() - 1; i >= 0; i--) {
              foldersToCreate.get(i).create(false, true, new NullProgressMonitor());
            }           
            // create tml file
            fileToCreate.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor());
            // open editor
            WorkbenchUtils.openEditor(Plugin.getDefault().getWorkbench(), fileToCreate);
          } catch (CoreException e) {
          }       
        }
View Full Code Here

    }

    public void apply(IDocument document) {
      IResource resource = _markerAnnotation.getMarker().getResource();
      if (resource instanceof IFile) {
        IFile referer = (IFile) resource;
        WGADesignStructureHelper helper = new WGADesignStructureHelper(referer);
       
        try {
          helper.createLabel(_labelFilename, _labelKey, "");                 
          // revalidate tmlfile and open editor
View Full Code Here

       
     
        if (!labelFilename.equalsIgnoreCase("general")) {
          // check if labelfile exists
          try {
            IFile labelFile = designHelper.getLabelFile(labelFilename);
            if (labelFile == null || !labelFile.exists()) {
              try {             
                IRegion attributeRegion = tmlInfo.getAttributeValueRegion("file");
                if (attributeRegion != null) {
                  charStart = attributeRegion.getOffset();
                  charEnd = charStart + attributeRegion.getLength();
View Full Code Here

  public String getTypeLabel() {
    return null;
  }

  public void open() {
    IFile file = Plugin.getDefault().getActiveFile();
    if (file != null) {
      IFile referenceFile = WGADesignStructureHelper.findReferencedTMLModule(file, _reference, _tmlRegion.getAttributeValue("medium"));
      if (referenceFile != null) {
        if (Plugin.getDefault().isDebugging()) {
          System.out.println(referenceFile.getProjectRelativePath());
        }
        try {
          WorkbenchUtils.openEditor(Plugin.getDefault().getWorkbench(), referenceFile, ResourceIDs.EDITOR_TML);
        } catch (PartInitException e) {
          Plugin.getDefault().logError("Unable to open editor for reference '" + _reference + "'.", e);
View Full Code Here

  private boolean hasMDHeader() {
    boolean hasMDHeader = false;
    try {
      IAdaptable element = getElement();
      if (element instanceof IFile) {
        IFile tmlFile = (IFile) getElement();
        TMLDocumentProvider provider = new TMLDocumentProvider();   
        IFileEditorInput input = new FileEditorInput(tmlFile);     
        provider.connect(input);
       
        if (provider.getDocument(input).getContentType(0).equals(TMLPartitionScanner.TML_METAHEADER)) {
View Full Code Here

  @Override
  public Model getModel() {
    if (_model == null) {
      IAdaptable element = getElement();
      if (element instanceof IFile) {
        IFile tmlFile = (IFile) getElement()
        _model = new TMLFileMetadataModel(tmlFile);
      }
    }
    return _model;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.IFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.