You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kalumet-commits@incubator.apache.org by jb...@apache.org on 2011/11/23 20:52:25 UTC
svn commit: r1205585 [5/23] - in /incubator/kalumet/trunk: ./ console/
console/src/main/java/org/apache/kalumet/console/app/
console/src/main/resources/org/apache/kalumet/console/app/templates/
Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagersPane.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagersPane.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagersPane.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationContentManagersPane.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,415 @@
+/*
+ * 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.kalumet.console.app;
+
+import java.util.Iterator;
+
+import nextapp.echo2.app.Button;
+import nextapp.echo2.app.Column;
+import nextapp.echo2.app.ContentPane;
+import nextapp.echo2.app.Extent;
+import nextapp.echo2.app.Grid;
+import nextapp.echo2.app.Insets;
+import nextapp.echo2.app.Label;
+import nextapp.echo2.app.Row;
+import nextapp.echo2.app.event.ActionEvent;
+import nextapp.echo2.app.event.ActionListener;
+import org.apache.kalumet.console.configuration.ConfigurationManager;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.ContentManager;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.ws.client.ContentManagerClient;
+
+/**
+ * J2EE application content managers pane.
+ */
+public class ApplicationContentManagersPane extends ContentPane {
+
+ private ApplicationWindow parent;
+ private Grid grid;
+
+ class UpdateThread extends Thread {
+
+ public String contentManagerName;
+ public boolean ended = false;
+ public boolean failure = false;
+ public String message;
+
+ public void run() {
+ try {
+ // load Kalumet configuration
+ Kalumet kalumet = ConfigurationManager.loadStore();
+ // looking for the agent
+ Agent agent = kalumet.getAgent(parent.getParentPane().getEnvironmentWindow().getEnvironment().getAgent());
+ if (agent == null) {
+ throw new IllegalArgumentException("agent not found.");
+ }
+ // call the webservice
+ ContentManagerClient client = new ContentManagerClient(agent.getHostname(), agent.getPort());
+ client.update(parent.getParentPane().getEnvironmentWindow().getEnvironmentName(), parent.getServerName(), parent.getApplicationName(), contentManagerName, false);
+ } catch (Exception e) {
+ failure = true;
+ message = "J2EE application " + parent.getApplicationName() + " content manager " + contentManagerName + " update failed: " + e.getMessage();
+ } finally {
+ ended = true;
+ }
+ }
+ }
+
+ // toggle active
+ private ActionListener toggleActive = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // looking for the content manager object
+ ContentManager contentManager = parent.getApplication().getContentManager(event.getActionCommand());
+ if (contentManager == null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("contentmanager.notfound"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // change the state and add a change event
+ if (contentManager.isActive()) {
+ contentManager.setActive(false);
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add("Disable J2EE application " + parent.getApplicationName() + " content manager " + contentManager.getName());
+ } else {
+ contentManager.setActive(true);
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add("Enable J2EE application " + parent.getApplicationName() + " content manager " + contentManager.getName());
+ }
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+ // toggle blocker
+ private ActionListener toggleBlocker = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // looking for the content manager object
+ ContentManager contentManager = parent.getApplication().getContentManager(event.getActionCommand());
+ if (contentManager == null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("contentmanager.notfound"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // change the blocker state and add a change event
+ if (contentManager.isBlocker()) {
+ contentManager.setBlocker(false);
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add("Set not blocker for J2EE application " + parent.getApplicationName() + " content manager " + contentManager.getName());
+ } else {
+ contentManager.setBlocker(true);
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add("Set blocker for J2EE application " + parent.getApplicationName() + " content manager " + contentManager.getName());
+ }
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+ // delete
+ private ActionListener delete = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // looking for the content manager object
+ final ContentManager contentManager = parent.getApplication().getContentManager(event.getActionCommand());
+ if (contentManager == null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("contentmanager.notfound"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // delete the content manager object
+ parent.getApplication().getContentManagers().remove(contentManager);
+ // add a change event
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add("Delete J2EE application " + parent.getApplicationName() + " content manager " + contentManager.getName());
+ // change the updated flag
+ parent.getParentPane().getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ }));
+ }
+ };
+ // update
+ private ActionListener update = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the lock
+ if (!parent.getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if a change has not been saved
+ if (parent.getParentPane().getEnvironmentWindow().isUpdated()) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.notsaved"), parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // get the content manager name
+ final String contentManagerName = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo("J2EE application " + parent.getApplicationName() + " content manager " + contentManagerName + " update in progress...", parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add("J2EE application " + parent.getApplicationName() + " content manager " + contentManagerName + " update requested.");
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ updateThread.contentManagerName = contentManagerName;
+ updateThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable() {
+ public void run() {
+ if (updateThread.ended) {
+ if (updateThread.failure) {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(updateThread.message, parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add(updateThread.message);
+ } else {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm("J2EE application " + parent.getApplicationName() + " content manager " + contentManagerName + " updated.", parent.getParentPane().getEnvironmentWindow().getEnvironmentName());
+ parent.getParentPane().getEnvironmentWindow().getChangeEvents().add("J2EE application " + parent.getApplicationName() + " content manager " + contentManagerName + " updated.");
+ }
+ } else {
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), this);
+ }
+ }
+ });
+ }
+ }));
+ }
+ };
+ // edit
+ private ActionListener edit = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if (KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent(
+ "contentmanagerwindow_" + parent.getParentPane().getEnvironmentWindow().getEnvironmentName() + "_" + parent.getServerName() + "_" + parent.getApplicationName() + "_" + event.getActionCommand()) == null) {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ApplicationContentManagerWindow(ApplicationContentManagersPane.this, event.getActionCommand()));
+ }
+ }
+ };
+ // create
+ private ActionListener create = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ApplicationContentManagerWindow(ApplicationContentManagersPane.this, null));
+ }
+ };
+ // copy
+ private ActionListener copy = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // looking for the content manager object
+ ContentManager contentManager = parent.getApplication().getContentManager(event.getActionCommand());
+ if (contentManager == null) {
+ return;
+ }
+ try {
+ KalumetConsoleApplication.getApplication().setCopyComponent(contentManager.clone());
+ } catch (Exception e) {
+ return;
+ }
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationContentManagersPane</code>.
+ *
+ * @param parent the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationContentManagersPane(ApplicationWindow parent) {
+ super();
+ setStyleName("tab.content");
+
+ // update parent
+ this.parent = parent;
+
+ // column layout content
+ Column content = new Column();
+ add(content);
+
+ // add the create button
+ if (parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ Button createButton = new Button(Messages.getString("contentmanager.add"), Styles.ADD);
+ createButton.addActionListener(create);
+ content.add(createButton);
+ }
+
+ // add the content managers grid
+ grid = new Grid(4);
+ grid.setStyleName("border.grid");
+ grid.setColumnWidth(0, new Extent(50, Extent.PX));
+ content.add(grid);
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane
+ */
+ public void update() {
+ // remove all content mangers grid children
+ grid.removeAll();
+ // add content managers grid header
+ // action header
+ Label actionHeader = new Label(" ");
+ actionHeader.setStyleName("grid.header");
+ grid.add(actionHeader);
+ // name header
+ Label nameHeader = new Label(Messages.getString("name"));
+ nameHeader.setStyleName("grid.header");
+ grid.add(nameHeader);
+ // classname header
+ Label classnameHeader = new Label(Messages.getString("classname"));
+ classnameHeader.setStyleName("grid.header");
+ grid.add(classnameHeader);
+ // agent header
+ Label agentHeader = new Label(Messages.getString("agent"));
+ agentHeader.setStyleName("grid.header");
+ grid.add(agentHeader);
+ // add content manager
+ for (Iterator contentManagerIterator = parent.getApplication().getContentManagers().iterator(); contentManagerIterator.hasNext(); ) {
+ ContentManager contentManager = (ContentManager) contentManagerIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing(new Extent(2));
+ row.setInsets(new Insets(2));
+ grid.add(row);
+ // copy
+ Button copyButton = new Button(Styles.PAGE_COPY);
+ copyButton.setToolTipText(Messages.getString("copy"));
+ copyButton.setActionCommand(contentManager.getName());
+ copyButton.addActionListener(copy);
+ row.add(copyButton);
+ // active
+ Button activeButton;
+ if (contentManager.isActive()) {
+ activeButton = new Button(Styles.LIGHTBULB);
+ activeButton.setToolTipText(Messages.getString("switch.disable"));
+ } else {
+ activeButton = new Button(Styles.LIGHTBULB_OFF);
+ activeButton.setToolTipText(Messages.getString("switch.enable"));
+ }
+ if (parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ activeButton.setActionCommand(contentManager.getName());
+ activeButton.addActionListener(toggleActive);
+ }
+ row.add(activeButton);
+ // blocker
+ Button blockerButton;
+ if (contentManager.isBlocker()) {
+ blockerButton = new Button(Styles.PLUGIN);
+ blockerButton.setToolTipText(Messages.getString("switch.notblocker"));
+ } else {
+ blockerButton = new Button(Styles.PLUGIN_DISABLED);
+ blockerButton.setToolTipText(Messages.getString("switch.blocker"));
+ }
+ if (parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ blockerButton.setActionCommand(contentManager.getName());
+ blockerButton.addActionListener(toggleBlocker);
+ }
+ row.add(blockerButton);
+ // up
+ // TODO
+ // down
+ // TODO
+ // update
+ if (parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsUpdatePermission) {
+ Button updateButton = new Button(Styles.COG);
+ updateButton.setToolTipText(Messages.getString("update"));
+ updateButton.setActionCommand(contentManager.getName());
+ updateButton.addActionListener(update);
+ row.add(updateButton);
+ }
+ // delete
+ if (parent.getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ Button deleteButton = new Button(Styles.DELETE);
+ deleteButton.setToolTipText(Messages.getString("delete"));
+ deleteButton.setActionCommand(contentManager.getName());
+ deleteButton.addActionListener(delete);
+ row.add(deleteButton);
+ }
+ // name
+ Button name = new Button(contentManager.getName());
+ name.setStyleName("default");
+ name.setActionCommand(contentManager.getName());
+ name.addActionListener(edit);
+ grid.add(name);
+ // classname
+ Label classname = new Label(contentManager.getClassname());
+ classname.setStyleName("default");
+ grid.add(classname);
+ // agent
+ Label agent = new Label(contentManager.getAgent());
+ agent.setStyleName("default");
+ grid.add(agent);
+ }
+ }
+
+ /**
+ * Get the parent <code>ApplicationWindow</code>.
+ *
+ * @return the parent <code>ApplicationWindow</code>.
+ */
+ public ApplicationWindow getParentPane() {
+ return parent;
+ }
+
+}
Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseSqlScriptWindow.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseSqlScriptWindow.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseSqlScriptWindow.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationDatabaseSqlScriptWindow.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,642 @@
+/*
+ * 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.kalumet.console.app;
+
+import java.util.Iterator;
+
+import nextapp.echo2.app.Button;
+import nextapp.echo2.app.ContentPane;
+import nextapp.echo2.app.Extent;
+import nextapp.echo2.app.Grid;
+import nextapp.echo2.app.Insets;
+import nextapp.echo2.app.Label;
+import nextapp.echo2.app.Row;
+import nextapp.echo2.app.SelectField;
+import nextapp.echo2.app.SplitPane;
+import nextapp.echo2.app.TextField;
+import nextapp.echo2.app.WindowPane;
+import nextapp.echo2.app.event.ActionEvent;
+import nextapp.echo2.app.event.ActionListener;
+import nextapp.echo2.extras.app.TabPane;
+import nextapp.echo2.extras.app.layout.TabPaneLayoutData;
+import org.apache.kalumet.model.Mapping;
+import org.apache.kalumet.model.SqlScript;
+
+/**
+ * J2EE application database sql script window.
+ */
+public class ApplicationDatabaseSqlScriptWindow extends WindowPane {
+
+ private String sqlScriptName;
+ private SqlScript sqlScript;
+ private ApplicationDatabaseWindow parent;
+ private TextField nameField;
+ private SelectField activeField;
+ private SelectField blockerField;
+ private SelectField forceField;
+ private TextField uriField;
+ private Grid mappingsGrid;
+ private TextField newMappingKeyField;
+ private TextField newMappingValueField;
+
+ // refresh
+ private ActionListener refresh = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // looking for the sql script object
+ ApplicationDatabaseSqlScriptWindow.this.sqlScript = parent.getDatabase().getSqlScript(sqlScriptName);
+ if (ApplicationDatabaseSqlScriptWindow.this.sqlScript == null) {
+ ApplicationDatabaseSqlScriptWindow.this.sqlScript = new SqlScript();
+ }
+ // update the window
+ update();
+ }
+ };
+ // close
+ private ActionListener close = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ ApplicationDatabaseSqlScriptWindow.this.userClose();
+ }
+ };
+ // delete
+ private ActionListener delete = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // delete the sql script
+ parent.getDatabase().getSqlScripts().remove(sqlScript);
+ // add a change event
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add("Delete SQL script " + sqlScript.getName());
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent pane
+ parent.update();
+ // close the window
+ ApplicationDatabaseSqlScriptWindow.this.userClose();
+ }
+ }));
+ }
+ };
+ // apply
+ private ActionListener apply = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // get the fields value
+ String nameFieldValue = nameField.getText();
+ int activeFieldIndex = activeField.getSelectedIndex();
+ int blockerFieldIndex = blockerField.getSelectedIndex();
+ int forceFieldIndex = forceField.getSelectedIndex();
+ String uriFieldValue = uriField.getText();
+ // check fields
+ if (nameFieldValue == null || nameFieldValue.trim().length() < 1 || uriFieldValue == null || uriFieldValue.trim().length() < 1) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("sql.script.mandatory"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // if the user change the sql script name, check if the new name
+ // doesn't already exist
+ if (sqlScriptName == null || (sqlScriptName != null && !sqlScriptName.equals(nameFieldValue))) {
+ if (parent.getDatabase().getSqlScript(nameFieldValue) != null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("sql.script.exists"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ }
+ // add a change event
+ if (sqlScriptName != null) {
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add("Change SQL script " + sqlScript.getName());
+ }
+ // update the sql script object
+ sqlScript.setName(nameFieldValue);
+ if (activeFieldIndex == 0) {
+ sqlScript.setActive(true);
+ } else {
+ sqlScript.setActive(false);
+ }
+ if (blockerFieldIndex == 0) {
+ sqlScript.setBlocker(true);
+ } else {
+ sqlScript.setBlocker(false);
+ }
+ if (forceFieldIndex == 0) {
+ sqlScript.setForce(true);
+ } else {
+ sqlScript.setForce(false);
+ }
+ sqlScript.setUri(uriFieldValue);
+ // add the sql script object if needed
+ if (sqlScriptName == null) {
+ try {
+ parent.getDatabase().addSqlScript(sqlScript);
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add("Add SQL script " + sqlScript.getName());
+ } catch (Exception e) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("sql.script.exists"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ }
+ // update the window definition
+ setTitle(Messages.getString("sql.script") + " " + sqlScript.getName());
+ setId("sqlscriptwindow_" + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_" + sqlScript.getName());
+ sqlScriptName = sqlScript.getName();
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the parent window
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+ // delete mapping
+ public ActionListener deleteMapping = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // looking for the mapping object
+ Mapping mapping = sqlScript.getMapping(event.getActionCommand());
+ if (mapping == null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("mapping.notfound"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // delete the mapping object
+ sqlScript.getMappings().remove(mapping);
+ // add a change event
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add("Delete SQL script " + sqlScript.getName() + " mapping " + mapping.getKey());
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+ // edit mapping
+ private ActionListener editMapping = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // get fields
+ TextField mappingKeyField = (TextField) ApplicationDatabaseSqlScriptWindow.this.getComponent("mappingkey_"
+ + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_" + sqlScriptName + "_" + event.getActionCommand());
+ TextField mappingValueField = (TextField) ApplicationDatabaseSqlScriptWindow.this.getComponent("mappingvalue_"
+ + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_" + sqlScriptName + "_" + event.getActionCommand());
+ // get fields value
+ String mappingKeyFieldValue = mappingKeyField.getText();
+ String mappingValueFieldValue = mappingValueField.getText();
+ // check fields
+ if (mappingKeyFieldValue == null || mappingKeyFieldValue.trim().length() < 1) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("mapping.mandatory"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // if the user change the mapping key, check if the key doesn't already
+ // exists
+ if (!mappingKeyFieldValue.equals(event.getActionCommand())) {
+ if (sqlScript.getMapping(mappingKeyFieldValue) != null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("mapping.exists"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ }
+ // looking for the mapping object
+ Mapping mapping = sqlScript.getMapping(event.getActionCommand());
+ if (mapping == null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("mapping.notfound"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // add change event
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add("Change SQL script " + sqlScript.getName() + " mapping " + mapping.getKey());
+ // update the mapping
+ mapping.setKey(mappingKeyFieldValue);
+ mapping.setValue(mappingValueFieldValue);
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+ // create mapping
+ private ActionListener createMapping = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ && !parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // get fields value
+ String newMappingKeyFieldValue = newMappingKeyField.getText();
+ String newMappingValueFieldValue = newMappingValueField.getText();
+ // check fields
+ if (newMappingKeyFieldValue == null || newMappingKeyFieldValue.trim().length() < 1) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("mapping.mandatory"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // create the mapping object
+ Mapping mapping = new Mapping();
+ mapping.setKey(newMappingKeyFieldValue);
+ mapping.setValue(newMappingValueFieldValue);
+ try {
+ sqlScript.addMapping(mapping);
+ } catch (Exception e) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("mapping.exists"), parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // add a change event
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getChangeEvents().add("Add SQL script " + sqlScript.getName() + " mapping " + mapping.getKey());
+ // change the updated flag
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().updateJournalPane();
+ // update the window
+ update();
+ }
+ };
+ // copy
+ private ActionListener copy = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ KalumetConsoleApplication.getApplication().setCopyComponent(sqlScript.clone());
+ } catch (Exception e) {
+ return;
+ }
+ }
+ };
+ // paste
+ private ActionListener paste = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if (copy == null || !(copy instanceof SqlScript)) {
+ return;
+ }
+ sqlScript = (SqlScript) copy;
+ sqlScriptName = null;
+ // update the parent pane
+ parent.update();
+ // update the window
+ update();
+ }
+ };
+ // copy mapping
+ private ActionListener copyMapping = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // looking for the mapping object
+ Mapping mapping = sqlScript.getMapping(event.getActionCommand());
+ if (mapping == null) {
+ return;
+ }
+ try {
+ KalumetConsoleApplication.getApplication().setCopyComponent(mapping.clone());
+ } catch (Exception e) {
+ return;
+ }
+ }
+ };
+ // paste mapping
+ private ActionListener pasteMapping = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ // check if the copy is correct
+ if (copy == null || !(copy instanceof Mapping)) {
+ return;
+ }
+ // update new field
+ newMappingKeyField.setText(((Mapping) copy).getKey());
+ newMappingValueField.setText(((Mapping) copy).getValue());
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationDatabaseSqlScriptWindow</code>.
+ *
+ * @param parent the parent <code>ApplicationDatabaseWindow</code>.
+ * @param sqlScriptName the original <code>SqlScript</code> name.
+ */
+ public ApplicationDatabaseSqlScriptWindow(ApplicationDatabaseWindow parent, String sqlScriptName) {
+ super();
+
+ // update the parent pane
+ this.parent = parent;
+
+ // update the sql script name
+ this.sqlScriptName = sqlScriptName;
+
+ // update the sql script object from the parent pane
+ this.sqlScript = parent.getDatabase().getSqlScript(sqlScriptName);
+ if (this.sqlScript == null) {
+ this.sqlScript = new SqlScript();
+ }
+
+ if (sqlScriptName == null) {
+ setTitle(Messages.getString("sql.script"));
+ } else {
+ setTitle(Messages.getString("sql.script") + " " + sqlScriptName);
+ }
+ setId("sqlscriptwindow_" + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_" + parent.getParentPane().getParentPane().getServerName() + "_"
+ + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_" + sqlScriptName);
+ setStyleName("default");
+ setModal(false);
+ setDefaultCloseOperation(WindowPane.DISPOSE_ON_CLOSE);
+
+ // create a split pane for the control buttons
+ SplitPane splitPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent(32));
+ add(splitPane);
+
+ // add the control pane
+ Row controlRow = new Row();
+ controlRow.setStyleName("control");
+ splitPane.add(controlRow);
+ // add the refresh button
+ Button refreshButton = new Button(Messages.getString("reload"), Styles.DATABASE_REFRESH);
+ refreshButton.setStyleName("control");
+ refreshButton.addActionListener(refresh);
+ controlRow.add(refreshButton);
+ // add the copy button
+ Button copyButton = new Button(Messages.getString("copy"), Styles.PAGE_COPY);
+ copyButton.setStyleName("control");
+ copyButton.addActionListener(copy);
+ controlRow.add(copyButton);
+ if (parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().adminPermission
+ || parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().jeeApplicationsPermission) {
+ // add the paste button
+ Button pasteButton = new Button(Messages.getString("paste"), Styles.PAGE_PASTE);
+ pasteButton.setStyleName("control");
+ pasteButton.addActionListener(paste);
+ controlRow.add(pasteButton);
+ // add the apply button
+ Button applyButton = new Button(Messages.getString("apply"), Styles.ACCEPT);
+ applyButton.setStyleName("control");
+ applyButton.addActionListener(apply);
+ controlRow.add(applyButton);
+ // add the delete button
+ Button deleteButton = new Button(Messages.getString("delete"), Styles.DELETE);
+ deleteButton.setStyleName("control");
+ deleteButton.addActionListener(delete);
+ controlRow.add(deleteButton);
+ }
+ // add the close button
+ Button closeButton = new Button(Messages.getString("close"), Styles.CROSS);
+ closeButton.setStyleName("control");
+ closeButton.addActionListener(close);
+ controlRow.add(closeButton);
+
+ // add the main tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName("default");
+ splitPane.add(tabPane);
+
+ // add the general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle(Messages.getString("general"));
+ ContentPane generalTabPane = new ContentPane();
+ generalTabPane.setStyleName("tab.content");
+ generalTabPane.setLayoutData(tabLayoutData);
+ tabPane.add(generalTabPane);
+
+ Grid generalLayoutGrid = new Grid(2);
+ generalLayoutGrid.setStyleName("default");
+ generalLayoutGrid.setColumnWidth(0, new Extent(20, Extent.PERCENT));
+ generalLayoutGrid.setColumnWidth(1, new Extent(80, Extent.PERCENT));
+ generalTabPane.add(generalLayoutGrid);
+ // name
+ Label nameLabel = new Label(Messages.getString("name"));
+ nameLabel.setStyleName("grid.cell");
+ generalLayoutGrid.add(nameLabel);
+ nameField = new TextField();
+ nameField.setStyleName("default");
+ nameField.setWidth(new Extent(100, Extent.PERCENT));
+ generalLayoutGrid.add(nameField);
+ // active
+ Label activeLabel = new Label(Messages.getString("active"));
+ activeLabel.setStyleName("grid.cell");
+ generalLayoutGrid.add(activeLabel);
+ activeField = new SelectField(MainScreen.LABELS);
+ activeField.setSelectedIndex(0);
+ activeField.setStyleName("default");
+ activeField.setWidth(new Extent(10, Extent.EX));
+ generalLayoutGrid.add(activeField);
+ Label blockerLabel = new Label(Messages.getString("blocker"));
+ blockerLabel.setStyleName("grid.cell");
+ generalLayoutGrid.add(blockerLabel);
+ blockerField = new SelectField(MainScreen.LABELS);
+ blockerField.setSelectedIndex(0);
+ blockerField.setStyleName("default");
+ blockerField.setWidth(new Extent(10, Extent.EX));
+ generalLayoutGrid.add(blockerField);
+ Label forceLabel = new Label(Messages.getString("force"));
+ forceLabel.setStyleName("grid.cell");
+ generalLayoutGrid.add(forceLabel);
+ forceField = new SelectField(MainScreen.LABELS);
+ forceField.setSelectedIndex(0);
+ forceField.setStyleName("default");
+ forceField.setWidth(new Extent(10, Extent.EX));
+ generalLayoutGrid.add(forceField);
+ Label uriLabel = new Label(Messages.getString("uri"));
+ uriLabel.setStyleName("grid.cell");
+ generalLayoutGrid.add(uriLabel);
+ uriField = new TextField();
+ uriField.setStyleName("default");
+ uriField.setWidth(new Extent(100, Extent.PERCENT));
+ generalLayoutGrid.add(uriField);
+
+ // add the mappings tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle(Messages.getString("mappings"));
+ ContentPane mappingsTabPane = new ContentPane();
+ mappingsTabPane.setStyleName("tab.content");
+ mappingsTabPane.setLayoutData(tabLayoutData);
+ tabPane.add(mappingsTabPane);
+ mappingsGrid = new Grid(3);
+ mappingsGrid.setStyleName("grid.border");
+ mappingsGrid.setColumnWidth(0, new Extent(50, Extent.PX));
+ mappingsGrid.setColumnWidth(1, new Extent(50, Extent.PERCENT));
+ mappingsGrid.setColumnWidth(2, new Extent(50, Extent.PERCENT));
+ mappingsTabPane.add(mappingsGrid);
+
+ // update the window
+ update();
+ }
+
+ /**
+ * Update the window.
+ */
+ public void update() {
+ // update the sql script name field
+ nameField.setText(sqlScript.getName());
+ // update the sql script active field
+ if (sqlScript.isActive()) {
+ activeField.setSelectedIndex(0);
+ } else {
+ activeField.setSelectedIndex(1);
+ }
+ // update the sql script blocker field
+ if (sqlScript.isBlocker()) {
+ blockerField.setSelectedIndex(0);
+ } else {
+ blockerField.setSelectedIndex(1);
+ }
+ // update the sql script force field
+ if (sqlScript.isForce()) {
+ forceField.setSelectedIndex(0);
+ } else {
+ forceField.setSelectedIndex(1);
+ }
+ // update the sql script uri field
+ uriField.setText(sqlScript.getUri());
+
+ // remove all mappings grid children
+ mappingsGrid.removeAll();
+ // add mappings grid header
+ Label mappingActionHeader = new Label(" ");
+ mappingActionHeader.setStyleName("grid.header");
+ mappingsGrid.add(mappingActionHeader);
+ Label mappingKeyHeader = new Label(Messages.getString("key"));
+ mappingKeyHeader.setStyleName("grid.header");
+ mappingsGrid.add(mappingKeyHeader);
+ Label mappingValueHeader = new Label(Messages.getString("value"));
+ mappingValueHeader.setStyleName("grid.header");
+ mappingsGrid.add(mappingValueHeader);
+ // add mapping
+ for (Iterator mappingIterator = sqlScript.getMappings().iterator(); mappingIterator.hasNext(); ) {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ // row
+ Row row = new Row();
+ row.setCellSpacing(new Extent(2));
+ row.setInsets(new Insets(2));
+ mappingsGrid.add(row);
+ // mapping copy
+ Button copyButton = new Button(Styles.PAGE_COPY);
+ copyButton.setToolTipText(Messages.getString("copy"));
+ copyButton.setActionCommand(mapping.getKey());
+ copyButton.addActionListener(copyMapping);
+ row.add(copyButton);
+ // mapping delete / edit
+ if (parent.getEnvironmentWindow().adminPermission
+ || parent.getEnvironmentWindow().jeeApplicationsPermission) {
+ // mapping delete
+ Button deleteButton = new Button(Styles.DELETE);
+ deleteButton.setToolTipText(Messages.getString("delete"));
+ deleteButton.setActionCommand(mapping.getKey());
+ deleteButton.addActionListener(deleteMapping);
+ row.add(deleteButton);
+ // mapping apply
+ Button applyButton = new Button(Styles.ACCEPT);
+ applyButton.setToolTipText(Messages.getString("apply"));
+ applyButton.setActionCommand(mapping.getKey());
+ applyButton.addActionListener(editMapping);
+ row.add(applyButton);
+ }
+ // mapping key
+ TextField mappingKeyField = new TextField();
+ mappingKeyField.setStyleName("default");
+ mappingKeyField.setWidth(new Extent(100, Extent.PERCENT));
+ mappingKeyField.setId("mappingkey_" + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getParentPane().getServerName() + "_" + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_" + sqlScriptName + "_" + mapping.getKey());
+ mappingKeyField.setText(mapping.getKey());
+ mappingsGrid.add(mappingKeyField);
+ // mapping value
+ TextField mappingValueField = new TextField();
+ mappingValueField.setStyleName("default");
+ mappingValueField.setWidth(new Extent(100, Extent.PERCENT));
+ mappingValueField.setId("mappingvalue_" + parent.getParentPane().getParentPane().getParentPane().getEnvironmentWindow().getEnvironmentName() + "_"
+ + parent.getParentPane().getParentPane().getServerName() + "_" + parent.getParentPane().getParentPane().getApplicationName() + "_" + parent.getDatabaseName() + "_" + sqlScriptName + "_" + mapping.getKey());
+ mappingValueField.setText(mapping.getValue());
+ mappingsGrid.add(mappingValueField);
+ }
+ // add a new mapping
+ if (parent.getEnvironmentWindow().adminPermission
+ || parent.getEnvironmentWindow().jeeApplicationsPermission) {
+ // row
+ Row row = new Row();
+ row.setCellSpacing(new Extent(2));
+ row.setInsets(new Insets(2));
+ mappingsGrid.add(row);
+ // paste
+ Button pasteButton = new Button(Styles.PAGE_PASTE);
+ pasteButton.setToolTipText(Messages.getString("paste"));
+ pasteButton.addActionListener(pasteMapping);
+ row.add(pasteButton);
+ // add
+ Button addButton = new Button(Styles.ADD);
+ addButton.setToolTipText(Messages.getString("add"));
+ addButton.addActionListener(createMapping);
+ row.add(addButton);
+ // new mapping key
+ newMappingKeyField = new TextField();
+ newMappingKeyField.setStyleName("default");
+ newMappingKeyField.setWidth(new Extent(100, Extent.PERCENT));
+ mappingsGrid.add(newMappingKeyField);
+ // new mapping value
+ newMappingValueField = new TextField();
+ newMappingValueField.setStyleName("default");
+ newMappingValueField.setWidth(new Extent(100, Extent.PERCENT));
+ mappingsGrid.add(newMappingValueField);
+ }
+ }
+
+}