Commit 27272ee8 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added initial support for file and project wizards

parent afc846e6
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -16,10 +16,18 @@ Require-Bundle: org.etsi.mts.tdl.tx,
 org.eclipse.ui.ide;bundle-version="3.5.0",
 org.eclipse.ui,
 org.eclipse.compare,
 org.eclipse.xtext.builder
 org.eclipse.xtext.builder,
 org.eclipse.jdt.core,
 org.eclipse.xtend.lib,
 org.eclipse.core.runtime,
 org.eclipse.core.resources,
 org.eclipse.pde.core,
 org.eclipse.ui.forms,
 org.etsi.mts.tdl.openapi2tdl.next
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.etsi.mts.tdl.ui.contentassist,
 org.etsi.mts.tdl.ui.quickfix,
 org.etsi.mts.tdl.tx.ui.internal
 org.etsi.mts.tdl.tx.ui.internal,
 org.etsi.mts.tdl.ui.wizard
Bundle-Activator: org.etsi.mts.tdl.tx.ui.internal.TxActivator
+101 −0
Original line number Diff line number Diff line
@@ -438,4 +438,105 @@
			type="text">
		</fileTypes>
	</extension>
	<extension
		point="org.eclipse.ui.newWizards">
		<category id="org.etsi.mts.tdl.ui.category" name="TDLtx">
		</category>
		<wizard
			category="org.etsi.mts.tdl.ui.category"
			class="org.etsi.mts.tdl.ui.TDLtxExecutableExtensionFactory:org.eclipse.xtext.ui.wizard.template.TemplateNewProjectWizard"
			id="org.etsi.mts.tdl.ui.wizard.TDLtxNewProjectWizard"
			name="TDLtx Project"
			icon="icons/new_TDLtx_proj.gif"
			project="true">
		</wizard>
	</extension>
	<extension
		point="org.eclipse.xtext.ui.projectTemplate">
		<projectTemplateProvider
			class="org.etsi.mts.tdl.ui.TDLtxExecutableExtensionFactory:org.etsi.mts.tdl.ui.wizard.TDLtxProjectTemplateProvider"
			grammarName="org.etsi.mts.tdl.TDLtx">
		</projectTemplateProvider>
	</extension>
	<extension
		point="org.eclipse.ui.perspectiveExtensions">
		<perspectiveExtension targetID="org.eclipse.ui.resourcePerspective">
			<newWizardShortcut id="org.etsi.mts.tdl.ui.wizard.TDLtxNewProjectWizard"/>
		</perspectiveExtension>
		<perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective">
			<newWizardShortcut id="org.etsi.mts.tdl.ui.wizard.TDLtxNewProjectWizard"/>
		</perspectiveExtension>
	</extension>
	<extension
		point="org.eclipse.ui.menus">
		<menuContribution
			allPopups="false"
			locationURI="toolbar:org.eclipse.ui.main.toolbar">
			<toolbar
				id="org.etsi.mts.tdl.ui.toolbar">
				<!--
					For some reason the tooltip is not shown when hovering over the toolbar button
					See also https://www.eclipse.org/forums/index.php/t/1079111/
				-->
				<command
					commandId="org.eclipse.ui.newWizard"
					tooltip="Create a new TDLtx project">
					<parameter
						name="newWizardId"
						value="org.etsi.mts.tdl.ui.wizard.TDLtxNewProjectWizard">
					</parameter>
				</command>
			</toolbar>
		</menuContribution>
	</extension>
	<extension
		point="org.eclipse.ui.newWizards">
		<category id="org.etsi.mts.tdl.ui.category" name="TDLtx">
		</category>
		<wizard
			category="org.etsi.mts.tdl.ui.category"
			class="org.etsi.mts.tdl.ui.TDLtxExecutableExtensionFactory:org.eclipse.xtext.ui.wizard.template.TemplateNewFileWizard"
			id="org.etsi.mts.tdl.ui.wizard.TDLtxNewFileWizard"
			name="TDLtx File"
			icon="icons/new_TDLtx_file.png">
		</wizard>
	</extension>
	<extension
		point="org.eclipse.xtext.ui.fileTemplate">
		<fileTemplateProvider
			class="org.etsi.mts.tdl.ui.TDLtxExecutableExtensionFactory:org.etsi.mts.tdl.ui.wizard.TDLtxFileTemplateProvider"
			grammarName="org.etsi.mts.tdl.TDLtx">
		</fileTemplateProvider>
	</extension>
	<extension
		point="org.eclipse.ui.perspectiveExtensions">
		<perspectiveExtension targetID="org.eclipse.ui.resourcePerspective">
			<newWizardShortcut id="org.etsi.mts.tdl.ui.wizard.TDLtxNewFileWizard"/>
		</perspectiveExtension>
		<perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective">
			<newWizardShortcut id="org.etsi.mts.tdl.ui.wizard.TDLtxNewFileWizard"/>
		</perspectiveExtension>
	</extension>
	<extension
		point="org.eclipse.ui.menus">
		<menuContribution
			allPopups="false"
			locationURI="toolbar:org.eclipse.ui.main.toolbar">
			<toolbar
				id="org.etsi.mts.tdl.ui.toolbar">
				<!--
					For some reason the tooltip is not shown when hovering over the toolbar button
					See also https://www.eclipse.org/forums/index.php/t/1079111/
				-->
				<command
					commandId="org.eclipse.ui.newWizard"
					tooltip="Create a new TDLtx file">
					<parameter
						name="newWizardId"
						value="org.etsi.mts.tdl.ui.wizard.TDLtxNewFileWizard">
					</parameter>
				</command>
			</toolbar>
		</menuContribution>
	</extension>
