Search in sources :

Example 36 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-plugins by JetBrains.

the class OsgiRunConfigurationEditor method resetEditorFrom.

@Override
protected void resetEditorFrom(@NotNull OsgiRunConfiguration osgiRunConfiguration) {
    myRunConfiguration = osgiRunConfiguration;
    myVmOptions.setText(osgiRunConfiguration.getVmParameters());
    myProgramParameters.setText(osgiRunConfiguration.getProgramParameters());
    myFrameworkInstances.setSelectedItem(osgiRunConfiguration.getInstanceToUse());
    myClassPathAllBundles.setSelected(osgiRunConfiguration.isIncludeAllBundlesInClassPath());
    if (myCurrentRunPropertiesEditor != null) {
        myCurrentRunPropertiesEditor.resetEditorFrom(osgiRunConfiguration);
    }
    // I deliberately set the list of modules as the last step here as
    // the framework specific modules are cleaned out when you change the framework instance
    // so the framework instance should be changed first
    List<SelectedBundle> modules = osgiRunConfiguration.getBundlesToDeploy();
    RunConfigurationTableModel model = getTableModel();
    while (model.getRowCount() > 0) {
        model.removeBundleAt(0);
    }
    for (SelectedBundle module : modules) {
        model.addBundle(module);
    }
    myBundlesTable.getColumnModel().getColumn(1).setPreferredWidth(200);
    myFrameworkStartLevel.setValue(osgiRunConfiguration.getFrameworkStartLevel());
    myDefaultStartLevel.setValue(osgiRunConfiguration.getDefaultStartLevel());
    boolean useUserDefinedFields = !osgiRunConfiguration.isGenerateWorkingDir();
    myWorkingDirField.setText(osgiRunConfiguration.getWorkingDir());
    if (myWorkingDirField.getText().length() == 0) {
        final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(myProject);
        if (extension != null) {
            final VirtualFilePointer outputDirPointer = extension.getCompilerOutputPointer();
            if (outputDirPointer != null) {
                myWorkingDirField.setText(VfsUtilCore.urlToPath(outputDirPointer.getUrl() + "/run.osgi/"));
            }
        }
    }
    myWorkingDirField.setEnabled(useUserDefinedFields);
    myUserDefinedDir.setSelected(useUserDefinedFields);
    myOsmorcControlledDir.setSelected(!useUserDefinedFields);
    myJrePathEditor.setPathOrName(osgiRunConfiguration.getAlternativeJrePath(), osgiRunConfiguration.isUseAlternativeJre());
}
Also used : CompilerProjectExtension(com.intellij.openapi.roots.CompilerProjectExtension) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer)

Example 37 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.

the class UpdateInfoTree method createTree.

private void createTree() {
    SmartExpander.installOn(myTree);
    SelectionSaver.installOn(myTree);
    createTreeModel();
    myTree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            AbstractTreeNode treeNode = (AbstractTreeNode) e.getPath().getLastPathComponent();
            VirtualFilePointer pointer = null;
            if (treeNode instanceof FileTreeNode) {
                pointer = ((FileTreeNode) treeNode).getFilePointer();
            }
            if (pointer != null) {
                mySelectedUrl = pointer.getUrl();
                mySelectedFile = pointer.getFile();
            } else {
                mySelectedUrl = null;
                mySelectedFile = null;
            }
        }
    });
    myTree.setCellRenderer(new UpdateTreeCellRenderer());
    TreeUtil.installActions(myTree);
    new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {

        public String convert(TreePath path) {
            Object last = path.getLastPathComponent();
            if (last instanceof AbstractTreeNode) {
                return ((AbstractTreeNode) last).getText();
            }
            return TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING.convert(path);
        }
    }, true);
    myTree.addMouseListener(new PopupHandler() {

        public void invokePopup(Component comp, int x, int y) {
            final DefaultActionGroup group = (DefaultActionGroup) ActionManager.getInstance().getAction("UpdateActionGroup");
            if (group != null) {
                //if no UpdateActionGroup was configured
                ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UPDATE_POPUP, group);
                popupMenu.getComponent().show(comp, x, y);
            }
        }
    });
    EditSourceOnDoubleClickHandler.install(myTree);
    EditSourceOnEnterKeyHandler.install(myTree);
    myTree.setSelectionRow(0);
}
Also used : TreeSelectionListener(javax.swing.event.TreeSelectionListener) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) TreePath(javax.swing.tree.TreePath) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 38 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.

the class FileTreeNode method acceptFilter.

@Override
protected boolean acceptFilter(Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
    try {
        VirtualFilePointer filePointer = getFilePointer();
        if (!filePointer.isValid()) {
            return false;
        }
        VirtualFile file = filePointer.getFile();
        if (file != null && file.isValid() && filter.first.contains(file, getProject(), filter.second)) {
            applyFilter(true);
            return true;
        }
    } catch (Throwable e) {
    // TODO: catch and ignore exceptions: see to FilePatternPackageSet
    // sometimes for new file DirectoryFileIndex.getContentRootForFile() return random path
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer)

Example 39 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.

the class LibraryImpl method isValid.

@Override
public boolean isValid(@NotNull final String url, @NotNull final OrderRootType rootType) {
    final VirtualFilePointerContainer container = myRoots.get(rootType);
    final VirtualFilePointer fp = container.findByUrl(url);
    return fp != null && fp.isValid();
}
Also used : VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 40 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.

the class LibraryImpl method removeRoot.

@Override
public boolean removeRoot(@NotNull String url, @NotNull OrderRootType rootType) {
    checkDisposed();
    LOG.assertTrue(isWritable());
    final VirtualFilePointerContainer container = myRoots.get(rootType);
    final VirtualFilePointer byUrl = container.findByUrl(url);
    if (byUrl != null) {
        container.remove(byUrl);
        if (myExcludedRoots != null) {
            for (String excludedRoot : myExcludedRoots.getUrls()) {
                if (!isUnderRoots(excludedRoot)) {
                    VirtualFilePointer pointer = myExcludedRoots.findByUrl(excludedRoot);
                    if (pointer != null) {
                        myExcludedRoots.remove(pointer);
                    }
                }
            }
        }
        myJarDirectories.remove(rootType, url);
        return true;
    }
    return false;
}
Also used : VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Aggregations

VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)66 MockVirtualFile (com.intellij.mock.MockVirtualFile)23 File (java.io.File)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 NotNull (org.jetbrains.annotations.NotNull)12 VirtualFilePointerContainer (com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)11 IOException (java.io.IOException)8 Disposable (com.intellij.openapi.Disposable)7 VirtualFilePointerListener (com.intellij.openapi.vfs.pointers.VirtualFilePointerListener)6 ArrayList (java.util.ArrayList)5 Element (org.jdom.Element)5 Nullable (org.jetbrains.annotations.Nullable)4 Job (com.intellij.concurrency.Job)3 FileEditorProvider (com.intellij.openapi.fileEditor.FileEditorProvider)3 FileEditorState (com.intellij.openapi.fileEditor.FileEditorState)3 VirtualFilePointerManager (com.intellij.openapi.vfs.pointers.VirtualFilePointerManager)3 JobLauncher (com.intellij.concurrency.JobLauncher)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 PathManagerEx (com.intellij.openapi.application.ex.PathManagerEx)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2