mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 16:28:56 +00:00
[#1321] Do not override icons when regenerate.
Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
This commit is contained in:
parent
35c544fa81
commit
9d9137ef66
6 changed files with 57 additions and 20 deletions
|
@ -35,5 +35,12 @@ class BinaryFileAccess {
|
|||
fileSystemAccess.generateFile(path, new ByteArrayInputStream(internalContents))
|
||||
}
|
||||
}
|
||||
|
||||
def existIn(IXtextGeneratorFileSystemAccess fileSystemAccess) {
|
||||
if (fileSystemAccess === null) {
|
||||
return false
|
||||
}
|
||||
return fileSystemAccess.isFile(path)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class TemplateFileWizardFragment extends AbstractXtextGeneratorFragment {
|
|||
</perspectiveExtension>
|
||||
</extension>
|
||||
'''
|
||||
|
||||
|
||||
if (generateToolbarButton) {
|
||||
projectConfig.eclipsePlugin.pluginXml.entries += '''
|
||||
<extension
|
||||
|
@ -171,12 +171,15 @@ class TemplateFileWizardFragment extends AbstractXtextGeneratorFragment {
|
|||
|
||||
def generateDefaultIcons() {
|
||||
val projectTemplate = fileAccessFactory.createBinaryFile("file_template.png")
|
||||
projectTemplate.content = readBinaryFileFromPackage("file_template.png")
|
||||
projectTemplate.writeTo(projectConfig.eclipsePlugin.icons)
|
||||
|
||||
if (!projectTemplate.existIn(projectConfig.eclipsePlugin.icons)) {
|
||||
projectTemplate.content = readBinaryFileFromPackage("file_template.png")
|
||||
projectTemplate.writeTo(projectConfig.eclipsePlugin.icons)
|
||||
}
|
||||
val newProject = fileAccessFactory.createBinaryFile("new_" + grammar.simpleName + "_file.png")
|
||||
newProject.content = readBinaryFileFromPackage("new_xfile.png")
|
||||
newProject.writeTo(projectConfig.eclipsePlugin.icons)
|
||||
if (!newProject.existIn(projectConfig.eclipsePlugin.icons)) {
|
||||
newProject.content = readBinaryFileFromPackage("new_xfile.png")
|
||||
newProject.writeTo(projectConfig.eclipsePlugin.icons)
|
||||
}
|
||||
}
|
||||
|
||||
private def byte[] readBinaryFileFromPackage(String fileName) {
|
||||
|
|
|
@ -111,7 +111,7 @@ class TemplateProjectWizardFragment extends AbstractXtextGeneratorFragment {
|
|||
</perspectiveExtension>
|
||||
</extension>
|
||||
'''
|
||||
|
||||
|
||||
if (generateToolbarButton) {
|
||||
projectConfig.eclipsePlugin.pluginXml.entries += '''
|
||||
<extension
|
||||
|
@ -244,12 +244,15 @@ class TemplateProjectWizardFragment extends AbstractXtextGeneratorFragment {
|
|||
|
||||
def generateDefaultIcons() {
|
||||
val projectTemplate = fileAccessFactory.createBinaryFile("project_template.png")
|
||||
projectTemplate.content = readBinaryFileFromPackage("project_template.png")
|
||||
projectTemplate.writeTo(projectConfig.eclipsePlugin.icons)
|
||||
|
||||
if (!projectTemplate.existIn(projectConfig.eclipsePlugin.icons)) {
|
||||
projectTemplate.content = readBinaryFileFromPackage("project_template.png")
|
||||
projectTemplate.writeTo(projectConfig.eclipsePlugin.icons)
|
||||
}
|
||||
val newProject = fileAccessFactory.createBinaryFile("new_" + grammar.simpleName + "_proj.gif")
|
||||
newProject.content = readBinaryFileFromPackage("new_xproj.gif")
|
||||
newProject.writeTo(projectConfig.eclipsePlugin.icons)
|
||||
if (!newProject.existIn(projectConfig.eclipsePlugin.icons)) {
|
||||
newProject.content = readBinaryFileFromPackage("new_xproj.gif")
|
||||
newProject.writeTo(projectConfig.eclipsePlugin.icons)
|
||||
}
|
||||
}
|
||||
|
||||
private def byte[] readBinaryFileFromPackage(String fileName) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Arrays;
|
|||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess;
|
||||
|
||||
/**
|
||||
* A utility class for generating binary files.
|
||||
|
@ -38,6 +39,13 @@ public class BinaryFileAccess {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean existIn(final IXtextGeneratorFileSystemAccess fileSystemAccess) {
|
||||
if ((fileSystemAccess == null)) {
|
||||
return false;
|
||||
}
|
||||
return fileSystemAccess.isFile(this.path);
|
||||
}
|
||||
|
||||
@Pure
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
|
|
|
@ -403,14 +403,22 @@ public class TemplateFileWizardFragment extends AbstractXtextGeneratorFragment {
|
|||
|
||||
public void generateDefaultIcons() {
|
||||
final BinaryFileAccess projectTemplate = this.fileAccessFactory.createBinaryFile("file_template.png");
|
||||
projectTemplate.setContent(this.readBinaryFileFromPackage("file_template.png"));
|
||||
projectTemplate.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
boolean _existIn = projectTemplate.existIn(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
boolean _not = (!_existIn);
|
||||
if (_not) {
|
||||
projectTemplate.setContent(this.readBinaryFileFromPackage("file_template.png"));
|
||||
projectTemplate.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
}
|
||||
String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
|
||||
String _plus = ("new_" + _simpleName);
|
||||
String _plus_1 = (_plus + "_file.png");
|
||||
final BinaryFileAccess newProject = this.fileAccessFactory.createBinaryFile(_plus_1);
|
||||
newProject.setContent(this.readBinaryFileFromPackage("new_xfile.png"));
|
||||
newProject.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
boolean _existIn_1 = newProject.existIn(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
boolean _not_1 = (!_existIn_1);
|
||||
if (_not_1) {
|
||||
newProject.setContent(this.readBinaryFileFromPackage("new_xfile.png"));
|
||||
newProject.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] readBinaryFileFromPackage(final String fileName) {
|
||||
|
|
|
@ -606,14 +606,22 @@ public class TemplateProjectWizardFragment extends AbstractXtextGeneratorFragmen
|
|||
|
||||
public void generateDefaultIcons() {
|
||||
final BinaryFileAccess projectTemplate = this.fileAccessFactory.createBinaryFile("project_template.png");
|
||||
projectTemplate.setContent(this.readBinaryFileFromPackage("project_template.png"));
|
||||
projectTemplate.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
boolean _existIn = projectTemplate.existIn(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
boolean _not = (!_existIn);
|
||||
if (_not) {
|
||||
projectTemplate.setContent(this.readBinaryFileFromPackage("project_template.png"));
|
||||
projectTemplate.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
}
|
||||
String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
|
||||
String _plus = ("new_" + _simpleName);
|
||||
String _plus_1 = (_plus + "_proj.gif");
|
||||
final BinaryFileAccess newProject = this.fileAccessFactory.createBinaryFile(_plus_1);
|
||||
newProject.setContent(this.readBinaryFileFromPackage("new_xproj.gif"));
|
||||
newProject.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
boolean _existIn_1 = newProject.existIn(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
boolean _not_1 = (!_existIn_1);
|
||||
if (_not_1) {
|
||||
newProject.setContent(this.readBinaryFileFromPackage("new_xproj.gif"));
|
||||
newProject.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] readBinaryFileFromPackage(final String fileName) {
|
||||
|
|
Loading…
Reference in a new issue