Author: rob.stryker(a)jboss.com
Date: 2012-01-24 04:34:20 -0500 (Tue, 24 Jan 2012)
New Revision: 38074
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
Log:
JBIDE-10490 and JBIDE-10700 to trunk for beta1
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2012-01-24
09:02:49 UTC (rev 38073)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2012-01-24
09:34:20 UTC (rev 38074)
@@ -28,6 +28,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerAttributes;
import org.eclipse.wst.server.core.IServerType;
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
@@ -178,7 +179,7 @@
/**
* @since 2.3
*/
- public static String getFromSecureStorage(IServer server, String key) {
+ public static String getFromSecureStorage(IServerAttributes server, String key) {
try {
ISecurePreferences node = getNode(server);
String val = node.get(key, null);
@@ -210,7 +211,7 @@
}
}
- private static ISecurePreferences getNode(IServer server) throws
UnsupportedEncodingException {
+ private static ISecurePreferences getNode(IServerAttributes server) throws
UnsupportedEncodingException {
String secureKey = new StringBuilder(PREFERNCES_BASEKEY)
.append(server.getName())
.append(Path.SEPARATOR).toString();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java 2012-01-24
09:02:49 UTC (rev 38073)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java 2012-01-24
09:34:20 UTC (rev 38074)
@@ -122,6 +122,7 @@
public SetPassCommand(IServerWorkingCopy server) {
super(server, Messages.EditorChangePasswordCommandName, passText, passText.getText(),
IJBossToolingConstants.SERVER_PASSWORD, passModifyListener);
+ oldVal = passText.getText();
}
public void execute() {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java 2012-01-24
09:02:49 UTC (rev 38073)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java 2012-01-24
09:34:20 UTC (rev 38074)
@@ -24,7 +24,8 @@
this.key = attributeKey;
this.newVal = newVal;
this.listener = listener;
- this.oldVal = wc.getAttribute(attributeKey, ""); //$NON-NLS-1$
+ if( key != null )
+ this.oldVal = wc.getAttribute(attributeKey, ""); //$NON-NLS-1$
}
public void execute() {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-01-24
09:02:49 UTC (rev 38073)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-01-24
09:34:20 UTC (rev 38074)
@@ -36,7 +36,8 @@
org.eclipse.ui.console;bundle-version="3.5.100",
org.eclipse.core.expressions;bundle-version="3.4.300",
org.eclipse.wst.common.modulecore;bundle-version="1.2.101",
- org.jboss.ide.eclipse.as.wtp.core;bundle-version="2.3.0"
+ org.jboss.ide.eclipse.as.wtp.core;bundle-version="2.3.0",
+ org.eclipse.ui.forms;bundle-version="3.5.101"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.jboss.tools.common.databinding,
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-01-24
09:02:49 UTC (rev 38073)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-01-24
09:34:20 UTC (rev 38074)
@@ -238,5 +238,15 @@
</build>
</profile></pattern>
</template>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.ui.editorPageSections">
+ <section
+
class="org.jboss.tools.openshift.express.internal.ui.behaviour.ExpressDetailsSection"
+
id="org.jboss.tools.openshift.express.ui.behaviour.details.section"
+ insertionId="org.eclipse.wst.server.editor.overview.left"
+ order="10"
+
typeIds="org.jboss.tools.openshift.express.openshift.server.type">
+ </section>
</extension>
</plugin>
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-01-24
09:02:49 UTC (rev 38073)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-01-24
09:34:20 UTC (rev 38074)
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.jboss.tools.openshift.express.internal.core.behaviour;
+import static org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants.SERVER_PASSWORD;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.wst.server.core.IRuntime;
@@ -23,6 +25,7 @@
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
/**
* This class holds the attribute names whose values will be
@@ -39,6 +42,7 @@
public static final String ATTRIBUTE_APPLICATION_ID =
"org.jboss.tools.openshift.express.internal.core.behaviour.ApplicationId";
public static final String ATTRIBUTE_DOMAIN =
"org.jboss.tools.openshift.express.internal.core.behaviour.Domain";
public static final String ATTRIBUTE_USERNAME =
"org.jboss.tools.openshift.express.internal.core.behaviour.Username";
+ // Legacy, not to be used
public static final String ATTRIBUTE_PASSWORD =
"org.jboss.tools.openshift.express.internal.core.behaviour.Password";
public static final String ATTRIBUTE_REMOTE_NAME =
"org.jboss.tools.openshift.express.internal.core.behaviour.RemoteName";
public static final String ATTRIBUTE_REMOTE_NAME_DEFAULT = "origin";
@@ -88,6 +92,16 @@
return wc.save(false, new NullProgressMonitor());
}
+ public static String getExpressRemoteName(IServerAttributes attributes ) {
+ return attributes.getAttribute(ATTRIBUTE_REMOTE_NAME, (String)null);
+ }
+
+ public static IServer setExpressRemoteName(IServer server, String val) throws
CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(ATTRIBUTE_REMOTE_NAME, val);
+ return wc.save(false, new NullProgressMonitor());
+ }
+
public static String getExpressUsername(IServerAttributes attributes ) {
return attributes.getAttribute(ATTRIBUTE_USERNAME, (String)null);
}
@@ -99,14 +113,20 @@
}
// TODO Must secure this!!!
- public static String getExpressPassword(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_PASSWORD, (String)null);
+ public static String getExpressPassword(IServerWorkingCopy server ) {
+ return getExpressApplicationId(server.getOriginal());
}
+ public static String getExpressPassword(IServer server ) {
+ String s = ServerUtil.getFromSecureStorage(server,
ExpressServerUtils.ATTRIBUTE_PASSWORD);
+ if( s == null )
+ return server.getAttribute(ExpressServerUtils.ATTRIBUTE_PASSWORD, (String)null);
+ return s;
+ }
+
public static IServer setExpressPassword(IServer server, String val) throws
CoreException {
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.setAttribute(ATTRIBUTE_PASSWORD, val);
- return wc.save(false, new NullProgressMonitor());
+ ServerUtil.storeInSecureStorage(server, ExpressServerUtils.ATTRIBUTE_PASSWORD, val);
+ return server;
}
@@ -182,7 +202,6 @@
wc.setHost(host);
wc.setAttribute(IDeployableServer.SERVER_MODE, "openshift");
wc.setAttribute(ATTRIBUTE_USERNAME, username);
- wc.setAttribute(ATTRIBUTE_PASSWORD, password);
wc.setAttribute(ATTRIBUTE_DOMAIN, domain);
wc.setAttribute(ATTRIBUTE_APPLICATION_NAME, appName);
wc.setAttribute(ATTRIBUTE_APPLICATION_ID, appId);
@@ -192,7 +211,9 @@
wc.setAttribute(IJBossToolingConstants.IGNORE_LAUNCH_COMMANDS, "true");
wc.setAttribute(IJBossToolingConstants.WEB_PORT, 80);
wc.setAttribute(IJBossToolingConstants.WEB_PORT_DETECT, "false");
- return wc.save(true, new NullProgressMonitor());
+ IServer saved = wc.save(true, new NullProgressMonitor());
+ ExpressServerUtils.setExpressPassword(wc, password);
+ return saved;
}
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-01-24
09:34:20 UTC (rev 38074)
@@ -0,0 +1,148 @@
+package org.jboss.tools.openshift.express.internal.ui.behaviour;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.editor.ServerEditorSection;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.editor.ServerWorkingCopyPropertyCommand;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
+
+public class ExpressDetailsSection extends ServerEditorSection {
+ private ModifyListener nameModifyListener, remoteModifyListener, passModifyListener;
+ private Text nameText, passText, remoteText;
+ private ServerAttributeHelper helper;
+
+ private String passwordString;
+
+ public void createSection(Composite parent) {
+ super.createSection(parent);
+ FormToolkit toolkit = new FormToolkit(parent.getDisplay());
+
+ Section section = toolkit.createSection(parent,
ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);
+ section.setText("Express Server in Source Mode (Details)");
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |
GridData.VERTICAL_ALIGN_FILL));
+ Composite composite = toolkit.createComposite(section);
+ composite.setLayout(new GridLayout(2, false));
+
+ fillSection(composite, toolkit);
+ addListeners();
+
+ toolkit.paintBordersFor(composite);
+ section.setClient(composite);
+ }
+
+ private void fillSection(Composite composite, FormToolkit toolkit) {
+
+ GridData d = new GridData(); d.horizontalSpan = 2;
+
+ Label appName = toolkit.createLabel(composite, "Application Name");
+ Label appNameVal = toolkit.createLabel(composite,
ExpressServerUtils.getExpressApplicationName(server));
+ Label appId = toolkit.createLabel(composite, "Application Id");
+ Label appIdVal = toolkit.createLabel(composite,
ExpressServerUtils.getExpressApplicationId(server));
+
+ Label username = toolkit.createLabel(composite, Messages.swf_Username);
+ username.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ String n = ExpressServerUtils.getExpressUsername(server);
+ nameText = toolkit.createText(composite, n);
+ String p = ExpressServerUtils.getExpressPassword(server.getOriginal());
+ Label password = toolkit.createLabel(composite, Messages.swf_Password);
+ password.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ passText = toolkit.createText(composite, p);
+ passwordString = p;
+ String remote = ExpressServerUtils.getExpressRemoteName(server);
+ Label remoteName = toolkit.createLabel(composite, "Remote Name");
+ remoteName.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ remoteText = toolkit.createText(composite, remote);
+
+ d = new GridData(); d.grabExcessHorizontalSpace = true; d.widthHint = 100;
+ nameText.setLayoutData(d);
+ d = new GridData(); d.grabExcessHorizontalSpace = true; d.widthHint = 100;
+ passText.setLayoutData(d);
+
+ }
+
+ private void addListeners() {
+ nameModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ execute(new SetUserCommand(server));
+ }
+ };
+ remoteModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ execute(new SetRemoteCommand(server));
+ }
+ };
+
+ passModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ execute(new SetPassCommand(server));
+ }
+ };
+
+ nameText.addModifyListener(nameModifyListener);
+ remoteText.addModifyListener(remoteModifyListener);
+ passText.addModifyListener(passModifyListener);
+ }
+
+ public class SetUserCommand extends ServerWorkingCopyPropertyCommand {
+ public SetUserCommand(IServerWorkingCopy server) {
+ super(server, Messages.EditorChangeUsernameCommandName, nameText, nameText.getText(),
+ ExpressServerUtils.ATTRIBUTE_USERNAME, nameModifyListener);
+ }
+ }
+
+ public class SetRemoteCommand extends ServerWorkingCopyPropertyCommand {
+ public SetRemoteCommand(IServerWorkingCopy server) {
+ super(server, "Change Remote Name", remoteText, remoteText.getText(),
+ ExpressServerUtils.ATTRIBUTE_REMOTE_NAME, remoteModifyListener);
+ }
+ }
+
+ public class SetPassCommand extends ServerWorkingCopyPropertyCommand {
+ public SetPassCommand(IServerWorkingCopy server) {
+ super(server, Messages.EditorChangePasswordCommandName, passText, passText.getText(),
+ null, passModifyListener);
+ oldVal = passText.getText();
+ }
+
+ public void execute() {
+ passwordString = newVal;
+ }
+
+ public void undo() {
+ passwordString = oldVal;
+ text.removeModifyListener(listener);
+ text.setText(oldVal);
+ text.addModifyListener(listener);
+ }
+ }
+
+ /**
+ * Allow a section an opportunity to respond to a doSave request on the editor.
+ * @param monitor the progress monitor for the save operation.
+ */
+ public void doSave(IProgressMonitor monitor) {
+ try {
+ ExpressServerUtils.setExpressPassword(server.getOriginal(), passwordString);
+ monitor.worked(100);
+ } catch( CoreException ce ) {
+ // TODO
+ }
+ }
+
+}