com.intellij.openapi.actionSystem.impl.SimpleDataContext



API Populatity

3 Client projects

Project: com.intellij

Project go-lang-plugin-org/go-lang-idea-plugin in file ....redeul.google.go.compiler.GoCompilerTestCase.java (2013-12-05)
@@ -13,8 +13,6 @@ import com.intellij.execution.runners.ExecutionEnvironment;
 import com.intellij.execution.runners.ProgramRunner;
 import com.intellij.execution.ui.RunContentDescriptor;
 import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.openapi.compiler.*;
@@ -23,7 +21,6 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.ProjectJdkTable;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.SdkModificator;
-import com.intellij.openapi.roots.CompilerProjectExtension;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.roots.ProjectRootManager;
@@ -37,7 +34,6 @@ import com.intellij.testFramework.fixtures.TempDirTestFixture;
 import com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl;
 import com.intellij.util.concurrency.Semaphore;
 import com.intellij.util.ui.UIUtil;
-import ro.redeul.google.go.components.GoCompilerLoader;
 import ro.redeul.google.go.config.sdk.GoSdkData;
 import ro.redeul.google.go.config.sdk.GoSdkType;
 import ro.redeul.google.go.runner.GoApplicationConfiguration;
@@ -82,14 +78,12 @@ public abstract class GoCompilerTestCase extends JavaCodeInsightFixtureTestCase
         myMainOutput = new TempDirTestFixtureImpl();
         myMainOutput.setUp();
         super.setUp();
-        getProject().getComponent(GoCompilerLoader.class).projectOpened();
 
         CompilerManagerImpl.testSetup();
 
         new WriteCommandAction(getProject()) {
             protected void run(Result result) throws Throwable {
                 addGoFacetAndSdk(myModule, getProject());
-                CompilerProjectExtension.getInstance(getProject()).setCompilerOutputUrl(myMainOutput.findOrCreateDir("out").getUrl());
             }
         }.execute();
     }
@@ -124,7 +118,7 @@ public abstract class GoCompilerTestCase extends JavaCodeInsightFixtureTestCase
         assertTrue("Test go sdk not available to run tests, check that the system property [go.test.sdk.home] or your GOROOT environment variable are set correctly.",
                 goSdkData != null);
 
-        sdkModificator.setHomePath(goSdkData.GO_HOME_PATH);
+        sdkModificator.setHomePath(goSdkData.GO_GOROOT_PATH);
         sdkModificator.setVersionString(goSdkData.VERSION_MAJOR);
         sdkModificator.setSdkAdditionalData(goSdkData);
         sdkModificator.commitChanges();
Project JetBrains/ideavim in file ...3156ba7c/src.com.maddyhome.idea.vim.VimPlugin.java (2013-03-25)
@@ -18,6 +18,7 @@ package com.maddyhome.idea.vim;
 import com.intellij.notification.Notification;
 import com.intellij.notification.NotificationType;
 import com.intellij.notification.Notifications;
+import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
 import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ex.ApplicationManagerEx;
@@ -81,6 +82,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
   private static final String IDEAVIM_COMPONENT_NAME = "VimPlugin";
   public static final String IDEAVIM_NOTIFICATION_ID = "ideavim";
   public static final String IDEAVIM_NOTIFICATION_TITLE = "IdeaVim";
+  public static final int STATE_VERSION = 1;
 
   private static final boolean BLOCK_CURSOR_VIM_VALUE = true;
   private static final boolean ANIMATED_SCROLLING_VIM_VALUE = false;
@@ -93,6 +95,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
   private boolean isRefrainFromScrolling = false;
   private boolean error = false;
 
+  private int previousStateVersion = 0;
   private String previousKeyMap = "";
 
   // It is enabled by default to avoid any special configuration after plugin installation
@@ -142,6 +145,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
 
     ApplicationManager.getApplication().invokeLater(new Runnable() {
       public void run() {
+        updateState();
         checkAndInstallKeymap();
       }
     });
@@ -161,6 +165,20 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
     LOG.debug("done");
   }
 