</plugin>
+101 −0
Original line number Diff line number Diff line
@@ -431,4 +431,105 @@
			type="text">
		</fileTypes>
	</extension>
	<extension
		point="org.eclipse.ui.newWizards">
		<category id="org.etsi.mts.tdl.ui.category" name="TDLtx">
		</category>
		<wizard
			category="org.etsi.mts.tdl.ui.category"
			class="org.etsi.mts.tdl.ui.TDLtxExecutableExtensionFactory:org.eclipse.xtext.ui.wizard.template.TemplateNewProjectWizard"
			id="org.etsi.mts.tdl.ui.wizard.TDLtxNewProjectWizard"
			name="TDLtx Project"
			icon="icons/new_TDLtx_proj.gif"
			project="true">
		</wizard>
	</extension>
	<extension
		point="org.eclipse.xtext.ui.projectTemplate">
		<projectTemplateProvider
			class="org.etsi.mts.tdl.ui.TDLtxExecutableExtensionFactory:org.etsi.mts.tdl.ui.wizard.TDLtxProjectTemplateProvider"
			grammarName="org.etsi.mts.tdl.TDLtx">
		</projectTemplateProvider>
	</extension>
	<extension
		point="org.eclipse.ui.perspectiveExtensions">
		<perspectiveExtension targetID="org.eclipse.ui.resourcePerspective">
			<newWizardShortcut id="org.etsi.mts.tdl.ui.wizard.TDLtxNewProjectWizard"/>
		</perspectiveExtension>
		<perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective">
			<newWizardShortcut id="org.etsi.mts.tdl.ui.wizard.TDLtxNewProjectWizard"/>
		</perspectiveExtension>
	</extension>
	<extension
		point="org.eclipse.ui.menus">
		<menuContribution
			allPopups="false"
			locationURI="toolbar:org.eclipse.ui.main.toolbar">
			<toolbar
				id="org.etsi.mts.tdl.ui.toolbar">
				<!--
					For some reason the tooltip is not shown when hovering over the toolbar button
					See also https://www.eclipse.org/forums/index.php/t/1079111/
				-->
				<command
					commandId="org.eclipse.ui.newWizard"
					tooltip="Create a new TDLtx project">
					<parameter
						name="newWizardId"
						value="org.etsi.mts.tdl.ui.wizard.TDLtxNewProjectWizard">
					</parameter>
				</command>
			</toolbar>
		</menuContribution>
	</extension>
	<extension
		point="org.eclipse.ui.newWizards">
		<category id="org.etsi.mts.tdl.ui.category" name="TDLtx">
		</category>
		<wizard
			category="org.etsi.mts.tdl.ui.category"
			class="org.etsi.mts.tdl.ui.TDLtxExecutableExtensionFactory:org.eclipse.xtext.ui.wizard.template.TemplateNewFileWizard"
			id="org.etsi.mts.tdl.ui.wizard.TDLtxNewFileWizard"
			name="TDLtx File"
			icon="icons/new_TDLtx_file.png">
		</wizard>
	</extension>
	<extension
		point="org.eclipse.xtext.ui.fileTemplate">
		<fileTemplateProvider
			class="org.etsi.mts.tdl.ui.TDLtxExecutableExtensionFactory:org.etsi.mts.tdl.ui.wizard.TDLtxFileTemplateProvider"
			grammarName="org.etsi.mts.tdl.TDLtx">
		</fileTemplateProvider>
	</extension>
	<extension
		point="org.eclipse.ui.perspectiveExtensions">
		<perspectiveExtension targetID="org.eclipse.ui.resourcePerspective">
			<newWizardShortcut id="org.etsi.mts.tdl.ui.wizard.TDLtxNewFileWizard"/>
		</perspectiveExtension>
		<perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective">
			<newWizardShortcut id="org.etsi.mts.tdl.ui.wizard.TDLtxNewFileWizard"/>
		</perspectiveExtension>
	</extension>
	<extension
		point="org.eclipse.ui.menus">
		<menuContribution
			allPopups="false"
			locationURI="toolbar:org.eclipse.ui.main.toolbar">
			<toolbar
				id="org.etsi.mts.tdl.ui.toolbar">
				<!--
					For some reason the tooltip is not shown when hovering over the toolbar button
					See also https://www.eclipse.org/forums/index.php/t/1079111/
				-->
				<command
					commandId="org.eclipse.ui.newWizard"
					tooltip="Create a new TDLtx file">
					<parameter
						name="newWizardId"
						value="org.etsi.mts.tdl.ui.wizard.TDLtxNewFileWizard">
					</parameter>
				</command>
			</toolbar>
		</menuContribution>
	</extension>
</plugin>
+27 −0
Original line number Diff line number Diff line
/*
 * generated by Xtext 2.27.0
 */
package org.etsi.mts.tdl.ui.wizard;

import org.eclipse.osgi.util.NLS;

public class Messages extends NLS {
	private static final String BUNDLE_NAME = "org.etsi.mts.tdl.ui.wizard.messages"; //$NON-NLS-1$
	
	public static String TDLtxProject_Label;
	public static String TDLtxProject_Description;
	public static String TDLtxFile_Label;
	public static String TDLtxFile_Description;
	public static String TDLtxFileExtras_Label;
	public static String TDLtxFileExtras_Description;
	public static String TDLtxProjectWithOpenAPI_Label;
	public static String TDLtxProjectWithOpenAPI_Description;
	
	static {
	// initialize resource bundle
	NLS.initializeMessages(BUNDLE_NAME, Messages.class);
	}
	
	private Messages() {
	}
}
+69 −0
Original line number Diff line number Diff line
/*
 * generated by Xtext 2.27.0
 */
package org.etsi.mts.tdl.ui.wizard


import org.eclipse.xtext.ui.wizard.template.FileTemplate
import org.eclipse.xtext.ui.wizard.template.IFileGenerator
import org.eclipse.xtext.ui.wizard.template.IFileTemplateProvider
import org.etsi.mts.tdl.openapi2tdl.next.ConverterNext
import com.google.inject.Inject

/**
 * Create a list with all file templates to be shown in the template new file wizard.
 * 
 * Each template is able to generate one or more files.
 */
class TDLtxFileTemplateProvider implements IFileTemplateProvider {
    @Inject
    TDLtxFile txFile

    @Inject
    TDLtxFileExtras txFileExtra
    
	override getFileTemplates() {
//		#[new TDLtxFile, new TDLtxFileExtras]
        #[txFile, txFileExtra]
	}
}

@FileTemplate(label="TDLtx", icon="file_template.png", description="Create a new package for TDLtx.")
final class TDLtxFile {
	val packageName = combo("Package Name:", #["Example", "Sample", "Tutorial", "Pack"], "The name of the package")

    //TODO: reuse?
	override generateFiles(IFileGenerator generator) {
		generator.generate('''«folder»/«name».tdltx''', '''
			/*
			 * This is an example model
			 */
			Package «packageName» {
			    
			}
		''')
	}
}

//TODO: this seems to be inactive...
@FileTemplate(label="TDLtx extra", icon="file_template.png", description="Create a new package for TDLtx with extras.")
final class TDLtxFileExtras {
//    val packageName = combo("Package Name:", #["Example", "Sample", "Tutorial", "Pack"], "The name of the package")
    val testFile = "/Users/philip-iii/Dev/git/etsi-labs/eg-203647-restful-api-guide/OpenAPI/ExampleAPI.yaml"
    val dataDefinitionsPath = text("Data DefinitionsPath:", testFile, "The data definitions path to import from")

    //TODO: reuse?
    override generateFiles(IFileGenerator generator) {
//        generator.generate('''«folder»/«name».tdltx''', '''
//            /*
//             * This is an example model
//             */
//            Package «name» {
//                
//            }
//        ''')
//        generator.generate('''«folder»/«packageName».tdltx''', TemplateContent.Example)
        //TODO: this gets loaded twice? already when the template is selected? and the file is not opened automatically
        ConverterNext.process(dataDefinitionsPath.value, "/Users/philip-iii/Dev/workspaces/runtime/2021-06-M3-clean/"+folder+"/"+name+".tdltx")
    }
}
Loading