コード例 #1
0
  public static boolean checkSourceRootsConfigured(
      final Module module, final boolean askUserToSetupSourceRoots) {
    List<VirtualFile> sourceRoots =
        ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
    if (sourceRoots.isEmpty()) {
      if (!askUserToSetupSourceRoots) {
        return false;
      }

      Project project = module.getProject();
      Messages.showErrorDialog(
          project,
          ProjectBundle.message("module.source.roots.not.configured.error", module.getName()),
          ProjectBundle.message("module.source.roots.not.configured.title"));

      ProjectSettingsService.getInstance(project)
          .showModuleConfigurationDialog(module.getName(), CommonContentEntriesEditor.NAME);

      sourceRoots =
          ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
      if (sourceRoots.isEmpty()) {
        return false;
      }
    }
    return true;
  }
コード例 #2
0
 protected boolean validateAndApply() {
   String newName = myNameField.getText().trim();
   if (newName.length() == 0) {
     newName = null;
   }
   if (shouldCheckName(newName)) {
     final LibraryTable.ModifiableModel tableModifiableModel = getTableModifiableModel();
     if (tableModifiableModel != null && !(tableModifiableModel instanceof ModuleLibraryTable)) {
       if (newName == null) {
         Messages.showErrorDialog(
             ProjectBundle.message("library.name.not.specified.error", newName),
             ProjectBundle.message("library.name.not.specified.title"));
         return false;
       }
       if (LibraryEditingUtil.libraryAlreadyExists(tableModifiableModel, newName)) {
         Messages.showErrorDialog(
             ProjectBundle.message("library.name.already.exists.error", newName),
             ProjectBundle.message("library.name.already.exists.title"));
         return false;
       }
     }
     myLibraryRootsComponent.renameLibrary(newName);
   }
   myLibraryRootsComponent.applyProperties();
   return true;
 }
コード例 #3
0
 @Override
 @Nullable
 protected ClasspathTableItem<?> createTableItem(final Library item) {
   // clear invalid order entry corresponding to added library if any
   final ModifiableRootModel rootModel = myClasspathPanel.getRootModel();
   final OrderEntry[] orderEntries = rootModel.getOrderEntries();
   for (OrderEntry orderEntry : orderEntries) {
     if (orderEntry instanceof LibraryOrderEntry) {
       final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) orderEntry;
       if (item.equals(libraryOrderEntry.getLibrary())) {
         return ClasspathTableItem.createItem(libraryOrderEntry, myContext);
       }
       String name = item.getName();
       if (name != null && name.equals(libraryOrderEntry.getLibraryName())) {
         if (orderEntry.isValid()) {
           Messages.showErrorDialog(
               ProjectBundle.message("classpath.message.library.already.added", item.getName()),
               ProjectBundle.message("classpath.title.adding.dependency"));
           return null;
         } else {
           rootModel.removeOrderEntry(orderEntry);
         }
       }
     }
   }
   final LibraryOrderEntry orderEntry = rootModel.addLibraryEntry(item);
   DependencyScope defaultScope = getDefaultScope(item);
   if (defaultScope != null) {
     orderEntry.setScope(defaultScope);
   }
   return ClasspathTableItem.createItem(orderEntry, myContext);
 }
コード例 #4
0
  public static void showDialogAndAddLibraryToDependencies(
      final Library library, final Project project, boolean allowEmptySelection) {
    for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
      if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
        return;
      }
    }

    final ModuleStructureConfigurable moduleStructureConfigurable =
        ModuleStructureConfigurable.getInstance(project);
    final List<Module> modules =
        LibraryEditingUtil.getSuitableModules(
            moduleStructureConfigurable, ((LibraryEx) library).getKind(), library);
    if (modules.isEmpty()) return;
    final ChooseModulesDialog dlg =
        new ChooseModulesDialog(
            moduleStructureConfigurable.getProject(),
            modules,
            ProjectBundle.message("choose.modules.dialog.title"),
            ProjectBundle.message("choose.modules.dialog.description", library.getName()));
    if (dlg.showAndGet()) {
      final List<Module> chosenModules = dlg.getChosenElements();
      for (Module module : chosenModules) {
        moduleStructureConfigurable.addLibraryOrderEntry(module, library);
      }
    }
  }
コード例 #5
0
    @Override
    @NotNull
    @SuppressWarnings({"NonStaticInitializer"})
    protected Action[] createActions() {
      final Action okAction = getOKAction();
      assignMnemonic(ADD_IN_CODE, okAction);
      final String externalName = ProjectBundle.message("external.annotations.external.option");
      return new Action[] {
        okAction,
        new AbstractAction(externalName) {
          {
            assignMnemonic(externalName, this);
          }

          @Override
          public void actionPerformed(final ActionEvent e) {
            if (canBeHidden()) {
              setToBeShown(toBeShown(), true);
            }
            close(2);
          }
        },
        getCancelAction()
      };
    }
 public JavadocPathsEditor(Sdk sdk) {
   super(
       ProjectBundle.message("sdk.configure.javadoc.tab"),
       JavadocOrderRootType.getInstance(),
       FileChooserDescriptorFactory.createMultipleJavaPathDescriptor());
   mySdk = sdk;
 }
コード例 #7
0
  private void initProject(@NotNull ProjectImpl project, @Nullable ProjectImpl template)
      throws IOException {
    final ProgressIndicator indicator = myProgressManager.getProgressIndicator();
    if (indicator != null && !project.isDefault()) {
      indicator.setText(ProjectBundle.message("loading.components.for", project.getName()));
      indicator.setIndeterminate(true);
    }

    ApplicationManager.getApplication()
        .getMessageBus()
        .syncPublisher(ProjectLifecycleListener.TOPIC)
        .beforeProjectLoaded(project);

    try {
      if (template != null) {
        project.getStateStore().loadProjectFromTemplate(template);
      } else {
        project.getStateStore().load();
      }
      project.loadProjectComponents();
      project.init();
    } catch (IOException e) {
      scheduleDispose(project);
      throw e;
    } catch (ProcessCanceledException e) {
      scheduleDispose(project);
      throw e;
    }
  }
コード例 #8
0
 private JComponent createAddPrefixComponent(final SourceFolder folder) {
   final IconActionComponent iconComponent =
       new IconActionComponent(
           ADD_PREFIX_ICON,
           ADD_PREFIX_ROLLOVER_ICON,
           ProjectBundle.message("module.paths.package.prefix.tooltip"),
           new Runnable() {
             public void run() {
               final String message =
                   ProjectBundle.message(
                       "module.paths.package.prefix.prompt",
                       toRelativeDisplayPath(folder.getUrl(), getContentEntry().getUrl() + ":"));
               final String prefix =
                   Messages.showInputDialog(
                       JavaContentRootPanel.this,
                       message,
                       ProjectBundle.message("module.paths.package.prefix.title"),
                       Messages.getQuestionIcon(),
                       folder.getPackagePrefix(),
                       null);
               if (prefix != null) {
                 myCallback.setPackagePrefix(folder, prefix);
               }
             }
           });
   final JPanel panel = new JPanel(new BorderLayout());
   panel.setOpaque(false);
   panel.add(iconComponent, BorderLayout.CENTER);
   panel.add(Box.createHorizontalStrut(3), BorderLayout.EAST);
   return panel;
 }
コード例 #9
0
 @Override
 public String suggestSdkName(String currentSdkName, String sdkHome) {
   final String suggestedName;
   if (currentSdkName != null && !currentSdkName.isEmpty()) {
     final Matcher matcher = VERSION_STRING_PATTERN.matcher(currentSdkName);
     final boolean replaceNameWithVersion = matcher.matches();
     if (replaceNameWithVersion) {
       // user did not change name -> set it automatically
       final String versionString = getVersionString(sdkHome);
       suggestedName =
           versionString == null
               ? currentSdkName
               : matcher.replaceFirst("$1" + versionString + "$3");
     } else {
       suggestedName = currentSdkName;
     }
   } else {
     String versionString = getVersionString(sdkHome);
     suggestedName =
         versionString == null
             ? ProjectBundle.message("sdk.java.unknown.name")
             : getVersionNumber(versionString);
   }
   return suggestedName;
 }