+  private void updateState() {
+    if (isEnabled()) {
+      if (previousStateVersion < 1) {
+        if (Messages.showYesNoDialog("Vim keymap generator has been updated to create keymaps more compatible " +
+                                     "with base keymaps.\n\nDo you want to reconfigure your Vim keymap?\n\n" +
+                                     "(You can do it later using Tools | Reconfigure Vim Keymap).",
+                                     IDEAVIM_NOTIFICATION_TITLE,
+                                     Messages.getQuestionIcon()) == Messages.YES) {
+          KeyHandler.executeAction("VimReconfigureKeymap", SimpleDataContext.getProjectContext(null));
+        }
+      }
+    }
+  }
+
   private static void checkAndInstallKeymap() {
     // Ensure that Vim keymap is installed and install if not.
     // Moreover we can use installed keymap as indicator of the first time installed plugin
@@ -264,6 +282,11 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
     // Restore whether the plugin is enabled or not
     Element state = element.getChild("state");
     if (state != null) {
+      try {
+        previousStateVersion = Integer.valueOf(state.getAttributeValue("version"));
+      }
+      catch (NumberFormatException ignored) {
+      }
       enabled = Boolean.valueOf(state.getAttributeValue("enabled"));
       previousKeyMap = state.getAttributeValue("keymap");
     }
@@ -278,6 +301,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
     final Element element = new Element("ideavim");
     // Save whether the plugin is enabled or not
     final Element state = new Element("state");
+    state.setAttribute("version", Integer.toString(STATE_VERSION));
     state.setAttribute("enabled", Boolean.toString(enabled));
     state.setAttribute("keymap", previousKeyMap);
     element.addContent(state);
Project JetBrains/intellij-community in file ...4idea.src.git4idea.history.wholeTree.GitLogUI.java (2011-10-24)
@@ -12,8 +12,10 @@
  */
 package git4idea.history.wholeTree;
 
+import com.intellij.ide.DataManager;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
 import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
@@ -69,6 +71,7 @@ import javax.swing.table.TableColumnModel;
 import javax.swing.table.TableModel;
 import java.awt.*;
 import java.awt.datatransfer.StringSelection;
+import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseWheelEvent;
 import java.io.File;
@@ -131,6 +134,7 @@ public class GitLogUI implements Disposable {
   private JPanel myEqualToHeadr;
   private boolean myThereAreFilters;
   private final GitLogUI.MyShowTreeAction myMyShowTreeAction;
+  //private GitLogUI.MyTreeSettingsButton myMyTreeSettingsButton;
 
   public GitLogUI(Project project, final Mediator mediator) {
     myProject = project;
@@ -652,7 +656,33 @@ public class GitLogUI implements Disposable {
     final JPanel mainBorderWrapper = new JPanel(new BorderLayout());
     final JPanel wrapperGutter = new JPanel(new BorderLayout());
     //myGraphGutter.getComponent().setVisible(false);
-    myEqualToHeadr = new JPanel() {
+    createTreeUpperComponent();
+    wrapperGutter.add(myEqualToHeadr, BorderLayout.NORTH);
+    wrapperGutter.add(myGraphGutter.getComponent(), BorderLayout.CENTER);
+    mainBorderWrapper.add(wrapperGutter, BorderLayout.WEST);
+    mainBorderWrapper.add(scrollPane, BorderLayout.CENTER);
+    //mainBorderWrapper.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor()));
+    wrapper.add(mainBorderWrapper, BorderLayout.CENTER);
+    myDetailsPanel = new GitLogDetailsPanel(myProject, myDetailsCache, new Convertor<VirtualFile, SymbolicRefs>() {
+      @Override
+      public SymbolicRefs convert(VirtualFile o) {
+        return myRefs.get(o);
+      }
+    });
+    final JPanel borderWrapper = new JPanel(new BorderLayout());
+    borderWrapper.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor()));
+    borderWrapper.add(myDetailsPanel.getComponent(), BorderLayout.CENTER);
+
+    final Splitter splitter = new Splitter(true, 0.6f);
+    splitter.setFirstComponent(wrapper);
+    splitter.setSecondComponent(borderWrapper);
+    splitter.setDividerWidth(4);
+    return splitter;
+  }
+
+  private void createTreeUpperComponent() {
+    final MyTreeSettings treeSettings = new MyTreeSettings();
+    myEqualToHeadr = new JPanel(new BorderLayout()) {
       @Override
       public Dimension getPreferredSize() {
         return getMySize();
@@ -674,28 +704,29 @@ public class GitLogUI implements Disposable {
         return new Dimension(width, height);
       }
     };
-    myEqualToHeadr.setBorder(BorderFactory.createMatteBorder(0,0,1,0,UIUtil.getBorderColor()));
-    wrapperGutter.add(myEqualToHeadr, BorderLayout.NORTH);
-    wrapperGutter.add(myGraphGutter.getComponent(), BorderLayout.CENTER);
-    mainBorderWrapper.add(wrapperGutter, BorderLayout.WEST);
-    mainBorderWrapper.add(scrollPane, BorderLayout.CENTER);
-    //mainBorderWrapper.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor()));
-    wrapper.add(mainBorderWrapper, BorderLayout.CENTER);
-    myDetailsPanel = new GitLogDetailsPanel(myProject, myDetailsCache, new Convertor<VirtualFile, SymbolicRefs>() {
+    myEqualToHeadr.setBorder(BorderFactory.createMatteBorder(1,0,1,0, UIUtil.getBorderColor()));
+    final JPanel wr2 = new JPanel(new BorderLayout());
+    wr2.add(treeSettings.getLabel(), BorderLayout.EAST);
+    myEqualToHeadr.add(wr2, BorderLayout.CENTER);
+    treeSettings.getLabel().setBorder(BorderFactory.createLineBorder(UIUtil.getLabelBackground()));
+    treeSettings.getLabel().addMouseListener(new MouseAdapter() {
       @Override
-      public SymbolicRefs convert(VirtualFile o) {
-        return myRefs.get(o);
+      public void mouseReleased(MouseEvent e) {
+        treeSettings.execute(e);
       }
-    });
-    final JPanel borderWrapper = new JPanel(new BorderLayout());
-    borderWrapper.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor()));
-    borderWrapper.add(myDetailsPanel.getComponent(), BorderLayout.CENTER);
 
-    final Splitter splitter = new Splitter(true, 0.6f);
-    splitter.setFirstComponent(wrapper);
-    splitter.setSecondComponent(borderWrapper);
-    splitter.setDividerWidth(4);
-    return splitter;
+      @Override
+      public void mouseExited(MouseEvent e) {
+        treeSettings.getLabel().setBackground(UIUtil.getLabelBackground());
+        treeSettings.getLabel().setBorder(BorderFactory.createLineBorder(UIUtil.getLabelBackground()));
+      }
+
+      @Override
+      public void mouseEntered(MouseEvent e) {
+        treeSettings.getLabel().setBackground(UIUtil.getLabelBackground().darker());
+        treeSettings.getLabel().setBorder(BorderFactory.createLineBorder(Color.black));
+      }
+    });
   }
 
   private ActionPopupMenu createContextMenu() {
@@ -1678,4 +1709,59 @@ public class GitLogUI implements Disposable {
       }
     }
   }
+  
+  public class MyTreeSettings {
+    private final DumbAwareAction myMultiColorAction;
+    private final DumbAwareAction myCalmAction;
+    private final Icon myIcon;
+    private JLabel myLabel;
+
+    public MyTreeSettings() {
+      myIcon = IconLoader.getIcon("/general/comboArrow.png");
+
+      myMultiColorAction = new DumbAwareAction("Multicolour") {
+        @Override
+        public void actionPerformed(AnActionEvent e) {
+          myGraphGutter.setStyle(GraphGutter.PresentationStyle.multicolour);
+        }
+      };
+      myCalmAction = new DumbAwareAction("Calm") {
+        @Override
+        public void actionPerformed(AnActionEvent e) {
+          myGraphGutter.setStyle(GraphGutter.PresentationStyle.calm);
+        }
+      };
+      myLabel = new JLabel(myIcon);
+      myLabel.setOpaque(false);
+    }
+
+    public JLabel getLabel() {
+      return myLabel;
+    }
+
+    public Icon getIcon() {
+      return myIcon;
+    }
+
+    public void execute(final MouseEvent e) {
+      final DefaultActionGroup group = createActionGroup();
+      final DataContext parent = DataManager.getInstance().getDataContext(myEqualToHeadr);
+      final DataContext dataContext = SimpleDataContext.getSimpleContext(PlatformDataKeys.PROJECT.getName(), myProject, parent);
+      final JBPopup popup = JBPopupFactory.getInstance()
+        .createActionGroupPopup(null, group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true,
+                                new Runnable() {
+                                  @Override
+                                  public void run() {
+                                  }
+                                }, 20);
+      popup.show(new RelativePoint(e));
+    }
+
+    private DefaultActionGroup createActionGroup() {
+      final DefaultActionGroup dab = new DefaultActionGroup();
+      dab.add(myMultiColorAction);
+      dab.add(myCalmAction);
+      return dab;
+    }
+  }
 }