Java Code Examples for org.eclipse.ui.dialogs.WizardNewFileCreationPage

The following examples show how to use org.eclipse.ui.dialogs.WizardNewFileCreationPage. These examples are extracted from open source projects. 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 Project: solidity-ide   Source File: NewFileWizard.java    License: 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 Project: M2Doc   Source File: SelectTemplatePage.java    License: 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 Project: M2Doc   Source File: ImportTemplateWizard.java    License: 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
/**
 * 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
@Override
protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection) {
    return new SwagEditNewWizardPage(selection);
}
 
Example 6
@Override
protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection) {
    return new NewOpenApiV3SpecWizardPage(selection);
}
 
Example 7
Source Project: M2Doc   Source File: SelectTemplatePage.java    License: 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
abstract protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection);