Search in sources :

Example 31 with FileObject

use of org.openide.filesystems.FileObject in project cakephp-netbeans by cakephp.

the class CakePhpGoToViewAction method goToView.

@Override
public boolean goToView() {
    EditorSupport editorSupport = Lookup.getDefault().lookup(EditorSupport.class);
    PhpBaseElement phpElement = editorSupport.getElement(controller, offset);
    if (phpElement == null) {
        return false;
    }
    FileObject view = CakePhpUtils.getView(controller, phpElement);
    if (view != null) {
        UiUtils.open(view, DEFAULT_OFFSET);
        return true;
    }
    return false;
}
Also used : EditorSupport(org.netbeans.modules.php.api.editor.EditorSupport) FileObject(org.openide.filesystems.FileObject) PhpBaseElement(org.netbeans.modules.php.api.editor.PhpBaseElement)

Example 32 with FileObject

use of org.openide.filesystems.FileObject in project enclojure by EricThorsen.

the class SourcePathProviderImpl method getURL.

/**
 * Translates a relative path ("java/lang/Thread.java") to url
 * ("file:///C:/Sources/java/lang/Thread.java"). Uses GlobalPathRegistry
 * if global == true.
 *
 * @param relativePath a relative path (java/lang/Thread.java)
 * @param global true if global path should be used
 * @return url or <code>null</code>
 */
public String getURL(String relativePath, boolean global) {
    if (verbose) {
        System.out.println("SPPI: getURL " + relativePath + " global " + global);
    // ET I seem to get explicit paths here for clojure files?
    }
    String cf = checkClojureFile(relativePath);
    if (cf != null) {
        return cf;
    }
    FileObject fo;
    try {
        LOG.log(Level.ALL, " SourcePathProviderImpl::getURL - " + relativePath);
        if (originalSourcePath == null) {
            fo = GlobalPathRegistry.getDefault().findResource(relativePath);
        } else {
            synchronized (this) {
                if (!global) {
                    fo = smartSteppingSourcePath.findResource(relativePath);
                    if (verbose) {
                        System.out.println("SPPI:   fo " + fo);
                    }
                } else {
                    fo = originalSourcePath.findResource(relativePath);
                    if (verbose) {
                        System.out.println("SPPI:   fo " + fo);
                    }
                }
            }
        }
        if (fo == null) {
            LOG.log(Level.ALL, " SourcePathProviderImpl::getURL - NO GO for: " + relativePath);
            return null;
        }
        return fo.getURL().toString();
    } catch (FileStateInvalidException e) {
        if (verbose) {
            System.out.println("SPPI:   FileStateInvalidException");
        }
        return null;
    }
}
Also used : FileStateInvalidException(org.openide.filesystems.FileStateInvalidException) FileObject(org.openide.filesystems.FileObject)

Example 33 with FileObject

use of org.openide.filesystems.FileObject in project enclojure by EricThorsen.

the class ClojureToggleBreakpointActionProvider method propertyChange.

public void propertyChange(PropertyChangeEvent evt) {
    String url = Context.getCurrentURL();
    // #67910 - setting of a bp allowed only in JSP contained in some web module
    FileObject fo = Utils.getFileObjectFromUrl(url);
    boolean isClojure = Utils.isClojure(fo);
    // #issue 65969 fix:
    // we allow bp setting only if the file is JSP or TAG file and target server of it's module is NOT WebLogic 9;
    // TODO it should be solved by adding new API into j2eeserver which should announce whether the target server
    // supports JSP debugging or not
    // String serverID = Utils.getTargetServerID(fo);
    setEnabled(ActionsManager.ACTION_TOGGLE_BREAKPOINT, isClojure);
    if (debugger != null && debugger.getState() == debugger.STATE_DISCONNECTED)
        destroy();
}
Also used : FileObject(org.openide.filesystems.FileObject)

Example 34 with FileObject

use of org.openide.filesystems.FileObject in project enclojure by EricThorsen.

the class ClojureTemplateWizardIterator method instantiate.

public Set instantiate() throws /*ProgressHandle handle*/
IOException {
    Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
    // File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
    // dirF.mkdirs();
    // 
    // FileObject template = Templates.getTemplate(wiz);
    // FileObject dir = FileUtil.toFileObject(dirF);
    File dirF = (File) wiz.getProperty("projdir");
    dirF.mkdirs();
    FileObject template = Templates.getTemplate(wiz);
    // FileObject dir = FileUtil.toFileObject(dirF);
    try {
        // FF - exclide thie lib/clojure.jar if the user selects another clojure reference
        // if(  dir.getPath().startsWith(ClojureTemplatePanelVisual.getDefaultClojureReferencePath()))
        ClojureTemplatePanelVisual component = (ClojureTemplatePanelVisual) current().getComponent();
        unZipFile(template.getInputStream(), dirF, component.packageNameTextField.getText(), component.getProjectName());
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
    FileObject dir = FileUtil.toFileObject(dirF);
    // Always open top dir as a project:
    resultSet.add(dir);
    // Look for nested projects to open as well:
    Enumeration<? extends FileObject> e = dir.getFolders(true);
    while (e.hasMoreElements()) {
        FileObject subfolder = e.nextElement();
        if (ProjectManager.getDefault().isProject(subfolder)) {
            resultSet.add(subfolder);
        }
    }
    File parent = dirF.getParentFile();
    if (parent != null && parent.exists()) {
        ProjectChooser.setProjectsFolder(parent);
    }
    // }
    return resultSet;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) FileObject(org.openide.filesystems.FileObject) File(java.io.File) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

FileObject (org.openide.filesystems.FileObject)34 File (java.io.File)15 IOException (java.io.IOException)9 NotifyDescriptor (org.openide.NotifyDescriptor)6 ImportControllerUI (org.gephi.desktop.importer.api.ImportControllerUI)5 ActionEvent (java.awt.event.ActionEvent)4 InputStream (java.io.InputStream)4 JPanel (javax.swing.JPanel)4 DocumentBuilder (javax.xml.parsers.DocumentBuilder)4 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)4 ProjectControllerUI (org.gephi.desktop.project.api.ProjectControllerUI)4 Document (org.w3c.dom.Document)4 ActionListener (java.awt.event.ActionListener)3 ArrayList (java.util.ArrayList)3 JFileChooser (javax.swing.JFileChooser)3 MostRecentFiles (org.gephi.desktop.mrufiles.api.MostRecentFiles)3 FileImporter (org.gephi.io.importer.spi.FileImporter)3 DialogFileFilter (org.gephi.ui.utils.DialogFileFilter)3 ClassPath (org.netbeans.api.java.classpath.ClassPath)3 DialogDescriptor (org.openide.DialogDescriptor)3