From eab4676419a6973c0a77d0c8916571eb97eb8a92 Mon Sep 17 00:00:00 2001 From: Gaurav Gupta Date: Tue, 5 May 2020 20:12:56 +0530 Subject: [PATCH] ECOSYS-33 fix format and copyright year --- .../starting/AdminCredentialsDialog.java | 202 +++++++++--------- .../starting/PayaraServerLaunchDelegate.java | 2 +- .../tools/server/starting/PayaraStartJob.java | 7 +- 3 files changed, 110 insertions(+), 101 deletions(-) diff --git a/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/AdminCredentialsDialog.java b/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/AdminCredentialsDialog.java index f5d8658e..e6571c9b 100644 --- a/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/AdminCredentialsDialog.java +++ b/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/AdminCredentialsDialog.java @@ -1,9 +1,7 @@ /****************************************************************************** - * Copyright (c) 2018-2019 Payara Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v2.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v20.html + * Copyright (c) 2020 Payara Foundation All rights reserved. This program and the accompanying + * materials are made available under the terms of the Eclipse Public License v2.0 which accompanies + * this distribution, and is available at http://www.eclipse.org/legal/epl-v20.html * SPDX-License-Identifier: EPL-2.0 ******************************************************************************/ @@ -29,96 +27,104 @@ public class AdminCredentialsDialog extends TitleAreaDialog { - private Text adminNameText; - private Text passwordText; - - private static final String SAVE_LABEL = "Save"; - - private IServerWorkingCopy serverWorkingCopy; - - private AdminCredentialsDialog(IServerWorkingCopy serverWorkingCopy, Shell parentShell) { - super(parentShell); - this.serverWorkingCopy = serverWorkingCopy; - } - - public static void open(IServer server) { - Display display = PlatformUI.getWorkbench().getDisplay(); - display.asyncExec(() -> { - IServerWorkingCopy serverWorkingCopy; - if (server instanceof IServerWorkingCopy) { - serverWorkingCopy = (IServerWorkingCopy) server; - } else { - serverWorkingCopy = server.createWorkingCopy(); - } - AdminCredentialsDialog dialog = new AdminCredentialsDialog(serverWorkingCopy, display.getActiveShell()); - dialog.create(); - dialog.open(); - }); - } - - @Override - public void create() { - super.create(); - super.getShell().setText("Payara Administrator Credentials"); - setTitle("Wrong user name or password"); - setMessage("Authorization failed while checking " + serverWorkingCopy.getName() - + " status. Please provide valid administrator credentials.", IMessageProvider.WARNING); - } - - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, SAVE_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite area = (Composite) super.createDialogArea(parent); - Composite container = new Composite(area, SWT.NONE); - container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - GridLayout layout = new GridLayout(2, false); - container.setLayout(layout); - - createAdminNameComponent(container); - createPasswordComponent(container); - - return area; - } - - private void createAdminNameComponent(Composite container) { - Label adminNameLabel = new Label(container, SWT.NONE); - adminNameLabel.setText("Username"); - - GridData grid = new GridData(); - grid.grabExcessHorizontalSpace = true; - grid.horizontalAlignment = GridData.FILL; - - adminNameText = new Text(container, SWT.BORDER); - adminNameText.setText(serverWorkingCopy.getAttribute(PayaraServer.ATTR_ADMIN, "admin")); - adminNameText.setLayoutData(grid); - } - - private void createPasswordComponent(Composite container) { - Label passwordLabel = new Label(container, SWT.NONE); - passwordLabel.setText("Password"); - - GridData grid = new GridData(); - grid.grabExcessHorizontalSpace = true; - grid.horizontalAlignment = GridData.FILL; - passwordText = new Text(container, SWT.PASSWORD | SWT.BORDER); - passwordText.setText(serverWorkingCopy.getAttribute(PayaraServer.ATTR_ADMINPASS, "")); - passwordText.setLayoutData(grid); - } - - @Override - protected void okPressed() { - try { - serverWorkingCopy.setAttribute(PayaraServer.ATTR_ADMIN, adminNameText.getText()); - serverWorkingCopy.setAttribute(PayaraServer.ATTR_ADMINPASS, passwordText.getText()); - serverWorkingCopy.save(true, null); - } catch (CoreException e) { - throw new RuntimeException(e); - } - super.okPressed(); - } - -} \ No newline at end of file + private Text adminNameText; + private Text passwordText; + + private static final String SAVE_LABEL = "Save"; + + private IServerWorkingCopy serverWorkingCopy; + + + private AdminCredentialsDialog(IServerWorkingCopy serverWorkingCopy, Shell parentShell) { + super(parentShell); + this.serverWorkingCopy = serverWorkingCopy; + } + + + public static void open(IServer server) { + Display display = PlatformUI.getWorkbench().getDisplay(); + display.asyncExec(() -> { + IServerWorkingCopy serverWorkingCopy; + if (server instanceof IServerWorkingCopy) { + serverWorkingCopy = (IServerWorkingCopy) server; + } else { + serverWorkingCopy = server.createWorkingCopy(); + } + AdminCredentialsDialog dialog = new AdminCredentialsDialog(serverWorkingCopy, display.getActiveShell()); + dialog.create(); + dialog.open(); + }); + } + + + @Override + public void create() { + super.create(); + super.getShell().setText("Payara Administrator Credentials"); + setTitle("Wrong user name or password"); + setMessage("Authorization failed while checking " + serverWorkingCopy.getName() + + " status. Please provide valid administrator credentials.", IMessageProvider.WARNING); + } + + + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, SAVE_LABEL, true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + + @Override + protected Control createDialogArea(Composite parent) { + Composite area = (Composite) super.createDialogArea(parent); + Composite container = new Composite(area, SWT.NONE); + container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + GridLayout layout = new GridLayout(2, false); + container.setLayout(layout); + + createAdminNameComponent(container); + createPasswordComponent(container); + + return area; + } + + + private void createAdminNameComponent(Composite container) { + Label adminNameLabel = new Label(container, SWT.NONE); + adminNameLabel.setText("Username"); + + GridData grid = new GridData(); + grid.grabExcessHorizontalSpace = true; + grid.horizontalAlignment = GridData.FILL; + + adminNameText = new Text(container, SWT.BORDER); + adminNameText.setText(serverWorkingCopy.getAttribute(PayaraServer.ATTR_ADMIN, "admin")); + adminNameText.setLayoutData(grid); + } + + + private void createPasswordComponent(Composite container) { + Label passwordLabel = new Label(container, SWT.NONE); + passwordLabel.setText("Password"); + + GridData grid = new GridData(); + grid.grabExcessHorizontalSpace = true; + grid.horizontalAlignment = GridData.FILL; + passwordText = new Text(container, SWT.PASSWORD | SWT.BORDER); + passwordText.setText(serverWorkingCopy.getAttribute(PayaraServer.ATTR_ADMINPASS, "")); + passwordText.setLayoutData(grid); + } + + + @Override + protected void okPressed() { + try { + serverWorkingCopy.setAttribute(PayaraServer.ATTR_ADMIN, adminNameText.getText()); + serverWorkingCopy.setAttribute(PayaraServer.ATTR_ADMINPASS, passwordText.getText()); + serverWorkingCopy.save(true, null); + } catch (CoreException e) { + throw new RuntimeException(e); + } + super.okPressed(); + } + +} diff --git a/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/PayaraServerLaunchDelegate.java b/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/PayaraServerLaunchDelegate.java index 70cc3af0..369a7854 100644 --- a/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/PayaraServerLaunchDelegate.java +++ b/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/PayaraServerLaunchDelegate.java @@ -355,7 +355,7 @@ private boolean isRunning(PayaraServerBehaviour serverBehavior) throws CoreExcep abort(canntCommunicate, new RuntimeException(abortLaunchMsg + domainNotMatch + checkVpnOrProxy)); break; case RUNNING_CREDENTIAL_PROBLEM: - AdminCredentialsDialog.open(thisServer); + AdminCredentialsDialog.open(thisServer); abort(canntCommunicate, new RuntimeException(abortLaunchMsg + wrongUsernamePassword)); break; case RUNNING_DOMAIN_MATCHING: diff --git a/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/PayaraStartJob.java b/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/PayaraStartJob.java index 6dde14fa..3718fba5 100644 --- a/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/PayaraStartJob.java +++ b/plugins/org.eclipse.payara.tools/src/org/eclipse/payara/tools/server/starting/PayaraStartJob.java @@ -124,13 +124,16 @@ public ResultProcess call() throws Exception { startupConsole.stopLogging(); payaraProcess.destroy(); - throw new PayaraLaunchException("BAD GATEWAY response code returned. Check your proxy settings. Killing startup process.", payaraProcess); + throw new PayaraLaunchException( + "BAD GATEWAY response code returned. Check your proxy settings. Killing startup process.", + payaraProcess); case RUNNING_CREDENTIAL_PROBLEM: startupConsole.stopLogging(); payaraProcess.destroy(); AdminCredentialsDialog.open(payaraServerBehaviour.getServer()); - throw new PayaraLaunchException("Wrong user name or password. Killing startup process.", payaraProcess); + throw new PayaraLaunchException("Wrong user name or password. Killing startup process.", + payaraProcess); case RUNNING_DOMAIN_MATCHING: startupConsole.stopLogging(); break check_server_status;