コード例 #10
0
 public FileChooserDescriptor getHomeChooserDescriptor() {
   final FileChooserDescriptor descriptor =
       new FileChooserDescriptor(false, true, false, false, false, false) {
         @Override
         public void validateSelectedFiles(VirtualFile[] files) throws Exception {
           if (files.length != 0) {
             final String selectedPath = files[0].getPath();
             boolean valid = isValidSdkHome(selectedPath);
             if (!valid) {
               valid = isValidSdkHome(adjustSelectedSdkHome(selectedPath));
               if (!valid) {
                 String message =
                     files[0].isDirectory()
                         ? ProjectBundle.message(
                             "sdk.configure.home.invalid.error", getPresentableName())
                         : ProjectBundle.message(
                             "sdk.configure.home.file.invalid.error", getPresentableName());
                 throw new Exception(message);
               }
             }
           }
         }
       };
   descriptor.setTitle(ProjectBundle.message("sdk.configure.home.title", getPresentableName()));
   return descriptor;
 }
コード例 #11
0
  @Override
  public boolean validate() throws ConfigurationException {
    ProjectTemplate template = getSelectedTemplate();
    if (template == null) {
      throw new ConfigurationException(
          StringUtil.capitalize(
              ProjectBundle.message(
                  "project.new.wizard.from.template.error", myWizardContext.getPresentationName())),
          "Error");
    }

    if (myWizardContext.isCreatingNewProject()) {
      if (!myNamePathComponent.validateNameAndPath(myWizardContext, myFormatPanel.isDefault()))
        return false;
    }

    if (!validateModulePaths()) return false;
    if (!myWizardContext.isCreatingNewProject()) {
      validateExistingModuleName();
    }

    ValidationInfo info = template.validateSettings();
    if (info != null) {
      throw new ConfigurationException(info.message, "Error");
    }
    if (mySettingsStep != null) {
      return mySettingsStep.validate();
    }
    return true;
  }
コード例 #12
0
  private void waitForFileWatcher(@NotNull Project project) {
    LocalFileSystem fs = LocalFileSystem.getInstance();
    if (!(fs instanceof LocalFileSystemImpl)) return;

    final FileWatcher watcher = ((LocalFileSystemImpl) fs).getFileWatcher();
    if (!watcher.isOperational() || !watcher.isSettingRoots()) return;

    LOG.info("FW/roots waiting started");
    Task.Modal task =
        new Task.Modal(project, ProjectBundle.message("project.load.progress"), true) {
          @Override
          public void run(@NotNull ProgressIndicator indicator) {
            indicator.setIndeterminate(true);
            indicator.setText(ProjectBundle.message("project.load.waiting.watcher"));
            if (indicator instanceof ProgressWindow) {
              ((ProgressWindow) indicator).setCancelButtonText(CommonBundle.message("button.skip"));
            }
            while (watcher.isSettingRoots() && !indicator.isCanceled()) {
              TimeoutUtil.sleep(10);
            }
            LOG.info("FW/roots waiting finished");
          }
        };
    myProgressManager.run(task);
  }
コード例 #13
0
 private void setupRootAndAnnotateExternally(
     @NotNull final OrderEntry entry,
     @NotNull final Project project,
     @NotNull final PsiModifierListOwner listOwner,
     @NotNull final String annotationFQName,
     @NotNull final PsiFile fromFile,
     @NotNull final String packageName,
     @Nullable final PsiNameValuePair[] value) {
   final FileChooserDescriptor descriptor =
       FileChooserDescriptorFactory.createSingleFolderDescriptor();
   descriptor.setTitle(
       ProjectBundle.message(
           "external.annotations.root.chooser.title", entry.getPresentableName()));
   descriptor.setDescription(
       ProjectBundle.message("external.annotations.root.chooser.description"));
   final VirtualFile newRoot = FileChooser.chooseFile(descriptor, project, null);
   if (newRoot == null) {
     notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
     return;
   }
   new WriteCommandAction(project) {
     @Override
     protected void run(final Result result) throws Throwable {
       appendChosenAnnotationsRoot(entry, newRoot);
       XmlFile xmlFileInRoot =
           findXmlFileInRoot(findExternalAnnotationsXmlFiles(listOwner), newRoot);
       if (xmlFileInRoot != null) { // file already exists under appeared content root
         if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFileInRoot)) {
           notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
           return;
         }
         annotateExternally(listOwner, annotationFQName, xmlFileInRoot, fromFile, value);
       } else {
         final XmlFile annotationsXml = createAnnotationsXml(newRoot, packageName);
         if (annotationsXml != null) {
           final List<PsiFile> createdFiles = new ArrayList<PsiFile>();
           createdFiles.add(annotationsXml);
           String fqn = getFQN(packageName, fromFile);
           if (fqn != null) {
             myExternalAnnotations.put(fqn, createdFiles);
           }
         }
         annotateExternally(listOwner, annotationFQName, annotationsXml, fromFile, value);
       }
     }
   }.execute();
 }
