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 [7/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/ApplicationServerCachesPane.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerCachesPane.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerCachesPane.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerCachesPane.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,304 @@
+/*
+ * 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.TextField;
+import nextapp.echo2.app.event.ActionEvent;
+import nextapp.echo2.app.event.ActionListener;
+import org.apache.kalumet.model.Cache;
+
+/**
+ * J2EE application server caches pane.
+ */
+public class ApplicationServerCachesPane extends ContentPane {
+
+ private ApplicationServerWindow parent;
+
+ private Grid grid;
+ private TextField newPathField;
+
+ // delete
+ private ActionListener delete = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeServersPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restrictied"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // get the cache path
+ final String cachePath = event.getActionCommand();
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // looking for the cache object
+ Cache cache = parent.getApplicationServer().getCache(cachePath);
+ if (cache == null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("cache.notfound"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // remove the cache
+ parent.getApplicationServer().getCaches().remove(cache);
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add("Delete cache " + cache.getPath());
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ }));
+ }
+ };
+ // edit
+ private ActionListener edit = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeServersPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // get the cache path
+ String cachePath = event.getActionCommand();
+ // get the cache path field
+ TextField cachePathField = (TextField) ApplicationServerCachesPane.this.getComponent("pathfield_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + parent.getApplicationServerName() + "_" + cachePath);
+ // get the cache path field value
+ String cachePathFieldValue = cachePathField.getText();
+ // check mandatory field
+ if (cachePathFieldValue == null || cachePathFieldValue.trim().length() < 1) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("cache.mandatory"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // if the user change the cache path, check if the cache path doesn't
+ // already exist
+ if (!cachePath.equals(cachePathFieldValue)) {
+ if (parent.getApplicationServer().getCache(cachePathFieldValue) != null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("cache.exists"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ }
+ // looking for the cache object
+ Cache cache = parent.getApplicationServer().getCache(cachePath);
+ if (cache == null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("cache.notfound"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add("Change cache " + cache.getPath());
+ // update the cache object
+ cache.setPath(cachePathFieldValue);
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+ // create
+ private ActionListener create = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeServersPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // get cache path value
+ String newPathFieldValue = newPathField.getText();
+ // check mandatory field
+ if (newPathFieldValue == null || newPathFieldValue.trim().length() < 1) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("cache.mandatory"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // create a new cache object
+ Cache cache = new Cache();
+ cache.setPath(newPathFieldValue);
+ try {
+ parent.getApplicationServer().addCache(cache);
+ } catch (Exception e) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("cache.exists"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add("Add cache " + cache.getPath());
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated(true);
+ // update the journal log tab pane
+ parent.getEnvironmentWindow().updateJournalPane();
+ // update the pane
+ update();
+ }
+ };
+ // copy
+ private ActionListener copy = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // looking for the cache object
+ Cache cache = parent.getApplicationServer().getCache(event.getActionCommand());
+ if (cache == null) {
+ return;
+ }
+ try {
+ // put the cache clone in the copy component
+ KalumetConsoleApplication.getApplication().setCopyComponent(cache.clone());
+ } catch (Exception e) {
+ return;
+ }
+ }
+ };
+ // paste
+ private ActionListener paste = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the copy is correct
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ if (copy == null || !(copy instanceof Cache)) {
+ return;
+ }
+ // update the new fields
+ newPathField.setText(((Cache) copy).getPath());
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationServerCachesPane</code>.
+ *
+ * @param parent the parent <code>ApplicationServerWindow</code>.
+ */
+ public ApplicationServerCachesPane(ApplicationServerWindow parent) {
+ super();
+ setStyleName("tab.content");
+
+ // update parent
+ this.parent = parent;
+
+ // add the caches grid
+ grid = new Grid(2);
+ grid.setStyleName("border.grid");
+ grid.setColumnWidth(0, new Extent(50, Extent.PX));
+ add(grid);
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update() {
+ // remove all caches grid children
+ grid.removeAll();
+ // action header
+ Label actionHeader = new Label(" ");
+ actionHeader.setStyleName("grid.header");
+ grid.add(actionHeader);
+ Label pathHeader = new Label(Messages.getString("path"));
+ pathHeader.setStyleName("grid.header");
+ grid.add(pathHeader);
+ // add cache
+ for (Iterator cacheIterator = parent.getApplicationServer().getCaches().iterator(); cacheIterator.hasNext(); ) {
+ Cache cache = (Cache) cacheIterator.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(cache.getPath());
+ copyButton.addActionListener(copy);
+ row.add(copyButton);
+ // delete / edit
+ if (getEnvironmentWindow().adminPermission
+ || getEnvironmentWindow().jeeServersPermission) {
+ // edit
+ Button editButton = new Button(Styles.ACCEPT);
+ editButton.setActionCommand(cache.getPath());
+ editButton.addActionListener(edit);
+ row.add(editButton);
+ // delete
+ Button deleteButton = new Button(Styles.DELETE);
+ deleteButton.setToolTipText(Messages.getString("delete"));
+ deleteButton.setActionCommand(cache.getPath());
+ deleteButton.addActionListener(delete);
+ row.add(deleteButton);
+ }
+ // path
+ TextField cachePathField = new TextField();
+ cachePathField.setId("pathfield_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + parent.getApplicationServerName() + "_" + cache.getPath());
+ cachePathField.setStyleName("default");
+ cachePathField.setWidth(new Extent(100, Extent.PERCENT));
+ cachePathField.setText(cache.getPath());
+ grid.add(cachePathField);
+ }
+ // add cache adding row
+ if (getEnvironmentWindow().adminPermission
+ || getEnvironmentWindow().jeeServersPermission) {
+ // row
+ Row row = new Row();
+ row.setCellSpacing(new Extent(2));
+ row.setInsets(new Insets(2));
+ grid.add(row);
+ // paste
+ Button pasteButton = new Button(Styles.PAGE_PASTE);
+ pasteButton.addActionListener(paste);
+ row.add(pasteButton);
+ // add
+ Button addButton = new Button(Styles.ADD);
+ addButton.addActionListener(create);
+ row.add(addButton);
+ // path
+ newPathField = new TextField();
+ newPathField.setStyleName("default");
+ newPathField.setWidth(new Extent(100, Extent.PERCENT));
+ grid.add(newPathField);
+ }
+ }
+
+ public EnvironmentWindow getEnvironmentWindow() {
+ return parent.getEnvironmentWindow();
+ }
+
+}
Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerGeneralPane.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerGeneralPane.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerGeneralPane.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerGeneralPane.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,340 @@
+/*
+ * 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.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.PasswordField;
+import nextapp.echo2.app.SelectField;
+import nextapp.echo2.app.TextArea;
+import nextapp.echo2.app.TextField;
+import nextapp.echo2.app.list.DefaultListModel;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.kalumet.console.configuration.ConfigurationManager;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.Kalumet;
+
+/**
+ * J2EE application server general pane.
+ */
+public class ApplicationServerGeneralPane extends ContentPane {
+
+ private static String[] APPLICATIONSERVER_TYPES = new String[]{Messages.getString("jboss4"), Messages.getString("weblogic8"),
+ Messages.getString("websphere5")};
+
+ private ApplicationServerWindow parent;
+ private TextField nameField;
+ private SelectField activeField;
+ private SelectField blockerField;
+ private SelectField typeField;
+ private TextField jmxField;
+ private TextField adminUserField;
+ private PasswordField adminPasswordField;
+ private PasswordField adminConfirmPasswordField;
+ private SelectField agentField;
+ private SelectField updateRequireRestartField;
+ private SelectField updateRequireCachesClean;
+ private SelectField stopUsingJmx;
+ private TextArea startupCommandArea;
+ private TextArea shutdownCommandArea;
+
+ /**
+ * Create a new <code>ApplicationServerGeneralPane</code>.
+ *
+ * @param parent the parent <code>ApplicationServerWindow</code>.
+ */
+ public ApplicationServerGeneralPane(ApplicationServerWindow parent) {
+ super();
+ setStyleName("tab.content");
+
+ // update parent
+ this.parent = parent;
+
+ // add the general layout grid
+ Grid layout = new Grid(2);
+ layout.setStyleName("default");
+ layout.setColumnWidth(0, new Extent(20, Extent.PERCENT));
+ layout.setColumnWidth(1, new Extent(80, Extent.PERCENT));
+ layout.setInsets(new Insets(2));
+ add(layout);
+
+ // add the name field
+ Label nameLabel = new Label(Messages.getString("name"));
+ nameLabel.setStyleName("grid.cell");
+ layout.add(nameLabel);
+ nameField = new TextField();
+ nameField.setStyleName("default");
+ nameField.setWidth(new Extent(100, Extent.PERCENT));
+ layout.add(nameField);
+ // add the active select field
+ Label activeLabel = new Label(Messages.getString("active"));
+ activeLabel.setStyleName("grid.cell");
+ layout.add(activeLabel);
+ activeField = new SelectField(MainScreen.LABELS);
+ activeField.setStyleName("default");
+ activeField.setWidth(new Extent(10, Extent.EX));
+ activeField.setSelectedIndex(0);
+ layout.add(activeField);
+ // add the blocker select field
+ Label blockerLabel = new Label(Messages.getString("blocker"));
+ blockerLabel.setStyleName("grid.cell");
+ layout.add(blockerLabel);
+ blockerField = new SelectField(MainScreen.LABELS);
+ blockerField.setStyleName("default");
+ blockerField.setWidth(new Extent(10, Extent.EX));
+ blockerField.setSelectedIndex(0);
+ layout.add(blockerField);
+ // add the type select field
+ Label typeLabel = new Label(Messages.getString("type"));
+ typeLabel.setStyleName("grid.cell");
+ layout.add(typeLabel);
+ typeField = new SelectField(ApplicationServerGeneralPane.APPLICATIONSERVER_TYPES);
+ typeField.setStyleName("default");
+ typeField.setSelectedIndex(0);
+ typeField.setWidth(new Extent(50, Extent.EX));
+ layout.add(typeField);
+ // add the jmx url field
+ Label jmxLabel = new Label(Messages.getString("jmx"));
+ jmxLabel.setStyleName("grid.cell");
+ layout.add(jmxLabel);
+ jmxField = new TextField();
+ jmxField.setStyleName("default");
+ jmxField.setWidth(new Extent(100, Extent.PERCENT));
+ layout.add(jmxField);
+ // add the admin user field
+ Label adminUserLabel = new Label(Messages.getString("user"));
+ adminUserLabel.setStyleName("grid.cell");
+ layout.add(adminUserLabel);
+ adminUserField = new TextField();
+ adminUserField.setStyleName("default");
+ adminUserField.setWidth(new Extent(100, Extent.PERCENT));
+ layout.add(adminUserField);
+ // add the admin user password field
+ Label adminPasswordLabel = new Label(Messages.getString("password"));
+ adminPasswordLabel.setStyleName("grid.cell");
+ layout.add(adminPasswordLabel);
+ adminPasswordField = new PasswordField();
+ adminPasswordField.setStyleName("default");
+ adminPasswordField.setWidth(new Extent(100, Extent.PERCENT));
+ layout.add(adminPasswordField);
+ Label adminConfirmPasswordLabel = new Label(Messages.getString("password.confirm"));
+ adminConfirmPasswordLabel.setStyleName("grid.cell");
+ layout.add(adminConfirmPasswordLabel);
+ adminConfirmPasswordField = new PasswordField();
+ adminConfirmPasswordField.setStyleName("default");
+ adminConfirmPasswordField.setWidth(new Extent(100, Extent.PERCENT));
+ layout.add(adminConfirmPasswordField);
+ // add the agent field
+ Label agentLabel = new Label(Messages.getString("agent"));
+ agentLabel.setStyleName("grid.cell");
+ layout.add(agentLabel);
+ agentField = new SelectField();
+ agentField.setStyleName("default");
+ agentField.setWidth(new Extent(50, Extent.EX));
+ layout.add(agentField);
+ // add the update require restart field
+ Label updateRequireRestartLabel = new Label(Messages.getString("update.require.restart"));
+ updateRequireRestartLabel.setStyleName("grid.cell");
+ layout.add(updateRequireRestartLabel);
+ updateRequireRestartField = new SelectField(MainScreen.LABELS);
+ updateRequireRestartField.setStyleName("default");
+ updateRequireRestartField.setSelectedIndex(0);
+ updateRequireRestartField.setWidth(new Extent(10, Extent.EX));
+ layout.add(updateRequireRestartField);
+ // add the update require cache cleaning field
+ Label updateRequireCachesCleaningLabel = new Label(Messages.getString("update.require.caches.clean"));
+ updateRequireCachesCleaningLabel.setStyleName("grid.cell");
+ layout.add(updateRequireCachesCleaningLabel);
+ updateRequireCachesClean = new SelectField(MainScreen.LABELS);
+ updateRequireCachesClean.setStyleName("default");
+ updateRequireCachesClean.setSelectedIndex(0);
+ updateRequireCachesClean.setWidth(new Extent(10, Extent.EX));
+ layout.add(updateRequireCachesClean);
+ // add the use jmx stop field
+ Label stopUsingJmxLabel = new Label(Messages.getString("stop.using.jmx"));
+ stopUsingJmxLabel.setStyleName("grid.cell");
+ layout.add(stopUsingJmxLabel);
+ stopUsingJmx = new SelectField(MainScreen.LABELS);
+ stopUsingJmx.setStyleName("default");
+ stopUsingJmx.setSelectedIndex(0);
+ stopUsingJmx.setWidth(new Extent(10, Extent.EX));
+ layout.add(stopUsingJmx);
+ // add the startup command area
+ Label startupCommandLabel = new Label(Messages.getString("applicationserver.startup"));
+ startupCommandLabel.setStyleName("grid.cell");
+ layout.add(startupCommandLabel);
+ startupCommandArea = new TextArea();
+ startupCommandArea.setStyleName("default");
+ startupCommandArea.setWidth(new Extent(100, Extent.PERCENT));
+ startupCommandArea.setHeight(new Extent(20, Extent.EX));
+ layout.add(startupCommandArea);
+ // add the shutdown command area
+ Label serverShutdownCommandLabel = new Label(Messages.getString("applicationserver.shutdown"));
+ serverShutdownCommandLabel.setStyleName("grid.cell");
+ layout.add(serverShutdownCommandLabel);
+ shutdownCommandArea = new TextArea();
+ shutdownCommandArea.setStyleName("default");
+ shutdownCommandArea.setWidth(new Extent(100, Extent.PERCENT));
+ shutdownCommandArea.setHeight(new Extent(20, Extent.EX));
+ layout.add(shutdownCommandArea);
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update() {
+ // updae the JEE server name field
+ nameField.setText(parent.getApplicationServer().getName());
+ // update the JEE server active field
+ if (parent.getApplicationServer().isActive()) {
+ activeField.setSelectedIndex(0);
+ } else {
+ activeField.setSelectedIndex(1);
+ }
+ // update the JEE server blocker field
+ if (parent.getApplicationServer().isBlocker()) {
+ blockerField.setSelectedIndex(0);
+ } else {
+ blockerField.setSelectedIndex(1);
+ }
+ // update the JEE server type field
+ if (StringUtils.containsIgnoreCase(parent.getApplicationServer().getClassname(), "jboss")) {
+ typeField.setSelectedIndex(0);
+ }
+ if (StringUtils.containsIgnoreCase(parent.getApplicationServer().getClassname(), "weblogic")) {
+ typeField.setSelectedIndex(1);
+ }
+ if (StringUtils.containsIgnoreCase(parent.getApplicationServer().getClassname(), "websphere")) {
+ typeField.setSelectedIndex(2);
+ }
+ // update the jee application server jmx field
+ jmxField.setText(parent.getApplicationServer().getJmxurl());
+ // update the jee application server admin user field
+ adminUserField.setText(parent.getApplicationServer().getAdminuser());
+ // update the jee application server admin password/confirm password
+ // fields
+ adminPasswordField.setText(parent.getApplicationServer().getAdminpassword());
+ adminConfirmPasswordField.setText(parent.getApplicationServer().getAdminpassword());
+ // load Kalumet configuration
+ Kalumet kalumet = null;
+ try {
+ kalumet = ConfigurationManager.loadStore();
+ } catch (Exception e) {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("db.read") + ": " + e.getMessage());
+ return;
+ }
+ // update the jee application server agent
+ DefaultListModel agentListModel = (DefaultListModel) agentField.getModel();
+ agentListModel.removeAll();
+ agentListModel.add("");
+ for (Iterator agentIterator = kalumet.getAgents().iterator(); agentIterator.hasNext(); ) {
+ Agent agent = (Agent) agentIterator.next();
+ agentListModel.add(agent.getId());
+ }
+ agentField.setSelectedItem(parent.getApplicationServer().getAgent());
+ // update the jee application server update require restart field
+ if (parent.getApplicationServer().isUpdateRequireRestart()) {
+ updateRequireRestartField.setSelectedIndex(0);
+ } else {
+ updateRequireRestartField.setSelectedIndex(1);
+ }
+ // update the jee application server update require caches cleaning field
+ if (parent.getApplicationServer().isUpdateRequireCacheCleaning()) {
+ updateRequireCachesClean.setSelectedIndex(0);
+ } else {
+ updateRequireCachesClean.setSelectedIndex(1);
+ }
+ // update the use jmx stop field
+ if (parent.getApplicationServer().isUsejmxstop()) {
+ stopUsingJmx.setSelectedIndex(0);
+ } else {
+ stopUsingJmx.setSelectedIndex(1);
+ }
+ // update the startup command area
+ startupCommandArea.setText(parent.getApplicationServer().getStartupcommand());
+ // update the shutdown command area
+ shutdownCommandArea.setText(parent.getApplicationServer().getShutdowncommand());
+ }
+
+ public TextField getNameField() {
+ return this.nameField;
+ }
+
+ public SelectField getActiveField() {
+ return this.activeField;
+ }
+
+ public SelectField getBlockerField() {
+ return this.blockerField;
+ }
+
+ public SelectField getTypeField() {
+ return this.typeField;
+ }
+
+ public TextField getJmxField() {
+ return this.jmxField;
+ }
+
+ public TextField getAdminUserField() {
+ return this.adminUserField;
+ }
+
+ public PasswordField getAdminPasswordField() {
+ return this.adminPasswordField;
+ }
+
+ public PasswordField getAdminConfirmPasswordField() {
+ return this.adminConfirmPasswordField;
+ }
+
+ public SelectField getUpdateRequireRestartField() {
+ return this.updateRequireRestartField;
+ }
+
+ public SelectField getUpdateRequireCachesCleanField() {
+ return this.updateRequireCachesClean;
+ }
+
+ public SelectField getStopUsingJmxField() {
+ return this.stopUsingJmx;
+ }
+
+ public TextArea getStartupCommandArea() {
+ return this.startupCommandArea;
+ }
+
+ public TextArea getShutdownCommandArea() {
+ return this.shutdownCommandArea;
+ }
+
+ public SelectField getAgentField() {
+ return this.agentField;
+ }
+
+}
Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerWindow.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerWindow.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerWindow.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/ApplicationServerWindow.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,677 @@
+/*
+ * 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 nextapp.echo2.app.Button;
+import nextapp.echo2.app.Extent;
+import nextapp.echo2.app.Row;
+import nextapp.echo2.app.SplitPane;
+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.console.configuration.ConfigurationManager;
+import org.apache.kalumet.model.Agent;
+import org.apache.kalumet.model.J2EEApplicationServer;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.ws.client.J2EEApplicationServerClient;
+
+/**
+ * J2EE application server window.
+ */
+public class ApplicationServerWindow extends WindowPane {
+
+ private String serverName;
+ private J2EEApplicationServer server = null;
+ private ApplicationServersPane parent;
+ private ApplicationServerGeneralPane generalPane;
+ private ApplicationServerCachesPane cachesPane;
+
+ // status thread
+ class StatusThread extends Thread {
+
+ 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.getEnvironmentWindow().getEnvironment().getAgent());
+ if (agent == null) {
+ throw new IllegalArgumentException("agent not found.");
+ }
+ // call the webservice
+ J2EEApplicationServerClient client = new J2EEApplicationServerClient(agent.getHostname(), agent.getPort());
+ message = client.status(parent.getEnvironmentWindow().getEnvironmentName(), serverName);
+ } catch (Exception e) {
+ failure = true;
+ message = "J2EE application server " + serverName + " status check failed: " + e.getMessage();
+ } finally {
+ ended = true;
+ }
+ }
+ }
+
+ // update thread
+ class UpdateThread extends Thread {
+
+ 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.getEnvironmentWindow().getEnvironment().getAgent());
+ if (agent == null) {
+ throw new IllegalArgumentException("agent not found.");
+ }
+ // call the webservice
+ J2EEApplicationServerClient client = new J2EEApplicationServerClient(agent.getHostname(), agent.getPort());
+ client.update(parent.getEnvironmentWindow().getEnvironmentName(), serverName, false);
+ } catch (Exception e) {
+ failure = true;
+ message = "J2EE application server " + serverName + " update failed: " + e.getMessage();
+ } finally {
+ ended = true;
+ }
+ }
+ }
+
+ // stop thread
+ class StopThread extends Thread {
+
+ 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.getEnvironmentWindow().getEnvironment().getAgent());
+ if (agent == null) {
+ throw new IllegalArgumentException("agent not found.");
+ }
+ // call the webservice
+ J2EEApplicationServerClient client = new J2EEApplicationServerClient(agent.getHostname(), agent.getPort());
+ client.stop(parent.getEnvironmentWindow().getEnvironmentName(), serverName);
+ } catch (Exception e) {
+ failure = true;
+ message = "J2EE application server " + serverName + " stop failed: " + e.getMessage();
+ } finally {
+ ended = true;
+ }
+ }
+ }
+
+ // start thread
+ class StartThread extends Thread {
+
+ 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.getEnvironmentWindow().getEnvironment().getAgent());
+ if (agent == null) {
+ throw new IllegalArgumentException("agent not found.");
+ }
+ // call the webservice
+ J2EEApplicationServerClient client = new J2EEApplicationServerClient(agent.getHostname(), agent.getPort());
+ client.start(parent.getEnvironmentWindow().getEnvironmentName(), serverName);
+ } catch (Exception e) {
+ failure = true;
+ message = "J2EE application server " + serverName + " start failed: " + e.getMessage();
+ } finally {
+ ended = true;
+ }
+ }
+ }
+
+ // close
+ private ActionListener close = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ ApplicationServerWindow.this.userClose();
+ }
+ };
+ // refresh
+ private ActionListener refresh = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // looking for original application server object
+ server = parent.getEnvironmentWindow().getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServer(serverName);
+ if (server == null) {
+ server = new J2EEApplicationServer();
+ }
+ // update the window
+ update();
+ }
+ };
+ // apply
+ private ActionListener apply = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the lock
+ if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeServersPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // get fields value
+ String nameFieldValue = generalPane.getNameField().getText();
+ int activeFieldIndex = generalPane.getActiveField().getSelectedIndex();
+ int blockerFieldIndex = generalPane.getBlockerField().getSelectedIndex();
+ int typeFieldIndex = generalPane.getTypeField().getSelectedIndex();
+ String jmxFieldValue = generalPane.getJmxField().getText();
+ String adminUserFieldValue = generalPane.getAdminUserField().getText();
+ String adminPasswordFieldValue = generalPane.getAdminPasswordField().getText();
+ String adminConfirmPasswordFieldValue = generalPane.getAdminConfirmPasswordField().getText();
+ int updateRequireRestartFieldIndex = generalPane.getUpdateRequireRestartField().getSelectedIndex();
+ int updateRequireCachesCleanFieldIndex = generalPane.getUpdateRequireCachesCleanField().getSelectedIndex();
+ int stopUsingJmxFieldIndex = generalPane.getStopUsingJmxField().getSelectedIndex();
+ String startupCommandAreaValue = generalPane.getStartupCommandArea().getText();
+ String shutdownCommandAreaValue = generalPane.getShutdownCommandArea().getText();
+ String agentFieldValue = (String) generalPane.getAgentField().getSelectedItem();
+ // check fields
+ // name and JMX are mandatory
+ if (nameFieldValue == null || nameFieldValue.trim().length() < 1 || jmxFieldValue == null || jmxFieldValue.trim().length() < 1) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("applicationserver.mandatory"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check password matching
+ if (!adminPasswordFieldValue.equals(adminConfirmPasswordFieldValue)) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("applicationserver.password.notmatch"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // if the user change the J2EE application server name, check if the
+ // JEE application server name doesn't already exist
+ if (serverName == null || (serverName != null && !serverName.equals(nameFieldValue))) {
+ if (parent.getEnvironmentWindow().getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServer(nameFieldValue) != null) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("applicationserver.exists"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ }
+ // add a change event
+ if (serverName != null) {
+ parent.getEnvironmentWindow().getChangeEvents().add("Change J2EE application server " + server.getName());
+ }
+ // update the application server object
+ server.setName(nameFieldValue);
+ if (activeFieldIndex == 0) {
+ server.setActive(true);
+ } else {
+ server.setActive(false);
+ }
+ if (blockerFieldIndex == 0) {
+ server.setBlocker(true);
+ } else {
+ server.setBlocker(false);
+ }
+ if (typeFieldIndex == 0) {
+ server.setClassname("org.apache.kalumet.controller.jboss.JBossController");
+ }
+ if (typeFieldIndex == 1) {
+ server.setClassname("org.apache.kalumet.controller.weblogic.WeblogicController");
+ }
+ if (typeFieldIndex == 2) {
+ server.setClassname("org.apache.kalumet.controller.websphere.WebsphereController");
+ }
+ server.setJmxurl(jmxFieldValue);
+ server.setAdminuser(adminUserFieldValue);
+ server.setAdminpassword(adminPasswordFieldValue);
+ if (updateRequireRestartFieldIndex == 0) {
+ server.setUpdateRequireRestart(true);
+ } else {
+ server.setUpdateRequireRestart(false);
+ }
+ if (updateRequireCachesCleanFieldIndex == 0) {
+ server.setUpdateRequireCacheCleaning(true);
+ } else {
+ server.setUpdateRequireCacheCleaning(false);
+ }
+ if (stopUsingJmxFieldIndex == 0) {
+ server.setUsejmxstop(true);
+ } else {
+ server.setUsejmxstop(false);
+ }
+ server.setStartupcommand(startupCommandAreaValue);
+ server.setShutdowncommand(shutdownCommandAreaValue);
+ server.setAgent(agentFieldValue);
+ // add the application server object if needed
+ if (serverName == null) {
+ try {
+ parent.getEnvironmentWindow().getEnvironment().getJ2EEApplicationServers().addJ2EEApplicationServer(server);
+ parent.getEnvironmentWindow().getChangeEvents().add("Add J2EE application server " + server.getName());
+ } catch (Exception e) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("applicationserver.exists"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ }
+ // update the window definition
+ setTitle(Messages.getString("applicationserver") + " " + server.getName());
+ setId("applicationserverwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + server.getName());
+ serverName = server.getName();
+ // change the updated flag
+ parent.getEnvironmentWindow().setUpdated(true);
+ // update the whole environment window
+ parent.getEnvironmentWindow().update();
+ // update the window
+ update();
+ }
+ };
+ // delete
+ private ActionListener delete = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the environment lock
+ if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!getEnvironmentWindow().adminPermission
+ || !getEnvironmentWindow().jeeServersPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // display confirm window
+ KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // delete the application server object
+ parent.getEnvironmentWindow().getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServers().remove(server);
+ // add a change event
+ parent.getEnvironmentWindow().getChangeEvents().add("Delete J2EE application server " + server.getName());
+ // update the window
+ update();
+ // update the whole parent window
+ parent.getEnvironmentWindow().update();
+ // close the window
+ ApplicationServerWindow.this.userClose();
+ }
+ }));
+ }
+ };
+ // copy
+ private ActionListener copy = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ // put the application server clone in the copy component
+ KalumetConsoleApplication.getApplication().setCopyComponent(server.clone());
+ } catch (Exception e) {
+ return;
+ }
+ }
+ };
+ // paste
+ private ActionListener paste = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the copy component is correct
+ Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+ if (copy == null || !(copy instanceof J2EEApplicationServer)) {
+ return;
+ }
+ // update the application server object
+ server = (J2EEApplicationServer) copy;
+ serverName = null;
+ // update the whole window
+ parent.getEnvironmentWindow().update();
+ // update the window
+ update();
+ }
+ };
+ // status
+ private ActionListener status = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if some change has not yet been saved
+ if (parent.getEnvironmentWindow().isUpdated()) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.notsaved"), parent.getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // add a message into the log pane and the journal
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo("J2EE application server " + serverName + " status check in progress...", parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add("J2EE application server " + serverName + " status check requested.");
+ // start status thread
+ final StatusThread statusThread = new StatusThread();
+ statusThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable() {
+ public void run() {
+ if (statusThread.ended) {
+ if (statusThread.failure) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(statusThread.message, parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add(statusThread.message);
+ } else {
+ KalumetConsoleApplication.getApplication().getLogPane().addInfo("J2EE application server " + serverName + " status: " + statusThread.message, parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add("J2EE application server " + serverName + " status: " + statusThread.message);
+ }
+ } else {
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), this);
+ }
+ }
+ });
+ }
+ };
+ // update
+ private ActionListener update = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the lock
+ if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeServersUpdatePermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if some change has not been saved
+ if (getEnvironmentWindow().isUpdated()) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.notsaved"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // 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 server " + serverName + " update in progress...", parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add("J2EE application server " + serverName + " update requested.");
+ // start the update thread
+ final UpdateThread updateThread = new UpdateThread();
+ 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.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add(updateThread.message);
+ } else {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm("J2EE application server " + serverName + " updated.", parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add("J2EE application server " + serverName + " updated.");
+ }
+ } else {
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), this);
+ }
+ }
+ });
+ }
+ }));
+ }
+ };
+ // stop
+ private ActionListener stop = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the lock
+ if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeServersControlPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if some change has been saved
+ if (getEnvironmentWindow().isUpdated()) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.notsaved"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // 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 server " + serverName + " stop in progress...", parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add("J2EE application server " + serverName + " stop requested.");
+ // start the stop thread
+ final StopThread stopThread = new StopThread();
+ stopThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable() {
+ public void run() {
+ if (stopThread.ended) {
+ if (stopThread.failure) {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(stopThread.message, parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add(stopThread.message);
+ } else {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm("J2EE application server " + serverName + " stopped.", parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add("J2EE application server " + serverName + " stopped.");
+ }
+ } else {
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), this);
+ }
+ }
+ });
+ }
+ }));
+ }
+ };
+ // start
+ private ActionListener start = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // check if the user has the lock
+ if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if the user can do it
+ if (!getEnvironmentWindow().adminPermission
+ && !getEnvironmentWindow().jeeServersControlPermission) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // check if some change has not been saved
+ if (getEnvironmentWindow().isUpdated()) {
+ KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.notsaved"), getEnvironmentWindow().getEnvironmentName());
+ return;
+ }
+ // 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 server " + serverName + " start in progress...", parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add("J2EE application server " + serverName + " start requested.");
+ // start the start thread
+ final StartThread startThread = new StartThread();
+ startThread.start();
+ // sync with the client
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), new Runnable() {
+ public void run() {
+ if (startThread.ended) {
+ if (startThread.failure) {
+ KalumetConsoleApplication.getApplication().getLogPane().addError(startThread.message, parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add(startThread.message);
+ } else {
+ KalumetConsoleApplication.getApplication().getLogPane().addConfirm("J2EE application server " + serverName + " started.", parent.getEnvironmentWindow().getEnvironmentName());
+ parent.getEnvironmentWindow().getChangeEvents().add("J2EE application server " + serverName + " started.");
+ }
+ } else {
+ KalumetConsoleApplication.getApplication().enqueueTask(KalumetConsoleApplication.getApplication().getTaskQueue(), this);
+ }
+ }
+ });
+ }
+ }));
+ }
+ };
+
+ /**
+ * Create a new <code>ApplicationServerWindow</code>.
+ *
+ * @param parent the <code>ApplicationServersPane</code>.
+ * @param ApplicationServerName the original J2EE application server name.
+ */
+ public ApplicationServerWindow(ApplicationServersPane parent, String ApplicationServerName) {
+ super();
+
+ // update the parent tab pane
+ this.parent = parent;
+
+ // update the application server name
+ this.serverName = ApplicationServerName;
+
+ // update the application server object from the parent environment
+ this.server = parent.getEnvironmentWindow().getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServer(serverName);
+ if (this.server == null) {
+ this.server = new J2EEApplicationServer();
+ }
+
+ if (serverName == null) {
+ setTitle(Messages.getString("applicationserver"));
+ } else {
+ setTitle(Messages.getString("applicationserver") + " " + serverName);
+ }
+ setId("applicationserverwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + serverName);
+ setStyleName("default");
+ setWidth(new Extent(800, Extent.PX));
+ setHeight(new Extent(600, Extent.PX));
+ setIcon(Styles.APPLICATION);
+ 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 (getEnvironmentWindow().adminPermission
+ || getEnvironmentWindow().jeeServersPermission) {
+ // 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 status button
+ Button statusButton = new Button(Messages.getString("status"), Styles.INFORMATION);
+ statusButton.setStyleName("control");
+ statusButton.addActionListener(status);
+ controlRow.add(statusButton);
+ if (getEnvironmentWindow().adminPermission
+ || getEnvironmentWindow().jeeServersControlPermission) {
+ // add the stop button
+ Button stopButton = new Button(Messages.getString("stop"), Styles.FLAG_RED);
+ stopButton.setStyleName("control");
+ stopButton.addActionListener(stop);
+ controlRow.add(stopButton);
+ // add the start button
+ Button startButton = new Button(Messages.getString("start"), Styles.FLAG_GREEN);
+ startButton.setStyleName("control");
+ startButton.addActionListener(start);
+ controlRow.add(startButton);
+ }
+ if (getEnvironmentWindow().adminPermission
+ || getEnvironmentWindow().jeeServersUpdatePermission) {
+ // add the update button
+ Button updateButton = new Button(Messages.getString("update"), Styles.COG);
+ updateButton.setStyleName("control");
+ updateButton.addActionListener(update);
+ controlRow.add(updateButton);
+ }
+ if (getEnvironmentWindow().adminPermission
+ || getEnvironmentWindow().jeeServersPermission) {
+ // 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 tab pane
+ TabPane tabPane = new TabPane();
+ tabPane.setStyleName("default");
+ splitPane.add(tabPane);
+
+ // add the jee application server general tab
+ TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle(Messages.getString("general"));
+ generalPane = new ApplicationServerGeneralPane(this);
+ generalPane.setLayoutData(tabLayoutData);
+ tabPane.add(generalPane);
+
+ // add the jee application server caches tab
+ tabLayoutData = new TabPaneLayoutData();
+ tabLayoutData.setTitle(Messages.getString("caches"));
+ cachesPane = new ApplicationServerCachesPane(this);
+ cachesPane.setLayoutData(tabLayoutData);
+ tabPane.add(cachesPane);
+
+ // update the pane
+ update();
+ }
+
+ /**
+ * Update the pane.
+ */
+ public void update() {
+ generalPane.update();
+ cachesPane.update();
+ }
+
+ public J2EEApplicationServer getApplicationServer() {
+ return this.server;
+ }
+
+ public String getApplicationServerName() {
+ return this.serverName;
+ }
+
+ public EnvironmentWindow getEnvironmentWindow() {
+ return parent.getEnvironmentWindow();
+ }
+
+}