@Override public boolean validateSourceGroup() { if (!super.validateSourceGroup()) return false; try { @SuppressWarnings("unchecked") List<IResource> whiteCheckedResources = getWhiteCheckedResources(); UIPlugin plugin = UIPlugin.getInstance(); String owner = null; Diagnostic diag = new Diagnostic(); for (ExportSpec spec : getExportSpecs(whiteCheckedResources)) { try { Metadata md = getForge() .createFromModuleDirectory( spec.getModuleRoot(), false, spec.getFileFilter(), null, diag); if (md != null) { ModuleName name = md.getName(); if (owner == null) owner = name.getOwner(); else if (!owner.equals(name.getOwner())) { setErrorMessage(plugin.getString("_UI_MultipleModuleOwners")); return false; } } } catch (IOException e) { } } if (owner == null) { setErrorMessage(plugin.getString("_UI_NoModulesSelected")); return false; } if (!owner.equals(loginField.getText())) { // Owner changed validationChange = true; try { loginField.setText(owner); String password = null; if (saveInSecureStoreButton.getSelection()) password = loadSecurePassword(owner); if (password == null) password = ""; passwordField.setText(password); } finally { validationChange = false; } } return true; } catch (CoreException e) { setErrorMessage(e.getMessage()); return false; } }
@Override public String hrefForUnresolved(ModuleName fromModuleName, String name) { StringBuilder builder = new StringBuilder(); builder.append("javascript:showUnresolved("); builder.append("'"); fromModuleName.toString(builder, '_'); builder.append("', "); builder.append("'"); builder.append(name); builder.append("'"); builder.append(")"); return builder.toString(); }
@Override protected InputStream getInitialContents() { // Cheat by creating content manually here - not really worth the trouble of creating a // model to get these empty strings // IPath path = getContainerFullPath(); String folderName = path.lastSegment(); String[] split = ModuleName.splitName(folderName); StringBuilder bld = new StringBuilder(); bld.append("name '"); if (split[0] != null) { bld.append(split[0]); bld.append('-'); bld.append(split[1]); } bld.append("'\nversion '0.1.0'\n\nauthor ''\nlicense ''\n"); return new ByteArrayInputStream(bld.toString().getBytes(UTF_8)); }
public String getModuleOwner() { String moduleOwner = preferenceHelper.getForgeLogin(); if (moduleOwner == null) moduleOwner = ModuleName.safeOwner(System.getProperty("user.name")); return moduleOwner; }