Example #1
0
  public void update(AnActionEvent e) {
    super.update(e);

    final Project project = e.getData(DataKeys.PROJECT);
    final VirtualFile file = e.getData(DataKeys.VIRTUAL_FILE);

    boolean visible =
        project != null
            && file != null
            && !file.isDirectory()
            && file.getFileType() == CppSupportLoader.CPP_FILETYPE
            && !Communicator.isHeaderFile(file);
    boolean enabled = visible;

    if (!visible) {
      visible = ActionPlaces.MAIN_MENU.equals(e.getPlace());
    }

    e.getPresentation().setEnabled(enabled);
    e.getPresentation().setVisible(visible);

    if (visible) {
      final String s =
          "Do c&ompile for " + (file != null ? file.getName() : "selected c/c++ fileToCompile");
      e.getPresentation().setText(s);
      e.getPresentation().setDescription(s);
    }
  }
  // get gitRepository
  // check for existing git repo
  // check available repos and privateRepo access (net)
  // Show dialog (window)
  // create GitHub repo (net)
  // create local git repo (if not exist)
  // add GitHub as a remote host
  // make first commit
  // push everything (net)
  @Override
  public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);

    if (project == null || project.isDisposed() || !GithubUtil.testGitExecutable(project)) {
      return;
    }

    shareProjectOnGithub(project, file);
  }
 public void update(AnActionEvent e) {
   final Project project = e.getData(CommonDataKeys.PROJECT);
   if (project == null || project.isDefault()) {
     setVisibleEnabled(e, false, false);
     return;
   }
   setVisibleEnabled(e, true, true);
 }
 @Override
 public void update(AnActionEvent event) {
   final Presentation presentation = event.getPresentation();
   final Project project = event.getData(CommonDataKeys.PROJECT);
   presentation.setEnabled(project != null);
   presentation.setVisible(
       ActionPlaces.isMainMenuOrActionSearch(event.getPlace()) && !PlatformUtils.isCidr());
 }
  @Override
  public void update(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    final Change[] changes = e.getData(getChangesKey());

    final Presentation presentation = e.getPresentation();
    presentation.setVisible(VcsDataKeys.CHANGES.getData(dataContext) != null);
    presentation.setEnabled(enabled(project, changes));
  }
    public void setSelected(AnActionEvent e, boolean state) {
      T change = ObjectUtils.tryCast(e.getData(VcsDataKeys.CURRENT_CHANGE), myClass);
      if (change == null) return;

      if (state) {
        myViewer.includeChange(change);
      } else {
        myViewer.excludeChange(change);
      }
    }
 @Override
 public void actionPerformed(final AnActionEvent e) {
   final Project project = e.getData(CommonDataKeys.PROJECT);
   if (project != null) {
     RunnerAndConfigurationSettings settings = chooseTempSettings(project);
     if (settings != null) {
       final RunManager runManager = RunManager.getInstance(project);
       runManager.makeStable(settings);
     }
   }
 }
