Author: adietish
Date: 2011-02-03 05:59:00 -0500 (Thu, 03 Feb 2011)
New Revision: 28960
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllMatcher.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/StringMatcher.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllImageFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/FieldMatcher.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudElementFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/ICloudElementFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/IInstanceFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/ImageFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/InstanceFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/SecurePasswordStore.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterWizard.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterWizard.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
[JBIDE-8187] added capability to filter for instance alias
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2011-02-03 10:55:48
UTC (rev 28959)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2011-02-03 10:59:00
UTC (rev 28960)
@@ -1,3 +1,10 @@
+2011-02-03 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/deltacloud/core/ImageFilter.java:
+ * src/org/jboss/tools/deltacloud/core/InstanceFilter.java:
+ * src/org/jboss/tools/deltacloud/core/AbstractCloudElementFilter.java:
+ [JBIDE-8187] added capability to filter for instance alias
+
2011-01-27 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (getServerType):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudElementFilter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudElementFilter.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudElementFilter.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -15,10 +15,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import java.util.regex.PatternSyntaxException;
-import org.eclipse.core.runtime.Assert;
-
/**
* @author Jeff Johnston
* @author André Dietisheim
@@ -30,10 +27,37 @@
private IFieldMatcher nameRule;
private IFieldMatcher idRule;
+
public AbstractCloudElementFilter(DeltaCloud cloud) {
+ setRules(new AllMatcher(), new AllMatcher());
this.cloud = cloud;
}
+ public AbstractCloudElementFilter(String nameRule, String idRule, DeltaCloud cloud) {
+ setRules(nameRule, idRule);
+ this.cloud = cloud;
+ }
+
+ public AbstractCloudElementFilter(IFieldMatcher nameRule, IFieldMatcher idRule,
DeltaCloud cloud) {
+ setRules(nameRule, idRule);
+ this.cloud = cloud;
+ }
+
+ protected Iterator<String> setRules(String rules) {
+ Iterator<String> rulesIterator =
Arrays.asList(rules.split(EXPRESSION_DELIMITER)).iterator();
+ setRules(createRule(rulesIterator), createRule(rulesIterator));
+ return rulesIterator;
+ }
+
+ private void setRules(String nameRule, String idRule) {
+ setRules(createRule(nameRule), createRule(idRule));
+ }
+
+ private void setRules(IFieldMatcher nameMatcher, IFieldMatcher idMatcher) {
+ this.nameRule = nameMatcher;
+ this.idRule = idMatcher;
+ }
+
public Collection<CLOUDELEMENT> filter(CLOUDELEMENT[] cloudElements) throws
DeltaCloudException {
List<CLOUDELEMENT> filteredElements = new ArrayList<CLOUDELEMENT>();
for (CLOUDELEMENT cloudElement : cloudElements) {
@@ -49,33 +73,25 @@
&& idRule.matches(cloudElement.getId());
}
- public abstract void setRules(String rulesString) throws PatternSyntaxException;
-
- protected Iterator<String> setRules(String ruleString, Iterator<String>
rulesIterator)
- throws PatternSyntaxException {
- this.nameRule = createRule(rulesIterator);
- this.idRule = createRule(rulesIterator);
- return rulesIterator;
+ protected IFieldMatcher createRule(Iterator<String> rulesIterator) {
+ if (!rulesIterator.hasNext()) {
+ return new AllMatcher();
+ }
+ return createRule(rulesIterator.next());
}
- protected Iterator<String> getRulesIterator(String ruleString) {
- return Arrays.asList(ruleString.split(";")).iterator();
- }
-
- protected IFieldMatcher createRule(Iterator<String> rulesIterator) {
- Assert.isLegal(rulesIterator.hasNext());
- String expression = rulesIterator.next();
- if (expression.equals(ALL_MATCHER_EXPRESSION)) {
- return new AllFieldMatcher();
+ protected IFieldMatcher createRule(String rule) {
+ if (rule == null || rule.equals(ALL_MATCHER_EXPRESSION)) {
+ return new AllMatcher();
} else {
- return new FieldMatcher(expression);
+ return new StringMatcher(rule);
}
}
protected DeltaCloud getCloud() {
return cloud;
}
-
+
@Override
public String toString() {
return nameRule + ";" //$NON-NLS-1$
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -1,15 +0,0 @@
-package org.jboss.tools.deltacloud.core;
-
-public class AllFieldMatcher implements IFieldMatcher {
-
- @Override
- public boolean matches(String input) {
- return true;
- }
-
- @Override
- public String toString() {
- return "*"; //$NON-NLS-1$
- }
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllImageFilter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllImageFilter.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllImageFilter.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.deltacloud.core;
-
-/**
- * A filter for images that matches on all elements (no criteria checked)
- *
- * @see IImageFilter
- * @see DeltaCloud#getImageFilter()
- *
- * @author Jeff Johnston
- * @author André Dietisheim
- */
-public class AllImageFilter extends AbstractCloudElementFilter<DeltaCloudImage>
implements IImageFilter {
-
- private IFieldMatcher matcher = new AllFieldMatcher();
-
- public AllImageFilter(DeltaCloud cloud) {
- super(cloud);
- }
-
- @Override
- public boolean matches(DeltaCloudImage image) {
- return true;
- }
-
- @Override
- public void setRules(String ruleString) {
- // ignore, never set the rules for this filter
- }
-
- @Override
- public IFieldMatcher getNameRule() {
- return matcher;
- }
-
- @Override
- public IFieldMatcher getIdRule() {
- return matcher;
- }
-
- public IFieldMatcher getArchRule() {
- return matcher;
- }
-
- public IFieldMatcher getDescRule() {
- return matcher;
- }
-
- @Override
- public String toString() {
- return ALL_STRING;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -1,70 +0,0 @@
-package org.jboss.tools.deltacloud.core;
-
-/**
- * A filter for instances that matches on all elements (no criteria checked)
- *
- * @see IInstanceFilter
- * @see DeltaCloud#getInstanceFilter()
- *
- * @author Jeff Johnston
- * @author André Dietisheim
- */
-public class AllInstanceFilter extends
AbstractCloudElementFilter<DeltaCloudInstance> implements IInstanceFilter {
-
- public AllInstanceFilter(DeltaCloud cloud) {
- super(cloud);
- }
-
- private IFieldMatcher matcher = new AllFieldMatcher();
-
- @Override
- public boolean matches(DeltaCloudInstance instance) {
- return true;
- }
-
- @Override
- public void setRules(String ruleString) {
- // ignore, never set the rules for this filter
- }
-
-
- @Override
- public IFieldMatcher getNameRule() {
- return matcher;
- }
-
- @Override
- public IFieldMatcher getIdRule() {
- return matcher;
- }
-
- @Override
- public IFieldMatcher getImageIdRule() {
- return matcher;
- }
-
- @Override
- public IFieldMatcher getKeyNameRule() {
- return matcher;
- }
-
- @Override
- public IFieldMatcher getOwnerIdRule() {
- return matcher;
- }
-
- @Override
- public IFieldMatcher getProfileRule() {
- return matcher;
- }
-
- @Override
- public IFieldMatcher getRealmRule() {
- return matcher;
- }
-
- @Override
- public String toString() {
- return ALL_STRING;
- }
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllMatcher.java
(from rev 28745,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllMatcher.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllMatcher.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -0,0 +1,15 @@
+package org.jboss.tools.deltacloud.core;
+
+public class AllMatcher implements IFieldMatcher {
+
+ @Override
+ public boolean matches(String input) {
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "*"; //$NON-NLS-1$
+ }
+
+}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -15,7 +15,6 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import java.util.regex.PatternSyntaxException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.tools.deltacloud.core.client.API.Driver;
@@ -70,7 +69,8 @@
public DeltaCloud(String name, String url, String username, String password,
DeltaCloudDriver driver)
throws DeltaCloudException {
- this(name, url, username, password, driver, IImageFilter.ALL_STRING,
IInstanceFilter.ALL_STRING, new ArrayList<IInstanceAliasMapping>());
+ this(name, url, username, password, driver, IImageFilter.ALL_STRING,
IInstanceFilter.ALL_STRING,
+ new ArrayList<IInstanceAliasMapping>());
}
public DeltaCloud(String name, String url, String username, DeltaCloudDriver driver,
String imageFilterRules,
@@ -88,8 +88,8 @@
this.driver = driver;
this.passwordStore = createSecurePasswordStore(name, username, password);
this.client = createClient(url, username, passwordStore.getPassword());
- this.imageFilter = createImageFilter(imageFilterRules);
- this.instanceFilter = createInstanceFilter(instanceFilterRules);
+ this.imageFilter = new ImageFilter(instanceFilterRules, this);
+ this.instanceFilter = new InstanceFilter(instanceFilterRules, this);
this.instanceAliasMappings = instanceAliasMappings;
}
@@ -211,64 +211,29 @@
return instanceFilter;
}
- public void updateInstanceFilter(String ruleString) throws Exception {
- String rules = getInstanceFilter().toString();
- instanceFilter = createInstanceFilter(ruleString);
- if (!rules.equals(ruleString)) {
- // TODO: remove notification with all instanceRepo, replace by
- // notifying the changed instance
- firePropertyChange(
+ public void updateInstanceFilter(String nameRule, String idRule, String aliasRule,
String imageIdRule,
+ String ownerIdRule, String keyNameRule, String realmRule, String profileRule) throws
Exception {
+ instanceFilter =
+ new InstanceFilter(nameRule, idRule, aliasRule, imageIdRule, ownerIdRule,
keyNameRule, realmRule,
+ profileRule, this);
+ firePropertyChange(
PROP_INSTANCES, getInstancesRepository().get(), getInstancesRepository().get());
- DeltaCloudManager.getDefault().saveClouds();
- }
+ DeltaCloudManager.getDefault().saveClouds();
}
- private IInstanceFilter createInstanceFilter(String ruleString) {
- IInstanceFilter instanceFilter = null;
- if (IInstanceFilter.ALL_STRING.equals(ruleString)) {
- instanceFilter = new AllInstanceFilter(this);
- } else {
- try {
- instanceFilter = new InstanceFilter(this);
- instanceFilter.setRules(ruleString);
- } catch (PatternSyntaxException e) {
- instanceFilter.setRules(IInstanceFilter.ALL_STRING);
- }
- }
- return instanceFilter;
- }
-
public IImageFilter getImageFilter() {
return imageFilter;
}
- public void updateImageFilter(String ruleString) throws Exception {
- String rules = getImageFilter().toString();
- this.imageFilter = createImageFilter(ruleString);
- if (!rules.equals(ruleString)) {
- // TODO: remove notification with all instanceRepo, replace by
- // notifying the changed instance
- firePropertyChange(PROP_IMAGES, getImagesRepository().get(),
getImagesRepository().get());
- // TODO: move to notification based approach
- DeltaCloudManager.getDefault().saveClouds();
- }
+ public void updateImageFilter(String nameRule, String idRule, String archRule, String
descRule) throws Exception {
+ this.imageFilter = new ImageFilter(nameRule, idRule, archRule, descRule, this);
+ // TODO: remove notification with all instanceRepo, replace by
+ // notifying the changed instance
+ firePropertyChange(PROP_IMAGES, getImagesRepository().get(),
getImagesRepository().get());
+ // TODO: move to notification based approach
+ DeltaCloudManager.getDefault().saveClouds();
}
- private IImageFilter createImageFilter(String ruleString) {
- IImageFilter imageFilter = null;
- if (IImageFilter.ALL_STRING.equals(ruleString)) {
- imageFilter = new AllImageFilter(this);
- } else {
- try {
- imageFilter = new ImageFilter(this);
- imageFilter.setRules(ruleString);
- } catch (PatternSyntaxException e) {
- imageFilter.setRules(IImageFilter.ALL_STRING);
- }
- }
- return imageFilter;
- }
-
/**
* Loads all children of this delta cloud instance (regardless if things
* have already been loaded before). Catched and collects individual errors
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/FieldMatcher.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/FieldMatcher.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/FieldMatcher.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.deltacloud.core;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * @author Jeff Johnston
- * @author André Dietisheim
- */
-public class FieldMatcher implements IFieldMatcher {
-
- private String rule;
- private Pattern pattern;
-
- public FieldMatcher(String rule) throws PatternSyntaxException {
- this.rule = rule;
- String regexRule = transform(rule);
- pattern = Pattern.compile(regexRule, Pattern.CASE_INSENSITIVE);
- }
-
- private String transform(String rule) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < rule.length(); ++i) {
- char ch = rule.charAt(i);
- if (Character.isLetterOrDigit(ch))
- buffer.append(ch);
- else if (ch == '*') {
- buffer.append(".*?");
- } else {
- buffer.append('\\');
- buffer.append(ch);
- }
- }
- return buffer.toString();
- }
-
- @Override
- public boolean matches(String input) {
- Matcher m = pattern.matcher(input);
- return m.matches();
- }
-
- @Override
- public String toString() {
- return rule;
- }
-
-}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/ICloudElementFilter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/ICloudElementFilter.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/ICloudElementFilter.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -37,8 +37,6 @@
public Collection<CLOUDELEMENT> filter(CLOUDELEMENT[] cloudElements) throws
DeltaCloudException;
- public void setRules(String ruleString);
-
public IFieldMatcher getNameRule();
public IFieldMatcher getIdRule();
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/IInstanceFilter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/IInstanceFilter.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/IInstanceFilter.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -16,6 +16,7 @@
*/
public interface IInstanceFilter extends ICloudElementFilter<DeltaCloudInstance> {
+ public IFieldMatcher getAliasRule();
public IFieldMatcher getImageIdRule();
public IFieldMatcher getOwnerIdRule();
public IFieldMatcher getKeyNameRule();
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/ImageFilter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/ImageFilter.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/ImageFilter.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -11,7 +11,6 @@
package org.jboss.tools.deltacloud.core;
import java.util.Iterator;
-import java.util.regex.PatternSyntaxException;
/**
* A filter that may be applied on DeltaCloudImages
@@ -24,39 +23,57 @@
public class ImageFilter extends AbstractCloudElementFilter<DeltaCloudImage>
implements IImageFilter {
private IFieldMatcher archRule;
+ private IFieldMatcher descRule;
public ImageFilter(DeltaCloud cloud) {
+ super(new AllMatcher(), new AllMatcher(), cloud);
+ setRules(new AllMatcher(), new AllMatcher());
+ }
+
+ public ImageFilter(String rules, DeltaCloud cloud) {
super(cloud);
+ setRules(rules);
}
- private IFieldMatcher descRule;
-
+ public ImageFilter(String nameRule, String idRule, String archRule, String descRule,
DeltaCloud cloud) {
+ super(nameRule, idRule, cloud);
+ setRules(archRule, descRule);
+ }
+
@Override
+ protected Iterator<String> setRules(String rules) {
+ Iterator<String> rulesIterator = super.setRules(rules);
+ setRules(createRule(rulesIterator), createRule(rulesIterator));
+ return rulesIterator;
+ }
+
+ private void setRules(String archRule, String descRule) {
+ setRules(createRule(archRule), createRule(descRule));
+ }
+
+ private void setRules(IFieldMatcher archMatcher, IFieldMatcher descMatcher) {
+ this.archRule = archMatcher;
+ this.descRule = descMatcher;
+ }
+
+ @Override
public boolean matches(DeltaCloudImage image) {
return super.matches(image) &&
- archRule.matches(image.getArchitecture()) &&
- descRule.matches(image.getDescription());
+ archRule.matches(image.getArchitecture()) &&
+ descRule.matches(image.getDescription());
}
@Override
- public void setRules(String ruleString) throws PatternSyntaxException {
- // TODO: replace filter passing (;-delimited string) by list
- Iterator<String> rulesIterator = super.setRules(ruleString,
getRulesIterator(ruleString));
- this.archRule = createRule(rulesIterator);
- this.descRule = createRule(rulesIterator);
- }
-
- @Override
public String toString() {
- return super.toString() //$NON-NLS-1$
- + archRule + ";" //$NON-NLS-1$
- + descRule; //$NON-NLS-1$
+ return super.toString() //$NON-NLS-1$
+ + archRule + EXPRESSION_DELIMITER //$NON-NLS-1$
+ + descRule; //$NON-NLS-1$
}
-
+
public IFieldMatcher getArchRule() {
return archRule;
}
-
+
public IFieldMatcher getDescRule() {
return descRule;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/InstanceFilter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/InstanceFilter.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/InstanceFilter.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -11,7 +11,6 @@
package org.jboss.tools.deltacloud.core;
import java.util.Iterator;
-import java.util.regex.PatternSyntaxException;
/**
* A filter that may be applied on DeltaCloudInstances
@@ -23,6 +22,7 @@
*/
public class InstanceFilter extends AbstractCloudElementFilter<DeltaCloudInstance>
implements IInstanceFilter {
+ private IFieldMatcher aliasRule;
private IFieldMatcher imageIdRule;
private IFieldMatcher realmRule;
private IFieldMatcher profileRule;
@@ -30,37 +30,73 @@
private IFieldMatcher keyNameRule;
public InstanceFilter(DeltaCloud cloud) {
+ this(new AllMatcher(), new AllMatcher(), new AllMatcher(), new AllMatcher(), new
AllMatcher(),
+ new AllMatcher(), new AllMatcher(), new AllMatcher(), cloud);
+ }
+
+ public InstanceFilter(IFieldMatcher nameMatcher, IFieldMatcher idMatcher, IFieldMatcher
aliasMatcher,
+ IFieldMatcher imageIdMatcher, IFieldMatcher realmMatcher, IFieldMatcher
profileMatcher,
+ IFieldMatcher ownerIdMatcher, IFieldMatcher keyMatcher, DeltaCloud cloud) {
+ super(nameMatcher, idMatcher, cloud);
+ setRules(aliasMatcher, imageIdMatcher, realmMatcher, profileMatcher, ownerIdMatcher,
+ keyMatcher);
+ }
+
+ public InstanceFilter(String rulesString, DeltaCloud cloud) {
super(cloud);
+ setRules(rulesString);
}
-
+
+ public InstanceFilter(String nameRule, String idRule, String aliasRule, String
imageIdRule,
+ String ownerIdRule, String keyNameRule, String realmRule, String profileRule,
DeltaCloud cloud) {
+ super(nameRule, idRule, cloud);
+ setRules(aliasRule, imageIdRule, ownerIdRule, keyNameRule, realmRule, profileRule);
+ }
+
@Override
+ protected Iterator<String> setRules(String rules) {
+ Iterator<String> rulesIterator = super.setRules(rules);
+ setRules(createRule(rulesIterator), createRule(rulesIterator),
createRule(rulesIterator),
+ createRule(rulesIterator), createRule(rulesIterator), createRule(rulesIterator));
+ return rulesIterator;
+ }
+
+ private void setRules(String aliasRule, String imageIdRule, String ownerIdRule, String
keyNameRule,
+ String realmRule, String profileRule) {
+ setRules(createRule(aliasRule), createRule(imageIdRule), createRule(ownerIdRule),
createRule(keyNameRule),
+ createRule(realmRule), createRule(profileRule));
+ }
+
+ private void setRules(IFieldMatcher aliasMatcher, IFieldMatcher imageIdMatcher,
IFieldMatcher realmMatcher,
+ IFieldMatcher profileMatcher, IFieldMatcher ownerIdMatcher, IFieldMatcher
keyNameMatcher) {
+ this.aliasRule = aliasMatcher;
+ this.imageIdRule = imageIdMatcher;
+ this.ownerIdRule = ownerIdMatcher;
+ this.keyNameRule = keyNameMatcher;
+ this.realmRule = realmMatcher;
+ this.profileRule = profileMatcher;
+ }
+
+ @Override
public boolean matches(DeltaCloudInstance instance) {
return super.matches(instance) &&
- imageIdRule.matches(instance.getImageId()) &&
- ownerIdRule.matches(instance.getOwnerId()) &&
- keyNameRule.matches(instance.getKeyId()) &&
- realmRule.matches(instance.getRealmId()) &&
- profileRule.matches(instance.getProfileId());
+ aliasRule.matches(instance.getAlias()) &&
+ imageIdRule.matches(instance.getImageId()) &&
+ ownerIdRule.matches(instance.getOwnerId()) &&
+ keyNameRule.matches(instance.getKeyId()) &&
+ realmRule.matches(instance.getRealmId()) &&
+ profileRule.matches(instance.getProfileId());
}
@Override
- public void setRules(String ruleString) throws PatternSyntaxException {
- Iterator<String> rulesIterator = super.setRules(ruleString,
getRulesIterator(ruleString));
- this.imageIdRule = createRule(rulesIterator);
- this.ownerIdRule = createRule(rulesIterator);
- this.keyNameRule = createRule(rulesIterator);
- this.realmRule = createRule(rulesIterator);
- this.profileRule = createRule(rulesIterator);
- }
-
- @Override
public String toString() {
return super.toString()
- + imageIdRule + ";" //$NON-NLS-1$
- + ownerIdRule + ";" //$NON-NLS-1$
- + keyNameRule + ";" //$NON-NLS-1$
- + realmRule + ";" //$NON-NLS-1$
- + profileRule; //$NON-NLS-1$
+ + aliasRule + EXPRESSION_DELIMITER
+ + imageIdRule + EXPRESSION_DELIMITER
+ + ownerIdRule + EXPRESSION_DELIMITER
+ + keyNameRule + EXPRESSION_DELIMITER
+ + realmRule + EXPRESSION_DELIMITER
+ + profileRule; //$NON-NLS-1$
}
@Override
@@ -69,6 +105,11 @@
}
@Override
+ public IFieldMatcher getAliasRule() {
+ return aliasRule;
+ }
+
+ @Override
public IFieldMatcher getKeyNameRule() {
return keyNameRule;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/SecurePasswordStore.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/SecurePasswordStore.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/SecurePasswordStore.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -100,7 +100,7 @@
if (password == null) {
return null;
}
- return EncodingUtils.encodeBase64(password.getBytes());
+ return new String(EncodingUtils.decodeBase64(password));
}
private void storeInPreferences(String password, IStorageKey key) throws
DeltaCloudException {
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/StringMatcher.java
(from rev 28745,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/FieldMatcher.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/StringMatcher.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/StringMatcher.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.deltacloud.core;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/**
+ * @author Jeff Johnston
+ * @author André Dietisheim
+ */
+public class StringMatcher implements IFieldMatcher {
+
+ private String rule;
+ private Pattern pattern;
+
+ public StringMatcher(String rule) throws PatternSyntaxException {
+ this.rule = rule;
+ String regexRule = transform(rule);
+ pattern = Pattern.compile(regexRule, Pattern.CASE_INSENSITIVE);
+ }
+
+ private String transform(String rule) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < rule.length(); ++i) {
+ char ch = rule.charAt(i);
+ if (Character.isLetterOrDigit(ch))
+ buffer.append(ch);
+ else if (ch == '*') {
+ buffer.append(".*?");
+ } else {
+ buffer.append('\\');
+ buffer.append(ch);
+ }
+ }
+ return buffer.toString();
+ }
+
+ @Override
+ public boolean matches(String input) {
+ if (input == null) {
+ return false;
+ }
+ Matcher m = pattern.matcher(input);
+ return m.matches();
+ }
+
+ @Override
+ public String toString() {
+ return rule;
+ }
+
+}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-02-03 10:55:48
UTC (rev 28959)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-02-03 10:59:00
UTC (rev 28960)
@@ -1,3 +1,9 @@
+2011-02-03 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties:
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java:
+ [JBIDE-8187] added capability to filter for instance alias
+
2011-02-02 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -39,7 +39,6 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.deltacloud.core.AllImageFilter;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
@@ -120,7 +119,7 @@
public FindImagePage(DeltaCloud cloud) {
super(WizardMessages.getString(NAME));
this.cloud = cloud;
- filter = new AllImageFilter(cloud);
+ filter = new ImageFilter(cloud);
setDescription(WizardMessages.getString(DESC));
setTitle(WizardMessages.getString(TITLE));
setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
@@ -158,8 +157,7 @@
+ desc + "*"; //$NON-NLS-1$
if (!newRules.equals(oldRules)) {
- filter = new ImageFilter(cloud);
- filter.setRules(newRules);
+ filter = new ImageFilter(newRules, cloud);
oldRules = newRules;
asyncSetImagesToViewer(filter);
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterWizard.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterWizard.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -44,11 +44,7 @@
String descRule = mainPage.getDescRule();
try {
- getDeltaCloud().updateImageFilter(
- nameRule + ";" + //$NON-NLS-1$
- idRule + ";" + //$NON-NLS-1$
- archRule + ";" + //$NON-NLS-1$
- descRule);
+ getDeltaCloud().updateImageFilter(nameRule, idRule, archRule, descRule);
} catch (Exception e) {
// TODO: internationalize strings
ErrorUtils.handleError(
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -10,21 +10,23 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.ICloudElementFilter;
+import org.jboss.tools.deltacloud.core.IFieldMatcher;
+import org.jboss.tools.deltacloud.core.IInstanceFilter;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
/**
@@ -40,30 +42,33 @@
private final static String INVALID_SEMICOLON = "ErrorFilterSemicolon.msg";
//$NON-NLS-1$
private final static String NAME_LABEL = "Name.label"; //$NON-NLS-1$
private final static String ID_LABEL = "Id.label"; //$NON-NLS-1$
+ private final static String ALIAS_LABEL = "Alias.label"; //$NON-NLS-1$
private final static String OWNER_ID_LABEL = "OwnerId.label"; //$NON-NLS-1$
private final static String IMAGE_ID_LABEL = "ImageId.label"; //$NON-NLS-1$
private final static String KEYNAME_LABEL = "Key.label"; //$NON-NLS-1$
private final static String REALM_LABEL = "Realm.label"; //$NON-NLS-1$
private final static String PROFILE_LABEL = "Profile.label"; //$NON-NLS-1$
private final static String DEFAULT_LABEL = "DefaultButton.label";
//$NON-NLS-1$
-
+
private DeltaCloud cloud;
private Text nameText;
private Text idText;
+ private Text aliasText;
private Text imageIdText;
private Text ownerIdText;
- private Text keyNameText;
+ private Text keyIdText;
private Text realmText;
private Text profileText;
-
+
private Button defaultName;
private Button defaultId;
+ private Button defaultAlias;
private Button defaultImageId;
private Button defaultOwnerId;
private Button defaultKeyId;
private Button defaultRealm;
private Button defaultProfile;
-
+
public InstanceFilterPage(DeltaCloud cloud) {
super(WizardMessages.getString(NAME));
this.cloud = cloud;
@@ -72,35 +77,39 @@
setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
setPageComplete(false);
}
-
+
public String getNameRule() {
return nameText.getText();
}
-
+
public String getIdRule() {
return idText.getText();
}
-
+
+ public String getAliasRule() {
+ return aliasText.getText();
+ }
+
public String getImageIdRule() {
return imageIdText.getText();
}
-
+
public String getOwnerIdRule() {
return ownerIdText.getText();
}
-
+
public String getKeyNameRule() {
- return keyNameText.getText();
+ return keyIdText.getText();
}
-
+
public String getRealmRule() {
return realmText.getText();
}
-
+
public String getProfileRule() {
return profileText.getText();
}
-
+
private ModifyListener Listener = new ModifyListener() {
@Override
@@ -109,54 +118,74 @@
validate();
}
};
-
- private SelectionAdapter ButtonListener = new SelectionAdapter() {
+
+ private SelectionAdapter buttonListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- Button b = (Button)e.widget;
- if (b == defaultName)
- nameText.setText("*"); //$NON-NLS-1$
- else if (b == defaultId)
- idText.setText("*"); //$NON-NLS-1$
- else if (b == defaultImageId)
- imageIdText.setText("*"); //$NON-NLS-1$
- else if (b == defaultOwnerId)
- ownerIdText.setText("*"); //$NON-NLS-1$
- else if (b == defaultKeyId)
- keyNameText.setText("*"); //$NON-NLS-1$
- else if (b == defaultRealm)
- realmText.setText("*"); //$NON-NLS-1$
- else if (b == defaultProfile)
- profileText.setText("*"); //$NON-NLS-1$
+ Button b = (Button) e.widget;
+ Text text = getTextWidget(b);
+ if (text != null) {
+ text.setText(ICloudElementFilter.ALL_MATCHER_EXPRESSION);
+ }
}
-
+
+ private Text getTextWidget(Button button) {
+ Text text = null;
+ if (button == defaultName) {
+ text = nameText;
+ }
+ else if (button == defaultId) {
+ text = idText;
+ }
+ else if (button == defaultAlias) {
+ text = aliasText;
+ }
+ else if (button == defaultImageId) {
+ text = imageIdText;
+ }
+ else if (button == defaultOwnerId) {
+ text = ownerIdText;
+ }
+ else if (button == defaultKeyId) {
+ text = keyIdText;
+ }
+ else if (button == defaultRealm) {
+ text = realmText;
+ }
+ else if (button == defaultProfile) {
+ text = profileText;
+ }
+ return text;
+ }
};
-
+
private void validate() {
boolean complete = true;
boolean error = false;
-
+
if (nameText.getText().length() == 0 ||
idText.getText().length() == 0 ||
+ aliasText.getText().length() == 0 ||
imageIdText.getText().length() == 0 ||
ownerIdText.getText().length() == 0 ||
- keyNameText.getText().length() == 0 ||
+ keyIdText.getText().length() == 0 ||
realmText.getText().length() == 0 ||
profileText.getText().length() == 0) {
-
+
setErrorMessage(WizardMessages.getString(EMPTY_RULE));
error = true;
} else if (nameText.getText().contains(";") ||
idText.getText().contains(";") ||
+ aliasText.getText().contains(";") ||
imageIdText.getText().contains(";") ||
ownerIdText.getText().contains(";") ||
- keyNameText.getText().contains(";") ||
+ keyIdText.getText().contains(";") ||
realmText.getText().contains(";") ||
profileText.getText().contains(";")) {
setErrorMessage(WizardMessages.getString(INVALID_SEMICOLON));
error = true;
}
-
+
if (!error)
setErrorMessage(null);
setPageComplete(complete && !error);
@@ -165,215 +194,93 @@
@Override
public void createControl(Composite parent) {
final Composite container = new Composite(parent, SWT.NULL);
- FormLayout layout = new FormLayout();
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- container.setLayout(layout);
-
+ GridLayoutFactory.fillDefaults().numColumns(3).spacing(8, 4).applyTo(container);
+
Label label = new Label(container, SWT.NULL);
label.setText(WizardMessages.getString(FILTER_LABEL));
+ GridDataFactory.fillDefaults().span(3, 1).align(SWT.LEFT, SWT.CENTER).indent(0,
14).hint(SWT.DEFAULT, 30).applyTo(label);
- Label nameLabel = new Label(container, SWT.NULL);
- nameLabel.setText(WizardMessages.getString(NAME_LABEL));
-
- nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- nameText.setText(cloud.getInstanceFilter().getNameRule().toString());
- nameText.addModifyListener(Listener);
-
- defaultName = new Button(container, SWT.NULL);
- defaultName.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultName.addSelectionListener(ButtonListener);
+ IInstanceFilter filter = cloud.getInstanceFilter();
- Label idLabel = new Label(container, SWT.NULL);
- idLabel.setText(WizardMessages.getString(ID_LABEL));
+ Label nameLabel = createRuleLabel(WizardMessages.getString(NAME_LABEL), container);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
+ this.nameText = createRuleText(filter.getNameRule(), container);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(nameText);
+ this.defaultName = createDefaultRuleButton(container);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultName);
- idText = new Text(container, SWT.BORDER | SWT.SINGLE);
- idText.setText(cloud.getInstanceFilter().getIdRule().toString());
- idText.addModifyListener(Listener);
+ Label aliasLabel = createRuleLabel(WizardMessages.getString(ALIAS_LABEL), container);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(aliasLabel);
+ this.aliasText = createRuleText(filter.getAliasRule(), container);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(aliasText);
+ this.defaultAlias = createDefaultRuleButton(container);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultAlias);
- defaultId = new Button(container, SWT.NULL);
- defaultId.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultId.addSelectionListener(ButtonListener);
+ Label idLabel = createRuleLabel(WizardMessages.getString(ID_LABEL), container);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(idLabel);
+ this.idText = createRuleText(filter.getIdRule(), container);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(idText);
+ this.defaultId = createDefaultRuleButton(container);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultId);
- Label imageIdLabel = new Label(container, SWT.NULL);
- imageIdLabel.setText(WizardMessages.getString(IMAGE_ID_LABEL));
-
- imageIdText = new Text(container, SWT.BORDER | SWT.SINGLE);
- imageIdText.setText(cloud.getInstanceFilter().getImageIdRule().toString());
- imageIdText.addModifyListener(Listener);
-
- defaultImageId = new Button(container, SWT.NULL);
- defaultImageId.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultImageId.addSelectionListener(ButtonListener);
+ Label imageIdLabel = createRuleLabel(WizardMessages.getString(IMAGE_ID_LABEL),
container);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(imageIdLabel);
+ this.imageIdText = createRuleText(filter.getImageIdRule(), container);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(imageIdText);
+ this.defaultImageId = createDefaultRuleButton(container);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultImageId);
- Label ownerIdLabel = new Label(container, SWT.NULL);
- ownerIdLabel.setText(WizardMessages.getString(OWNER_ID_LABEL));
+ Label ownerIdLabel = createRuleLabel(WizardMessages.getString(OWNER_ID_LABEL),
container);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(ownerIdLabel);
+ this.ownerIdText = createRuleText(filter.getOwnerIdRule(), container);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(ownerIdText);
+ this.defaultOwnerId = createDefaultRuleButton(container);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultOwnerId);
- ownerIdText = new Text(container, SWT.BORDER | SWT.SINGLE);
- ownerIdText.setText(cloud.getInstanceFilter().getOwnerIdRule().toString());
- ownerIdText.addModifyListener(Listener);
-
- defaultOwnerId = new Button(container, SWT.NULL);
- defaultOwnerId.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultOwnerId.addSelectionListener(ButtonListener);
+ Label keyNameLabel = createRuleLabel(WizardMessages.getString(KEYNAME_LABEL),
container);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(keyNameLabel);
+ this.keyIdText = createRuleText(filter.getKeyNameRule(), container);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(keyIdText);
+ this.defaultKeyId = createDefaultRuleButton(container);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultKeyId);
- Label keyNameLabel = new Label(container, SWT.NULL);
- keyNameLabel.setText(WizardMessages.getString(KEYNAME_LABEL));
+ Label realmLabel = createRuleLabel(WizardMessages.getString(REALM_LABEL), container);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(realmLabel);
+ this.realmText = createRuleText(filter.getKeyNameRule(), container);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(realmText);
+ this.defaultRealm = createDefaultRuleButton(container);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultRealm);
- keyNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- keyNameText.setText(cloud.getInstanceFilter().getKeyNameRule().toString());
- keyNameText.addModifyListener(Listener);
-
- defaultKeyId = new Button(container, SWT.NULL);
- defaultKeyId.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultKeyId.addSelectionListener(ButtonListener);
+ Label profileLabel = createRuleLabel(WizardMessages.getString(PROFILE_LABEL),
container);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(profileLabel);
+ this.profileText = createRuleText(filter.getProfileRule(), container);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(profileText);
+ this.defaultProfile = createDefaultRuleButton(container);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultProfile);
- Label realmLabel = new Label(container, SWT.NULL);
- realmLabel.setText(WizardMessages.getString(REALM_LABEL));
+ setControl(container);
+ setPageComplete(true);
+ }
- realmText = new Text(container, SWT.BORDER | SWT.SINGLE);
- realmText.setText(cloud.getInstanceFilter().getRealmRule().toString());
- realmText.addModifyListener(Listener);
-
- defaultRealm = new Button(container, SWT.NULL);
- defaultRealm.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultRealm.addSelectionListener(ButtonListener);
-
- Label profileLabel = new Label(container, SWT.NULL);
- profileLabel.setText(WizardMessages.getString(PROFILE_LABEL));
+ private Label createRuleLabel(String text, Composite container) {
+ Label label = new Label(container, SWT.NULL);
+ label.setText(text);
+ return label;
+ }
- profileText = new Text(container, SWT.BORDER | SWT.SINGLE);
- profileText.setText(cloud.getInstanceFilter().getProfileRule().toString());
- profileText.addModifyListener(Listener);
-
- defaultProfile = new Button(container, SWT.NULL);
- defaultProfile.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultProfile.addSelectionListener(ButtonListener);
-
- Point p1 = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point p2 = nameText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point p3 = defaultName.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- int centering = (p2.y - p1.y + 1) / 2;
- int centering2 = (p3.y - p2.y + 1) / 2;
+ private Button createDefaultRuleButton(final Composite container) {
+ Button button = new Button(container, SWT.NULL);
+ button.setText(WizardMessages.getString(DEFAULT_LABEL));
+ button.addSelectionListener(buttonListener);
+ return button;
+ }
- FormData f = new FormData();
- f.top = new FormAttachment(0);
- label.setLayoutData(f);
+ private Text createRuleText(IFieldMatcher rule, final Composite container) {
+ Assert.isNotNull(rule, "Rule may not be null");
- f = new FormData();
- f.top = new FormAttachment(label, 11 + centering + centering2);
- f.left = new FormAttachment(0, 0);
- nameLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(label, 11);
- f.right = new FormAttachment(100);
- defaultName.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(label, 11 + centering2);
- f.left = new FormAttachment(profileLabel, 5);
- f.right = new FormAttachment(defaultName, -10);
- nameText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(nameLabel, 11 + centering + centering2);
- f.left = new FormAttachment(0, 0);
- idLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(nameLabel, 11);
- f.right = new FormAttachment(100);
- defaultId.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(nameLabel, 11 + centering2);
- f.left = new FormAttachment(profileLabel, 5);
- f.right = new FormAttachment(defaultId, -10);
- idText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(idLabel, 11 + centering + centering2);
- f.left = new FormAttachment(0, 0);
- imageIdLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(idLabel, 11);
- f.right = new FormAttachment(100);
- defaultImageId.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(idLabel, 11 + centering2);
- f.left = new FormAttachment(profileLabel, 5);
- f.right = new FormAttachment(defaultImageId, -10);
- imageIdText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(imageIdLabel, 11 + centering + centering2);
- f.left = new FormAttachment(0, 0);
- ownerIdLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(imageIdLabel, 11);
- f.right = new FormAttachment(100);
- defaultOwnerId.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(imageIdLabel, 11 + centering2);
- f.left = new FormAttachment(profileLabel, 5);
- f.right = new FormAttachment(defaultOwnerId, -10);
- ownerIdText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(ownerIdLabel, 11 + centering + centering2);
- f.left = new FormAttachment(0, 0);
- keyNameLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(ownerIdLabel, 11);
- f.right = new FormAttachment(100);
- defaultKeyId.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(ownerIdLabel, 11 + centering2);
- f.left = new FormAttachment(profileLabel, 5);
- f.right = new FormAttachment(defaultKeyId, -10);
- keyNameText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(keyNameLabel, 11 + centering + centering2);
- f.left = new FormAttachment(0, 0);
- realmLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(keyNameLabel, 11);
- f.right = new FormAttachment(100);
- defaultRealm.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(keyNameLabel, 11 + centering2);
- f.left = new FormAttachment(profileLabel, 5);
- f.right = new FormAttachment(defaultRealm, -10);
- realmText.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(realmLabel, 11 + centering + centering2);
- f.left = new FormAttachment(0, 0);
- profileLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(realmLabel, 11);
- f.right = new FormAttachment(100);
- defaultProfile.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(realmLabel, 11 + centering2);
- f.left = new FormAttachment(profileLabel, 5);
- f.right = new FormAttachment(defaultProfile, -10);
- profileText.setLayoutData(f);
-
- setControl(container);
- setPageComplete(true);
+ Text text = new Text(container, SWT.BORDER | SWT.SINGLE);
+ text.setText(rule.toString());
+ text.addModifyListener(Listener);
+ return text;
}
-
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterWizard.java 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterWizard.java 2011-02-03
10:59:00 UTC (rev 28960)
@@ -20,47 +20,43 @@
public class InstanceFilterWizard extends AbstractDeltaCloudWizard {
private InstanceFilterPage mainPage;
-
+
public InstanceFilterWizard(DeltaCloud cloud) {
super(cloud);
}
-
+
@Override
public void addPages() {
mainPage = new InstanceFilterPage(getDeltaCloud());
addPage(mainPage);
}
-
+
@Override
public boolean canFinish() {
return mainPage.isPageComplete();
}
-
+
@Override
public boolean performFinish() {
String nameRule = mainPage.getNameRule();
String idRule = mainPage.getIdRule();
+ String aliasRule = mainPage.getAliasRule();
String imageIdRule = mainPage.getImageIdRule();
String ownerIdRule = mainPage.getOwnerIdRule();
String keyNameRule = mainPage.getKeyNameRule();
String realmRule = mainPage.getRealmRule();
String profileRule = mainPage.getProfileRule();
-
+
try {
- getDeltaCloud().updateInstanceFilter(nameRule + ";" + //$NON-NLS-1$
- idRule + ";" + //$NON-NLS-1$
- imageIdRule + ";" + //$NON-NLS-1$
- ownerIdRule + ";" + //$NON-NLS-1$
- keyNameRule + ";" + //$NON-NLS-1$
- realmRule + ";" + //$NON-NLS-1$
- profileRule);
+ getDeltaCloud().updateInstanceFilter(
+ nameRule, idRule, aliasRule, imageIdRule, ownerIdRule, keyNameRule, realmRule,
profileRule);
} catch (Exception e) {
// TODO: internationalize strings
ErrorUtils.handleError(
"Error",
"Could not update filters", e, Display.getDefault().getActiveShell());
}
-
+
return true;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-02-03
10:55:48 UTC (rev 28959)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-02-03
10:59:00 UTC (rev 28960)
@@ -25,6 +25,7 @@
Url.label=URL:
Name.label=Name:
+Alias.label=Alias:
Type.label=Type:
UserName.label=Username:
Password.label=Password: