Skip to content

Commit

Permalink
Merge branch 'main' into splitOffSDKs
Browse files Browse the repository at this point in the history
  • Loading branch information
keinhaar authored Dec 9, 2024
2 parents 0d3886d + 55fdf22 commit 69d1b87
Show file tree
Hide file tree
Showing 32 changed files with 1,895 additions and 494 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.List;

/**
* Creates web app projects populated with files relevant to the selected natures.
Expand Down Expand Up @@ -56,10 +56,6 @@ public interface Participant {

void addContainerPath(IPath containerPath);

void addFile(IPath path, InputStream inputStream);

void addFile(IPath path, String content) throws UnsupportedEncodingException;

void addNature(String natureId);

/**
Expand All @@ -86,10 +82,6 @@ void create(IProgressMonitor monitor) throws CoreException, MalformedURLExceptio

void setProjectName(String projectName);

void setTemplates(String... templates);

void setTemplateSources(String... sources);

/**
* Build an Ant project.
*
Expand All @@ -105,25 +97,24 @@ void create(IProgressMonitor monitor) throws CoreException, MalformedURLExceptio
void setBuildMaven(boolean buildMaven);

/**
* Returns the created Java project. This is available half way through the creation process.
*
* @return the java projeect.
* Returns the created Java projects. This is available half way through the creation process.
* @return the java project.
*/
IJavaProject getCreatedJavaProject();
List<IJavaProject> getCreatedJavaProjects();

/**
* Returns build a Maven Project.
*
* @return Maven selected
*/
boolean getBuildMaven();
boolean isBuildMaven();

/**
* Returns build an ant project.
*
* @return Ant selected
*/
boolean getBuiltAnt();
boolean isBuiltAnt();