Example #8
0
  public void actionPerformed(AnActionEvent event) {
    Project project = event.getData(PlatformDataKeys.PROJECT);
    Icon i = getQuestionIcon();

    //Prompt the user for their choice of dimension filters (only one-at-a-time atm)
    String dimension = showInputDialog(project, "What dimesion would you like to filter by?", "Dimension name",i);
    String value = showInputDialog(project, "What choice would you like to make in dimension " + dimension + "?", "Chocie", i);

    //Grab the file and store it's current state before making any modifications
    //TODO: this will have to account for if a partial selection has already been made on the file
    VirtualFile f = event.getData(DataKeys.VIRTUAL_FILE);
    String name = f.getName();


    //Perform the modification to the file, store it's new state, and display to the user
    Choice c = new Choice(dimension, value);

    //TODO: rather than passing in names, pass in some representation of the original file and the modified file
    FileVariation fv = new FileVariation(name, name, c);
    variedFiles.add(fv);
  }
 public void actionPerformed(final AnActionEvent e) {
   LogModel model = myConsole.myProjectModel;
   for (Notification notification : model.getNotifications()) {
     notification.expire();
     model.removeNotification(notification);
   }
   model.setStatusMessage(null, 0);
   final Editor editor = e.getData(CommonDataKeys.EDITOR);
   if (editor != null) {
     editor.getDocument().deleteString(0, editor.getDocument().getTextLength());
   }
 }
  @Override
  public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(PlatformDataKeys.PROJECT);
    if (project == null) return;

    Runnable searchEverywhere = mySearchEverywhereRunnable;
    mySearchEverywhereRunnable = null;
    hideHints();

    if (searchEverywhere != null) {
      searchEverywhere.run();
      return;
    }

    final RelativePoint popupPosition =
        JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext());
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.usages");

    UsageTarget[] usageTargets = e.getData(UsageView.USAGE_TARGETS_KEY);
    final Editor editor = e.getData(PlatformDataKeys.EDITOR);
    if (usageTargets == null) {
      chooseAmbiguousTargetAndPerform(
          project,
          editor,
          new PsiElementProcessor<PsiElement>() {
            @Override
            public boolean execute(@NotNull final PsiElement element) {
              startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE);
              return false;
            }
          });
    } else {
      PsiElement element = ((PsiElementUsageTarget) usageTargets[0]).getElement();
      if (element != null) {
        startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE);
      }
    }
  }
  public void actionPerformed(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    final Change[] changes = e.getData(getChangesKey());

    if (!enabled(project, changes)) {
      return;
    }

    final Change change = changes[0];

    final CalculateAndShow worker =
        new CalculateAndShow(project, change, e.getPresentation().getText());
    ProgressManager.getInstance().run(worker);
  }
 @Override
 public void update(final AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   final Project project = e.getData(CommonDataKeys.PROJECT);
   if (project == null) {
     disable(presentation);
     return;
   }
   RunnerAndConfigurationSettings settings = chooseTempSettings(project);
   if (settings == null) {
     disable(presentation);
   } else {
     presentation.setText(
         ExecutionBundle.message(
             "save.temporary.run.configuration.action.name", settings.getName()));
     presentation.setDescription(presentation.getText());
     presentation.setVisible(true);
     presentation.setEnabled(true);
   }
 }
 @Override
 public void update(AnActionEvent e) {
   Presentation presentation = e.getPresentation();
   Project project = e.getData(CommonDataKeys.PROJECT);
   if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) {
     presentation.setDescription(
         ExecutionBundle.message("choose.run.configuration.action.description"));
   }
   try {
     if (project == null || project.isDisposed() || !project.isInitialized()) {
       updatePresentation(null, null, null, presentation);
       presentation.setEnabled(false);
     } else {
       updatePresentation(
           ExecutionTargetManager.getActiveTarget(project),
           RunManagerEx.getInstanceEx(project).getSelectedConfiguration(),
           project,
           presentation);
       presentation.setEnabled(true);
     }
   } catch (IndexNotReadyException e1) {
     presentation.setEnabled(false);
   }
 }
 @Override
 public void update(AnActionEvent e) {
   Editor editor = e.getData(CommonDataKeys.EDITOR);
   e.getPresentation().setEnabled(editor != null && editor.getDocument().getTextLength() > 0);
 }
 @NotNull
 public static Notification get(@NotNull AnActionEvent e) {
   //noinspection ConstantConditions
   return e.getData(KEY);
 }
 public void actionPerformed(AnActionEvent e) {
   Change change = e.getData(VcsDataKeys.CURRENT_CHANGE);
   askAndMove(myProject, Collections.singletonList(change), null);
 }
 @Override
 protected boolean isEnabled(AnActionEvent e) {
   Change change = e.getData(VcsDataKeys.CURRENT_CHANGE);
   if (change == null) return false;
   return super.isEnabled(e);
 }
    public boolean isSelected(AnActionEvent e) {
      T change = ObjectUtils.tryCast(e.getData(VcsDataKeys.CURRENT_CHANGE), myClass);
      if (change == null) return false;

      return myViewer.isIncluded(change);
    }
  @Override
  public void actionPerformed(AnActionEvent event) {
    final Project project = event.getData(CommonDataKeys.PROJECT);

    LOG.assertTrue(project != null);

    final FileChooserDescriptor descriptor =
        new FileChooserDescriptor(false, true, false, false, false, false) {
          @Override
          public Icon getIcon(VirtualFile file) {
            if (file.isDirectory()) {
              if (file.findChild(
                      InspectionApplication.DESCRIPTIONS
                          + "."
                          + StdFileTypes.XML.getDefaultExtension())
                  != null) {
                return AllIcons.Nodes.InspectionResults;
              }
            }
            return super.getIcon(file);
          }
        };
    descriptor.setTitle("Select Path");
    descriptor.setDescription("Select directory which contains exported inspections results");
    final VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, null);
    if (virtualFile == null || !virtualFile.isDirectory()) return;

    final Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap = new HashMap<>();
    final String[] profileName = new String[1];
    final Runnable process =
        () -> {
          final VirtualFile[] files = virtualFile.getChildren();
          try {
            for (final VirtualFile inspectionFile : files) {
              if (inspectionFile.isDirectory()) continue;
              final String shortName = inspectionFile.getNameWithoutExtension();
              final String extension = inspectionFile.getExtension();
              if (shortName.equals(InspectionApplication.DESCRIPTIONS)) {
                profileName[0] =
                    ApplicationManager.getApplication()
                        .runReadAction(
                            (Computable<String>)
                                () ->
                                    OfflineViewParseUtil.parseProfileName(
                                        LoadTextUtil.loadText(inspectionFile).toString()));
              } else if (XML_EXTENSION.equals(extension)) {
                resMap.put(
                    shortName,
                    ApplicationManager.getApplication()
                        .runReadAction(
                            new Computable<Map<String, Set<OfflineProblemDescriptor>>>() {
                              @Override
                              public Map<String, Set<OfflineProblemDescriptor>> compute() {
                                return OfflineViewParseUtil.parse(
                                    LoadTextUtil.loadText(inspectionFile).toString());
                              }
                            }));
              }
            }
          } catch (final Exception e) { // all parse exceptions
            SwingUtilities.invokeLater(
                () ->
                    Messages.showInfoMessage(
                        e.getMessage(),
                        InspectionsBundle.message("offline.view.parse.exception.title")));
            throw new ProcessCanceledException(); // cancel process
          }
        };
    ProgressManager.getInstance()
        .runProcessWithProgressAsynchronously(
            project,
            InspectionsBundle.message("parsing.inspections.dump.progress.title"),
            process,
            () ->
                SwingUtilities.invokeLater(
                    () -> {
                      final String name = profileName[0];
                      showOfflineView(
                          project,
                          name,
                          resMap,
                          InspectionsBundle.message("offline.view.title")
                              + " ("
                              + (name != null
                                  ? name
                                  : InspectionsBundle.message("offline.view.editor.settings.title"))
                              + ")");
                    }),
            null,
            new PerformAnalysisInBackgroundOption(project));
  }
