001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.setup.ui; 029 030import org.opencms.setup.CmsSetupBean; 031import org.opencms.ui.CmsVaadinUtils; 032 033import com.vaadin.server.VaadinRequest; 034import com.vaadin.server.VaadinServletRequest; 035import com.vaadin.ui.Button; 036import com.vaadin.ui.TextField; 037 038/** 039 * Setup step: Other settings. 040 */ 041public class CmsSetupStep05ServerSettings extends A_CmsSetupStep { 042 043 /** Back button. */ 044 private Button m_backButton; 045 046 /** Forward button. */ 047 private Button m_forwardButton; 048 049 /** MAC address. */ 050 private TextField m_macAddress; 051 052 /** Server id. */ 053 private TextField m_serverId; 054 055 /** Workplace server. */ 056 private TextField m_serverUrl; 057 058 /** 059 * Creates a new instance. 060 * 061 * @param context the setup context 062 */ 063 public CmsSetupStep05ServerSettings(I_SetupUiContext context) { 064 065 super(context); 066 067 CmsVaadinUtils.readAndLocalizeDesign(this, null, null); 068 m_serverId.setValue(m_context.getSetupBean().getServerName()); 069 m_macAddress.setValue(m_context.getSetupBean().getEthernetAddress()); 070 VaadinServletRequest request = (VaadinServletRequest)(VaadinRequest.getCurrent()); 071 String serverUrl = request.getScheme() + "://" + request.getServerName(); 072 int serverPort = request.getServerPort(); 073 if (serverPort != 80) { 074 serverUrl += ":" + serverPort; 075 } 076 m_serverUrl.setValue(serverUrl); 077 m_forwardButton.addClickListener(evt -> forward()); 078 m_backButton.addClickListener(evt -> m_context.stepBack()); 079 } 080 081 /** 082 * Proceed to next step. 083 */ 084 private void forward() { 085 086 try { 087 String macAddress = m_macAddress.getValue(); 088 String serverId = m_serverId.getValue(); 089 String serverUrl = m_serverUrl.getValue(); 090 CmsSetupBean setupBean = m_context.getSetupBean(); 091 setupBean.setEthernetAddress(macAddress); 092 setupBean.setServerName(serverId); 093 setupBean.setWorkplaceSite(serverUrl); 094 setupBean.prepareStep8(); 095 m_context.stepForward(); 096 } catch (Exception e) { 097 CmsSetupErrorDialog.showErrorDialog(e); 098 099 } 100 101 } 102 103}