/**
* Returns the Creation progress monitor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
import org.eclipse.jface.text.Document;
import org.eclipse.text.edits.TextEdit;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;
import java.util.Vector;

/**
* Generates source for files needed by web application projects.
*
*
* TODO: Convert these use to use templates.
*/
@SuppressWarnings("restriction")
Expand Down Expand Up @@ -128,13 +128,13 @@ public static List<File> findFilesInDir(File directory, FilenameFilter filter) {
/**
* Given a java.io.File containing Java source, call the Eclipse auto-format
* code on that source and write it back to disk.
*
*
* @param file
* @throws CoreException
*/
public static void reformatJavaSource(File file) throws CoreException {
try {
String generatedSource = textFromFile(file);
String generatedSource = Files.readString(file.toPath(), Charset.defaultCharset());
String reformattedSource = reformatJavaSourceAsString(generatedSource);
if (!reformattedSource.equals(generatedSource)) {
writeStringToFile(reformattedSource, file);
Expand Down Expand Up @@ -166,32 +166,6 @@ public static String reformatJavaSourceAsString(String source) {
return source;
}

/*
* TODO: These next two methods might be useful somewhere else in the
* future, but right now, this is the only place where we need to do I/O on
* java.io.Files instead of Eclipse resources.
*/
private static String textFromFile(File file) throws IOException {
char bytes[] = new char[1024];
int nread;
StringBuilder builder = new StringBuilder();

BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
while ((nread = reader.read(bytes, 0, 1024)) != -1) {
char toAppend[] = new char[nread];
System.arraycopy(bytes, 0, toAppend, 0, nread);
builder.append(toAppend);
}
} finally {
if (reader != null) {
reader.close();
}
}
return builder.toString();
}

private static void writeStringToFile(String string, File file)
throws IOException {
BufferedWriter bw = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IProjectConfigurationManager;

import java.util.List;

public class MavenEnablingWebAppCreatorParicipant implements IWebAppProjectCreator.Participant {

private IJavaProject javaProject;
private List<IJavaProject> javaProjects;

@Override
public void updateWebAppProjectCreator(IWebAppProjectCreator webAppProjectCreator) {
boolean buildMaven = webAppProjectCreator.getBuildMaven();
boolean buildMaven = webAppProjectCreator.isBuildMaven();
if (!buildMaven) {
return;
}

javaProject = webAppProjectCreator.getCreatedJavaProject();
if (javaProject == null) {
javaProjects = webAppProjectCreator.getCreatedJavaProjects();
if (javaProjects == null) {
return;
}

Expand All @@ -42,7 +44,10 @@ private void runJob() {
protected IStatus run(IProgressMonitor monitor) {
// Turn on the Maven nature
try {
NatureUtils.addNature(javaProject.getProject(), MavenUtils.MAVEN2_NATURE_ID);
for(int i=0;i<javaProjects.size();i++)
{
NatureUtils.addNature(javaProjects.get(i).getProject(), MavenUtils.MAVEN2_NATURE_ID);
}
} catch (CoreException e1) {
e1.printStackTrace();
return Status.CANCEL_STATUS;
Expand All @@ -53,7 +58,10 @@ protected IStatus run(IProgressMonitor monitor) {
// Maven update project will add the Maven dependencies to the classpath
IProjectConfigurationManager projectConfig = MavenPlugin.getProjectConfigurationManager();
try {
projectConfig.updateProjectConfiguration(javaProject.getProject(), monitor);
for(int i=0;i<javaProjects.size();i++)
{
projectConfig.updateProjectConfiguration(javaProjects.get(i).getProject(), monitor);
}
} catch (CoreException e) {
// TODO(${user}): Auto-generated catch block
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
eclipse.preferences.version=1
encoding//project_templates/client_server_shared/client/.settings/org.eclipse.jdt.core.prefs=UTF-8
encoding//project_templates/client_server_shared/server/.settings/org.eclipse.jdt.core.prefs=UTF-8
encoding//project_templates/client_server_shared/shared/.settings/org.eclipse.jdt.core.prefs=UTF-8
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ Require-Bundle:
com.gwtplugins.gdt.eclipse.platform,
org.eclipse.equinox.common,
system.bundle,
org.eclipse.core.runtime
org.eclipse.core.runtime,
org.jdom2,
org.apache.commons.commons-io
Import-Package: org.eclipse.core.runtime.preferences
3 changes: 2 additions & 1 deletion plugins/com.gwtplugins.gdt.eclipse.suite/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ bin.includes = META-INF/,\
plugin.xml,\
icons/,\
about.ini,\
plugin.properties
plugin.properties,\
project_templates/
javacSource=11
javacTarget=11
21 changes: 21 additions & 0 deletions plugins/com.gwtplugins.gdt.eclipse.suite/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@
id="com.gwtplugins.gdt.eclipse.suite.newWizards"
name="%gwt.label.new">
</category>
<wizard
category="com.gwtplugins.gdt.eclipse.suite.newWizards"
class="com.google.gdt.eclipse.suite.wizards.NewWebAppTemplateProjectWizard"
icon="icons/gdt-new-project_16x16.png"
id="com.gwtplugins.gdt.eclipse.suite.wizards.newMultiProjectWizard"
name="GWT Template based Project"
preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective"
project="true">
</wizard>
<wizard
category="com.gwtplugins.gdt.eclipse.suite.newWizards"
class="com.google.gdt.eclipse.suite.wizards.NewWebAppProjectWizard"
Expand All @@ -223,24 +232,36 @@
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaPerspective">
<newWizardShortcut
id="com.gwtplugins.gdt.eclipse.suite.wizards.newMultiProjectWizard">
</newWizardShortcut>
<newWizardShortcut
id="com.gwtplugins.gdt.eclipse.suite.wizards.newProjectWizard">
</newWizardShortcut>
</perspectiveExtension>
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaBrowsingPerspective">
<newWizardShortcut
id="com.gwtplugins.gdt.eclipse.suite.wizards.newMultiProjectWizard">
</newWizardShortcut>
<newWizardShortcut
id="com.gwtplugins.gdt.eclipse.suite.wizards.newProjectWizard">
</newWizardShortcut>
</perspectiveExtension>
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaHierarchyPerspective">
<newWizardShortcut
id="com.gwtplugins.gdt.eclipse.suite.wizards.newMultiProjectWizard">
</newWizardShortcut>
<newWizardShortcut
id="com.gwtplugins.gdt.eclipse.suite.wizards.newProjectWizard">
</newWizardShortcut>
</perspectiveExtension>
<perspectiveExtension
targetID="org.eclipse.jst.j2ee.J2EEPerspective">
<newWizardShortcut
id="com.gwtplugins.gdt.eclipse.suite.wizards.newMultiProjectWizard">
</newWizardShortcut>
<newWizardShortcut
id="com.gwtplugins.gdt.eclipse.suite.wizards.newProjectWizard">
</newWizardShortcut>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
When updating your version of GWT, you should also update this DTD reference,
so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.10.0//EN"
"http://gwtproject.org/doctype/2.10.0/gwt-module.dtd">
<module rename-to='example'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>

<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->

<!-- Other module inherits -->
<inherits name='${PACKAGENAME}.shared'/>

<!-- Specify the app entry point class. -->
<entry-point class='${PACKAGENAME}.ui.Main'/>

<!-- Specify the paths for translatable code -->
<source path='ui'/>
</module>
Loading

0 comments on commit 69d1b87

Please sign in to comment.