コード例 #14
0
 private Module createModule(final ModuleBuilder builder) {
   try {
     return ApplicationManager.getApplication()
         .runWriteAction(
             new ThrowableComputable<Module, Exception>() {
               @Override
               public Module compute() throws Exception {
                 return builder.createModule(myModuleModel);
               }
             });
   } catch (Exception e) {
     Messages.showErrorDialog(
         ProjectBundle.message("module.add.error.message", e.getMessage()),
         ProjectBundle.message("module.add.error.title"));
     return null;
   }
 }
コード例 #15
0
 public LibraryEditorDialogBase(
     final Component parent, final LibraryRootsComponent libraryRootsComponent) {
   super(parent, true);
   myLibraryRootsComponent = libraryRootsComponent;
   libraryRootsComponent.resetProperties();
   setTitle(ProjectBundle.message("library.configure.title"));
   Disposer.register(getDisposable(), myLibraryRootsComponent);
 }
コード例 #16
0
ファイル: FacetDetectionStep.java プロジェクト: jexp/idea2
 protected void onFinished(
     final Map<
             ModuleDescriptor, Map<File, List<FacetDetectionProcessor.DetectedInWizardFacetInfo>>>
         result,
     final boolean canceled) {
   myDetectedFacetsComponent.clear();
   for (ModuleDescriptor moduleDescriptor : result.keySet()) {
     myDetectedFacetsComponent.addFacets(moduleDescriptor, result.get(moduleDescriptor));
   }
   myDetectedFacetsComponent.createTree();
   if (result.isEmpty()) {
     myFacetsDetectedLabel.setText(ProjectBundle.message("label.text.no.facets.detected"));
   } else {
     myFacetsDetectedLabel.setText(
         ProjectBundle.message("label.text.the.following.facets.are.detected"));
   }
 }
コード例 #17
0
 public MyExternalPromptDialog(final Project project) {
   super(
       project,
       MESSAGE,
       ProjectBundle.message("external.annotation.prompt"),
       Messages.getQuestionIcon());
   myProject = project;
   init();
 }
コード例 #18
0
ファイル: FacetDetectionStep.java プロジェクト: jexp/idea2
 public FacetDetectionStep(final Icon icon, ModuleType moduleType) {
   super(
       ProjectBundle.message(
           "message.text.stop.searching.for.facets",
           ApplicationNamesInfo.getInstance().getProductName()));
   myIcon = icon;
   myModuleType = moduleType;
   myDetectedFacetsComponent = new DetectedFacetsTreeComponent();
 }
コード例 #19
0
 public ToggleSourcesStateAction(
     JTree tree, ContentEntryTreeEditor entryEditor, boolean editTestSources) {
   super(tree);
   myEntryTreeEditor = entryEditor;
   myEditTestSources = editTestSources;
   final Presentation templatePresentation = getTemplatePresentation();
   if (editTestSources) {
     templatePresentation.setText(ProjectBundle.message("module.toggle.test.sources.action"));
     templatePresentation.setDescription(
         ProjectBundle.message("module.toggle.test.sources.action.description"));
     templatePresentation.setIcon(IconSet.TEST_ROOT_FOLDER);
   } else {
     templatePresentation.setText(ProjectBundle.message("module.toggle.sources.action"));
     templatePresentation.setDescription(
         ProjectBundle.message("module.toggle.sources.action.description"));
     templatePresentation.setIcon(IconSet.SOURCE_ROOT_FOLDER);
   }
 }
コード例 #20
0
 @Override
 public void update(final AnActionEvent e) {
   super.update(e);
   final Presentation presentation = e.getPresentation();
   presentation.setText(
       ProjectBundle.message(
           myEditTestSources
               ? "module.toggle.test.sources.action"
               : "module.toggle.sources.action"));
 }
コード例 #21
0
 public Pair<Image, Point> createDraggedImage(DnDAction action, Point dragOrigin) {
   final List<PackagingElementNode<?>> nodes = getNodesToDrag();
   if (nodes.size() == 1) {
     return DnDAwareTree.getDragImage(this, getPathFor(nodes.get(0)), dragOrigin);
   }
   return DnDAwareTree.getDragImage(
       this,
       ProjectBundle.message("drag.n.drop.text.0.packaging.elements", nodes.size()),
       dragOrigin);
 }
