Beispiel #1
0
 @Override
 public String getDetailsText() {
   final StringBuilder messageText = new StringBuilder();
   messageText.append("<html>");
   messageText.append("Type : ").append(myModelRoot.getType()).append("<br>");
   messageText
       .append("Manager : ")
       .append(
           myModelRoot.getModelRoot().getManager() != null
               ? myModelRoot.getModelRoot().getManager().getClassName()
               : "Default")
       .append("<br>");
   messageText.append("Path : ").append(myModelRoot.getPath()).append("<br>");
   return messageText.toString();
 }
Beispiel #2
0
    private void updateTree() {
      if (myFileSystemTree != null) {
        Disposer.dispose(myFileSystemTree);
        myFileSystemTree = null;
      }

      myFileSystemTree =
          new FileSystemTreeImpl(
              null, new FileChooserDescriptor(true, true, true, true, true, false));
      AbstractTreeUi ui = myFileSystemTree.getTreeBuilder().getUi();

      String path = myModelRoot.getPath() == null ? "" : myModelRoot.getPath();
      VirtualFile virtualFile =
          VirtualFileManager.getInstance()
              .findFileByUrl(VirtualFileManager.constructUrl("file", path));
      if (myModelRoot.getModule() != null && (virtualFile == null || path.isEmpty())) {
        if (myModelRoot.getModule() instanceof AbstractModule) {
          virtualFile =
              VirtualFileManager.getInstance()
                  .findFileByUrl(
                      VirtualFileManager.constructUrl(
                          "file",
                          ((AbstractModule) myModelRoot.getModule())
                              .getModuleSourceDir()
                              .getPath()));
        }
      }

      if (virtualFile != null) myFileSystemTree.select(virtualFile, null);

      myFileSystemTree.addListener(
          new Listener() {
            @Override
            public void selectionChanged(List<VirtualFile> selection) {
              if (selection.size() > 0) {
                myModelRoot.setPath(FileUtil.getCanonicalPath(selection.get(0).getPath()));
                myEventDispatcher.getMulticaster().fireDataChanged();
              }
            }
          },
          SModelRootEntry.this);

      Disposer.register(SModelRootEntry.this, myFileSystemTree);

      myTreePanel.removeAll();
      myTreePanel.add(ui.getTree(), BorderLayout.CENTER);
      ui.scrollSelectionToVisible(null, true);
    }
 public static void addModelRoots(
     SolutionDescriptor solutionDescriptor, VirtualFile[] roots, ModelRootManager rootMgr) {
   Set<String> seenPaths = new HashSet<String>();
   for (ModelRootDescriptor d : solutionDescriptor.getModelRootDescriptors()) {
     ModelRoot root = d.getRoot();
     if (root != null && EqualUtil.equals(root.getManager(), rootMgr)) {
       seenPaths.add(root.getPath());
     }
   }
   for (VirtualFile f : roots) {
     SModelRoot modelRoot = new SModelRoot(rootMgr);
     modelRoot.setPath(getLocalPath(f));
     if (!seenPaths.add(modelRoot.getPath())) continue;
     solutionDescriptor.getModelRootDescriptors().add(modelRoot.toDescriptor());
   }
 }
Beispiel #4
0
 @Override
 public boolean isValid() {
   String path = myModelRoot.getPath();
   return (new java.io.File(path != null ? path : "")).exists();
 }
Beispiel #5
0
    @Override
    public JComponent createComponent() {
      JPanel panel = new JPanel(new GridLayoutManager(2, 1));

      List<ModelRootManager> managers = ManagerTableCellEditor.getManagers();
      managers.remove(null);
      final ModelRootManager empty = new ModelRootManager("", "Default");
      managers.add(empty);
      myComboBox = new ComboBox(managers.toArray(), 10);
      myComboBox.setRenderer(
          new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(
                JList list, Object value, int index, boolean selected, boolean focus) {
              ModelRootManager manager = ((ModelRootManager) value);
              String managerName = NameUtil.shortNameFromLongName(manager.getClassName());
              return super.getListCellRendererComponent(list, managerName, index, selected, focus);
            }
          });
      panel.add(
          myComboBox,
          new GridConstraints(
              0,
              0,
              1,
              1,
              GridConstraints.ANCHOR_NORTHWEST,
              GridConstraints.FILL_HORIZONTAL,
              GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK,
              GridConstraints.SIZEPOLICY_FIXED,
              null,
              null,
              null));
      myComboBox.setSelectedItem(
          myModelRoot.getModelRoot().getManager() == null
              ? empty
              : myModelRoot.getModelRoot().getManager());
      myComboBox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              if (e.getStateChange() == ItemEvent.SELECTED) {
                ModelRootManager manager = (ModelRootManager) e.getItem();
                myModelRoot.getModelRoot().setManager(manager.equals(empty) ? null : manager);
                myEventDispatcher.getMulticaster().fireDataChanged();
              }
            }
          });

      myTreePanel = new JPanel(new BorderLayout());
      updateTree();
      final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTreePanel);
      panel.add(
          scrollPane,
          new GridConstraints(
              1,
              0,
              1,
              1,
              GridConstraints.ANCHOR_CENTER,
              GridConstraints.FILL_BOTH,
              GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK,
              GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK,
              null,
              null,
              null));

      return panel;
    }