Author: angelos
Date: Thu Mar 24 02:59:47 2011
New Revision: 1084833
URL: http://svn.apache.org/viewvc?rev=1084833&view=rev
Log:
Cleanup in the web ui.
Added:
incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java
Modified:
incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
Added: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java?rev=1084833&view=auto
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java
(added)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/EditWindow.java
Thu Mar 24 02:59:47 2011
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.webui.vaadin;
+
+import com.vaadin.ui.*;
+import org.apache.ace.webui.NamedObject;
+import org.apache.ace.webui.UIExtensionFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class EditWindow extends Window {
+ private final Window m_main;
+ private TextField m_name;
+
+ public EditWindow(final NamedObject object, Window main, List<UIExtensionFactory>
factories) {
+ m_main = main;
+ setModal(true);
+ setCaption("Edit " + object.getName());
+ setWidth("500px");
+
+ VerticalLayout layout = (VerticalLayout) getContent();
+ layout.setMargin(true);
+ layout.setSpacing(true);
+
+ m_name = new TextField("name");
+ final TextField description = new TextField("description");
+
+ m_name.setValue(object.getName());
+ description.setValue(object.getDescription());
+
+ layout.addComponent(m_name);
+ layout.addComponent(description);
+
+ TabSheet tabs = new TabSheet();
+ tabs.setHeight("350px");
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("object", object);
+ for (UIExtensionFactory factory : factories) {
+ com.vaadin.ui.Component component = factory.create(context);
+ tabs.addTab(component);
+ }
+ layout.addComponent(tabs);
+
+ Button close = new Button("Ok", new Button.ClickListener() {
+ // inline click-listener
+ public void buttonClick(Button.ClickEvent event) {
+ // close the window by removing it from the parent window
+ getParent().removeWindow(EditWindow.this);
+ // create the feature
+ object.setDescription((String) description.getValue());
+ }
+ });
+ // The components added to the window are actually added to the window's
+ // layout; you can use either. Alignments are set using the layout
+ layout.addComponent(close);
+ layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
+ }
+
+ public void show() {
+ if (getParent() != null) {
+ // window is already showing
+ m_main.getWindow().showNotification("Window is already open");
+ } else {
+ // Open the subwindow by adding it to the parent
+ // window
+ m_main.getWindow().addWindow(this);
+ }
+ setRelevantFocus();
+ }
+
+ private void setRelevantFocus() {
+ m_name.focus();
+ }
+}
+
Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1084833&r1=1084832&r2=1084833&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
Thu Mar 24 02:59:47 2011
@@ -630,61 +630,11 @@ public class VaadinClient extends com.va
private void remove(ArtifactObject artifact) {
removeItem(artifact.getName());
}
- @Override
- public void showEditWindow(String objectName, final NamedObject object, Window main) {
- final Window featureWindow = new Window();
- featureWindow.setModal(true);
- featureWindow.setCaption("Edit " + objectName);
- featureWindow.setWidth("500px");
-
- VerticalLayout layout = (VerticalLayout) featureWindow.getContent();
- layout.setMargin(true);
- layout.setSpacing(true);
-
- final TextField name = new TextField("name");
- final TextField description = new TextField("description");
-
- name.setValue(object.getName());
- description.setValue(object.getDescription());
-
- layout.addComponent(name);
- layout.addComponent(description);
-
- TabSheet tabs = new TabSheet();
- tabs.setHeight("350px");
- Map<String, Object> context = new HashMap<String, Object>();
- context.put("object", object);
- for (UIExtensionFactory factory : m_factories) {
- com.vaadin.ui.Component component = factory.create(context);
- tabs.addTab(component);
- }
- layout.addComponent(tabs);
-
- Button close = new Button("Ok", new Button.ClickListener() {
- // inline click-listener
- public void buttonClick(ClickEvent event) {
- // close the window by removing it from the parent window
- (featureWindow.getParent()).removeWindow(featureWindow);
- // create the feature
- object.setDescription((String) description.getValue());
- }
- });
- // The components added to the window are actually added to the window's
- // layout; you can use either. Alignments are set using the layout
- layout.addComponent(close);
- layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
-
- if (featureWindow.getParent() != null) {
- // window is already showing
- main.getWindow().showNotification("Window is already open");
- } else {
- // Open the subwindow by adding it to the parent
- // window
- main.getWindow().addWindow(featureWindow);
- }
- name.setReadOnly(true);
- description.focus();
- }
+
+ @Override
+ public void showEditWindow(final NamedObject object, Window main) {
+ new EditWindow(object, main, m_factories).show();
+ }
};
}
@@ -768,61 +718,11 @@ public class VaadinClient extends com.va
private void remove(GroupObject go) {
removeItem(go.getName());
}
- @Override
- public void showEditWindow(String objectName, final NamedObject object, Window main) {
- final Window featureWindow = new Window();
- featureWindow.setModal(true);
- featureWindow.setCaption("Edit " + objectName);
- featureWindow.setWidth("500px");
-
- VerticalLayout layout = (VerticalLayout) featureWindow.getContent();
- layout.setMargin(true);
- layout.setSpacing(true);
-
- final TextField name = new TextField("name");
- final TextField description = new TextField("description");
-
- name.setValue(object.getName());
- description.setValue(object.getDescription());
-
- layout.addComponent(name);
- layout.addComponent(description);
-
- TabSheet tabs = new TabSheet();
- tabs.setHeight("350px");
- Map<String, Object> context = new HashMap<String, Object>();
- context.put("object", object);
- for (UIExtensionFactory factory : m_factories) {
- com.vaadin.ui.Component component = factory.create(context);
- tabs.addTab(component);
- }
- layout.addComponent(tabs);
-
- Button close = new Button("Ok", new Button.ClickListener() {
- // inline click-listener
- public void buttonClick(ClickEvent event) {
- // close the window by removing it from the parent window
- (featureWindow.getParent()).removeWindow(featureWindow);
- // create the feature
- object.setDescription((String) description.getValue());
- }
- });
- // The components added to the window are actually added to the window's
- // layout; you can use either. Alignments are set using the layout
- layout.addComponent(close);
- layout.setComponentAlignment(close, "right");
-
- if (featureWindow.getParent() != null) {
- // window is already showing
- main.getWindow().showNotification("Window is already open");
- } else {
- // Open the subwindow by adding it to the parent
- // window
- main.getWindow().addWindow(featureWindow);
- }
- name.setReadOnly(true);
- description.focus();
- }
+
+ @Override
+ public void showEditWindow(final NamedObject object, Window main) {
+ new EditWindow(object, main, m_factories);
+ }
};
}
@@ -950,61 +850,11 @@ public class VaadinClient extends com.va
private void remove(LicenseObject distribution) {
removeItem(distribution.getName());
}
- @Override
- public void showEditWindow(String objectName, final NamedObject object, Window main) {
- final Window featureWindow = new Window();
- featureWindow.setModal(true);
- featureWindow.setCaption("Edit " + objectName);
- featureWindow.setWidth("500px");
-
- VerticalLayout layout = (VerticalLayout) featureWindow.getContent();
- layout.setMargin(true);
- layout.setSpacing(true);
-
- final TextField name = new TextField("name");
- final TextField description = new TextField("description");
-
- name.setValue(object.getName());
- description.setValue(object.getDescription());
-
- layout.addComponent(name);
- layout.addComponent(description);
-
- TabSheet tabs = new TabSheet();
- tabs.setHeight("350px");
- Map<String, Object> context = new HashMap<String, Object>();
- context.put("object", object);
- for (UIExtensionFactory factory : m_factories) {
- com.vaadin.ui.Component component = factory.create(context);
- tabs.addTab(component);
- }
- layout.addComponent(tabs);
-
- Button close = new Button("Ok", new Button.ClickListener() {
- // inline click-listener
- public void buttonClick(ClickEvent event) {
- // close the window by removing it from the parent window
- (featureWindow.getParent()).removeWindow(featureWindow);
- // create the feature
- object.setDescription((String) description.getValue());
- }
- });
- // The components added to the window are actually added to the window's
- // layout; you can use either. Alignments are set using the layout
- layout.addComponent(close);
- layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
-
- if (featureWindow.getParent() != null) {
- // window is already showing
- main.getWindow().showNotification("Window is already open");
- } else {
- // Open the subwindow by adding it to the parent
- // window
- main.getWindow().addWindow(featureWindow);
- }
- name.setReadOnly(true);
- description.focus();
- }
+
+ @Override
+ public void showEditWindow(final NamedObject object, Window main) {
+ new EditWindow(object, main, m_factories);
+ }
};
}
@@ -1083,50 +933,11 @@ public class VaadinClient extends com.va
private void remove(StatefulGatewayObject statefulTarget) {
removeItem(statefulTarget.getID());
}
- @Override
- public void showEditWindow(String objectName, final NamedObject object, Window main) {
- final Window featureWindow = new Window();
- featureWindow.setModal(true);
- featureWindow.setCaption("Edit " + objectName + ": " + object.getName());
- featureWindow.setWidth("500px");
-
- VerticalLayout layout = (VerticalLayout) featureWindow.getContent();
- layout.setMargin(true);
- layout.setSpacing(true);
-
- TabSheet tabs = new TabSheet();
- tabs.setHeight("350px");
- Map<String, Object> context = new HashMap<String, Object>();
- context.put("object", object);
- for (UIExtensionFactory factory : m_factories) {
- com.vaadin.ui.Component component = factory.create(context);
- tabs.addTab(component);
- }
- layout.addComponent(tabs);
-
- Button close = new Button("Ok", new Button.ClickListener() {
- // inline click-listener
- public void buttonClick(ClickEvent event) {
- // close the window by removing it from the parent window
- (featureWindow.getParent()).removeWindow(featureWindow);
- // create the feature
-// object.setDescription((String) description.getValue());
- }
- });
- // The components added to the window are actually added to the window's
- // layout; you can use either. Alignments are set using the layout
- layout.addComponent(close);
- layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
-
- if (featureWindow.getParent() != null) {
- // window is already showing
- main.getWindow().showNotification("Window is already open");
- } else {
- // Open the subwindow by adding it to the parent
- // window
- main.getWindow().addWindow(featureWindow);
- }
- }
+
+ @Override
+ public void showEditWindow(final NamedObject object, Window main) {
+ new EditWindow(object, main, m_factories);
+ }
};
}
@@ -1359,7 +1170,7 @@ public class VaadinClient extends com.va
String itemId = (String) event.getItemId();
RepositoryObject object = getFromId(itemId);
NamedObject namedObject = m_associations.getNamedObject(object);
- showEditWindow(name, namedObject, main);
+ showEditWindow(namedObject, main);
}
}
});
@@ -1367,7 +1178,7 @@ public class VaadinClient extends com.va
}
public abstract void populate();
protected abstract RepositoryObject getFromId(String id);
- public abstract void showEditWindow(String name, NamedObject object, Window main);
+ public abstract void showEditWindow(NamedObject object, Window main);
}
private class AddArtifactWindow extends Window {
|