Example #20
0
 public void actionPerformed(AnActionEvent anActionEvent) {
   invoke(
       anActionEvent.getData(DataKeys.PROJECT),
       anActionEvent.getData(DataKeys.VIRTUAL_FILE),
       null);
 }
Example #21
0
 @Nullable
 public static XDebuggerTree getTree(final AnActionEvent e) {
   return e.getData(XDEBUGGER_TREE_KEY);
 }
  @Override
  public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    if (project == null) {
      LOGGER.error("actionPerformed (genVCs): no project for " + e);
      return;
    }
    VirtualFile resolveFile = getRESOLVEFileFromEvent(e);
    LOGGER.info("prove actionPerformed " + (resolveFile == null ? "NONE" : resolveFile));
    if (resolveFile == null) return;
    String title = "RESOLVE Prove";
    boolean canBeCancelled = true;

    commitDoc(project, resolveFile);
    Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
    if (editor == null) return;

    RunRESOLVEOnLanguageFile gen = new RunRESOLVEOnLanguageFile(resolveFile, project, title);

    MyProverListener pl = new MyProverListener();
    VCOutputFile vco = generateVCs(resolveFile, editor, project);
    // give each action an instance of the prover listener and make Update() print the result as it
    // comes back produce
    if (vco == null) return;

    RESOLVEPluginController controller = RESOLVEPluginController.getInstance(project);
    VerifierPanel verifierPanel = controller.getVerifierPanel();
    verifierPanel.createVerifierView2(
        vco.getFinalVCs(), pl); // TODO: maybe make this take in a list of VCs

    addVCGutterIcons(vco, editor, project, pl);
    controller.getVerifierWindow().show(null);

    // runProver
    List<String> args = new ArrayList<>();
    args.add(resolveFile.getPath());
    args.add("-lib");
    args.add(RunRESOLVEOnLanguageFile.getContentRoot(project, resolveFile).getPath());
    args.add("-prove");
    RESOLVECompiler compiler = new RESOLVECompiler(args.toArray(new String[args.size()]));
    compiler.addProverListener(pl);

    // TODO: Instead of this being anon, make a separate static class and add an error listener to
    // 'compiler' that (make it accessible
    // right here though so the UI part below can stop and update remaining (unproved) vcs if the
    // compiler does indeed suffer some
    // catastrophic failure: npe, etc.
    Task.Backgroundable proverTask =
        new Task.Backgroundable(project, "Proving") {
          @Override
          public void run(@NotNull final ProgressIndicator progressIndicator) {
            compiler.processCommandLineTargets();
          }
        };
    ProgressManager.getInstance().run(proverTask);

    // TODO: Different status icons for different proof results.
    running = true;
    Task.Backgroundable task =
        new Task.Backgroundable(project, "Updating Presentation") {

          @Override
          public void run(@NotNull final ProgressIndicator progressIndicator) {
            Map<String, Boolean> processed = new HashMap<>();
            for (VC vc : vco.getFinalVCs()) {
              processed.put(vc.getName(), false);
            }
            while (pl.vcIsProved.size() != vco.getFinalVCs().size()) {
              // if (proverTask.getNotificationInfo().)//TODO: Put something here that breaks out of
              // this if the compiler crashes..
              for (VC vc : vco.getFinalVCs()) {
                if (pl.vcIsProved.containsKey(vc.getName()) && !processed.get(vc.getName())) {
                  processed.put(vc.getName(), true);
                  long dur = pl.vcMetrics.get(vc.getName()).getProofDuration();
                  ConditionCollapsiblePanel section =
                      verifierPanel.vcSelectorPanel.vcTabs.get(vc.getNumber());
                  section.changeToFinalState(
                      pl.vcIsProved.get(vc.getName())
                          ? ConditionCollapsiblePanel.State.PROVED
                          : ConditionCollapsiblePanel.State.NOT_PROVED,
                      dur);
                }
              }
            }
            running = false;
          }
        };
    ProgressManager.getInstance().run(task);
  }