Commit 10c5564c by Nepxion

修改界面

parent 1417f17e
...@@ -9,16 +9,33 @@ package com.nepxion.discovery.console.desktop; ...@@ -9,16 +9,33 @@ package com.nepxion.discovery.console.desktop;
* @version 1.0 * @version 1.0
*/ */
import java.awt.Component;
import java.awt.Font;
import java.awt.Frame; import java.awt.Frame;
import java.util.Locale; import java.util.Locale;
import java.util.Vector;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
import javax.swing.JPanel;
import org.apache.commons.lang3.StringUtils;
import com.nepxion.discovery.common.entity.UserEntity; import com.nepxion.discovery.common.entity.UserEntity;
import com.nepxion.discovery.console.desktop.controller.ServiceController; import com.nepxion.discovery.console.desktop.controller.ServiceController;
import com.nepxion.discovery.console.desktop.locale.ConsoleLocale;
import com.nepxion.swing.combobox.JBasicComboBox;
import com.nepxion.swing.dialog.JLoginDialog; import com.nepxion.swing.dialog.JLoginDialog;
import com.nepxion.swing.font.FontContext;
import com.nepxion.swing.label.JBasicLabel;
import com.nepxion.swing.layout.table.TableLayout;
public class ConsoleLogin extends JLoginDialog { public class ConsoleLogin extends JLoginDialog {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private JBasicLabel urlLabel;
private JBasicComboBox urlComboBox;
public ConsoleLogin() { public ConsoleLogin() {
super(null); super(null);
} }
...@@ -27,8 +44,75 @@ public class ConsoleLogin extends JLoginDialog { ...@@ -27,8 +44,75 @@ public class ConsoleLogin extends JLoginDialog {
super(parent); super(parent);
} }
@SuppressWarnings("unchecked")
@Override
protected void initEditorPanelLayout() {
urlLabel = new JBasicLabel();
urlLabel.setFont(new Font(FontContext.getFontName(), FONT_STYLE, FONT_SIZE));
String url = null;
try {
url = ServiceController.getUrl();
} catch (Exception e) {
}
Vector<String> urls = new Vector<String>();
if (StringUtils.isNotEmpty(url)) {
urls.add(url);
}
urlComboBox = new JBasicComboBox(urls);
urlComboBox.setEditable(true);
urlComboBox.setRenderer(new DefaultListCellRenderer() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("rawtypes")
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setToolTipText(value.toString());
return this;
}
});
double[][] size = {
{ 80, 230 },
{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED }
};
TableLayout tableLayout = new TableLayout(size);
tableLayout.setVGap(10);
editorPanel = new JPanel();
editorPanel.setLayout(tableLayout);
editorPanel.add(urlLabel, "0, 0");
editorPanel.add(urlComboBox, "1, 0");
editorPanel.add(accountLabel, "0, 1");
editorPanel.add(accountTextField, "1, 1");
editorPanel.add(passwordLabel, "0, 2");
editorPanel.add(passwordField, "1, 2");
editorPanel.add(localeLabel, "0, 3");
editorPanel.add(localeComboBox, "1, 3");
}
@Override
protected void initLocale(Locale locale) {
super.initLocale(locale);
urlLabel.setText(ConsoleLocale.getString("url", locale));
}
@Override @Override
public boolean login(String userId, String password, Locale locale) throws Exception { public boolean login(String userId, String password, Locale locale) throws Exception {
Object url = urlComboBox.getSelectedItem();
if (url == null || StringUtils.isEmpty(url.toString().trim())) {
throw new IllegalArgumentException("Console url can't be null or empty");
}
ServiceController.setUrl(url.toString().trim());
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
userEntity.setUserId(userId); userEntity.setUserId(userId);
userEntity.setPassword(password); userEntity.setPassword(password);
......
...@@ -33,6 +33,8 @@ import com.nepxion.discovery.console.desktop.entity.Instance; ...@@ -33,6 +33,8 @@ import com.nepxion.discovery.console.desktop.entity.Instance;
public class ServiceController { public class ServiceController {
public static RestTemplate restTemplate; public static RestTemplate restTemplate;
private static String consoleUrl;
static { static {
restTemplate = new RestTemplate(); restTemplate = new RestTemplate();
restTemplate.setErrorHandler(new RestErrorHandler()); restTemplate.setErrorHandler(new RestErrorHandler());
...@@ -238,12 +240,21 @@ public class ServiceController { ...@@ -238,12 +240,21 @@ public class ServiceController {
return result; return result;
} }
private static String getUrl() { public static String getUrl() {
String url = PropertiesContext.getProperties().getString("url"); String url = null;
if (StringUtils.isNotEmpty(consoleUrl)) {
url = consoleUrl;
} else {
url = PropertiesContext.getProperties().getString("url");
}
return UrlUtil.formatUrl(url); return UrlUtil.formatUrl(url);
} }
public static void setUrl(String url) {
consoleUrl = url;
}
private static String getUrl(Instance instance) { private static String getUrl(Instance instance) {
String url = "http://" + instance.getHost() + ":" + instance.getPort() + UrlUtil.formatContextPath(InstanceEntityWrapper.getContextPath(instance)); String url = "http://" + instance.getHost() + ":" + instance.getPort() + UrlUtil.formatContextPath(InstanceEntityWrapper.getContextPath(instance));
......
url=控制台地址
title=Discovery 灰度发布控制台 title=Discovery 灰度发布控制台
navigator_bar=导航区 navigator_bar=导航区
content_bar=工作区 content_bar=工作区
......
url=\u63a7\u5236\u53f0\u5730\u5740
title=Discovery \u7070\u5ea6\u53d1\u5e03\u63a7\u5236\u53f0 title=Discovery \u7070\u5ea6\u53d1\u5e03\u63a7\u5236\u53f0
navigator_bar=\u5bfc\u822a\u533a navigator_bar=\u5bfc\u822a\u533a
content_bar=\u5de5\u4f5c\u533a content_bar=\u5de5\u4f5c\u533a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment