org.eclipse.ui.dialogs.WizardNewFileCreationPage Java Examples

The following examples show how to use org.eclipse.ui.dialogs.WizardNewFileCreationPage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NewFileWizard.java    From solidity-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void addPages() {
	super.addPages();
	String fileExtension = fileExtensions.split("\\s*,\\s*")[0];
	mainPage = new WizardNewFileCreationPage("New File Page", getSelection()) {
		@Override
		protected InputStream getInitialContents() {
			NewFileTemplate template = new NewFileTemplate(this.getFileName().replace("."+fileExtension, ""), solidityVersion);
			
			return new StringInputStream(template.generate().toString());
		}
	};
	mainPage.setTitle("Solidity File");
	mainPage.setFileName("my_contract");
	mainPage.setFileExtension(fileExtension);
	addPage(mainPage);
}
 
Example #2
Source File: SelectTemplatePage.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Gets the {@link URI} from the given {@link WizardNewFileCreationPage}.
 * 
 * @param p
 *            the {@link WizardNewFileCreationPage}
 * @return the {@link URI} from the given {@link WizardNewFileCreationPage} if any, <code>null</code> otherwise
 */
public URI getBaseURI(WizardNewFileCreationPage p) {
    final URI res;

    final IPath path = p.getContainerFullPath();
    if (path != null) {
        final String fileName = p.getFileName();
        if (fileName != null && !fileName.isEmpty()) {
            res = URI.createPlatformResourceURI(path.toString() + "/" + fileName, true);
        } else {
            res = null;
        }
    } else {
        res = null;
    }

    return res;
}
 
Example #3
Source File: ImportTemplateWizard.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void addPages() {
    super.addPages();
    creationPage = new WizardNewFileCreationPage("Select destination Template file", structuredSelection);
    creationPage.setAllowExistingResources(true);
    creationPage.setFileExtension(M2DocUtils.DOCX_EXTENSION_FILE);

    importPage = new SelectRegisteredTemplatePage() {

        @Override
        protected void setSelectedTemplateURI(URI selectedTemplateURI) {
            super.setSelectedTemplateURI(selectedTemplateURI);
            creationPage.setFileName(selectedTemplateURI.lastSegment());
        }

    };

    addPage(importPage);
    addPage(creationPage);
}
 
Example #4
Source File: TemplateSelectionPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Update the preview content with the given template.
 * 
 * @param template
 */
protected void setPreviewContent(TemplateElement template)
{
	WizardNewFileCreationPage fileCreationPage = (WizardNewFileCreationPage) getPreviousPage();
	String templateContent = null;
	try
	{
		IPath path = fileCreationPage.getContainerFullPath().append(fileCreationPage.getFileName());
		templateContent = NewFileWizard.getTemplateContent(template, path);
	}
	catch (Exception e)
	{
		// logs the exception but allows the page to continue
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
	if (templateContent == null)
	{
		templatePreview.setText(""); //$NON-NLS-1$
	}
	else
	{
		templatePreview.setText(templateContent);
	}
	scroll.setMinSize(templatePreview.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
 
Example #5
Source File: SwagEditNewWizard.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection) {
    return new SwagEditNewWizardPage(selection);
}
 
Example #6
Source File: NewOpenApiV3SpecWizard.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection) {
    return new NewOpenApiV3SpecWizardPage(selection);
}
 
Example #7
Source File: SelectTemplatePage.java    From M2Doc with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Constructor.
 * 
 * @param page
 *            the {@link WizardNewFileCreationPage}.
 */
public SelectTemplatePage(WizardNewFileCreationPage page) {
    super("Select output folder");
    setTitle("Select the target container.");
    this.page = page;
}
 
Example #8
Source File: NewFileWizard.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 votes vote down vote up
abstract protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection);