下面列出了怎么用org.eclipse.ui.dialogs.WizardNewFileCreationPage的API类实例代码及写法,或者点击链接到github查看源代码。
@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);
}
/**
* 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;
}
@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);
}
/**
* 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));
}
@Override
protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection) {
return new SwagEditNewWizardPage(selection);
}
@Override
protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection) {
return new NewOpenApiV3SpecWizardPage(selection);
}
/**
* Constructor.
*
* @param page
* the {@link WizardNewFileCreationPage}.
*/
public SelectTemplatePage(WizardNewFileCreationPage page) {
super("Select output folder");
setTitle("Select the target container.");
this.page = page;
}
abstract protected WizardNewFileCreationPage newFileCreationPage(IStructuredSelection selection);