コード例 #22
0
 private RemoveInvalidElementsDialog(
     final String title,
     ConfigurationErrorType type,
     String invalidElements,
     final Project project,
     List<ConfigurationErrorDescription> errors) {
   super(project, true);
   setTitle(title);
   myDescriptionLabel.setText(
       ProjectBundle.message(
           type.canIgnore()
               ? "label.text.0.cannot.be.loaded.ignore"
               : "label.text.0.cannot.be.loaded.remove",
           invalidElements));
   myContentPanel.setLayout(new VerticalFlowLayout());
   for (ConfigurationErrorDescription error : errors) {
     JCheckBox checkBox = new JCheckBox(error.getElementName() + ".");
     checkBox.setSelected(true);
     myCheckboxes.put(checkBox, error);
     JPanel panel = new JPanel(new GridBagLayout());
     GridBagConstraints constraints = new GridBagConstraints();
     constraints.anchor = GridBagConstraints.NORTHWEST;
     constraints.ipadx = 5;
     panel.add(checkBox, constraints);
     constraints.anchor = GridBagConstraints.NORTHWEST;
     constraints.insets.top = 5;
     panel.add(
         new JLabel(
             "<html><body>"
                 + StringUtil.replace(error.getDescription(), "\n", "<br>")
                 + "</body></html>"),
         constraints);
     constraints.weightx = 1;
     panel.add(new JPanel(), constraints);
     myContentPanel.add(panel);
   }
   init();
   setOKButtonText(
       ProjectBundle.message(
           type.canIgnore() ? "button.text.ignore.selected" : "button.text.remove.selected"));
   setCancelButtonText(ProjectBundle.message("button.text.keep.all"));
 }
コード例 #23
0
  private void restoreCopy(VirtualFile file) {
    try {
      if (file == null) return; // Externally deleted actually.
      if (!file.isWritable()) return; // IDEA was unable to save it as well. So no need to restore.

      final byte[] bytes = mySavedCopies.get(file);
      if (bytes != null) {
        try {
          file.setBinaryContent(bytes, -1, mySavedTimestamps.get(file));
        } catch (IOException e) {
          Messages.showWarningDialog(
              ProjectBundle.message("project.reload.write.failed", file.getPresentableUrl()),
              ProjectBundle.message("project.reload.write.failed.title"));
        }
      }
    } finally {
      mySavedCopies.remove(file);
      mySavedTimestamps.remove(file);
    }
  }
コード例 #24
0
 @Override
 protected void doOKAction() {
   try {
     myProjectJdk = myConfigurable.getSelectedJdk(); // before dispose
     myConfigurable.apply();
     super.doOKAction();
   } catch (ConfigurationException e) {
     Messages.showMessageDialog(
         getContentPane(), e.getMessage(),
         ProjectBundle.message("sdk.configure.save.settings.error"), Messages.getErrorIcon());
   }
 }
コード例 #25
0
  @Override
  protected void doOKAction() {
    final LibraryCompositionSettings librarySettings = myComponent.getLibraryCompositionSettings();
    if (librarySettings != null) {
      final ModifiableRootModel modifiableModel =
          myModifiableModelsProvider.getModuleModifiableModel(myModule);
      if (!askAndRemoveDuplicatedLibraryEntry(
          modifiableModel, librarySettings.getLibraryDescription())) {
        if (myConfigurable.isOnlyLibraryAdded()) {
          myModifiableModelsProvider.disposeModuleModifiableModel(modifiableModel);
          return;
        }
        return;
      }

      // Fix
      new WriteAction() {
        @Override
        protected void run(final Result result) {
          myModifiableModelsProvider.commitModuleModifiableModel(modifiableModel);
        }
      }.execute();

      final boolean downloaded = librarySettings.downloadFiles(getRootPane());
      if (!downloaded) {
        int answer =
            Messages.showYesNoDialog(
                getRootPane(),
                ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
                CommonBundle.getWarningTitle(),
                Messages.getWarningIcon());
        if (answer != 0) {
          return;
        }
      }
    }

    new WriteAction() {
      @Override
      protected void run(final Result result) {
        final ModifiableRootModel rootModel =
            myModifiableModelsProvider.getModuleModifiableModel(myModule);
        if (librarySettings != null) {
          librarySettings.addLibraries(
              rootModel, new ArrayList<Library>(), myModel.getLibrariesContainer());
        }
        myConfigurable.addSupport(myModule, rootModel, myModifiableModelsProvider);
        myModifiableModelsProvider.commitModuleModifiableModel(rootModel);
      }
    }.execute();
    super.doOKAction();
  }
コード例 #26
0
  private void initPopupActions() {
    if (myPopupActions == null) {
      int actionIndex = 1;
      final List<AddItemPopupAction<?>> actions = new ArrayList<AddItemPopupAction<?>>();
      final StructureConfigurableContext context = getStructureConfigurableContext();
      actions.add(new AddNewModuleLibraryAction(this, actionIndex++, context));
      actions.add(
          new AddLibraryDependencyAction(
              this, actionIndex++, ProjectBundle.message("classpath.add.library.action"), context));
      actions.add(new AddModuleDependencyAction(this, actionIndex, context));

      myPopupActions = actions;
    }
  }
コード例 #27
0
  private boolean doRemoveModule(@NotNull ModuleEditor selectedEditor) {

    String question;
    if (myModuleEditors.size() == 1) {
      question = ProjectBundle.message("module.remove.last.confirmation");
    } else {
      question =
          ProjectBundle.message("module.remove.confirmation", selectedEditor.getModule().getName());
    }
    int result =
        Messages.showYesNoDialog(
            myProject,
            question,
            ProjectBundle.message("module.remove.confirmation.title"),
            Messages.getQuestionIcon());
    if (result != Messages.YES) {
      return false;
    }
    // do remove
    myModuleEditors.remove(selectedEditor.getModule());

    // destroyProcess removed module
    final Module moduleToRemove = selectedEditor.getModule();
    // remove all dependencies on the module that is about to be removed
    List<ModifiableRootModel> modifiableRootModels = new ArrayList<ModifiableRootModel>();
    for (final ModuleEditor moduleEditor : myModuleEditors.values()) {
      final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy();
      modifiableRootModels.add(modifiableRootModel);
    }

    // destroyProcess editor
    ModuleDeleteProvider.removeModule(moduleToRemove, null, modifiableRootModels, myModuleModel);
    processModuleCountChanged();
    Disposer.dispose(selectedEditor);

    return true;
  }
コード例 #28
0
 public void onWizardFinished() throws CommitStepException {
   if (isFrameworksMode()) {
     boolean ok = myFrameworksPanel.downloadLibraries();
     if (!ok) {
       int answer =
           Messages.showYesNoDialog(
               getComponent(),
               ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
               CommonBundle.getWarningTitle(),
               Messages.getWarningIcon());
       if (answer != Messages.YES) {
         throw new CommitStepException(null);
       }
     }
   }
 }
コード例 #29
0
 @Override
 protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) {
   AnActionButton specifyUrlButton =
       new AnActionButton(
           ProjectBundle.message("sdk.paths.specify.url.button"), IconUtil.getAddLinkIcon()) {
         @Override
         public void actionPerformed(AnActionEvent e) {
           onSpecifyUrlButtonClicked();
         }
       };
   specifyUrlButton.setShortcut(CustomShortcutSet.fromString("alt S"));
   specifyUrlButton.addCustomUpdater(
       new AnActionButtonUpdater() {
         @Override
         public boolean isEnabled(AnActionEvent e) {
           return myEnabled && !isUrlInserted();
         }
       });
   toolbarDecorator.addExtraAction(specifyUrlButton);
 }
コード例 #30
0
ファイル: StorageUtil.java プロジェクト: ngoanhtan/consulo
 @NotNull
 private static VirtualFile getOrCreateVirtualFile(
     @Nullable Object requestor, @NotNull File ioFile) throws IOException {
   VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile);
   if (virtualFile == null) {
     File parentFile = ioFile.getParentFile();
     // need refresh if the directory has just been created
     VirtualFile parentVirtualFile =
         parentFile == null
             ? null
             : LocalFileSystem.getInstance().refreshAndFindFileByIoFile(parentFile);
     if (parentVirtualFile == null) {
       throw new IOException(
           ProjectBundle.message(
               "project.configuration.save.file.not.found",
               parentFile == null ? "" : parentFile.getPath()));
     }
     virtualFile = parentVirtualFile.createChildData(requestor, ioFile.getName());
   }
   return virtualFile;
 }