Author: akazakov
Date: 2008-01-21 13:41:36 -0500 (Mon, 21 Jan 2008)
New Revision: 5854
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
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/preferences/SeamPreferencePage.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-1490 Since that Preference Page can work with a
few default runtimes (one for each seam version).
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2008-01-21
18:20:54 UTC (rev 5853)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2008-01-21
18:41:36 UTC (rev 5854)
@@ -115,8 +115,9 @@
runtime.setDefault(true);
}
- if (getDefaultRuntime() != null && runtime.isDefault()) {
- getDefaultRuntime().setDefault(false);
+ SeamRuntime oldDefaultRuntime = getDefaultRuntime(runtime.getVersion());
+ if (oldDefaultRuntime != null && runtime.isDefault()) {
+ oldDefaultRuntime.setDefault(false);
}
runtimes.put(runtime.getName(), runtime);
save();
@@ -230,13 +231,13 @@
*/
public SeamRuntime getDefaultRuntime(SeamVersion version) {
for (SeamRuntime rt : runtimes.values()) {
- if (rt.isDefault()) {
+ if (rt.isDefault() && rt.getVersion() == version) {
return rt;
}
}
return null;
}
-
+
/**
* Return version of configuration
*
@@ -318,4 +319,4 @@
}
}
}
-}
+}
\ No newline at end of file
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 2008-01-21
18:20:54 UTC (rev 5853)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-01-21
18:41:36 UTC (rev 5854)
@@ -206,12 +206,20 @@
* @return
*/
private Object getSeamRuntimeDefaultValue() {
- return ("".equals(SeamProjectPreferences //$NON-NLS-1$
- .getStringPreference(SeamProjectPreferences.SEAM_DEFAULT_RUNTIME_NAME)) ?
- (SeamRuntimeManager.getInstance().getDefaultRuntime()==null?
- "":SeamRuntimeManager.getInstance().getDefaultRuntime().getName()) :
//$NON-NLS-1$
- SeamProjectPreferences
- .getStringPreference(SeamProjectPreferences.SEAM_DEFAULT_RUNTIME_NAME));
+ String seamFacetVersion =
model.getProperty(IFacetDataModelProperties.FACET_VERSION_STR).toString();
+ SeamVersion seamVersion = SeamVersion.parseFromString(seamFacetVersion);
+
+ String seamDefaultRuntimeName =
SeamProjectPreferences.getStringPreference(SeamProjectPreferences.SEAM_DEFAULT_RUNTIME_NAME);
+ if("".equals(seamDefaultRuntimeName)) {
+ SeamRuntime defaultRuntime =
SeamRuntimeManager.getInstance().getDefaultRuntime(seamVersion);
+ if(defaultRuntime==null) {
+ return "";
+ } else {
+ return defaultRuntime.getName();
+ }
+ } else {
+ return seamDefaultRuntimeName;
+ }
}
private DataModelSynchronizer sync;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencePage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencePage.java 2008-01-21
18:20:54 UTC (rev 5853)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencePage.java 2008-01-21
18:41:36 UTC (rev 5854)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import java.util.Map;
import org.eclipse.jface.preference.PreferencePage;
@@ -32,24 +33,22 @@
* <li>define new </li>
* <li>change exists</li>
* <li>remove</li>
+ * <li>set default ones</li>
* </ul>
*
* @author eskimo
*/
-public class SeamPreferencePage extends PreferencePage implements
- IWorkbenchPreferencePage {
+public class SeamPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
/**
* Seam Preferences page ID
*/
public static final String SEAM_PREFERENCES_ID =
"org.jboss.tools.common.model.ui.seam";
-
+
private static final int COLUMNS = 3;
SeamRuntimeListFieldEditor seamRuntimes = new SeamRuntimeListFieldEditor(
"rtlist", SeamPreferencesMessages.SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES, new
ArrayList<SeamRuntime>(Arrays.asList(SeamRuntimeManager.getInstance().getRuntimes())));
//$NON-NLS-1$
-
- SeamRuntime initialDefault;
/**
* Create contents of Seam preferences page. SeamRuntime list editor is
@@ -64,8 +63,6 @@
root.setLayout(gl);
seamRuntimes.doFillIntoGrid(root);
- initialDefault = SeamRuntimeManager.getInstance().getDefaultRuntime();
-
return root;
}
@@ -92,12 +89,17 @@
SeamRuntimeManager.getInstance().removeRuntime(rt);
}
seamRuntimes.getRemoved().clear();
- if (initialDefault != null
- && seamRuntimes.getDefaultSeamRuntime() != initialDefault) {
- initialDefault.setDefault(false);
+ List<SeamRuntime> defaultRuntimes = seamRuntimes.getDefaultSeamRuntimes();
+ // reset all default runtimes
+ for (SeamRuntime seamRuntime : SeamRuntimeManager.getInstance().getRuntimes()) {
+ seamRuntime.setDefault(false);
}
- Map<SeamRuntime, SeamRuntime> changed = seamRuntimes
- .getChangedSeamRuntimes();
+ // set deafult runtimes
+ for (SeamRuntime seamRuntime : defaultRuntimes) {
+ seamRuntime.setDefault(true);
+ }
+ seamRuntimes.getDefaultSeamRuntimes().clear();
+ Map<SeamRuntime, SeamRuntime> changed = seamRuntimes.getChangedSeamRuntimes();
for (SeamRuntime c : changed.keySet()) {
SeamRuntime o = changed.get(c);
o.setHomeDir(c.getHomeDir());
@@ -105,15 +107,11 @@
String oldName = o.getName();
String newName = c.getName();
if (!oldName.equals(newName)) {
- SeamRuntimeManager.getInstance().changeRuntimeName(oldName,
- newName);
+ SeamRuntimeManager.getInstance().changeRuntimeName(oldName, newName);
}
}
seamRuntimes.getChangedSeamRuntimes().clear();
- if (seamRuntimes.getDefaultSeamRuntime() != null) {
- seamRuntimes.getDefaultSeamRuntime().setDefault(true);
- }
SeamRuntimeManager.getInstance().save();
}
@@ -137,4 +135,4 @@
performApply();
return super.performOk();
}
-}
+}
\ No newline at end of file
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 2008-01-21
18:20:54 UTC (rev 5853)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2008-01-21
18:41:36 UTC (rev 5854)
@@ -84,7 +84,7 @@
super.setElement(element);
project = (IProject) getElement().getAdapter(IProject.class);
}
-
+
boolean hasSeamSupport() {
return seamProject != null;
}
@@ -92,7 +92,7 @@
@Override
protected Control createContents(Composite parent) {
seamProject = SeamCorePlugin.getSeamProject(project, false);
-
+
boolean cannotBeModified = false;
if(seamProject != null) {
@@ -101,13 +101,13 @@
if(!cannotBeModified) {
cannotBeModified = isEarPartInEarSeamProject(project);
}
-
+
seamEnablement = IFieldEditorFactory.INSTANCE.createCheckboxEditor(
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT, false);
seamEnablement.setValue(hasSeamSupport());
SeamRuntime rs = SeamRuntimeManager.getInstance().getDefaultRuntime();
-
+
List<String> namesAsList = getNameList();
runtime =
IFieldEditorFactory.INSTANCE.createComboWithButton(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_RUNTIME,
@@ -121,7 +121,7 @@
SeamPreferencePage.SEAM_PREFERENCES_ID,
new String[] {SeamPreferencePage.SEAM_PREFERENCES_ID}, null
);
-
+
prefsdlg.open();
String v = runtime.getValueAsString();
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 2008-01-21
18:20:54 UTC (rev 5853)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2008-01-21
18:41:36 UTC (rev 5854)
@@ -99,7 +99,7 @@
private Map<SeamRuntime, SeamRuntime> changed = new HashMap<SeamRuntime,
SeamRuntime>();
- private SeamRuntime checkedElement = null;
+ private List<SeamRuntime> checkedElements = new ArrayList<SeamRuntime>();
private List<SeamRuntime> added = new ArrayList<SeamRuntime>();
@@ -129,8 +129,8 @@
*
* @return List<SeamRuntime>
*/
- public SeamRuntime getDefaultSeamRuntime() {
- return checkedElement;
+ public List<SeamRuntime> getDefaultSeamRuntimes() {
+ return checkedElements;
}
/**
@@ -271,9 +271,9 @@
tableView.getTable().setHeaderVisible(true);
tableView.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
+ SeamRuntime selRt = (SeamRuntime) event.getElement();
if (event.getChecked()) {
SeamRuntime deselRt = null;
- SeamRuntime selRt = (SeamRuntime) event.getElement();
Object[] selRts = tableView.getCheckedElements();
for (int i = 0; i < selRts.length; i++) {
@@ -287,21 +287,23 @@
if (deselRt != null) {
Object[] newChecked = new Object[selRts.length - 1];
+ checkedElements.clear();
int i = 0;
for (Object object : selRts) {
SeamRuntime rt = (SeamRuntime) object;
if (rt.getVersion() != selRt.getVersion()
|| rt == selRt) {
newChecked[i] = rt;
+ checkedElements.add(rt);
i++;
}
}
tableView.setCheckedElements(newChecked);
+ } else {
+ checkedElements.add((SeamRuntime)event.getElement());
}
-
- // checkedElement.setDefault(false);
- checkedElement = (SeamRuntime) event.getElement();
- // checkedElement.setDefault(true);
+ } else {
+ checkedElements.remove(selRt);
}
pcs.firePropertyChange(getName(), null, getValue());
}
@@ -309,9 +311,8 @@
for (SeamRuntime rt : (List<SeamRuntime>) getValue()) {
if (rt.isDefault()) {
- tableView.setCheckedElements(new Object[] {rt});
- checkedElement = rt;
- break;
+ tableView.setChecked(rt, true);
+ checkedElements.add(rt);
}
}
ActionPanel actionPanel = new ActionPanel(root, new BaseAction[] {
@@ -321,6 +322,26 @@
}
/**
+ * Checks all runtimes and set default one (for each version) if user did not do it.
+ */
+ private void setDefaultRuntimes() {
+ List<SeamRuntime> runtimes = (List<SeamRuntime>)getValue();
+ for (SeamRuntime seamRuntime : runtimes) {
+ boolean checked = false;
+ for(SeamRuntime checkedElement: checkedElements) {
+ if(checkedElement.getVersion() == seamRuntime.getVersion()) {
+ checked = true;
+ break;
+ }
+ }
+ if(!checked) {
+ tableView.setChecked(seamRuntime, true);
+ checkedElements.add(seamRuntime);
+ }
+ }
+ }
+
+ /**
* Return array of Controls that forms and editor
*
* @return Control[]
@@ -919,7 +940,6 @@
this.button.setEnabled(action.isEnabled());
this.button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- // TODO Auto-generated method stub
ActionButton.this.action.run();
}
@@ -1034,6 +1054,7 @@
.getActiveShell(), wiz);
dialog.open();
tableView.refresh();
+ setDefaultRuntimes();
}
}
@@ -1130,6 +1151,7 @@
removeRuntime(rt);
}
tableView.refresh();
+ setDefaultRuntimes();
}
private void removeRuntime(SeamRuntime r) {
@@ -1151,6 +1173,7 @@
}
((List) getValue()).remove(r);
}
+ checkedElements.remove(r);
}
private boolean isRuntimeUsed(String runtimeName) {
@@ -1165,5 +1188,4 @@
return false;
}
}
-
}
\ No newline at end of file