JBoss Tools SVN: r43870 - trunk/build/results.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2012-09-20 13:17:47 -0400 (Thu, 20 Sep 2012)
New Revision: 43870
Removed:
trunk/build/results/OLD/
Log:
purge empty folder
13 years, 6 months
JBoss Tools SVN: r43869 - in trunk: vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-09-20 12:47:41 -0400 (Thu, 20 Sep 2012)
New Revision: 43869
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/src/org/jboss/tools/vpe/docbook/template/DocbookTextTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-11588 : Open-on of EL from Visual Page Editor works incorrectly
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java 2012-09-20 16:18:44 UTC (rev 43868)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java 2012-09-20 16:47:41 UTC (rev 43869)
@@ -37,17 +37,6 @@
*/
public abstract class AbstractEditableJsfTemplate extends VpeAbstractTemplate {
- /**
- * Gets the output attribute node.
- *
- * @param element the element
- *
- * @return the output attribute node
- */
- public Attr getOutputAttributeNode(Element element) {
- return null;
- }
-
// general jsf attributes
/**
* Contains JSF attributes and appropriate HTML attributes
@@ -101,7 +90,7 @@
public IRegion getSourceRegionForOpenOn(VpePageContext pageContext, Node sourceNode ,nsIDOMNode domNode) {
final Attr attr= getOutputAttributeNode((Element) sourceNode);
- int offset = TextUtil.getStartELDocumentPosition(attr);
+ int offset = TextUtil.getPositionForOpenOn(attr, pageContext);
if(offset!=-1){
return new Region(offset, 0);
} else {
@@ -109,4 +98,21 @@
}
}
+
+ /**
+ * Gets the output attribute node.
+ * This method may be overridden in subclasses.
+ *
+ * @param element the element
+ *
+ * @return the output attribute node
+ */
+ public Attr getOutputAttributeNode(Element element) {
+ if (element.hasAttribute(JSF.ATTR_VALUE)) {
+ return element.getAttributeNode(JSF.ATTR_VALUE);
+ } else if (element.hasAttribute(JSF.ATTR_BINDING)) {
+ return element.getAttributeNode(JSF.ATTR_BINDING);
+ }
+ return null;
+ }
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2012-09-20 16:18:44 UTC (rev 43868)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2012-09-20 16:47:41 UTC (rev 43869)
@@ -42,16 +42,6 @@
*/
protected String escapeAttributeName = JSF.ATTR_ESCAPE;
- @Override
- public Attr getOutputAttributeNode(Element element) {
- if (element.hasAttribute(JSF.ATTR_VALUE)) {
- return element.getAttributeNode(JSF.ATTR_VALUE);
- } else if (element.hasAttribute(JSF.ATTR_BINDING)) {
- return element.getAttributeNode(JSF.ATTR_BINDING);
- }
- return null;
- }
-
/**
* copy outputAttributes
*
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2012-09-20 16:18:44 UTC (rev 43868)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2012-09-20 16:47:41 UTC (rev 43869)
@@ -12,15 +12,19 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
-import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.jst.jsp.util.NodesManagingUtil;
import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.mozilla.interfaces.nsIDOMKeyEvent;
import org.w3c.dom.Node;
@@ -41,7 +45,8 @@
private final static char CHR_ESC_STOP = ';';
private final static char CHR_HEX_FLAG = 'x';
private final static String SPCHARS = "\f\n\r\t\u0020\u2028\u2029"; //$NON-NLS-1$
- private static final Pattern elPattern = Pattern.compile("(#|\\$)\\{\\s*([^\\s])"); //$NON-NLS-1$
+ private static final Pattern EL_START_PATTERN = Pattern.compile("(#|\\$)\\{\\s*([^\\s])"); //$NON-NLS-1$
+ private static final String EL_END_PATTERN = "}"; //$NON-NLS-1$
private final static Map<Character, String> textSet = new HashMap<Character, String>();
static {
@@ -456,24 +461,47 @@
}
/**
* @author mareshkau
+ * @author Yahor Radtsevich (yradtsevich)
* @param node or attribute for which we want calculate position start el position
*
* @return position if we can find position
* -1 if we can't find pisition, <document_offcet>'#{el}', return start position of el
*/
- public static int getStartELDocumentPosition(Node node) {
-
+ @SuppressWarnings("restriction")
+ public static int getPositionForOpenOn(Node node, VpePageContext pageContext) {
if (node != null && node.getNodeValue() != null
&& node.getNodeValue().length() > 0) {
- int elPosition = 0;
- Matcher beginELExpresion = elPattern.matcher(node.getNodeValue());
- if (beginELExpresion.find()) {
- // +1 becouse we should have position of first symbol
- elPosition = beginELExpresion.start(2) + 1;
+ List<Integer> elStarts = new ArrayList<Integer>();
+ Matcher beginELExpresion = EL_START_PATTERN.matcher(node.getNodeValue());
+ while (beginELExpresion.find()) {
+ elStarts.add(beginELExpresion.start(2));
}
- int offset = NodesManagingUtil.getStartOffsetNode(node)
- + elPosition;
- return offset;
+
+ final int startOffsetNode = NodesManagingUtil.getStartOffsetNode(node);
+ final int endOffsetNode = startOffsetNode + node.getNodeValue().length();
+ int openOnOffset = startOffsetNode;
+ if (!elStarts.isEmpty()) {
+ // +1 because we should have position of first symbol
+ openOnOffset += elStarts.get(0) + 1;
+ }
+
+ // Fix for the cases when a part of node value is already selected in the source viewer (JBIDE-11588).
+ // If yes, than check if it is an el-expression and return position of the selection end.
+ Point selection = pageContext.getSourceBuilder().getSelectionRange();
+ int selectionStart = selection.x;
+ int selectionEnd = selectionStart + selection.y;
+ if (selectionStart >= startOffsetNode && selectionEnd <= endOffsetNode) {
+ for (int elStart : elStarts) {
+ int elEnd = node.getNodeValue().indexOf(EL_END_PATTERN, elStart);
+ if (selectionEnd >= elStart + startOffsetNode && selectionEnd <= elEnd + startOffsetNode) {
+ if (selectionStart != selectionEnd) {
+ openOnOffset = selectionEnd - 1;
+ }
+ }
+ }
+ }
+
+ return openOnOffset;
}
return -1;
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/src/org/jboss/tools/vpe/docbook/template/DocbookTextTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.docbook/src/org/jboss/tools/vpe/docbook/template/DocbookTextTemplate.java 2012-09-20 16:18:44 UTC (rev 43868)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.docbook/src/org/jboss/tools/vpe/docbook/template/DocbookTextTemplate.java 2012-09-20 16:47:41 UTC (rev 43869)
@@ -70,7 +70,7 @@
Point selection = pageContext.getSourceBuilder().getSelectionRange();
//processing for el expressions
- int offset = TextUtil.getStartELDocumentPosition(sourceNode);
+ int offset = TextUtil.getPositionForOpenOn(sourceNode, pageContext);
IRegion resultRegion;
if(offset >= 0) {
resultRegion = new Region(offset,0);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2012-09-20 16:18:44 UTC (rev 43868)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2012-09-20 16:47:41 UTC (rev 43869)
@@ -67,7 +67,7 @@
Point selection = pageContext.getSourceBuilder().getSelectionRange();
//processing for el expressions
- int offset = TextUtil.getStartELDocumentPosition(sourceNode);
+ int offset = TextUtil.getPositionForOpenOn(sourceNode, pageContext);
IRegion resultRegion;
if(offset >= 0) {
resultRegion = new Region(offset,0);
13 years, 6 months
JBoss Tools SVN: r43868 - trunk/vpe/plugins/org.jboss.tools.vpe.jsp/templates.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2012-09-20 12:18:44 -0400 (Thu, 20 Sep 2012)
New Revision: 43868
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.jsp/templates/vpe-templates-jsp.xml
Log:
https://issues.jboss.org/browse/JBIDE-9181 - jsp tags were made invisible, <vpe:any> was removed.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.jsp/templates/vpe-templates-jsp.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.jsp/templates/vpe-templates-jsp.xml 2012-09-20 16:09:05 UTC (rev 43867)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.jsp/templates/vpe-templates-jsp.xml 2012-09-20 16:18:44 UTC (rev 43868)
@@ -4,27 +4,19 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<vpe:tag name="jsp:declaration" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:expression" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:scriptlet" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:directive.attribute" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:directive.include" case-sensitive="yes">
@@ -46,15 +38,11 @@
</vpe:tag>
<vpe:tag name="jsp:directive.page" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:directive.tag" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:directive.taglib" case-sensitive="yes">
@@ -64,15 +52,11 @@
</vpe:tag>
<vpe:tag name="jsp:directive.variable" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:attribute" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:body" case-sensitive="yes">
@@ -86,45 +70,31 @@
</vpe:tag>
<vpe:tag name="jsp:element" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:doBody" case-sensitive="no">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:forward" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:getProperty" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:invoke" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:output" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:plugin" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:root" case-sensitive="yes">
@@ -134,9 +104,7 @@
</vpe:tag>
<vpe:tag name="jsp:setProperty" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
<vpe:tag name="jsp:text" case-sensitive="yes">
@@ -150,8 +118,6 @@
</vpe:tag>
<vpe:tag name="jsp:useBean" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <vpe:any value="{name()}" title="{tagstring()}" style="display:none;"/>
- </vpe:template>
+ <vpe:template children="no" modify="no" />
</vpe:tag>
</vpe:templates>
13 years, 6 months
JBoss Tools SVN: r43867 - in trunk/documentation/whatsnew: openshift and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-09-20 12:09:05 -0400 (Thu, 20 Sep 2012)
New Revision: 43867
Modified:
trunk/documentation/whatsnew/index.html
trunk/documentation/whatsnew/openshift/openshift-news-2.3.0.CR1.html
Log:
Added missing link from index to cdi-news-3.3.0.CR1.html
Modified: trunk/documentation/whatsnew/index.html
===================================================================
--- trunk/documentation/whatsnew/index.html 2012-09-20 14:58:14 UTC (rev 43866)
+++ trunk/documentation/whatsnew/index.html 2012-09-20 16:09:05 UTC (rev 43867)
@@ -89,6 +89,7 @@
<p><a href="jmx/jmx-news-1.2.0.CR1.html">JMX</a></p>
<p><a href="openshift/openshift-news-2.3.0.CR1.html">OpenShift
Tools</a></p>
+ <p><a href="cdi/cdi-news-3.3.0.CR1.html">CDI Tools</a></p>
<p><a href="maven/maven-news-3.3.0.CR1.html">Maven</a></p>
<p><a href="vpe/vpe-news-3.3.0.CR1.html">Visual Page
Editor/BrowserSim</a></p>
Modified: trunk/documentation/whatsnew/openshift/openshift-news-2.3.0.CR1.html
===================================================================
--- trunk/documentation/whatsnew/openshift/openshift-news-2.3.0.CR1.html 2012-09-20 14:58:14 UTC (rev 43866)
+++ trunk/documentation/whatsnew/openshift/openshift-news-2.3.0.CR1.html 2012-09-20 16:09:05 UTC (rev 43867)
@@ -29,7 +29,7 @@
<p align="right">
<a href="../index.html">< Main Index</a> <a
- href="../maven/maven-news-3.3.0.CR1.html">Maven Tools ></a>
+ href="../cdi/cdi-news-3.3.0.CR1.html">CDI Tools ></a>
</p>
<table border="0" cellpadding="10" cellspacing="0" width="80%">
13 years, 6 months
JBoss Tools SVN: r43866 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-09-20 10:58:14 -0400 (Thu, 20 Sep 2012)
New Revision: 43866
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java
Log:
[JBIDE-11912] corrected class header
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java 2012-09-20 14:57:32 UTC (rev 43865)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java 2012-09-20 14:58:14 UTC (rev 43866)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -7,6 +17,9 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
+/**
+ * @author Andre Dietisheim
+ */
public class OkButtonWizardDialog extends WizardDialog {
public OkButtonWizardDialog(Shell parentShell, IWizard newWizard) {
13 years, 6 months
JBoss Tools SVN: r43865 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui: wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-09-20 10:57:32 -0400 (Thu, 20 Sep 2012)
New Revision: 43865
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/command/ManageSSHKeysHandler.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
Log:
[JBIDE-11912] Replaced "Cancel" and "Finish" buttons by single "OK" button in manage ssh keys wizard
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/command/ManageSSHKeysHandler.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/command/ManageSSHKeysHandler.java 2012-09-20 14:31:58 UTC (rev 43864)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/command/ManageSSHKeysHandler.java 2012-09-20 14:57:32 UTC (rev 43865)
@@ -16,8 +16,8 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+import org.jboss.tools.openshift.express.internal.ui.wizard.OkButtonWizardDialog;
import org.jboss.tools.openshift.express.internal.ui.wizard.ssh.ManageSSHKeysWizard;
/**
@@ -35,7 +35,7 @@
Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
if (selectedElement instanceof UserDelegate) {
UserDelegate user = (UserDelegate) selectedElement;
- WizardUtils.openWizardDialog(new ManageSSHKeysWizard(user), HandlerUtil.getActiveShell(event));
+ new OkButtonWizardDialog(HandlerUtil.getActiveShell(event), new ManageSSHKeysWizard(user)).open();
}
}
return null;
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 14:31:58 UTC (rev 43864)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 14:57:32 UTC (rev 43865)
@@ -31,7 +31,6 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.openshift.express.internal.ui.databinding.RequiredControlDecorationUpdater;
@@ -85,7 +84,7 @@
@Override
public void widgetSelected(SelectionEvent e) {
- WizardUtils.openWizardDialog(new ManageSSHKeysWizard(pageModel.getUser()), getShell());
+ new OkButtonWizardDialog(getShell(), new ManageSSHKeysWizard(pageModel.getUser())).open();
}
};
}
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java 2012-09-20 14:57:32 UTC (rev 43865)
@@ -0,0 +1,22 @@
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class OkButtonWizardDialog extends WizardDialog {
+
+ public OkButtonWizardDialog(Shell parentShell, IWizard newWizard) {
+ super(parentShell, newWizard);
+ }
+
+ protected Control createButtonBar(Composite parent) {
+ Control control = super.createButtonBar(parent);
+ getButton(IDialogConstants.FINISH_ID).setText("OK");
+ getButton(CANCEL).setVisible(false);
+ return control;
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OkButtonWizardDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years, 6 months
JBoss Tools SVN: r43864 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-09-20 10:31:58 -0400 (Thu, 20 Sep 2012)
New Revision: 43864
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
Log:
corrected class header
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 14:31:02 UTC (rev 43863)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 14:31:58 UTC (rev 43864)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
+ * Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
13 years, 6 months
JBoss Tools SVN: r43863 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard: ssh and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-09-20 10:31:02 -0400 (Thu, 20 Sep 2012)
New Revision: 43863
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
Log:
[JBIDE-11912] removed SSH keys portion from NewDomainWizard, added link to ssh keys management wizard
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 13:52:33 UTC (rev 43862)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 14:31:02 UTC (rev 43863)
@@ -10,65 +10,39 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.io.File;
-import java.io.FileNotFoundException;
-
-import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.common.ui.databinding.MandatoryStringValidator;
+import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
-import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.databinding.RequiredControlDecorationUpdater;
-import org.jboss.tools.openshift.express.internal.ui.utils.FileUtils;
-import org.jboss.tools.openshift.express.internal.ui.utils.SSHUserConfig;
-import org.jboss.tools.openshift.express.internal.ui.utils.SSHUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
+import org.jboss.tools.openshift.express.internal.ui.wizard.ssh.ManageSSHKeysWizard;
-import com.openshift.client.OpenShiftException;
-
/**
* @author André Dietisheim
*/
public class NewDomainWizardPage extends AbstractOpenShiftWizardPage {
- private static final String FILTEREXPRESSION_PUBLIC_SSH_KEY = "*.pub";
- private static final String FILTERNAME_PUBLIC_SSH_KEY = "Public ssh key file (*.pub)";
-
private NewDomainWizardPageModel pageModel;
public NewDomainWizardPage(NewDomainWizardPageModel pageModel, IWizard wizard) {
@@ -95,156 +69,32 @@
final IObservableValue namespaceModelObservable = BeanProperties.value(
NewDomainWizardPageModel.PROPERTY_DOMAIN_ID).observe(pageModel);
ValueBindingBuilder.bind(namespaceTextObservable).to(namespaceModelObservable).in(dbc);
-
- Label sshKeyLabel = new Label(container, SWT.NONE);
- sshKeyLabel.setText("SSH Public Key");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(sshKeyLabel);
- Text sshKeyText = new Text(container, SWT.READ_ONLY | SWT.BORDER);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sshKeyText);
- Binding sshKeyTextBinding = dbc.bindValue(
- WidgetProperties.text(SWT.Modify).observe(sshKeyText),
- BeanProperties.value(NewDomainWizardPageModel.PROPERTY_SSHKEY).observe(pageModel),
- new UpdateValueStrategy().setAfterGetValidator(new MandatoryStringValidator(
- "You have to select a ssh public key")),
- new UpdateValueStrategy().setAfterGetValidator(new SSHKeyValidator()));
- ControlDecorationSupport.create(sshKeyTextBinding, SWT.TOP | SWT.LEFT);
- try {
- pageModel.initSshKey();
- } catch (OpenShiftException ex) {
- IStatus status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- "Could check your ssh keys", ex);
- OpenShiftUIActivator.log(status);
- ErrorDialog.openError(getShell(),
- "Error checking your ssh keys",
- "Could not check your ssh keys", status);
- }
- Button browseButton = new Button(container, SWT.PUSH);
- browseButton.setText("Browse...");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseButton);
- browseButton.addSelectionListener(onBrowse());
-
- Button createButton = new Button(container, SWT.PUSH);
- createButton.setText("New");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(createButton);
- createButton.addSelectionListener(onNew());
-
new Label(container, SWT.NONE); // spacer
Link sshPrefsLink = new Link(container, SWT.NONE);
- sshPrefsLink
- .setText("Please make sure that your private key for the public key is listed in the <a>SSH2 Preferences</a>");
+ sshPrefsLink.setText(
+ "Please make sure that you have SSH keys added to your OpenShift account.\n" +
+ "You may check them in the <a>SSH2 keys wizard</a>");
GridDataFactory.fillDefaults()
.span(3, 1).align(SWT.FILL, SWT.CENTER).applyTo(sshPrefsLink);
- sshPrefsLink.addSelectionListener(onSshPrefs());
+ sshPrefsLink.addSelectionListener(onManageSSHKeys());
}
- private SelectionListener onNew() {
+ private SelectionAdapter onManageSSHKeys() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
-
- try {
- if (pageModel.publicKeyExists()) {
- MessageDialog.openInformation(getShell(),
- "Libra Key already present",
- "You already have a key at \"" + pageModel.getPublicKey() + "\". Please move it or use it.");
- return;
- }
-
- InputDialog dialog = new PassphraseDialog(getShell());
- if (Dialog.OK == dialog.open()) {
- try {
- String passPhrase = dialog.getValue();
- pageModel.createLibraKeyPair(passPhrase);
- } catch (FileNotFoundException ex) {
- IStatus status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- "Could not read the ssh key folder", ex);
- OpenShiftUIActivator.log(status);
- ErrorDialog.openError(getShell(),
- "Error creating a new ssh key pair",
- "Could not create a new ssh key pair", status);
- }
- }
- } catch (OpenShiftException ex) {
- IStatus status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- "Could not create an ssh key pair", ex);
- OpenShiftUIActivator.log(status);
- ErrorDialog.openError(getShell(),
- "Error creating a new ssh key pair",
- "Could not create a new ssh key pair", status);
- }
+ WizardUtils.openWizardDialog(new ManageSSHKeysWizard(pageModel.getUser()), getShell());
}
};
}
- private SelectionListener onBrowse() {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- FileDialog dialog = new FileDialog(shell);
- try {
- dialog.setFilterPath(SshPrivateKeysPreferences.getSshKeyDirectory());
- } catch (FileNotFoundException ex) {
- // ignore
- }
- dialog.setFilterNames(new String[] { FILTERNAME_PUBLIC_SSH_KEY });
- dialog.setFilterExtensions(new String[] { FILTEREXPRESSION_PUBLIC_SSH_KEY });
- String sshKeyPath = dialog.open();
- if (sshKeyPath != null) {
- pageModel.setSshKey(sshKeyPath);
- }
- }
- };
- }
-
- private SelectionAdapter onSshPrefs() {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- SshPrivateKeysPreferences.openPreferencesPage(getShell());
- // refresh warning about key
- // (since user may have changed SSH2 prefs)
- getDatabindingContext().updateTargets();
- }
- };
- }
-
@Override
protected void setupWizardPageSupport(DataBindingContext dbc) {
ParametrizableWizardPageSupport.create(IStatus.ERROR | IStatus.CANCEL, this, dbc);
}
- private class SSHKeyValidator implements IValidator {
-
- @Override
- public IStatus validate(Object value) {
- if (!(value instanceof String)
- || StringUtils.isEmpty((String) value)
- || !FileUtils.canRead((String) value)) {
- return ValidationStatus.error("You have to provide a valid ssh public key");
- }
- if (pageModel.hasConfiguredFixedPrivateKeys()) {
- return ValidationStatus.warning(
- NLS.bind("Your SSH config ({0}) contains fixed keys for OpenShift servers. " +
- "This can override any Eclipse specific SSH key preferences.", new SSHUserConfig(SSHUtils.getSSH2Home()).getFile()));
- } else if (!SSHUtils.publicKeyMatchesPrivateKeyInPreferences(new File((String) value))) {
- return ValidationStatus.warning(
- NLS.bind("Could not find the private portion for your public key in the preferences. "
- + "Make sure it is listed in the ssh2 preferences.", value));
- }
- return ValidationStatus.ok();
- }
-
- }
-
private class NamespaceValidator extends MultiValidator {
private final ISWTObservableValue domainNameObservable;
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2012-09-20 13:52:33 UTC (rev 43862)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2012-09-20 14:31:02 UTC (rev 43863)
@@ -10,199 +10,38 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jsch.internal.core.IConstants;
-import org.eclipse.jsch.internal.core.JSchCorePlugin;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
-import org.jboss.tools.openshift.express.internal.ui.utils.FileUtils;
-import org.jboss.tools.openshift.express.internal.ui.utils.SSHUserConfig;
-import org.jboss.tools.openshift.express.internal.ui.utils.SSHUtils;
import com.openshift.client.IDomain;
-import com.openshift.client.IOpenShiftSSHKey;
-import com.openshift.client.ISSHPublicKey;
import com.openshift.client.OpenShiftException;
-import com.openshift.client.SSHKeyPair;
-import com.openshift.client.SSHPublicKey;
/**
* @author André Dietisheim
*/
public class NewDomainWizardPageModel extends ObservableUIPojo {
- public static final String ID_RSA_FILENAME = "id_rsa";
- public static final String LIBRA_ID_RSA_FILENAME = "libra_id_rsa";
- private static final String PUBLIC_KEY_SUFFIX = ".pub";
- private static final String KEYS_SEPARATOR = ",";
-
- private static final String SSHKEY_DEFAULT_NAME = "jbosstools"; //$NON-NLS-1$
-
public static final String PROPERTY_DOMAIN_ID = "domainId";
public static final String PROPERTY_SSHKEY = "sshKey";
private String domainId;
private IDomain domain;
- private String sshKey;
private UserDelegate user;
public NewDomainWizardPageModel(UserDelegate user) {
this.user = user;
}
-
- public void initSshKey() throws OpenShiftException {
- if (!publicKeyExists()) {
- return;
- }
- File libraPublicKey = getPublicKey();
- setSshKey(libraPublicKey.getAbsolutePath());
- }
-
- /**
- * Returns the file of the libra public key. It is not checking if the file exists.
- *
- * @return the libra public key
- * @throws OpenShiftException
- */
- public File getPublicKey() throws OpenShiftException {
- File libraPrivateKey = getPrivateKey();
- return new File(libraPrivateKey.getParent(), getPublicKeyPath(libraPrivateKey.getName()));
- }
-
- private String getPublicKeyPath(String privateKeyPath) {
- return privateKeyPath + PUBLIC_KEY_SUFFIX;
- }
-
- public File getPrivateKey() throws OpenShiftException {
- String ssh2Home = checkedGetSSH2Home();
- ensureSSHHomeExists(ssh2Home);
- if (hasConfiguredFixedPrivateKeys()) {
- return new File(ssh2Home, LIBRA_ID_RSA_FILENAME);
- } else {
- return new File(ssh2Home, ID_RSA_FILENAME);
- }
- }
-
- private String checkedGetSSH2Home() throws OpenShiftException {
- String ssh2Home = SSHUtils.getSSH2Home();
- if (ssh2Home == null
- || ssh2Home.trim().length() == 0) {
- throw new OpenShiftException("Could not determine your ssh2 home directory");
- }
- return ssh2Home;
- }
-
- public boolean hasConfiguredFixedPrivateKeys() {
- try {
- SSHUserConfig sshUserConfig = new SSHUserConfig(checkedGetSSH2Home());
- return sshUserConfig.hasLibraIdentifyFile();
- } catch (OpenShiftException e) {
- return false;
- }
- }
-
-
public String getDomainId() {
return this.domainId;
}
public void createDomain() throws OpenShiftException, IOException {
user.createDomain(domainId);
- ISSHPublicKey sshKey = loadSshKey();
- IOpenShiftSSHKey sshKeyResource = user.getSSHKeyByPublicKey(sshKey.getPublicKey());
- if (sshKeyResource == null) {
- user.putSSHKey(getTimestampKeyname(), sshKey);
- }
}
-
- private String getTimestampKeyname() {
- return new StringBuilder(
- SSHKEY_DEFAULT_NAME)
- .append(new SimpleDateFormat("yyyyMMddhmS").format(new Date()))
- .toString();
- }
-
- public String getSshKey() {
- return sshKey;
- }
-
- public boolean publicKeyExists() throws OpenShiftException {
- return FileUtils.canRead(getPublicKey());
- }
-
- public void createLibraKeyPair(String passPhrase) throws FileNotFoundException, OpenShiftException {
- File libraPublicKey = getPublicKey();
- if (libraPublicKey.canRead()) {
- // key already exists
- return;
- }
- ensureSSHHomeExists(checkedGetSSH2Home());
- File libraPrivateKey = getPrivateKey();
- SSHKeyPair keyPair = SSHKeyPair.create(passPhrase, libraPrivateKey.getAbsolutePath(), libraPublicKey.getAbsolutePath());
- setFilePermissions(libraPrivateKey);
- addToPrivateKeysPreferences(keyPair);
- setSshKey(keyPair.getPublicKeyPath());
- }
-
- private void ensureSSHHomeExists(String ssh2Home)
- throws OpenShiftException {
- File ssh2HomeFile = new File(ssh2Home);
- if (FileUtils.canRead(ssh2HomeFile)) {
- if (!FileUtils.isDirectory(ssh2HomeFile)) {
- throw new OpenShiftException(
- ssh2Home + " is a file instead of a directory. This prevents creation and usage of ssh keys");
- }
- return;
- }
-
- try {
- if(!ssh2HomeFile.mkdirs()) {
- throw new OpenShiftException("Could not create ssh2 home directory at {0}", ssh2Home);
- }
- } catch(SecurityException e) {
- throw new OpenShiftException(e, "Could not create ssh2 home directory at {0}", ssh2Home);
- }
- }
-
- private void setFilePermissions(File file) {
- // set f permission to correspond to 'chmod 0600' read/write only for user
- // First clear all permissions for both user and others
- file.setReadable(false, false);
- file.setWritable(false, false);
- // Enable only readable for user
- file.setReadable(true, true);
- file.setWritable(true, true);
- }
-
- private void addToPrivateKeysPreferences(SSHKeyPair keyPair) {
- Preferences preferences = JSchCorePlugin.getPlugin().getPluginPreferences();
- String privateKeys = preferences.getString(IConstants.KEY_PRIVATEKEY);
- if (privateKeys != null
- && privateKeys.trim().length() > 0) {
- privateKeys = privateKeys + "," + keyPair.getPrivateKeyPath();
- } else {
- privateKeys = keyPair.getPrivateKeyPath();
- }
- preferences.setValue(IConstants.KEY_PRIVATEKEY, privateKeys);
- JSchCorePlugin.getPlugin().setNeedToLoadKeys(true);
- JSchCorePlugin.getPlugin().savePluginPreferences();
- }
- public void setSshKey(String sshKey) {
- firePropertyChange(PROPERTY_SSHKEY, this.sshKey, this.sshKey = sshKey);
- }
-
- private ISSHPublicKey loadSshKey() throws IOException, OpenShiftException {
- return new SSHPublicKey(new File(sshKey));
- }
-
public void setDomainId(String domainId) {
firePropertyChange(PROPERTY_DOMAIN_ID, this.domainId, this.domainId = domainId);
}
@@ -215,4 +54,7 @@
return domain;
}
+ public UserDelegate getUser() {
+ return user;
+ }
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java 2012-09-20 13:52:33 UTC (rev 43862)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java 2012-09-20 14:31:02 UTC (rev 43863)
@@ -48,6 +48,9 @@
*/
public class AddSSHKeyWizardPage extends AbstractOpenShiftWizardPage {
+ private static final String FILTEREXPRESSION_PUBLIC_SSH_KEY = "*.pub";
+ private static final String FILTERNAME_PUBLIC_SSH_KEY = "Public ssh key file (*.pub)";
+
private AddSSHKeyWizardPageModel pageModel;
public AddSSHKeyWizardPage(UserDelegate user, IWizard wizard) {
@@ -128,6 +131,8 @@
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setFilterPath(SSHUtils.getSSH2Home());
+ dialog.setFilterExtensions(new String[] {FILTEREXPRESSION_PUBLIC_SSH_KEY });
+ dialog.setFilterNames(new String[]{FILTERNAME_PUBLIC_SSH_KEY});
String filePath = null;
if ((filePath = dialog.open()) != null) {
pageModel.setPublicKeyPath(filePath);
13 years, 6 months
JBoss Tools SVN: r43862 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui: wizard and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-09-20 09:52:33 -0400 (Thu, 20 Sep 2012)
New Revision: 43862
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SSHUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AbstractSSHKeyWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyJob.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ISSHKeyWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/NewSSHKeyWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/NewSSHKeyWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/databinding/SSHPublicKeyValidator.java
Log:
[JBIDE-11912] added links to ssh prefs and validation
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SSHUtils.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SSHUtils.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SSHUtils.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -10,15 +10,139 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.utils;
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jsch.internal.core.IConstants;
import org.eclipse.jsch.internal.core.JSchCorePlugin;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
/**
* @author Andre Dietisheim
*/
public class SSHUtils {
+ private static final String SSH_PREFERENCE_PAGE_ID = "org.eclipse.jsch.ui.SSHPreferences";
+ private static final String KEYS_SEPARATOR = ",";
+
public static String getSSH2Home() {
return JSchCorePlugin.getPlugin().getPluginPreferences().getString(IConstants.KEY_SSH2HOME);
}
+
+ public static void setPrivateKeyPermissions(File privateKey) {
+ // set f permission to correspond to 'chmod 0600' read/write only for
+ // user
+ // First clear all permissions for both user and others
+ privateKey.setReadable(false, false);
+ privateKey.setWritable(false, false);
+ // Enable only readable for user
+ privateKey.setReadable(true, true);
+ privateKey.setWritable(true, true);
+ }
+
+ public static String[] getPrivateKeysFromPreferences() {
+ String privateKeys =
+ JSchCorePlugin.getPlugin().getPluginPreferences().getString(IConstants.KEY_PRIVATEKEY);
+ if (privateKeys != null
+ && privateKeys.trim().length() > 0) {
+ return privateKeys.split(KEYS_SEPARATOR);
+ } else {
+ return new String[0];
+ }
+ }
+
+ public static boolean isPrivateKeyForPublicKeyKnownToSsh(String publicKeyPath) {
+ if (StringUtils.isEmpty(publicKeyPath)) {
+ return false;
+ }
+ for (String preferencesKey : getPrivateKeysFromPreferences()) {
+ try {
+ File privateKey = SshPrivateKeysPreferences.getKeyFile(preferencesKey);
+ if (privateKey == null
+ || !FileUtils.canRead(privateKey)) {
+ continue;
+ }
+ if (publicKeyPath.startsWith(privateKey.getAbsolutePath() + ".")
+ || publicKeyPath.startsWith(privateKey.getPath() + ".")) {
+ return true;
+ }
+ } catch (FileNotFoundException e) {
+ continue;
+ }
+ }
+ return false;
+ }
+
+ public static void addToPrivateKeysPreferences(File privateKey) {
+ Preferences preferences = JSchCorePlugin.getPlugin().getPluginPreferences();
+ String privateKeys = preferences.getString(IConstants.KEY_PRIVATEKEY);
+ if (privateKeys != null
+ && privateKeys.trim().length() > 0) {
+ privateKeys = privateKeys + "," + privateKey.getAbsolutePath();
+ } else {
+ privateKeys = privateKey.getAbsolutePath();
+ }
+ preferences.setValue(IConstants.KEY_PRIVATEKEY, privateKeys);
+ JSchCorePlugin.getPlugin().setNeedToLoadKeys(true);
+ JSchCorePlugin.getPlugin().savePluginPreferences();
+ }
+
+ public static int openPreferencesPage(Shell shell) {
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+ shell, SSH_PREFERENCE_PAGE_ID, null, null);
+ return dialog.open();
+
+ }
+
+ /**
+ * Returns <code>true</code> if the given
+ * @param publicKeyPath
+ * @return
+ */
+ public static boolean publicKeyMatchesPrivateKeyInPreferences(File publicKey) {
+ for (String preferencesKey : SSHUtils.getPrivateKeysFromPreferences()) {
+ try {
+ File privateKey = SshPrivateKeysPreferences.getKeyFile(preferencesKey.trim());
+ if (privateKey == null) {
+ continue;
+ }
+ if (publicKey.getAbsolutePath().startsWith(privateKey.getAbsolutePath() + ".")) {
+ return true;
+ }
+ } catch (FileNotFoundException e) {
+ continue;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the key file for a given relative or absolute keyPath. The
+ * keyPath may be absolute or relative to the ssh home directory.
+ *
+ * @param keyPath
+ * @return
+ * @throws FileNotFoundException
+ */
+ public static File getKeyForRelativeOrAbsolutePath(String keyPath) throws FileNotFoundException {
+ if (isEmpty(keyPath)) {
+ return null;
+ }
+
+ if (keyPath.startsWith(File.separator)) {
+ return new File(keyPath);
+ } else {
+ return new File(getSSH2Home(), keyPath);
+ }
+ }
+
+ private static boolean isEmpty(String string) {
+ return string == null
+ || string.isEmpty();
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -178,7 +178,7 @@
new RemoteNameValidationStatusProvider(remoteNameTextObservable, projectNameModelObservable));
Link sshPrefsLink = new Link(parent, SWT.NONE);
- sshPrefsLink.setText("Make sure your SSH key used with the domain is listed in <a>SSH2 Preferences</a>.");
+ sshPrefsLink.setText("Make sure your SSH key used with your user " + wizardModel.getUser().getUsername() + "\nis listed in <a>SSH2 Preferences</a>.");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).indent(10, 0)
.applyTo(sshPrefsLink);
sshPrefsLink.addSelectionListener(onSshPrefs());
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -235,7 +235,7 @@
return ValidationStatus.warning(
NLS.bind("Your SSH config ({0}) contains fixed keys for OpenShift servers. " +
"This can override any Eclipse specific SSH key preferences.", new SSHUserConfig(SSHUtils.getSSH2Home()).getFile()));
- } else if (!isKeyKnownToSsh((String) value)) {
+ } else if (!SSHUtils.publicKeyMatchesPrivateKeyInPreferences(new File((String) value))) {
return ValidationStatus.warning(
NLS.bind("Could not find the private portion for your public key in the preferences. "
+ "Make sure it is listed in the ssh2 preferences.", value));
@@ -243,27 +243,6 @@
return ValidationStatus.ok();
}
- private boolean isKeyKnownToSsh(String publicKeyPath) {
- if (StringUtils.isEmpty(publicKeyPath)) {
- return false;
- }
- for (String preferencesKey : pageModel.getPrivateKeysFromPreferences()) {
- try {
- File privateKey = SshPrivateKeysPreferences.getKeyFile(preferencesKey);
- if (privateKey == null
- || !FileUtils.canRead(privateKey)) {
- continue;
- }
- if (publicKeyPath.startsWith(privateKey.getAbsolutePath() + ".")
- || publicKeyPath.startsWith(privateKey.getPath() + ".")) {
- return true;
- }
- } catch (FileNotFoundException e) {
- continue;
- }
- }
- return false;
- }
}
private class NamespaceValidator extends MultiValidator {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -180,17 +180,6 @@
file.setReadable(true, true);
file.setWritable(true, true);
}
-
- public String[] getPrivateKeysFromPreferences() {
- String privateKeys =
- JSchCorePlugin.getPlugin().getPluginPreferences().getString(IConstants.KEY_PRIVATEKEY);
- if (privateKeys != null
- && privateKeys.trim().length() > 0) {
- return privateKeys.split(KEYS_SEPARATOR);
- } else {
- return new String[0];
- }
- }
private void addToPrivateKeysPreferences(SSHKeyPair keyPair) {
Preferences preferences = JSchCorePlugin.getPlugin().getPluginPreferences();
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AbstractSSHKeyWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AbstractSSHKeyWizardPageModel.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AbstractSSHKeyWizardPageModel.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -12,7 +12,10 @@
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+import org.jboss.tools.openshift.express.internal.ui.utils.SSHUtils;
+import com.openshift.client.OpenShiftException;
+
/**
* @author Andre Dietisheim
*/
@@ -48,4 +51,14 @@
protected UserDelegate getUser() {
return user;
}
+
+ protected String checkedGetSSH2Home() throws OpenShiftException {
+ String ssh2Home = SSHUtils.getSSH2Home();
+ if (ssh2Home == null
+ || ssh2Home.trim().length() == 0) {
+ throw new OpenShiftException("Could not determine your ssh2 home directory");
+ }
+ return ssh2Home;
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyJob.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyJob.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyJob.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -32,7 +32,7 @@
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- model.addConfiguredSSHKey();
+ model.addSSHKey();
return Status.OK_STATUS;
} catch (Exception e) {
return OpenShiftUIActivator.createErrorStatus(
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -30,8 +30,10 @@
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
@@ -49,7 +51,7 @@
private AddSSHKeyWizardPageModel pageModel;
public AddSSHKeyWizardPage(UserDelegate user, IWizard wizard) {
- super("Add existing SSH Key", "Add an exiting SSH key to your OpenShift account",
+ super("Add existing SSH Key", "Add an exiting SSH key to your OpenShift user " + user.getUsername(),
"AddSSHKeysPage", wizard);
this.pageModel = new AddSSHKeyWizardPageModel(user);
}
@@ -109,6 +111,14 @@
dbc.addValidationStatusProvider(sshPublicKeyValidator);
ControlDecorationSupport.create(
sshPublicKeyValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
+
+ Link sshPrefsLink = new Link(parent, SWT.NONE);
+ sshPrefsLink
+ .setText("Please make sure that your private key for this public key is listed in the\n<a>SSH2 Preferences</a>");
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.CENTER).applyTo(sshPrefsLink);
+ sshPrefsLink.addSelectionListener(onSshPrefs(dbc));
+
}
private SelectionListener onBrowse() {
@@ -126,6 +136,18 @@
};
}
+ private SelectionAdapter onSshPrefs(final DataBindingContext dbc) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ SSHUtils.openPreferencesPage(getShell());
+ // trigger revalidation after prefs were changed
+ dbc.updateTargets();
+ }
+ };
+ }
+
public IStatus addConfiguredSSHKey() {
try {
return WizardUtils.runInWizard(new AddSSHKeyJob(pageModel), getContainer());
@@ -133,4 +155,11 @@
return OpenShiftUIActivator.createErrorStatus("Could not add ssh key " + pageModel.getName() + ".");
}
}
+
+ @Override
+ protected void setupWizardPageSupport(DataBindingContext dbc) {
+ ParametrizableWizardPageSupport.create(
+ IStatus.ERROR | IStatus.INFO | IStatus.CANCEL, this,
+ dbc);
+ }
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPageModel.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPageModel.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -15,6 +15,7 @@
import java.io.IOException;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+import org.jboss.tools.openshift.express.internal.ui.utils.SSHUserConfig;
import com.openshift.client.OpenShiftException;
import com.openshift.client.SSHPublicKey;
@@ -48,7 +49,7 @@
return getUser().hasSSHPublicKey(publicKeyContent);
}
- public void addConfiguredSSHKey() throws FileNotFoundException, OpenShiftException, IOException {
+ public void addSSHKey() throws FileNotFoundException, OpenShiftException, IOException {
SSHPublicKey sshPublicKey = new SSHPublicKey(getPublicKey());
getUser().putSSHKey(getName(), sshPublicKey);
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ISSHKeyWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ISSHKeyWizardPageModel.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ISSHKeyWizardPageModel.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -31,7 +31,7 @@
public boolean hasPublicKey(String publicKeyContent);
- public void addConfiguredSSHKey() throws FileNotFoundException, OpenShiftException, IOException;
+ public void addSSHKey() throws FileNotFoundException, OpenShiftException, IOException;
public File getPublicKey();
}
\ No newline at end of file
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -14,10 +14,12 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.databinding.viewers.ViewerProperties;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -33,6 +35,7 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.statushandlers.StatusManager;
@@ -41,6 +44,7 @@
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.JobChainBuilder;
+import org.jboss.tools.openshift.express.internal.ui.utils.SSHUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.TableViewerBuilder;
import org.jboss.tools.openshift.express.internal.ui.utils.TableViewerBuilder.IColumnLabelProvider;
@@ -57,7 +61,8 @@
private TableViewer viewer;
public ManageSSHKeysWizardPage(UserDelegate user, IWizard wizard) {
- super("Manage SSH Keys", "Manage the SSH keys that are available to your OpenShift account",
+ super("Manage SSH Keys",
+ "Manage the SSH keys that are available to your OpenShift user\n" + user.getUsername(),
"ManageSSHKeysPage", wizard);
this.pageModel = new ManageSSHKeysWizardPageModel(user);
}
@@ -98,7 +103,19 @@
.align(SWT.FILL, SWT.FILL).applyTo(removeButton);
removeButton.setText("Remove...");
removeButton.addSelectionListener(onRemove());
+ ValueBindingBuilder
+ .bind(WidgetProperties.enabled().observe(removeButton))
+ .to(ViewerProperties.singleSelection().observe(viewer))
+ .converting(new Converter(IOpenShiftSSHKey.class, Boolean.class) {
+ @Override
+ public Object convert(Object fromObject) {
+ IOpenShiftSSHKey key = (IOpenShiftSSHKey) fromObject;
+ return key != null;
+ }
+ })
+ .in(dbc);
+
Composite filler = new Composite(sshKeysGroup, SWT.None);
GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.FILL).applyTo(filler);
@@ -108,6 +125,13 @@
.align(SWT.FILL, SWT.END).applyTo(refreshButton);
refreshButton.setText("Refresh...");
refreshButton.addSelectionListener(onRefresh());
+
+ Link sshPrefsLink = new Link(parent, SWT.NONE);
+ sshPrefsLink
+ .setText("Please make sure that your private keys for these public keys are listed in the\n<a>SSH2 Preferences</a>");
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.CENTER).applyTo(sshPrefsLink);
+ sshPrefsLink.addSelectionListener(onSshPrefs());
}
private SelectionListener onRemove() {
@@ -163,11 +187,11 @@
@Override
public void widgetSelected(SelectionEvent e) {
- if(WizardUtils.openWizardDialog(new NewSSHKeyWizard(pageModel.getUser()), getShell())
+ if (WizardUtils.openWizardDialog(new NewSSHKeyWizard(pageModel.getUser()), getShell())
== Dialog.CANCEL) {
return;
}
-
+
try {
WizardUtils.runInWizard(
new RefreshViewerJob(),
@@ -246,6 +270,16 @@
};
}
+ private SelectionAdapter onSshPrefs() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ SSHUtils.openPreferencesPage(getShell());
+ }
+ };
+ }
+
private class RemoveKeyJob extends Job {
private RemoveKeyJob() {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/NewSSHKeyWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/NewSSHKeyWizardPage.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/NewSSHKeyWizardPage.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -31,6 +31,7 @@
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
@@ -182,6 +183,14 @@
.in(dbc);
ControlDecorationSupport.create(
publicKeyBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
+
+ Link sshPrefsLink = new Link(parent, SWT.NONE);
+ sshPrefsLink
+ .setText("The private key of your new SSH key pair will get added to the \n<a>SSH2 Preferences</a>");
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.CENTER).applyTo(sshPrefsLink);
+ sshPrefsLink.addSelectionListener(onSshPrefs());
+
}
private SelectionListener onBrowse(final Text ssh2HomeText) {
@@ -232,4 +241,15 @@
return OpenShiftUIActivator.createErrorStatus("Could not add ssh key " + pageModel.getName() + ".");
}
}
+
+ private SelectionAdapter onSshPrefs() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ SSHUtils.openPreferencesPage(getShell());
+ }
+ };
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/NewSSHKeyWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/NewSSHKeyWizardPageModel.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/NewSSHKeyWizardPageModel.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -74,10 +74,10 @@
if (StringUtils.isEmpty(publicKeyName)) {
setPublicKeyName(privateKeyName + PUBLICKEY_SUFFIX);
} else {
- String publicKeyNameNoSuffix = StringUtils.getWithoutSuffix(publicKeyName, PUBLICKEY_SUFFIX);
+ String publicKeyNameNoSuffix = StringUtils.getWithoutSuffix(publicKeyName, PUBLICKEY_SUFFIX);
if (privateKeyName.startsWith(publicKeyNameNoSuffix)) {
setPublicKeyName(privateKeyName + PUBLICKEY_SUFFIX);
- }
+ }
}
}
@@ -96,17 +96,24 @@
public void setSSH2Home(String ssh2Home) {
firePropertyChange(PROPERTY_SSH2_HOME, this.ssh2Home, this.ssh2Home = ssh2Home);
}
-
+
public File getPublicKey() {
return new File(ssh2Home, publicKeyName);
}
-
- public void addConfiguredSSHKey() throws FileNotFoundException, OpenShiftException, IOException {
- String privateKeyPath = new File(ssh2Home, privateKeyName).getAbsolutePath();
- String publicKeyPath = new File(ssh2Home, publicKeyName).getAbsolutePath();
- SSHKeyPair keyPair = SSHKeyPair.create(privateKeyPathphrase, privateKeyPath, publicKeyPath);
+
+ public void addSSHKey() throws FileNotFoundException, OpenShiftException, IOException {
+ SSHKeyPair keyPair = createSSHKey();
+ SSHUtils.addToPrivateKeysPreferences(new File(keyPair.getPrivateKeyPath()));
getUser().putSSHKey(getName(), keyPair);
}
+ private SSHKeyPair createSSHKey() {
+ File privateKey = new File(ssh2Home, privateKeyName);
+ File publicKey = new File(ssh2Home, publicKeyName);
+ SSHKeyPair keyPair =
+ SSHKeyPair.create(privateKeyPathphrase, privateKey.getAbsolutePath(), publicKey.getAbsolutePath());
+ SSHUtils.setPrivateKeyPermissions(privateKey);
+ return keyPair;
+ }
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/databinding/SSHPublicKeyValidator.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/databinding/SSHPublicKeyValidator.java 2012-09-20 12:46:19 UTC (rev 43861)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/databinding/SSHPublicKeyValidator.java 2012-09-20 13:52:33 UTC (rev 43862)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard.ssh.databinding;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -17,7 +18,9 @@
import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.openshift.express.internal.ui.utils.SSHUserConfig;
+import org.jboss.tools.openshift.express.internal.ui.utils.SSHUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
import org.jboss.tools.openshift.express.internal.ui.wizard.ssh.AddSSHKeyWizardPageModel;
@@ -51,12 +54,32 @@
} catch (FileNotFoundException e) {
return ValidationStatus.error("Could not load file: " + e.getMessage());
} catch (OpenShiftException e) {
- return ValidationStatus.error(filePath + "is not a valid public SSH key: " + e.getMessage());
+ return ValidationStatus.error(filePath + " is not a valid public SSH key: " + e.getMessage());
} catch (IOException e) {
return ValidationStatus.error("Could not load file: " + e.getMessage());
}
- return Status.OK_STATUS;
+ if (hasSSHConfigurationIdentityKey()) {
+ return ValidationStatus.warning(
+ NLS.bind("Your SSH config ({0}) contains fixed keys for OpenShift servers. " +
+ "This can override any Eclipse specific SSH key preferences.", new SSHUserConfig(SSHUtils.getSSH2Home()).getFile()));
+ } else if (!SSHUtils.publicKeyMatchesPrivateKeyInPreferences(new File(filePath))) {
+ return ValidationStatus.warning(
+ NLS.bind("Could not find the private key for your public key in the preferences. "
+ + "Make sure it is listed in the ssh2 preferences.", filePath));
+ }
+
+
+ return ValidationStatus.ok();
}
+ public boolean hasSSHConfigurationIdentityKey() {
+ try {
+ SSHUserConfig sshUserConfig = new SSHUserConfig(SSHUtils.getSSH2Home());
+ return sshUserConfig.hasLibraIdentifyFile();
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
}
13 years, 6 months
JBoss Tools SVN: r43861 - trunk/as/tests/org.jboss.ide.eclipse.as.ui.bot.test/src/org/jboss/ide/eclipse/as/ui/bot/test/wizard.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2012-09-20 08:46:19 -0400 (Thu, 20 Sep 2012)
New Revision: 43861
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.ui.bot.test/src/org/jboss/ide/eclipse/as/ui/bot/test/wizard/ImportProjectWizard.java
Log:
Trying to load projects for import by focusing the table istead of pressing tab.
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.ui.bot.test/src/org/jboss/ide/eclipse/as/ui/bot/test/wizard/ImportProjectWizard.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.ui.bot.test/src/org/jboss/ide/eclipse/as/ui/bot/test/wizard/ImportProjectWizard.java 2012-09-20 11:30:04 UTC (rev 43860)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.ui.bot.test/src/org/jboss/ide/eclipse/as/ui/bot/test/wizard/ImportProjectWizard.java 2012-09-20 12:46:19 UTC (rev 43861)
@@ -1,8 +1,6 @@
package org.jboss.ide.eclipse.as.ui.bot.test.wizard;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory;
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -50,7 +48,7 @@
private void loadProjectsFromFolder() {
getBot().text(0).setText(projectPath);
getBot().text(0).setFocus();
- KeyboardFactory.getAWTKeyboard().pressShortcut(Keystrokes.TAB);
+ getProjectsTree().setFocus();
getBot().waitUntil(new ProjectIsLoaded());
}
@@ -58,14 +56,14 @@
getBot().radio("Select archive file:").click();
getBot().text(1).setText(zipFilePath);
getBot().text(1).setFocus();
- KeyboardFactory.getAWTKeyboard().pressShortcut(Keystrokes.TAB);
+ getProjectsTree().setFocus();
getBot().waitUntil(new ProjectIsLoaded());
}
private void selectProjects() {
selectCopyProjectsIntoWorkspace();
getBot().button("Deselect All").click();
- SWTBotTree projectsTree = getBot().treeWithLabel("Projects:");
+ SWTBotTree projectsTree = getProjectsTree();
for (String projectName : projectNames){
SWTBotTreeItem projectItem = getProjectTreeItem(projectsTree, projectName);
@@ -73,6 +71,10 @@
}
}
+ private SWTBotTree getProjectsTree() {
+ return getBot().treeWithLabel("Projects:");
+ }
+
private SWTBotTreeItem getProjectTreeItem(SWTBotTree projectsTree, String projectName) {
for (SWTBotTreeItem item : projectsTree.getAllItems()){
if (projectName.equals(getProjectLabel(item.getText()))){
13 years, 6 months