@NotNull public final ClassLoader getClassLoader() { ClassLoader loader = myClassLoader; if (loader == null) { final XmlTag tag = getXmlTag(); final PsiFile containingFile = tag.getContainingFile(); final AntBuildFileImpl buildFile = (AntBuildFileImpl)AntConfigurationBase.getInstance(containingFile.getProject()).getAntBuildFile(containingFile); if (buildFile != null) { loader = buildFile.getClassLoader(); } else { AntInstallation antInstallation = getAntInstallation(); loader = antInstallation.getClassLoader(); } myClassLoader = loader; } return loader; }
private void adjustName(final AntInstallation justCreated) { int nameIndex = 0; String adjustedName = justCreated.getName(); final ListModel model = myParent.getList().getModel(); int idx = 0; while (idx < model.getSize()) { final AntInstallation inst = (AntInstallation)model.getElementAt(idx++); if (adjustedName.equals(inst.getName())) { adjustedName = justCreated.getName() + " (" + (++nameIndex) + ")"; idx = 0; // search from beginning } } if (!adjustedName.equals(justCreated.getName())) { justCreated.setName(adjustedName); } }
private void saveAntInstallation(final AntInstallation antInstallation) { final GlobalAntConfiguration globalAntConfiguration = GlobalAntConfiguration.getInstance(); if (globalAntConfiguration == null) { return; } globalAntConfiguration.removeConfiguration(globalAntConfiguration.getConfiguredAnts() .get(antInstallation.getReference())); globalAntConfiguration.addConfiguration(antInstallation); }
public AntInstallation getAntInstallation() { final AntConfigurationBase configuration = AntConfigurationBase.getInstance(getXmlTag().getProject()); AntInstallation antInstallation = null; if (configuration != null) { antInstallation = configuration.getProjectDefaultAnt(); } if (antInstallation == null) { antInstallation = GlobalAntConfiguration.getInstance().getBundledAnt(); } assert antInstallation != null; return antInstallation; }
RunWithAntBinding(JRadioButton useDefaultAnt, JRadioButton useCustomAnt, ComboboxWithBrowseButton ants, final GlobalAntConfiguration antConfiguration) { myAntConfiguration = antConfiguration; myComponents.add(useDefaultAnt); myUseCustomAnt = useCustomAnt; myComponents.add(myUseCustomAnt); myAnts = ants; myUseDefaultAnt = useDefaultAnt; ButtonGroup group = new ButtonGroup(); group.add(useDefaultAnt); group.add(myUseCustomAnt); myUseCustomAnt.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { updateEnableCombobox(); if (myUseCustomAnt.isSelected() && !myLoadingValues) myAnts.getComboBox().requestFocusInWindow(); } }); myAntsController = new ChooseAndEditComboBoxController<AntReference, AntReference>(myAnts, new ConvertingIterator.IdConvertor<AntReference>(), AntReference.COMPARATOR) { public Iterator<AntReference> getAllListItems() { return antConfiguration.getConfiguredAnts().keySet().iterator(); } public AntReference openConfigureDialog(AntReference reference, JComponent parent) { AntSetPanel antSetPanel = new AntSetPanel(); AntInstallation installation = myAntConfiguration.getConfiguredAnts().get(reference); if (installation == null) installation = myAntConfiguration.getConfiguredAnts().get(AntReference.BUNDLED_ANT); antSetPanel.reset(); antSetPanel.setSelection(installation); AntInstallation antInstallation = antSetPanel.showDialog(parent); return antInstallation != null ? antInstallation.getReference() : null; } }; myAntsController.setRenderer(new AntUIUtil.AntReferenceRenderer(myAntConfiguration)); }
public AntInstallationRenderer(PropertiesEditor<AntInstallation> editor) { myEditor = editor != null ? editor : new PropertiesEditor<AntInstallation>(){ public AbstractProperty.AbstractPropertyContainer getProperties(AntInstallation antInstallation) { return antInstallation.getProperties(); } }; }
public static void customizeReference(AntReference antReference, SimpleColoredComponent component, GlobalAntConfiguration configuration) { AntInstallation antInstallation = antReference.find(configuration); if (antInstallation != null) customizeAnt(antInstallation.getProperties(), component); else { component.setIcon(PlatformIcons.INVALID_ENTRY_ICON); component.append(antReference.getName(), SimpleTextAttributes.ERROR_ATTRIBUTES); } }
public static void customizeAnt(AbstractProperty.AbstractPropertyContainer antProperties, SimpleColoredComponent component) { component.setIcon(AntIcons.AntInstallation); String name = AntInstallation.NAME.get(antProperties); component.append(name, SimpleTextAttributes.REGULAR_ATTRIBUTES); String versionString = AntInstallation.VERSION.get(antProperties); if (name.indexOf(versionString) == -1) component.append(" (" + versionString + ")", SimpleTextAttributes.SYNTHETIC_ATTRIBUTES); }
@Nullable public AntInstallation showDialog(JComponent parent) { final DialogWrapper dialog = new MyDialog(parent); if (!dialog.showAndGet()) { return null; } apply(); return myForm.getSelectedAnt(); }
public void applyModifications() { if (myCurrent != null) myBinding.apply(getProperties(myCurrent)); ArrayList<AbstractProperty> properties = new ArrayList<AbstractProperty>(); myBinding.addAllPropertiesTo(properties); for (AntInstallation ant : myWorkingProperties.keySet()) { EditPropertyContainer container = myWorkingProperties.get(ant); container.apply(); } myGlobalWorkingProperties.apply(); }
public EditPropertyContainer getProperties(AntInstallation ant) { EditPropertyContainer properties = myWorkingProperties.get(ant); if (properties != null) return properties; properties = new EditPropertyContainer(myGlobalWorkingProperties, ant.getProperties()); myWorkingProperties.put(ant, properties); return properties; }
public AntInstallation create() { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); VirtualFile file = FileChooser.chooseFile(descriptor, myParent, null, null); if (file == null) return null; try { final AntInstallation inst = AntInstallation.fromHome(file.getPresentableUrl()); adjustName(inst); return inst; } catch (AntInstallation.ConfigurationException e) { Messages.showErrorDialog(myParent, e.getMessage(), AntBundle.message("ant.setup.dialog.title")); return null; } }
protected void doOKAction() { final Set<String> names = new HashSet<String>(); final ListModel model = myForm.getAntsList().getModel(); for (int idx = 0; idx < model.getSize(); idx++) { final AntInstallation inst = (AntInstallation)model.getElementAt(idx); final String name = AntInstallation.NAME.get(myForm.getProperties(inst)); if (names.contains(name)) { Messages.showErrorDialog("Duplicate ant installation name: \"" + name+ "\"", getTitle()); return; } names.add(name); } super.doOKAction(); }
public static void customizeAnt(AbstractProperty.AbstractPropertyContainer antProperties, SimpleColoredComponent component) { component.setIcon(AllIcons.Ant.AntInstallation); String name = AntInstallation.NAME.get(antProperties); component.append(name, SimpleTextAttributes.REGULAR_ATTRIBUTES); String versionString = AntInstallation.VERSION.get(antProperties); if (name.indexOf(versionString) == -1) component.append(" (" + versionString + ")", SimpleTextAttributes.SYNTHETIC_ATTRIBUTES); }
@Nullable public AntInstallation showDialog(JComponent parent) { final DialogWrapper dialog = new MyDialog(parent); dialog.show(); if (!dialog.isOK()) { return null; } apply(); return myForm.getSelectedAnt(); }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { AntInstallation ant = (AntInstallation)value; if (ant == null) return; AbstractProperty.AbstractPropertyContainer container = myEditor.getProperties(ant); customizeAnt(container, this); }
public void setSelection(AntInstallation antInstallation) { myForm.selectAnt(antInstallation); }
public AntInstallation getSelectedAnt() { return myAnts.getSelectedItem(); }
public void setAnts(Collection<AntInstallation> antInstallations) { myAnts.setItems(antInstallations); }
public void selectAnt(AntInstallation antInstallation) { myAnts.setSelection(antInstallation); }
public ArrayList<AntInstallation> getAddedAnts() { return myAnts.getAdded(); }
public ArrayList<AntInstallation> getRemovedAnts() { return myAnts.getRemoved(); }
public RightPanel(UIPropertyBinding.Composite binding, PropertyChangeListener immediateUpdater) { myNameLabel.setLabelFor(myName); binding.addBinding(myClasspath.setClasspathProperty(AntInstallation.CLASS_PATH)); binding.bindString(myHome, AntInstallation.HOME_DIR); binding.bindString(myName, AntInstallation.NAME).addChangeListener(immediateUpdater); }
public NewAntFactory(AnActionListEditor<AntInstallation> parent) { myParent = parent; }
@Nullable private static VirtualFile getHelpFile(final PsiElement element) { final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class); if (xmlTag == null) { return null; } final AntDomElement antElement = AntSupport.getAntDomElement(xmlTag); if (antElement == null) { return null; } final AntDomProject antProject = antElement.getAntProject(); if (antProject == null) { return null; } final AntInstallation installation = antProject.getAntInstallation(); if (installation == null) { return null; // not configured properly and bundled installation missing } final String antHomeDir = AntInstallation.HOME_DIR.get(installation.getProperties()); if (antHomeDir == null) { return null; } @NonNls String path = antHomeDir + "/docs/manual"; String url; if (new File(path).exists()) { url = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, FileUtil.toSystemIndependentName(path)); } else { path = antHomeDir + "/docs.zip"; if (new File(path).exists()) { url = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, FileUtil.toSystemIndependentName(path) + JarFileSystem.JAR_SEPARATOR + "docs/manual"); } else { return null; } } final VirtualFile documentationRoot = VirtualFileManager.getInstance().findFileByUrl(url); if (documentationRoot == null) { return null; } return getHelpFile(antElement, documentationRoot); }