List of usage examples for org.eclipse.jdt.core IPackageFragment save
public void save(IProgressMonitor progress, boolean force) throws JavaModelException;
From source file:com.iw.plugins.spindle.ui.wizards.factories.LibraryFactory.java
License:Mozilla Public License
/** * Method createLibrary.// w w w .j a va 2 s . c o m * * @param root * @param pack * @param appname * @param monitor * @return IFile */ public static IFile createLibrary(IPackageFragmentRoot root, IPackageFragment pack, String libraryName, IProgressMonitor monitor) throws CoreException, InterruptedException { monitor.beginTask(UIPlugin.getString("ApplicationFactory.operationdesc", libraryName), 10); if (pack == null) { pack = root.getPackageFragment(""); } if (!pack.exists()) { String packName = pack.getElementName(); pack = root.createPackageFragment(packName, true, null); pack.save(new SubProgressMonitor(monitor, 1), true); } monitor.worked(1); IContainer folder = (IContainer) pack.getUnderlyingResource(); IFile file = folder.getFile(new Path(libraryName + ".library")); InputStream contents = new ByteArrayInputStream(getLibraryContent().getBytes()); file.create(contents, false, new SubProgressMonitor(monitor, 1)); monitor.worked(1); monitor.done(); return file; }
From source file:com.iw.plugins.spindle.wizards.factories.ApplicationFactory.java
License:Mozilla Public License
static public IFile createApplication(IPackageFragmentRoot root, IPackageFragment pack, String appname, String qualifiedEngineClassname, IProgressMonitor monitor) throws CoreException, InterruptedException { monitor.beginTask(MessageUtil.getFormattedString("ApplicationFactory.operationdesc", appname), 10); if (pack == null) { pack = root.getPackageFragment(""); }/*from w ww .j a va 2s. c o m*/ if (!pack.exists()) { String packName = pack.getElementName(); pack = root.createPackageFragment(packName, true, null); pack.save(new SubProgressMonitor(monitor, 1), true); } monitor.worked(1); IContainer folder = (IContainer) pack.getUnderlyingResource(); IFile file = folder.getFile(new Path(appname + ".application")); InputStream contents = new ByteArrayInputStream( getApplicationContent(appname, qualifiedEngineClassname, pack.getElementName()).getBytes()); file.create(contents, false, new SubProgressMonitor(monitor, 1)); monitor.worked(1); monitor.done(); return file; }
From source file:com.iw.plugins.spindle.wizards.factories.ComponentFactory.java
License:Mozilla Public License
public static IFile createComponent(IPackageFragmentRoot root, IPackageFragment pack, String componentName, IType specClass, IProgressMonitor monitor) throws CoreException, InterruptedException { monitor.beginTask(MessageUtil.getFormattedString("ApplicationFactory.operationdesc", componentName), 10); if (pack == null) { pack = root.getPackageFragment(""); }/* w w w . j a va 2 s .c om*/ if (!pack.exists()) { String packName = pack.getElementName(); pack = root.createPackageFragment(packName, true, null); pack.save(new SubProgressMonitor(monitor, 1), true); } monitor.worked(1); IContainer folder = (IContainer) pack.getUnderlyingResource(); IFile file = folder.getFile(new Path(componentName + ".jwc")); String qualifiedSpecClassname = specClass.getFullyQualifiedName(); InputStream contents = new ByteArrayInputStream(getComponentContent(qualifiedSpecClassname).getBytes()); file.create(contents, false, new SubProgressMonitor(monitor, 1)); monitor.worked(1); monitor.done(); return file; }
From source file:com.iw.plugins.spindle.wizards.factories.LibraryFactory.java
License:Mozilla Public License
/** * Method createLibrary.//from w w w . j a v a 2 s .c o m * @param root * @param pack * @param appname * @param monitor * @return IFile */ public static IFile createLibrary(IPackageFragmentRoot root, IPackageFragment pack, String libraryName, IProgressMonitor monitor) throws CoreException, InterruptedException { monitor.beginTask(MessageUtil.getFormattedString("ApplicationFactory.operationdesc", libraryName), 10); if (pack == null) { pack = root.getPackageFragment(""); } if (!pack.exists()) { String packName = pack.getElementName(); pack = root.createPackageFragment(packName, true, null); pack.save(new SubProgressMonitor(monitor, 1), true); } monitor.worked(1); IContainer folder = (IContainer) pack.getUnderlyingResource(); IFile file = folder.getFile(new Path(libraryName + ".library")); InputStream contents = new ByteArrayInputStream(getLibraryContent().getBytes()); file.create(contents, false, new SubProgressMonitor(monitor, 1)); monitor.worked(1); monitor.done(); return file; }
From source file:com.iw.plugins.spindle.wizards.factories.PageFactory.java
License:Mozilla Public License
public static IFile createPage(IPackageFragmentRoot root, IPackageFragment pack, String componentName, String specClass, IProgressMonitor monitor) throws CoreException, InterruptedException { monitor.beginTask(MessageUtil.getFormattedString("ApplicationFactory.operationdesc", componentName), 10); if (pack == null) { pack = root.getPackageFragment(""); }/* w w w. j a v a2s. c o m*/ if (!pack.exists()) { String packName = pack.getElementName(); pack = root.createPackageFragment(packName, true, null); pack.save(new SubProgressMonitor(monitor, 1), true); } monitor.worked(1); IContainer folder = (IContainer) pack.getUnderlyingResource(); IFile file = folder.getFile(new Path(componentName + ".page")); String qualifiedSpecClassname = specClass; InputStream contents = new ByteArrayInputStream(getComponentContent(qualifiedSpecClassname).getBytes()); file.create(contents, false, new SubProgressMonitor(monitor, 1)); monitor.worked(1); monitor.done(); return file; }
From source file:com.iw.plugins.spindle.wizards.NewTapComponentWizardPage.java
License:Mozilla Public License
public void createHTMLResource(IProgressMonitor monitor) throws InterruptedException, CoreException { IPackageFragmentRoot root = fContainerDialogField.getPackageFragmentRoot(); IPackageFragment pack = fPackageDialogField.getPackageFragment(); String componentName = fComponentNameDialog.getTextValue(); IContainer container = (IContainer) pack.getUnderlyingResource(); IFile file1 = container.getFile(new Path(componentName + ".html")); IFile file2 = container.getFile(new Path(componentName + ".htm")); if (file1.exists() || file2.exists()) { return;//ww w . ja v a 2 s .co m } monitor.beginTask("", 10); if (pack == null) { pack = root.getPackageFragment(""); } if (!pack.exists()) { String packName = pack.getElementName(); pack = root.createPackageFragment(packName, true, null); pack.save(new SubProgressMonitor(monitor, 1), true); } monitor.worked(1); IPreferenceStore pstore = TapestryPlugin.getDefault().getPreferenceStore(); String source = pstore.getString(P_HTML_TO_GENERATE); String comment = MessageUtil.getString("TAPESTRY.xmlComment"); if (source == null) { source = comment + MessageUtil.getString("TAPESTRY.genHTMLSource"); } if (!source.trim().startsWith(comment)) { source = comment + source; } InputStream contents = new ByteArrayInputStream(source.getBytes()); file1.create(contents, false, new SubProgressMonitor(monitor, 1)); monitor.worked(1); monitor.done(); }
From source file:edu.brown.cs.bubbles.bedrock.BedrockProject.java
License:Open Source License
/********************************************************************************/ void createPackage(String proj, String pkg, boolean force, IvyXmlWriter xw) throws BedrockException { IProject ip = findProject(proj);//w ww. j av a 2 s.c o m IJavaProject ijp = JavaCore.create(ip); IPackageFragmentRoot ipfr = null; try { for (IPackageFragmentRoot pfr : ijp.getAllPackageFragmentRoots()) { try { if (!pfr.isExternal() && !pfr.isArchive() && pfr.getKind() == IPackageFragmentRoot.K_SOURCE) { ipfr = pfr; break; } } catch (JavaModelException e) { } } } catch (JavaModelException e) { throw new BedrockException("Problem finding package roots: " + e, e); } if (ipfr == null) throw new BedrockException("Can't find source fragment root"); IPackageFragment ifr = null; try { ifr = ipfr.createPackageFragment(pkg, force, null); ifr.save(null, force); ifr.open(null); } catch (JavaModelException e) { throw new BedrockException("Problem creating package: " + e, e); } xw.begin("PACKAGE"); xw.field("NAME", ifr.getElementName()); File f = BedrockUtil.getFileForPath(ifr.getPath(), ip); xw.field("PATH", f.getAbsolutePath()); xw.end("PACKAGE"); }