Author: dgolovin
Date: 2007-09-19 21:29:34 -0400 (Wed, 19 Sep 2007)
New Revision: 3727
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-915 - test project is broken when projects created
as war
http://jira.jboss.com/jira/browse/JBIDE-919 - Seam property page has several issues
(especially when no runtimes are defined)
layout issue: Combo box field is very big in the height, but very small in the width.
Getting an "The current displayed page contains invalid values" when trying to
select the page.
http://jira.jboss.com/jira/browse/JBIDE-912 - If no seam runtimes are defined pressing
finish result in NPE
http://jira.jboss.com/jira/browse/JBIDE-906 - Create TestNG project for Seam
Project created in the same configuration as seam-gen does: with components.properties for
Web and test projects. Web project has enbedded-ejb disabled, test vice versa.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-09-20
01:29:29 UTC (rev 3726)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-09-20
01:29:34 UTC (rev 3727)
@@ -87,10 +87,11 @@
*/
DataModelValidatorDelegate validatorDelegate;
- IFieldEditor jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
+ final IFieldEditor jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
.createComboWithButton(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
"Seam Runtime", getRuntimeNames(),
- SeamRuntimeManager.getInstance().getDefaultRuntime()==null?"":SeamRuntimeManager.getInstance().getDefaultRuntime().getName(),
+ SeamRuntimeManager.getInstance().getDefaultRuntime()==null?
+ "":SeamRuntimeManager.getInstance().getDefaultRuntime().getName(),
true, new NewSeamRuntimeAction(), (IValidator)null);
// IFieldEditor jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
@@ -113,7 +114,7 @@
ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
"Connection profile:",
getProfileNameList(),
- "DefaultDS",
+ getProfileNameList().contains("DefaultDS")?"DefaultDS":"",
true, new EditConnectionProfileAction(),
new NewConnectionProfileAction(),
ValidatorFactory.NO_ERRORS_VALIDATOR);
@@ -364,10 +365,6 @@
ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, event
.getProperty().toString());
}
- if (event.getPropertyName().equals(
- ISeamFacetDataModelProperties.DB_TYPE)) {
-
- }
}
public static final String GENERIC_JDBC_PROVIDER_ID
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2007-09-20
01:29:29 UTC (rev 3726)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2007-09-20
01:29:34 UTC (rev 3727)
@@ -11,10 +11,16 @@
package org.jboss.tools.seam.ui.internal.project.facet;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -30,6 +36,7 @@
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.corext.util.Messages;
+import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
@@ -140,16 +147,36 @@
"Seam Home folder doesn't exist");
return errors;
}
- if (!new File(value.toString(), "seam").isFile()) {
+ File seamJarFile = new File(value.toString(), "jboss-seam.jar");
+ if (!seamJarFile.isFile()) {
errors = createErrorMap();
errors.put(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
"Home folder points to " +
- "location that does not look like seam home folder ('seam' script is
missing)");
+ "location that does not look like seam home folder ('jboss-seam.jar'
is missing)");
}
return errors;
}
};
+
+ public static void main(String[] args) {
+ ZipFile seamJar;
+ try {
+ seamJar = new ZipFile(new File("C:\\jboss-eap.rc1\\seam",
"jboss-seam.jar"));
+
+ ZipFileStructureProvider provider = new ZipFileStructureProvider(seamJar);
+ ZipEntry entry = seamJar.getEntry("META-INF/MANIFEST.MF");
+ InputStream str = provider.getContents(entry);
+
+ Properties manifest = new Properties();
+ manifest.load(str);
+
+ System.out.println(manifest.get("Seam-Version"));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
/**
*
*/
@@ -336,7 +363,7 @@
public Map<String, String> validate(Object value, Object context) {
if (value == null || "".equals(value.toString().trim())) {
return createErrormessage(
- ISeamFacetDataModelProperties.JBOSS_SEAM_HOME,
+ ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
"Seam Runtime is not selected");
}
return NO_ERRORS;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2007-09-20
01:29:29 UTC (rev 3726)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2007-09-20
01:29:34 UTC (rev 3727)
@@ -7,21 +7,25 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.ui.preferences;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.dialogs.PropertyPage;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.core.ISeamProject;
@@ -29,8 +33,13 @@
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
+import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
+import org.jboss.tools.seam.ui.widget.editor.ButtonFieldEditor;
+import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
+import org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor;
import org.jboss.tools.seam.ui.widget.editor.SwtFieldEditorFactory;
+import
org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor.SeamRuntimeNewWizard;
/**
* @author Viacheslav Kabanovich
@@ -40,64 +49,62 @@
IFieldEditor seamEnablement;
IFieldEditor runtime;
-
+
public SeamSettingsPreferencePage() {
}
- public void setElement(IAdaptable element) {
- super.setElement(element);
- project = (IProject)getElement().getAdapter(IProject.class);
- }
+ public void setElement(IAdaptable element) {
+ super.setElement(element);
+ project = (IProject) getElement().getAdapter(IProject.class);
+ }
@Override
protected Control createContents(Composite parent) {
- ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
+ ISeamProject seamProject = SeamCorePlugin
+ .getSeamProject(project, false);
boolean hasSeamSupport = seamProject != null;
- seamEnablement = SwtFieldEditorFactory.INSTANCE.createCheckboxEditor("Seam
support", "Seam support", false);
+ seamEnablement = SwtFieldEditorFactory.INSTANCE.createCheckboxEditor(
+ "Seam support", "Seam support", false);
seamEnablement.setValue(hasSeamSupport);
-
- SeamRuntime[] rs = SeamRuntimeManager.getInstance().getRuntimes();
- List<String> values = new ArrayList<String>();
- String defaultValue = null;
- for (int i = 0; i < rs.length; i++) {
- values.add(rs[i].getName());
- if(rs[i].isDefault()) defaultValue = rs[i].getName();
- }
- runtime = SwtFieldEditorFactory.INSTANCE.createComboEditor("Runtime",
"Runtime", values, defaultValue);
+ SeamRuntime rs = SeamRuntimeManager.getInstance().getDefaultRuntime();
+
+ runtime = SwtFieldEditorFactory.INSTANCE.createComboWithButton("Runtime",
+ "Runtime", SeamRuntimeManager.getInstance().getRuntimeNames(),
+ rs==null?"":rs.getName(),true,new
NewSeamRuntimeAction(),(IValidator)null);
+
List<IFieldEditor> editorOrder = new ArrayList<IFieldEditor>();
editorOrder.add(seamEnablement);
editorOrder.add(runtime);
- if(hasSeamSupport) {
+ if (hasSeamSupport) {
SeamRuntime current = seamProject.getRuntime();
- if(current != null) runtime.setValue(current.getName());
- } else {
- if(defaultValue != null) runtime.setValue(defaultValue);
+ if (current != null)
+ runtime.setValue(current.getName());
}
seamEnablement.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
Object value = evt.getNewValue();
- if(value instanceof Boolean) {
- boolean v = ((Boolean)value).booleanValue();
+ if (value instanceof Boolean) {
+ boolean v = ((Boolean) value).booleanValue();
updateRuntimeEnablement(v);
validate();
}
}
});
-
+
runtime.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
validate();
}
});
-
+
Composite composite = new Composite(parent, SWT.NONE);
int columnNumber = 1;
for (IFieldEditor fieldEditor : editorOrder) {
- if(fieldEditor.getNumberOfControls()>columnNumber)
- columnNumber=fieldEditor.getNumberOfControls();
+ if (fieldEditor.getNumberOfControls() > columnNumber)
+ columnNumber = fieldEditor.getNumberOfControls();
}
GridLayout gl = new GridLayout(columnNumber, false);
gl.verticalSpacing = 5;
@@ -110,67 +117,108 @@
}
runtime.setEditable(false);
- if(!hasSeamSupport) {
+ if (!hasSeamSupport) {
updateRuntimeEnablement(false);
}
return composite;
}
-
- public boolean performOk() {
- if(getSeamSupport()) {
- addSeamSupport();
- changeRuntime();
- } else {
- removeSeamSupport();
- }
- return true;
- }
+ public boolean performOk() {
+ if (getSeamSupport()) {
+ addSeamSupport();
+ changeRuntime();
+ } else {
+ removeSeamSupport();
+ }
+ return true;
+ }
+
private void updateRuntimeEnablement(boolean enabled) {
Object[] cs = runtime.getEditorControls();
for (int i = 0; i < cs.length; i++) {
- if(cs[i] instanceof Control) {
- ((Control)cs[i]).setEnabled(enabled);
+ if (cs[i] instanceof Control) {
+ ((Control) cs[i]).setEnabled(enabled);
}
}
}
-
+
private void removeSeamSupport() {
try {
- EclipseResourceUtil.removeNatureFromProject(project, ISeamProject.NATURE_ID);
+ EclipseResourceUtil.removeNatureFromProject(project,
+ ISeamProject.NATURE_ID);
} catch (CoreException e) {
SeamGuiPlugin.getPluginLog().logError(e);
}
}
-
+
private void addSeamSupport() {
try {
- EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
+ EclipseResourceUtil.addNatureToProject(project,
+ ISeamProject.NATURE_ID);
} catch (CoreException e) {
SeamGuiPlugin.getPluginLog().logError(e);
}
}
-
+
private void changeRuntime() {
String name = getRuntimeName();
- SeamRuntime r = SeamRuntimeManager.getInstance().findRuntimeByName(name);
- if(r == null) return;
- ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
- seamProject.setRuntime(r);
+ SeamRuntime r = SeamRuntimeManager.getInstance()
+ .findRuntimeByName(name);
+ if (r == null)
+ return;
+ ISeamProject seamProject = SeamCorePlugin
+ .getSeamProject(project, false);
+ seamProject.setRuntime(r);
}
-
+
private boolean getSeamSupport() {
Object o = seamEnablement.getValue();
- return o instanceof Boolean && ((Boolean)o).booleanValue();
+ return o instanceof Boolean && ((Boolean) o).booleanValue();
}
-
+
private String getRuntimeName() {
return runtime.getValueAsString();
}
-
+
private void validate() {
- //TODO
+ if(getSeamSupport() && (runtime.getValue()== null ||
"".equals(runtime.getValue()))) {
+ setValid(false);
+ setErrorMessage("Seam runtime is not selected");
+ } else {
+ setValid(true);
+ setErrorMessage(null);
+ }
}
+ public class NewSeamRuntimeAction extends
+ ButtonFieldEditor.ButtonPressedAction {
+ /**
+ * @param label
+ */
+ public NewSeamRuntimeAction() {
+ super("Add");
+ }
+
+ public void run() {
+ List<SeamRuntime> added = new ArrayList<SeamRuntime>();
+ Wizard wiz = new SeamRuntimeNewWizard(
+ (List<SeamRuntime>) new ArrayList<SeamRuntime>(Arrays
+ .asList(SeamRuntimeManager.getInstance()
+ .getRuntimes())), added);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+
+ if (added.size() > 0) {
+ SeamRuntimeManager.getInstance().addRuntime(added.get(0));
+ getFieldEditor().setValue(added.get(0).getName());
+ ((ITaggedFieldEditor) ((CompositeEditor) runtime)
+ .getEditors().get(1)).setTags(SeamRuntimeManager.getInstance().getRuntimeNames()
+ .toArray(new String[0]));
+ runtime.setValue(added.get(0).getName());
+ }
+ }
+ }
+
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-09-20
01:29:29 UTC (rev 3726)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-09-20
01:29:34 UTC (rev 3727)
@@ -495,7 +495,6 @@
WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
dialog.open();
tableView.refresh();
-// } else if(e.widget==rmBtn) {
}
}
}