Author: jawi
Date: Tue Apr 10 09:40:21 2012
New Revision: 1311658
URL: http://svn.apache.org/viewvc?rev=1311658&view=rev
Log:
ACE-201: no longer show the description field for targets. Made some additional small UI-enhancements.
Modified:
ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java
ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/GenericAddWindow.java
ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java?rev=1311658&r1=1311657&r2=1311658&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java (original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java Tue
Apr 10 09:40:21 2012
@@ -18,41 +18,86 @@
*/
package org.apache.ace.webui.vaadin;
-import com.vaadin.ui.*;
-import com.vaadin.ui.Button.ClickEvent;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.ace.webui.NamedObject;
import org.apache.ace.webui.UIExtensionFactory;
-import org.apache.ace.webui.domain.NamedTargetObject;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
/**
* Provides a generic editor for repository objects.
*/
-public class EditWindow extends Window {
+public abstract class EditWindow extends Window {
- private final TextField m_name;
- private final TextField m_description;
+ protected final TextField m_name;
+ protected final TextField m_description;
/**
* @param object
* @param factories
*/
- public EditWindow(final NamedObject object, List<UIExtensionFactory> factories)
{
+ public EditWindow(String caption, NamedObject object, List<UIExtensionFactory>
factories) {
setModal(true);
- setCaption("Edit " + object.getName());
- setWidth("500px");
+ setWidth("50em");
+ setCaption(caption);
m_name = new TextField("Name", object.getName());
- m_name.setReadOnly(object instanceof NamedTargetObject);
+ m_name.setReadOnly(true);
m_name.setWidth("100%");
m_description = new TextField("Description", object.getDescription());
m_description.setWidth("100%");
+ initDialog(object, factories);
+ }
+
+ /**
+ * Shows this dialog on screen.
+ *
+ * @param window the parent window to show this dialog on, cannot be <code>null</code>.
+ */
+ public void show(Window parent) {
+ if (getParent() != null) {
+ // window is already showing
+ parent.showNotification("Window is already open!");
+ }
+ else {
+ parent.addWindow(this);
+ }
+ setRelevantFocus();
+ }
+
+ /**
+ * Closes this dialog by removing it from the parent window.
+ */
+ protected void closeDialog() {
+ // close the window by removing it from the parent window
+ getParent().removeWindow(this);
+ }
+
+ /**
+ * Called when the {@link #onOk(String, String)} method failed with an exception.
+ *
+ * @param e the exception to handle, never <code>null</code>.
+ */
+ protected abstract void handleError(Exception e);
+
+ /**
+ * @param object
+ * @param factories
+ */
+ protected void initDialog(final NamedObject object, List<UIExtensionFactory> factories)
{
VerticalLayout fields = new VerticalLayout();
fields.setSpacing(true);
fields.addComponent(m_name);
@@ -78,17 +123,19 @@ public class EditWindow extends Window {
}
Button okButton = new Button("Ok", new Button.ClickListener() {
- public void buttonClick(Button.ClickEvent event) {
- if (object instanceof NamedTargetObject) {
- // do nothing
+ public void buttonClick(ClickEvent event) {
+ try {
+ onOk((String) m_name.getValue(), (String) m_description.getValue());
+ closeDialog();
}
- else {
- object.setDescription((String) m_description.getValue());
+ catch (Exception e) {
+ handleError(e);
}
-
- closeDialog();
}
});
+ // Allow enter to be used to close this dialog with enter directly...
+ okButton.setClickShortcut(KeyCode.ENTER);
+ okButton.addStyleName("primary");
Button cancelButton = new Button("Cancel", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
@@ -114,26 +161,13 @@ public class EditWindow extends Window {
}
/**
- * @param parent
- */
- public void show(Window parent) {
- if (getParent() != null) {
- // window is already showing
- parent.showNotification("Window is already open!");
- }
- else {
- parent.addWindow(this);
- }
- setRelevantFocus();
- }
-
- /**
- * Closes this dialog by removing it from the parent window.
+ * Called when the user acknowledges this window by pressing Ok.
+ *
+ * @param name the value of the name field;
+ * @param description the value of the description field.
+ * @throws Exception in case the creation failed.
*/
- void closeDialog() {
- // close the window by removing it from the parent window
- getParent().removeWindow(this);
- }
+ protected abstract void onOk(String name, String description) throws Exception;
/**
* Sets the focus to the name field.
Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/GenericAddWindow.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/GenericAddWindow.java?rev=1311658&r1=1311657&r2=1311658&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/GenericAddWindow.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/GenericAddWindow.java
Tue Apr 10 09:40:21 2012
@@ -18,6 +18,7 @@
*/
package org.apache.ace.webui.vaadin;
+import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -28,24 +29,59 @@ import com.vaadin.ui.Window;
public abstract class GenericAddWindow extends Window {
- private final TextField m_name;
- private final TextField m_description;
+ protected final TextField m_name;
+ protected final TextField m_description;
public GenericAddWindow(String caption) {
- this(caption, "Name");
- }
-
- public GenericAddWindow(String caption, String fieldName) {
setModal(true);
setWidth("15em");
setCaption(caption);
- m_name = new TextField(fieldName);
+ m_name = new TextField("Name");
m_name.setWidth("100%");
m_description = new TextField("Description");
m_description.setWidth("100%");
-
+
+ initDialog();
+ }
+
+ /**
+ * Shows this dialog on screen.
+ *
+ * @param window the parent window to show this dialog on, cannot be <code>null</code>.
+ */
+ public void show(final Window window) {
+ if (getParent() != null) {
+ // window is already showing
+ window.showNotification("Window is already open");
+ }
+ else {
+ // Open the subwindow by adding it to the parent window
+ window.addWindow(this);
+ }
+ setRelevantFocus();
+ }
+
+ /**
+ * Closes this dialog by removing it from the parent window.
+ */
+ protected void closeDialog() {
+ // close the window by removing it from the parent window
+ getParent().removeWindow(this);
+ }
+
+ /**
+ * Called when the {@link #onOk(String, String)} method failed with an exception.
+ *
+ * @param e the exception to handle, never <code>null</code>.
+ */
+ protected abstract void handleError(Exception e);
+
+ /**
+ * Initializes this dialog by placing all components on it.
+ */
+ protected void initDialog() {
VerticalLayout fields = new VerticalLayout();
fields.setSpacing(true);
fields.addComponent(m_name);
@@ -62,6 +98,9 @@ public abstract class GenericAddWindow e
}
}
});
+ // Allow enter to be used to close this dialog with enter directly...
+ okButton.setClickShortcut(KeyCode.ENTER);
+ okButton.addStyleName("primary");
Button cancelButton = new Button("Cancel", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
@@ -85,26 +124,6 @@ public abstract class GenericAddWindow e
layout.setComponentAlignment(buttonBar, Alignment.BOTTOM_RIGHT);
}
- public void show(final Window window) {
- if (getParent() != null) {
- // window is already showing
- window.showNotification("Window is already open");
- }
- else {
- // Open the subwindow by adding it to the parent window
- window.addWindow(this);
- }
- setRelevantFocus();
- }
-
- /**
- * Closes this dialog by removing it from the parent window.
- */
- void closeDialog() {
- // close the window by removing it from the parent window
- getParent().removeWindow(this);
- }
-
/**
* Called when the user acknowledges this window by pressing Ok.
*
@@ -115,13 +134,6 @@ public abstract class GenericAddWindow e
protected abstract void onOk(String name, String description) throws Exception;
/**
- * Called when the {@link #onOk(String, String)} method failed with an exception.
- *
- * @param e the exception to handle, never <code>null</code>.
- */
- protected abstract void handleError(Exception e);
-
- /**
* Sets the focus to the name field.
*/
private void setRelevantFocus() {
Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1311658&r1=1311657&r2=1311658&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
Tue Apr 10 09:40:21 2012
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -48,6 +49,8 @@ import org.apache.ace.client.repository.
import org.apache.ace.client.repository.stateful.StatefulTargetObject;
import org.apache.ace.client.repository.stateful.StatefulTargetRepository;
import org.apache.ace.test.utils.FileUtils;
+import org.apache.ace.webui.NamedObject;
+import org.apache.ace.webui.UIExtensionFactory;
import org.apache.ace.webui.vaadin.component.ArtifactsPanel;
import org.apache.ace.webui.vaadin.component.DistributionsPanel;
import org.apache.ace.webui.vaadin.component.FeaturesPanel;
@@ -277,7 +280,7 @@ public class VaadinClient extends com.va
}
m_featuresPanel = createFeaturesPanel();
- m_featureToolbar = createAddFeatureButton(m_mainWindow);
+ m_featureToolbar = createAddFeatureButton();
if (auth.hasRole("viewFeature")) {
m_grid.addComponent(m_featuresPanel, count, 2);
@@ -286,7 +289,7 @@ public class VaadinClient extends com.va
}
m_distributionsPanel = createDistributionsPanel();
- m_distributionToolbar = createAddDistributionButton(m_mainWindow);
+ m_distributionToolbar = createAddDistributionButton();
if (auth.hasRole("viewDistribution")) {
m_grid.addComponent(m_distributionsPanel, count, 2);
@@ -295,7 +298,7 @@ public class VaadinClient extends com.va
}
m_targetsPanel = createTargetsPanel();
- m_targetToolbar = createAddTargetButton(m_mainWindow);
+ m_targetToolbar = createAddTargetButton();
if (auth.hasRole("viewTarget")) {
m_grid.addComponent(m_targetsPanel, count, 2);
@@ -346,10 +349,8 @@ public class VaadinClient extends com.va
protected void associateFromRight(String left, String right) {
ArtifactObject artifact = getArtifact(left);
// if you drop on a resource processor, and try to get it, you
- // will get null
- // because you cannot associate anything with a resource
- // processor so we check
- // for null here
+ // will get null because you cannot associate anything with a
+ // resource processor so we check for null here
if (artifact != null) {
if (m_dynamicRelations) {
Map<String, String> properties = new HashMap<String, String>();
@@ -367,10 +368,8 @@ public class VaadinClient extends com.va
protected void associateFromLeft(String left, String right) {
ArtifactObject artifact = getArtifact(left);
// if you drop on a resource processor, and try to get it, you
- // will get null
- // because you cannot associate anything with a resource
- // processor so we check
- // for null here
+ // will get null because you cannot associate anything with a
+ // resource processor so we check for null here
if (artifact != null) {
if (m_dynamicRelations) {
Map<String, String> properties = new HashMap<String, String>();
@@ -531,6 +530,21 @@ public class VaadinClient extends com.va
private ArtifactsPanel createArtifactsPanel() {
return new ArtifactsPanel(m_associations, this) {
@Override
+ protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
+ return new EditWindow("Edit Artifact", object, extensions) {
+ @Override
+ protected void onOk(String name, String description) throws Exception
{
+ object.setDescription(description);
+ }
+
+ @Override
+ protected void handleError(Exception e) {
+ getWindow().showNotification("Failed to edit artifact!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+ }
+ };
+ }
+
+ @Override
protected ArtifactRepository getRepository() {
return m_artifactRepository;
}
@@ -545,6 +559,21 @@ public class VaadinClient extends com.va
private FeaturesPanel createFeaturesPanel() {
return new FeaturesPanel(m_associations, this) {
@Override
+ protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
+ return new EditWindow("Edit Feature", object, extensions) {
+ @Override
+ protected void onOk(String name, String description) throws Exception
{
+ object.setDescription(description);
+ }
+
+ @Override
+ protected void handleError(Exception e) {
+ getWindow().showNotification("Failed to edit feature!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+ }
+ };
+ }
+
+ @Override
protected FeatureRepository getRepository() {
return m_featureRepository;
}
@@ -559,6 +588,21 @@ public class VaadinClient extends com.va
private DistributionsPanel createDistributionsPanel() {
return new DistributionsPanel(m_associations, this) {
@Override
+ protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
+ return new EditWindow("Edit Distribution", object, extensions) {
+ @Override
+ protected void onOk(String name, String description) throws Exception
{
+ object.setDescription(description);
+ }
+
+ @Override
+ protected void handleError(Exception e) {
+ getWindow().showNotification("Failed to edit distribution!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+ }
+ };
+ }
+
+ @Override
protected DistributionRepository getRepository() {
return m_distributionRepository;
}
@@ -573,6 +617,30 @@ public class VaadinClient extends com.va
private TargetsPanel createTargetsPanel() {
return new TargetsPanel(m_associations, this) {
@Override
+ protected EditWindow createEditor(final NamedObject object, final List<UIExtensionFactory>
extensions) {
+ return new EditWindow("Edit Target", object, extensions) {
+ @Override
+ protected void onOk(String name, String description) throws Exception
{
+ // Nothing to edit!
+ }
+
+ @Override
+ protected void handleError(Exception e) {
+ getWindow().showNotification("Failed to edit target!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+ }
+
+ @Override
+ protected void initDialog(NamedObject object, List<UIExtensionFactory>
factories) {
+ m_name.setCaption("Identifier");
+ m_name.setReadOnly(true);
+ m_description.setVisible(false);
+
+ super.initDialog(object, factories);
+ }
+ };
+ }
+
+ @Override
protected StatefulTargetRepository getRepository() {
return m_statefulTargetRepository;
}
@@ -662,25 +730,23 @@ public class VaadinClient extends com.va
* Create a button to show popup window for adding a new feature. On success
* this calls the createFeature() method.
*
- * @param main Main Window
- * @return Button
+ * @return the add-feature button instance.
*/
- private Button createAddFeatureButton(final Window main) {
+ private Button createAddFeatureButton() {
Button button = new Button("Add Feature...");
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- GenericAddWindow addFeatureWindow = new GenericAddWindow("Add Feature") {
+ GenericAddWindow window = new GenericAddWindow("Add Feature") {
public void onOk(String name, String description) {
createFeature(name, description);
}
public void handleError(Exception e) {
// ACE-241: notify user when the feature-creation failed!
- main.showNotification("Failed to add new feature!", "<br/>Reason:
" + e.getMessage(),
- Notification.TYPE_ERROR_MESSAGE);
+ getWindow().showNotification("Failed to add new feature!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
}
};
- addFeatureWindow.show(main);
+ window.show(getMainWindow());
}
});
return button;
@@ -690,25 +756,23 @@ public class VaadinClient extends com.va
* Create a button to show a popup window for adding a new distribution. On
* success this calls the createDistribution() method.
*
- * @param main Main Window
- * @return Button
+ * @return the add-distribution button instance.
*/
- private Button createAddDistributionButton(final Window main) {
+ private Button createAddDistributionButton() {
Button button = new Button("Add Distribution...");
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- GenericAddWindow addDistributionWindow = new GenericAddWindow("Add Distribution")
{
+ GenericAddWindow window = new GenericAddWindow("Add Distribution") {
public void onOk(String name, String description) {
createDistribution(name, description);
}
public void handleError(Exception e) {
// ACE-241: notify user when the distribution-creation failed!
- main.showNotification("Failed to add new distribution!", "<br/>Reason:
" + e.getMessage(),
- Notification.TYPE_ERROR_MESSAGE);
+ getWindow().showNotification("Failed to add new distribution!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
}
};
- addDistributionWindow.show(main);
+ window.show(getMainWindow());
}
});
@@ -719,35 +783,41 @@ public class VaadinClient extends com.va
* Create a button to show a popup window for adding a new target. On
* success this calls the createTarget() method
*
- * @param main Main Window
- * @return Button
+ * @return the add-target button instance.
*/
- private Button createAddTargetButton(final Window main) {
+ private Button createAddTargetButton() {
Button button = new Button("Add target...");
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- GenericAddWindow addTargetWindow = new GenericAddWindow("Add Target", "Identifier")
{
- public void onOk(String id, String description) {
- createTarget(id, description);
+ GenericAddWindow window = new GenericAddWindow("Add Target") {
+ protected void onOk(String id, String description) {
+ createTarget(id);
}
- public void handleError(Exception e) {
+ protected void handleError(Exception e) {
// ACE-241: notify user when the target-creation failed!
- main.showNotification("Failed to add new target!", "<br/>Reason:
" + e.getMessage(),
- Notification.TYPE_ERROR_MESSAGE);
+ getWindow().showNotification("Failed to add new target!", "<br/>Reason:
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+ }
+
+ @Override
+ protected void initDialog() {
+ m_name.setCaption("Identifier");
+ m_description.setVisible(false);
+
+ super.initDialog();
}
};
- addTargetWindow.show(main);
+ window.show(getMainWindow());
}
});
return button;
}
/**
- * Create a new feature (GroupObject) in the feature repository
+ * Create a new feature in the feature repository.
*
- * @param name Name of the new feature
- * @param description Description of the new feature
+ * @param name the name of the new feature;
+ * @param description the description of the new feature.
*/
private void createFeature(String name, String description) {
Map<String, String> attributes = new HashMap<String, String>();
@@ -758,14 +828,11 @@ public class VaadinClient extends com.va
}
/**
- * Create a new Target (StatefulTargetObject) in the statefulTargetRepository
- *
- * @param name Name of the new Target
- * @param description Description of the new Target
+ * Create a new target in the stateful target repository.
*
- * TODO description is not persisted. Should we remote it?
+ * @param name the name of the new target;
*/
- private void createTarget(String name, String description) {
+ private void createTarget(String name) {
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(StatefulTargetObject.KEY_ID, name);
attributes.put(TargetObject.KEY_AUTO_APPROVE, "true");
@@ -774,10 +841,10 @@ public class VaadinClient extends com.va
}
/**
- * Create a new Distribution (LicenseObject) in the distributionRepository
+ * Create a new distribution in the distribution repository
*
- * @param name Name of the new Distribution (LicenseObject)
- * @param description Description of the new Distribution
+ * @param name the name of the new distribution;
+ * @param description the description of the new distribution.
*/
private void createDistribution(String name, String description) {
Map<String, String> attributes = new HashMap<String, String>();
@@ -811,7 +878,7 @@ public class VaadinClient extends com.va
}
private void showAddArtifactDialog() {
- final AddArtifactWindow featureWindow = new AddArtifactWindow(m_sessionDir, m_obrUrl)
{
+ final AddArtifactWindow window = new AddArtifactWindow(m_sessionDir, m_obrUrl) {
@Override
protected ArtifactRepository getArtifactRepository() {
return m_artifactRepository;
@@ -823,14 +890,7 @@ public class VaadinClient extends com.va
}
};
- if (featureWindow.getParent() != null) {
- // window is already showing
- getMainWindow().showNotification("Window is already open");
- }
- else {
- // Open the subwindow by adding it to the parent
- // window
- getMainWindow().addWindow(featureWindow);
- }
+ // Open the subwindow by adding it to the parent window
+ getMainWindow().addWindow(window);
}
}
Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java?rev=1311658&r1=1311657&r2=1311658&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/BaseObjectPanel.java
Tue Apr 10 09:40:21 2012
@@ -371,6 +371,8 @@ abstract class BaseObjectPanel<REPO_OBJ
}
return buttons;
}
+
+ protected abstract EditWindow createEditor(NamedObject object, List<UIExtensionFactory>
extensions);
/**
* Factory method to create an embeddable icon.
@@ -583,6 +585,6 @@ abstract class BaseObjectPanel<REPO_OBJ
*/
private void showEditWindow(NamedObject object) {
List<UIExtensionFactory> extensions = getExtensionFactories();
- new EditWindow(object, extensions).show(getParent().getWindow());
+ createEditor(object, extensions).show(getParent().getWindow());
}
}
\ No newline at end of file
|