Search in sources :

Example 41 with NotNull

use of org.jetbrains.annotations.NotNull in project robolectric by robolectric.

the class SdkEnvironment method createRuntimeSdkResourcePath.

@NotNull
private ResourcePath createRuntimeSdkResourcePath(DependencyResolver dependencyResolver) {
    try {
        Fs systemResFs = Fs.fromJar(dependencyResolver.getLocalArtifactUrl(sdkConfig.getAndroidSdkDependency()));
        Class<?> androidRClass = getRobolectricClassLoader().loadClass("android.R");
        Class<?> androidInternalRClass = getRobolectricClassLoader().loadClass("com.android.internal.R");
        return new ResourcePath(androidRClass, systemResFs.join("res"), systemResFs.join("assets"), androidInternalRClass);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
Also used : ResourcePath(org.robolectric.res.ResourcePath) Fs(org.robolectric.res.Fs) NotNull(org.jetbrains.annotations.NotNull)

Example 42 with NotNull

use of org.jetbrains.annotations.NotNull in project robolectric by robolectric.

the class ShadowProviderGeneratorTest method element.

@NotNull
private ExecutableElement element(String reset) {
    ExecutableElement resetterExecutable = mock(ExecutableElement.class);
    Name mock = mock(Name.class);
    when(mock.toString()).thenReturn(reset);
    when(resetterExecutable.getSimpleName()).thenReturn(mock);
    return resetterExecutable;
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) Name(javax.lang.model.element.Name) NotNull(org.jetbrains.annotations.NotNull)

Example 43 with NotNull

use of org.jetbrains.annotations.NotNull in project jadx by skylot.

the class CommonSearchDialog method initButtonsPanel.

@NotNull
protected JPanel initButtonsPanel() {
    progressPane = new ProgressPanel(mainWindow, false);
    JButton cancelButton = new JButton(NLS.str("search_dialog.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            dispose();
        }
    });
    JButton openBtn = new JButton(NLS.str("search_dialog.open"));
    openBtn.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            openSelectedItem();
        }
    });
    getRootPane().setDefaultButton(openBtn);
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(progressPane);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(openBtn);
    buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPane.add(cancelButton);
    return buttonPane;
}
Also used : JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) NotNull(org.jetbrains.annotations.NotNull)

Example 44 with NotNull

use of org.jetbrains.annotations.NotNull in project languagetool by languagetool-org.

the class ConfigurationDialog method getTreeModel.

@NotNull
private DefaultTreeModel getTreeModel(DefaultMutableTreeNode rootNode) {
    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    treeModel.addTreeModelListener(new TreeModelListener() {

        @Override
        public void treeNodesChanged(TreeModelEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getTreePath().getLastPathComponent();
            int index = e.getChildIndices()[0];
            node = (DefaultMutableTreeNode) node.getChildAt(index);
            if (node instanceof RuleNode) {
                RuleNode o = (RuleNode) node;
                if (o.getRule().isDefaultOff() || o.getRule().getCategory().isDefaultOff()) {
                    if (o.isEnabled()) {
                        config.getEnabledRuleIds().add(o.getRule().getId());
                        config.getDisabledRuleIds().remove(o.getRule().getId());
                    } else {
                        config.getEnabledRuleIds().remove(o.getRule().getId());
                        config.getDisabledRuleIds().add(o.getRule().getId());
                    }
                } else {
                    if (o.isEnabled()) {
                        config.getDisabledRuleIds().remove(o.getRule().getId());
                    } else {
                        config.getDisabledRuleIds().add(o.getRule().getId());
                    }
                }
            }
            if (node instanceof CategoryNode) {
                CategoryNode o = (CategoryNode) node;
                if (o.isEnabled()) {
                    config.getDisabledCategoryNames().remove(o.getCategory().getName());
                } else {
                    config.getDisabledCategoryNames().add(o.getCategory().getName());
                }
            }
        }

        @Override
        public void treeNodesInserted(TreeModelEvent e) {
        }

        @Override
        public void treeNodesRemoved(TreeModelEvent e) {
        }

        @Override
        public void treeStructureChanged(TreeModelEvent e) {
        }
    });
    return treeModel;
}
Also used : TreeModelEvent(javax.swing.event.TreeModelEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeModelListener(javax.swing.event.TreeModelListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) NotNull(org.jetbrains.annotations.NotNull)

Example 45 with NotNull

use of org.jetbrains.annotations.NotNull in project languagetool by languagetool-org.

the class ConfigurationDialog method getMouseAdapter.

@NotNull
private MouseAdapter getMouseAdapter() {
    return new MouseAdapter() {

        private void handlePopupEvent(MouseEvent e) {
            JTree tree = (JTree) e.getSource();
            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
            if (path == null) {
                return;
            }
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            TreePath[] paths = tree.getSelectionPaths();
            boolean isSelected = false;
            if (paths != null) {
                for (TreePath selectionPath : paths) {
                    if (selectionPath.equals(path)) {
                        isSelected = true;
                    }
                }
            }
            if (!isSelected) {
                tree.setSelectionPath(path);
            }
            if (node.isLeaf()) {
                JPopupMenu popup = new JPopupMenu();
                JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu"));
                aboutRuleMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent actionEvent) {
                        RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent();
                        Rule rule = node.getRule();
                        Language lang = config.getLanguage();
                        if (lang == null) {
                            lang = Languages.getLanguageForLocale(Locale.getDefault());
                        }
                        Tools.showRuleInfoDialog(tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, messages, lang.getShortCodeWithCountryAndVariant());
                    }
                });
                popup.add(aboutRuleMenuItem);
                popup.show(tree, e.getX(), e.getY());
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                handlePopupEvent(e);
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                handlePopupEvent(e);
            }
        }
    };
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) Language(org.languagetool.Language) Rule(org.languagetool.rules.Rule) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)6249 VirtualFile (com.intellij.openapi.vfs.VirtualFile)829 ArrayList (java.util.ArrayList)617 Project (com.intellij.openapi.project.Project)540 File (java.io.File)531 PsiElement (com.intellij.psi.PsiElement)461 Nullable (org.jetbrains.annotations.Nullable)391 Module (com.intellij.openapi.module.Module)315 PsiFile (com.intellij.psi.PsiFile)296 List (java.util.List)272 IOException (java.io.IOException)263 TextRange (com.intellij.openapi.util.TextRange)245 ContainerUtil (com.intellij.util.containers.ContainerUtil)170 Document (com.intellij.openapi.editor.Document)158 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)154 ASTNode (com.intellij.lang.ASTNode)145 Pair (com.intellij.openapi.util.Pair)141 StringUtil (com.intellij.openapi.util.text.StringUtil)133 Logger (com.intellij.openapi.diagnostic.Logger)127 Editor (com.intellij.openapi.editor.Editor)120