Search in sources :

Example 46 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 47 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 48 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 49 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)

Example 50 with FileObject

use of org.openide.filesystems.FileObject in project gephi by gephi.

the class DragNDropFrameAdapter method register.

public static void register() {
    JFrame frame = (JFrame) WindowManager.getDefault().getMainWindow();
    frame.setTransferHandler(new TransferHandler() {

        @Override
        public boolean canImport(TransferHandler.TransferSupport support) {
            if (!support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                return false;
            }
            // Impossible to get data here and look if compatible format
            return true;
        }

        @Override
        public boolean importData(TransferHandler.TransferSupport support) {
            if (!canImport(support)) {
                return false;
            }
            try {
                List data = (List) support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
                File file = (File) data.get(0);
                FileObject fileObject = FileUtil.toFileObject(file);
                if (!file.exists()) {
                    return false;
                }
                if (fileObject.hasExt(GEPHI_EXTENSION)) {
                    ProjectControllerUI pc = Lookup.getDefault().lookup(ProjectControllerUI.class);
                    try {
                        pc.openProject(file);
                    } catch (Exception ew) {
                        Exceptions.printStackTrace(ew);
                        NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(DragNDropFrameAdapter.class, "DragNDropFrameAdapter.openGephiError"), NotifyDescriptor.WARNING_MESSAGE);
                        DialogDisplayer.getDefault().notify(msg);
                    }
                } else {
                    ImportControllerUI importController = Lookup.getDefault().lookup(ImportControllerUI.class);
                    if (importController.getImportController().isFileSupported(FileUtil.toFile(fileObject))) {
                        importController.importFile(fileObject);
                    } else {
                        return false;
                    }
                }
                return true;
            } catch (UnsupportedFlavorException ex) {
                Exceptions.printStackTrace(ex);
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
            return false;
        }
    });
}
Also used : IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) NotifyDescriptor(org.openide.NotifyDescriptor) JFrame(javax.swing.JFrame) ImportControllerUI(org.gephi.desktop.importer.api.ImportControllerUI) TransferHandler(javax.swing.TransferHandler) List(java.util.List) FileObject(org.openide.filesystems.FileObject) File(java.io.File) ProjectControllerUI(org.gephi.desktop.project.api.ProjectControllerUI)

Aggregations

FileObject (org.openide.filesystems.FileObject)79 File (java.io.File)27 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)9 NotifyDescriptor (org.openide.NotifyDescriptor)7 Project (org.netbeans.api.project.Project)6 DataObject (org.openide.loaders.DataObject)6 ActionEvent (java.awt.event.ActionEvent)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)5 PropertyChangeListener (java.beans.PropertyChangeListener)5 InputStream (java.io.InputStream)5 JFileChooser (javax.swing.JFileChooser)5 JPanel (javax.swing.JPanel)5 ImportControllerUI (org.gephi.desktop.importer.api.ImportControllerUI)5 DialogFileFilter (org.gephi.ui.utils.DialogFileFilter)5 DialogDescriptor (org.openide.DialogDescriptor)5 ActionListener (java.awt.event.ActionListener)4 DocumentBuilder (javax.xml.parsers.DocumentBuilder)4 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)4 BorderLayout (java.awt.BorderLayout)3