/** * Is this library contains classes folder instead of a jar? */ public static boolean isLibraryDirectoryBased(ClassPathSupport.Item item) { assert item.getType() == ClassPathSupport.Item.TYPE_LIBRARY : item; Library l = item.getLibrary(); List<URL> cp = l.getContent("classpath"); // NOI18N if (cp.size() > 0 && cp.get(0).toString().startsWith("file:")) { // NOI18N return true; } return false; }
public void tableChanged(TableModelEvent e) { if (e.getColumn() != 1) { return; } TableModel listModel = uiProperties.WAR_CONTENT_ADDITIONAL_MODEL; ClassPathSupport.Item cpItem = (ClassPathSupport.Item) listModel.getValueAt(e.getFirstRow(), 0); String newPathInWar = (String) listModel.getValueAt(e.getFirstRow(), 1); String message = null; if (cpItem.getType() == ClassPathSupport.Item.TYPE_JAR && newPathInWar.startsWith("WEB-INF")) { //NOI18N if (newPathInWar.equals("WEB-INF\\lib") || newPathInWar.equals("WEB-INF/lib")) { //NOI18N if (cpItem.getResolvedFile().isDirectory()) { message = NbBundle.getMessage(CustomizerWar.class, "MSG_NO_FOLDER_IN_WEBINF_LIB", newPathInWar); // NOI18N } else { message = NbBundle.getMessage(CustomizerWar.class, "MSG_NO_FILE_IN_WEBINF_LIB", newPathInWar); // NOI18N } } else if (newPathInWar.equals("WEB-INF\\classes") || newPathInWar.equals("WEB-INF/classes")) { //NOI18N message = NbBundle.getMessage(CustomizerWar.class, "MSG_NO_FOLDER_IN_WEBINF_CLASSES", newPathInWar); // NOI18N } } if (message != null) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message (message, NotifyDescriptor.WARNING_MESSAGE)); } } }
private List<ClassPathSupport.Item> filterBrokenLibraryItems(List<ClassPathSupport.Item> items) { List<ClassPathSupport.Item> toRemove = new LinkedList<ClassPathSupport.Item>(); Collection<? extends BrokenLibraryRefFilter> filters = null; for (ClassPathSupport.Item item : items) { if (!item.isBroken() || item.getType() != ClassPathSupport.Item.TYPE_LIBRARY) { continue; } String libraryName = ClassPathSupport.getLibraryNameFromReference(item.getReference()); LOGGER.log(Level.FINE, "Broken reference to library: " + libraryName); if (filters == null) { // initializing the filters lazily because usually they will not be needed anyway // (most projects have no broken references) filters = createFilters(WebProject.this); } for (BrokenLibraryRefFilter filter : filters) { if (filter.removeLibraryReference(libraryName)) { LOGGER.log(Level.FINE, "Will remove broken reference to library " + libraryName + " because of filter " + filter.getClass().getName()); toRemove.add(item); break; } } } return toRemove; }
for (Iterator it = ClassPathUiSupport.getIterator(models[i]); it.hasNext();) { ClassPathSupport.Item itm = (ClassPathSupport.Item) it.next(); if (itm.getType() == ClassPathSupport.Item.TYPE_LIBRARY) { itm.reassignLibraryManager(man);
@Override public List<ArtifactCopyOnSaveSupport.Item> getArtifacts() { final AntProjectHelper helper = getAntProjectHelper(); ClassPathSupport cs = new ClassPathSupport(evaluator(), getReferenceHelper(), helper, getUpdateHelper(), new ClassPathSupportCallbackImpl(helper)); List<ArtifactCopyOnSaveSupport.Item> result = new ArrayList<ArtifactCopyOnSaveSupport.Item>(); for (ClassPathSupport.Item item : cs.itemsList( helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH).getProperty(ProjectProperties.JAVAC_CLASSPATH), ClassPathSupportCallbackImpl.ELEMENT_INCLUDED_LIBRARIES)) { if (!item.isBroken() && (item.getType() == ClassPathSupport.Item.TYPE_ARTIFACT || item.getType() == ClassPathSupport.Item.TYPE_LIBRARY || item.getType() == ClassPathSupport.Item.TYPE_LIBRARY)) { String included = item.getAdditionalProperty(ClassPathSupportCallbackImpl.INCLUDE_IN_DEPLOYMENT); String dirs = item.getAdditionalProperty(AntProjectConstants.DESTINATION_DIRECTORY); if (Boolean.parseBoolean(included)) { result.add(new Item(item, new ItemDescription("", RelocationType.fromString(dirs)))); } } } return result; }
@Override public List<ArtifactCopyOnSaveSupport.Item> getArtifacts() { final AntProjectHelper helper = getAntProjectHelper(); ClassPathSupport cs = new ClassPathSupport(evaluator(), getReferenceHelper(), helper, getUpdateHelper(), new ClassPathSupportCallbackImpl(helper)); List<ArtifactCopyOnSaveSupport.Item> result = new ArrayList<ArtifactCopyOnSaveSupport.Item>(); for (ClassPathSupport.Item item : cs.itemsList( helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH).getProperty(ProjectProperties.JAVAC_CLASSPATH), WebProjectProperties.TAG_WEB_MODULE_LIBRARIES)) { if (!item.isBroken() && (item.getType() == ClassPathSupport.Item.TYPE_ARTIFACT || item.getType() == ClassPathSupport.Item.TYPE_LIBRARY || item.getType() == ClassPathSupport.Item.TYPE_JAR)) { String path = item.getAdditionalProperty(ClassPathSupportCallbackImpl.PATH_IN_DEPLOYMENT); String dirs = item.getAdditionalProperty(AntProjectConstants.DESTINATION_DIRECTORY); if (path != null) { result.add(new Item(item, new ItemDescription(path, RelocationType.fromString(dirs)))); } } } return result; }
public void initItem(ClassPathSupport.Item item) { switch (item.getType()) { case ClassPathSupport.Item.TYPE_JAR: item.setAdditionalProperty(ClassPathSupportCallbackImpl.PATH_IN_DEPLOYMENT, item.getResolvedFile().isDirectory() ? ClassPathSupportCallbackImpl.PATH_IN_WAR_DIR : ClassPathSupportCallbackImpl.PATH_IN_WAR_LIB); break; case ClassPathSupport.Item.TYPE_LIBRARY: if (item.getLibrary().getType().equals(J2eePlatform.LIBRARY_TYPE)) { break; } item.setAdditionalProperty(ClassPathSupportCallbackImpl.PATH_IN_DEPLOYMENT, Utils.isLibraryDirectoryBased(item) ? ClassPathSupportCallbackImpl.PATH_IN_WAR_DIR : ClassPathSupportCallbackImpl.PATH_IN_WAR_LIB); break; default: item.setAdditionalProperty(ClassPathSupportCallbackImpl.PATH_IN_DEPLOYMENT, ClassPathSupportCallbackImpl.PATH_IN_WAR_LIB); } } };
private static void collectLibs(DefaultListModel model, List<String> libs, List<String> jarReferences) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) { if (!item.isBroken() && !libs.contains(item.getLibrary().getName())) { libs.add(item.getLibrary().getName()); } } if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null && item.getVariableBasedProperty() == null && !jarReferences.contains(item.getReference())) { //TODO reference is null for not yet persisted items. // there seems to be no way to generate a reference string without actually // creating and writing the property.. jarReferences.add(item.getReference()); } } } }
private void collectLibs(DefaultListModel model, List<String> libs, List<String> jarReferences) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) { if (!item.isBroken() && !libs.contains(item.getLibrary().getName())) { libs.add(item.getLibrary().getName()); } } if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null && item.getVariableBasedProperty() == null && !jarReferences.contains(item.getReference())) { //TODO reference is null for not yet persisted items. // there seems to be no way to generate a reference string without actually // creating and writing the property.. jarReferences.add(item.getReference()); } } } }
private static void collectLibs(DefaultListModel model, List<String> libs, List<String> jarReferences) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) { if (!item.isBroken() && !libs.contains(item.getLibrary().getName())) { libs.add(item.getLibrary().getName()); } } if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null && item.getVariableBasedProperty() == null && !jarReferences.contains(item.getReference())) { //TODO reference is null for not yet persisted items. // there seems to be no way to generate a reference string without actually // creating and writing the property.. jarReferences.add(item.getReference()); } } } }
private static void collectLibs(DefaultListModel model, List<String> libs, List<String> jarReferences) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) { if (!item.isBroken() && !libs.contains(item.getLibrary().getName())) { libs.add(item.getLibrary().getName()); } } if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null && item.getVariableBasedProperty() == null && !jarReferences.contains(item.getReference())) { //TODO reference is null for not yet persisted items. // there seems to be no way to generate a reference string without actually // creating and writing the property.. jarReferences.add(item.getReference()); } } } }
public void setValueAt(Object value, int row, int column) { if (column != 1 || !(value instanceof Boolean)) { return; } if (Boolean.TRUE.equals(value)) { ClassPathSupport.Item item = getItem(row); String pathInWar = (item.getType() == ClassPathSupport.Item.TYPE_JAR && item.getResolvedFile().isDirectory()) || (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY && Utils.isLibraryDirectoryBased(item)) ? ClassPathSupportCallbackImpl.PATH_IN_WAR_DIR : ClassPathSupportCallbackImpl.PATH_IN_WAR_LIB; item.setAdditionalProperty(ClassPathSupportCallbackImpl.PATH_IN_DEPLOYMENT, pathInWar); } else { getItem(row).setAdditionalProperty(ClassPathSupportCallbackImpl.PATH_IN_DEPLOYMENT, ClassPathSupportCallbackImpl.PATH_IN_WAR_NONE); } fireTableCellUpdated(row, column); }
private void updateJars(DefaultListModel model) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null) { item.updateJarReference(uiProperties.getProject().getAntProjectHelper()); } } } }
public static void updateDirsAttributeInCPSItem(org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item item, Element element) { String dirs = item.getAdditionalProperty(AntProjectConstants.DESTINATION_DIRECTORY); if (dirs == null) { dirs = AntProjectConstants.DESTINATION_DIRECTORY_LIB; if (item.getType() == ClassPathSupport.Item.TYPE_ARTIFACT && !item.isBroken()) { if (item.getArtifact() != null && item.getArtifact().getProject() != null && item.getArtifact().getProject().getLookup().lookup(J2eeModuleProvider.class) != null) { dirs = AntProjectConstants.DESTINATION_DIRECTORY_ROOT; } } } element.setAttribute("dirs", dirs); }
private void updateJars(DefaultListModel model) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null) { item.updateJarReference(uiProperties.getProject().getAntProjectHelper()); } } } }
public void initItem(ClassPathSupport.Item item) { if (item.getType() != ClassPathSupport.Item.TYPE_LIBRARY || !item.getLibrary().getType().equals(J2eePlatform.LIBRARY_TYPE)) { item.setAdditionalProperty(ClassPathSupportCallbackImpl.INCLUDE_IN_DEPLOYMENT, "true"); } } };
private void updateJars(DefaultListModel model) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null) { item.updateJarReference(uiProperties.getProject().getAntProjectHelper()); } } } }
public void initItem(Item item) { if (item.getType() != ClassPathSupport.Item.TYPE_LIBRARY || !item.getLibrary().getType().equals(J2eePlatform.LIBRARY_TYPE)) { item.setAdditionalProperty(ClassPathSupportCallbackImpl.PATH_IN_DEPLOYMENT, "/"); //NOI18N } }
public void initItem(ClassPathSupport.Item item) { if (item.getType() != ClassPathSupport.Item.TYPE_LIBRARY || !item.getLibrary().getType().equals(J2eePlatform.LIBRARY_TYPE)) { item.setAdditionalProperty(ClassPathSupportCallbackImpl.INCLUDE_IN_DEPLOYMENT, "true"); } } };
private void updateJars(DefaultListModel model) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null) { item.updateJarReference(uiProperties.getProject().getAntProjectHelper()); } } } }