tag:blogger.com,1999:blog-1557780184357927241.post741481029630716913..comments2023-06-22T20:43:37.886+05:30Comments on Eclipse Tips - Prakash G.R.: How to create a new File Wizard?Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-1557780184357927241.post-12283302494283725802016-06-11T13:02:19.440+05:302016-06-11T13:02:19.440+05:30It is also possible to use BasicFileNewResource Wi...It is also possible to use BasicFileNewResource WizardAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1557780184357927241.post-7740917865247273792016-01-20T20:38:05.298+05:302016-01-20T20:38:05.298+05:30Thanks for Sharing nice code. Using your code I am...Thanks for Sharing nice code. Using your code I am able to create files. But problem is while creating file, it requires parent folder/directory. I want to also create Project folder with files. I am attaching code for better clarity. Code for BuilderNewWizard.java is as follow:<br />package customplugin.wizards;<br /><br />import org.eclipse.core.resources.IFile;<br />import org.eclipse.jface.viewers.IStructuredSelection;<br />import org.eclipse.jface.wizard.Wizard;<br />import org.eclipse.ui.INewWizard;<br />import org.eclipse.ui.IWorkbench;<br /><br />public class BuilderNewWizard extends Wizard implements INewWizard {<br /><br /> private IStructuredSelection selection;<br /> private VocabWizardPage vocabWizardPage;<br /> private ArchWizardPage archWizardPage;<br /> private InteractionWizardPage interactionWizardPage;<br /> private DeployWizardPage deployWizardPage;<br /> private IWorkbench workbench;<br /><br /> public BuilderNewWizard() {<br /><br /> setWindowTitle("IoT Suite");<br /><br /> }<br /><br /> @Override<br /> public void init(IWorkbench workbench, IStructuredSelection selection) {<br /> this.workbench = workbench;<br /> this.selection = selection;<br /> }<br /><br /> @Override<br /> public boolean performFinish() {<br /><br /> IFile file = vocabWizardPage.createNewFile();<br /> file = archWizardPage.createNewFile();<br /> file = interactionWizardPage.createNewFile();<br /> file = deployWizardPage.createNewFile();<br /> if (file != null)<br /> return true;<br /><br /> else<br /> return false;<br /> }<br /><br /> @Override<br /> public void addPages() {<br /><br /> vocabWizardPage = new VocabWizardPage(selection);<br /> vocabWizardPage.setTitle("IoT Suite Configuration");<br /> vocabWizardPage.setDescription("Create IoTSuite Configuration");<br /> addPage(vocabWizardPage);<br /> archWizardPage = new ArchWizardPage(selection);<br /> archWizardPage.setTitle("IoT Suite Configuration");<br /> archWizardPage.setDescription("Create IoTSuite Configuration");<br /> addPage(archWizardPage);<br /> interactionWizardPage = new InteractionWizardPage(selection);<br /> interactionWizardPage.setTitle("IoT Suite Configuration");<br /> interactionWizardPage.setDescription("Create IoTSuite Configuration");<br /> addPage(interactionWizardPage);<br /> deployWizardPage = new DeployWizardPage(selection);<br /> deployWizardPage.setTitle("IoT Suite Configuration");<br /> deployWizardPage.setDescription("Create IoTSuite Configuration");<br /> addPage(deployWizardPage);<br /><br /> }<br /><br />}<br /><br />Code for creating One of Page is as follow:<br />package customplugin.wizards;<br /><br />import java.io.IOException;<br />import java.io.InputStream;<br /><br />import org.eclipse.jface.viewers.IStructuredSelection;<br />import org.eclipse.ui.dialogs.WizardNewFileCreationPage;<br /><br />import wizard_demo.Activator;<br /><br />public class VocabWizardPage extends WizardNewFileCreationPage {<br /><br /> public VocabWizardPage(IStructuredSelection selection) {<br /> super("VocabWizardPage", selection);<br /> setTitle("Vocab");<br /> setDescription("Creates a Vocab.mydsl File");<br /> setFileName("vocab");<br /> setFileExtension("mydsl");<br /> // TODO Auto-generated constructor stub<br /> }<br /><br /> @Override<br /> protected InputStream getInitialContents() {<br /> try {<br /><br /> return Activator.getDefault().getBundle().getEntry("").openStream();<br /> } catch (IOException e) {<br /> return null; // ignore and create empty comments<br /> }<br /> }<br /><br />}<br />Am I missing anything ?Saurabhhttps://github.com/chauhansaurabhbnoreply@blogger.comtag:blogger.com,1999:blog-1557780184357927241.post-88154610289880540762009-02-17T17:23:00.000+05:302009-02-17T17:23:00.000+05:30@B, that means an exception is thrown in create...@B,<BR/> that means an exception is thrown in createNewFile() method. You are potentially hitting an NPE/SWTException I guess. Try debugging into that code put that line of code inside a try-catch blockPrakash G.R.https://www.blogger.com/profile/13046268367318873066noreply@blogger.comtag:blogger.com,1999:blog-1557780184357927241.post-31203843112501383232009-02-17T17:15:00.000+05:302009-02-17T17:15:00.000+05:30Hi,I have a problem with this bit of code:IFile fi...Hi,<BR/><BR/>I have a problem with this bit of code:<BR/><BR/>IFile file = newFileWizardPage.createNewFile();<BR/> if (file != null)<BR/> return true;<BR/> else<BR/> return false;<BR/><BR/>When I place breakpoints on the return true and return false statements, I notice that they never get invoked. Thus I believe that it never leaves createNewFile(). It does not give an error, it just stops and does nothing.<BR/>I am stuck on this bit of code, can someone explain me what happens? and how to solve it.<BR/><BR/>greetz<BR/><BR/>B.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1557780184357927241.post-35485049796328475592008-08-05T20:48:00.000+05:302008-08-05T20:48:00.000+05:30Hi,how can create more than 1 file at once with th...Hi,<br>how can create more than 1 file at once with this API?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1557780184357927241.post-72051177452388264772008-08-05T21:02:00.000+05:302008-08-05T21:02:00.000+05:30hmmmmm. This API is aimed in creating a single fil...hmmmmm. This API is aimed in creating a single file. I guess it doesn't support creating multiple files. For that either you create you own wizard or hack the API somehow to support. If I were you, I would opt for the first wayAnonymousnoreply@blogger.com