Author: jjohnstn
Date: 2010-10-08 19:05:06 -0400 (Fri, 08 Oct 2010)
New Revision: 25660
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
2010-10-08 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilter.java: New file.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java: New file.
* src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java (getChildren):
Add
filtering.
(listChanged): Ditto.
(filter): New method.
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add new instance
filtering
messages.
* src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java (handleSelection): Add
enablement
of instances filter.
(fillLocalPullDown): Add instances filtering.
(fillContextMenu): Ditto.
(makeActions): Add instances filtering action. Disable all cloud-wide actions based on
whether
an item is selected or not.
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (createPartControl): Add
filtered
label.
(fillLocalPullDown): Add filtering action.
(makeActions): Ditto.
* src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
(inputChanged):
Add filtering support.
(filter): New method.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
(.widgetSelected): Fix
default values to be wildcards.
(validate): Remove regex checking of input rules.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
messages.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-08 23:00:27
UTC (rev 25659)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-08 23:05:06
UTC (rev 25660)
@@ -1,3 +1,31 @@
+2010-10-08 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilter.java: New file.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java: New file.
+ * src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java (getChildren):
Add
+ filtering.
+ (listChanged): Ditto.
+ (filter): New method.
+ * src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add new instance
filtering
+ messages.
+ * src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java (handleSelection): Add
enablement
+ of instances filter.
+ (fillLocalPullDown): Add instances filtering.
+ (fillContextMenu): Ditto.
+ (makeActions): Add instances filtering action. Disable all cloud-wide actions based on
whether
+ an item is selected or not.
+ * src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (createPartControl): Add
filtered
+ label.
+ (fillLocalPullDown): Add filtering action.
+ (makeActions): Ditto.
+ * src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
(inputChanged):
+ Add filtering support.
+ (filter): New method.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
(.widgetSelected): Fix
+ default values to be wildcards.
+ (validate): Remove regex checking of input rules.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties: Add new
messages.
+
2010-10-07 Jeff Johnston <jjohnstn(a)redhat.com>
[JBIDE-7181]
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-10-08
23:00:27 UTC (rev 25659)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-10-08
23:05:06 UTC (rev 25660)
@@ -10,11 +10,15 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.ui.views;
+import java.util.ArrayList;
+
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.IInstanceFilter;
import org.jboss.tools.deltacloud.core.IInstanceListListener;
public class CVInstancesCategoryElement extends CVCategoryElement implements
IInstanceListListener {
@@ -41,7 +45,7 @@
if (!initialized) {
DeltaCloud cloud = (DeltaCloud)getElement();
cloud.removeInstanceListListener(this);
- DeltaCloudInstance[] instances = cloud.getCurrInstances();
+ DeltaCloudInstance[] instances = filter(cloud.getCurrInstances());
for (int i = 0; i < instances.length; ++i) {
DeltaCloudInstance d = instances[i];
CVInstanceElement element = new CVInstanceElement(d, d.getName());
@@ -54,8 +58,9 @@
}
@Override
- public void listChanged(DeltaCloud cloud, DeltaCloudInstance[] instances) {
+ public void listChanged(DeltaCloud cloud, DeltaCloudInstance[] newInstances) {
clearChildren();
+ DeltaCloudInstance[] instances = filter(newInstances);
for (int i = 0; i < instances.length; ++i) {
DeltaCloudInstance d = instances[i];
CVInstanceElement element = new CVInstanceElement(d, d.getName());
@@ -70,4 +75,16 @@
});
}
+ private DeltaCloudInstance[] filter(DeltaCloudInstance[] input) {
+ ArrayList<DeltaCloudInstance> array = new ArrayList<DeltaCloudInstance>();
+ DeltaCloud cloud = (DeltaCloud)getElement();
+ IInstanceFilter f = cloud.getInstanceFilter();
+ for (int i = 0; i < input.length; ++i) {
+ DeltaCloudInstance instance = input[i];
+ if (f.isVisible(instance))
+ array.add(instance);
+ }
+ return array.toArray(new DeltaCloudInstance[array.size()]);
+ }
+
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-10-08
23:00:27 UTC (rev 25659)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-10-08
23:05:06 UTC (rev 25660)
@@ -37,6 +37,7 @@
Filtered.label=filtered
FilteredImages.tooltip=Images shown have been filtered
ImageFilter.label=Filter Images...
+InstanceFilter.label=Filter Instances...
CreateInstance.label=Launch Instance
DeleteInstance.label=Delete Instance
ShowInRSE.label=Show in Remote System Explorer
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java 2010-10-08
23:00:27 UTC (rev 25659)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java 2010-10-08
23:05:06 UTC (rev 25660)
@@ -52,6 +52,7 @@
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import org.jboss.tools.internal.deltacloud.ui.wizards.EditCloudConnection;
import org.jboss.tools.internal.deltacloud.ui.wizards.ImageFilter;
+import org.jboss.tools.internal.deltacloud.ui.wizards.InstanceFilter;
import org.jboss.tools.internal.deltacloud.ui.wizards.NewInstance;
@@ -82,6 +83,7 @@
private final static String DESTROYING_INSTANCE_TITLE =
"DestroyingInstance.title"; //$NON-NLS-1$
private final static String DESTROYING_INSTANCE_MSG =
"DestroyingInstance.msg"; //$NON-NLS-1$
private final static String IMAGE_FILTER = "ImageFilter.label"; //$NON-NLS-1$
+ private final static String INSTANCE_FILTER = "InstanceFilter.label";
//$NON-NLS-1$
public static final String COLLAPSE_ALL = "CollapseAll.label"; //$NON-NLS-1$
@@ -97,6 +99,7 @@
private Action createInstance;
private Action editCloud;
private Action imageFilterAction;
+ private Action instanceFilterAction;
private Map<String, Action> instanceActions;
@@ -177,6 +180,7 @@
removeCloud.setEnabled(selectedElement != null);
refreshAction.setEnabled(selectedElement != null);
imageFilterAction.setEnabled(selectedElement != null);
+ instanceFilterAction.setEnabled(selectedElement != null);
}
private void fillLocalPullDown(IMenuManager manager) {
@@ -185,6 +189,7 @@
manager.add(removeCloud);
manager.add(refreshAction);
manager.add(imageFilterAction);
+ manager.add(instanceFilterAction);
}
private void fillContextMenu(IMenuManager manager) {
@@ -202,6 +207,7 @@
manager.add(editCloud);
manager.add(removeCloud);
manager.add(imageFilterAction);
+ manager.add(instanceFilterAction);
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
@@ -446,6 +452,35 @@
imageFilterAction.setText(CVMessages.getString(IMAGE_FILTER));
imageFilterAction.setToolTipText(CVMessages.getString(IMAGE_FILTER));
+ instanceFilterAction = new Action() {
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ CloudViewElement element = (CloudViewElement)selection.getFirstElement();
+ while (element != null && !(element instanceof CVCloudElement)) {
+ element = (CloudViewElement)element.getParent();
+ }
+ if (element != null) {
+ CVCloudElement cve = (CVCloudElement)element;
+ final DeltaCloud cloud = (DeltaCloud)cve.getElement();
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ Shell shell = viewer.getControl().getShell();
+ IWizard wizard = new InstanceFilter(cloud);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.open();
+ }
+
+ });
+ }
+ }
+ };
+ instanceFilterAction.setText(CVMessages.getString(INSTANCE_FILTER));
+ instanceFilterAction.setToolTipText(CVMessages.getString(INSTANCE_FILTER));
+
doubleClickAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
@@ -461,6 +496,12 @@
collapseall.setText(CVMessages.getString(COLLAPSE_ALL));
collapseall.setToolTipText(CVMessages.getString(COLLAPSE_ALL));
collapseall.setImageDescriptor(SWTImagesFactory.DESC_COLLAPSE_ALL);
+
+ editCloud.setEnabled(selectedElement != null);
+ removeCloud.setEnabled(selectedElement != null);
+ refreshAction.setEnabled(selectedElement != null);
+ imageFilterAction.setEnabled(selectedElement != null);
+ instanceFilterAction.setEnabled(selectedElement != null);
}
private void hookDoubleClickAction() {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-10-08
23:00:27 UTC (rev 25659)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-10-08
23:05:06 UTC (rev 25660)
@@ -33,6 +33,8 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.rse.core.IRSECoreRegistry;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
@@ -56,6 +58,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.IActionBars;
@@ -67,10 +70,12 @@
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.core.ICloudManagerListener;
+import org.jboss.tools.deltacloud.core.IInstanceFilter;
import org.jboss.tools.deltacloud.core.IInstanceListListener;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+import org.jboss.tools.internal.deltacloud.ui.wizards.InstanceFilter;
import org.osgi.service.prefs.Preferences;
public class InstanceView extends ViewPart implements ICloudManagerListener,
IInstanceListListener {
@@ -91,11 +96,15 @@
private final static String DESTROYING_INSTANCE_MSG =
"DestroyingInstance.msg"; //$NON-NLS-1$
private final static String RSE_CONNECTING_MSG = "ConnectingRSE.msg";
//$NON-NLS-1$
private static final String REFRESH = "Refresh.label"; //$NON-NLS-1$
+ private static final String FILTER = "Filter.label"; //$NON-NLS-1$
+ private static final String FILTERED_LABEL = "Filtered.label"; //$NON-NLS-1$
+ private static final String FILTERED_TOOLTIP = "FilteredImages.tooltip";
//$NON-NLS-1$
private TableViewer viewer;
private Composite container;
private Combo cloudSelector;
+ private Label filterLabel;
private DeltaCloudInstance selectedElement;
private DeltaCloud[] clouds;
@@ -104,6 +113,7 @@
private InstanceViewLabelAndContentProvider contentProvider;
private Action refreshAction;
+ private Action filterAction;
private Action startAction;
private Action stopAction;
private Action destroyAction;
@@ -205,6 +215,10 @@
}
});
+ filterLabel = new Label(container, SWT.NULL);
+ filterLabel.setText(CVMessages.getString(FILTERED_LABEL));
+ filterLabel.setToolTipText(CVMessages.getString(FILTERED_TOOLTIP));
+
Composite tableArea = new Composite(container, SWT.NULL);
TableColumnLayout tableLayout = new TableColumnLayout();
tableArea.setLayout(tableLayout);
@@ -313,6 +327,7 @@
private void fillLocalPullDown(IMenuManager manager) {
manager.add(refreshAction);
+ manager.add(filterAction);
}
private void fillContextMenu(IMenuManager manager) {
@@ -368,6 +383,30 @@
refreshAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
+ filterAction = new Action() {
+ public void run() {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ Shell shell = viewer.getControl().getShell();
+ IWizard wizard = new InstanceFilter(currCloud);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.open();
+ if (!currCloud.getInstanceFilter().toString().equals(IInstanceFilter.ALL_STRING))
+ filterLabel.setVisible(true);
+ else
+ filterLabel.setVisible(false);
+ }
+
+ });
+ }
+ };
+ filterAction.setText(CVMessages.getString(FILTER));
+ filterAction.setToolTipText(CVMessages.getString(FILTER));
+
startAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java 2010-10-08
23:00:27 UTC (rev 25659)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java 2010-10-08
23:05:06 UTC (rev 25660)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.ui.views;
+import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
@@ -21,6 +22,7 @@
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.IInstanceFilter;
public class InstanceViewLabelAndContentProvider extends BaseLabelProvider implements
IStructuredContentProvider, ITableLabelProvider {
@@ -81,14 +83,25 @@
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput != null) {
if (newInput instanceof DeltaCloudInstance[]) {
- instances = (DeltaCloudInstance[])newInput;
+ instances = filter((DeltaCloudInstance[])newInput);
} else {
cloud = (DeltaCloud)newInput;
- instances = cloud.getCurrInstances();
+ instances = filter(cloud.getCurrInstances());
}
}
}
+ private DeltaCloudInstance[] filter(DeltaCloudInstance[] input) {
+ ArrayList<DeltaCloudInstance> array = new ArrayList<DeltaCloudInstance>();
+ IInstanceFilter f = cloud.getInstanceFilter();
+ for (int i = 0; i < input.length; ++i) {
+ DeltaCloudInstance instance = input[i];
+ if (f.isVisible(instance))
+ array.add(instance);
+ }
+ return array.toArray(new DeltaCloudInstance[array.size()]);
+ }
+
@Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java 2010-10-08
23:00:27 UTC (rev 25659)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java 2010-10-08
23:05:06 UTC (rev 25660)
@@ -1,8 +1,5 @@
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -28,7 +25,6 @@
private final static String FILTER_LABEL = "ImageFilter.label"; //$NON-NLS-1$
private final static String EMPTY_RULE = "ErrorFilterEmptyRule.msg";
//$NON-NLS-1$
private final static String INVALID_SEMICOLON = "ErrorFilterSemicolon.msg";
//$NON-NLS-1$
- private final static String FIELD_ERROR = "ErrorFieldError.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 ARCH_LABEL = "Arch.label"; //$NON-NLS-1$
@@ -85,14 +81,13 @@
public void widgetSelected(SelectionEvent e) {
Button b = (Button)e.widget;
if (b == defaultName)
- nameText.setText(".*"); //$NON-NLS-1$
+ nameText.setText("*"); //$NON-NLS-1$
else if (b == defaultId)
- idText.setText(".*"); //$NON-NLS-1$
+ idText.setText("*"); //$NON-NLS-1$
else if (b == defaultArch)
- archText.setText(".*"); //$NON-NLS-1$
+ archText.setText("*"); //$NON-NLS-1$
else if (b == defaultDesc)
- descText.setText(".*"); //$NON-NLS-1$
-
+ descText.setText("*"); //$NON-NLS-1$
}
};
@@ -116,43 +111,6 @@
error = true;
}
- try {
- @SuppressWarnings("unused")
- Pattern p = Pattern.compile(nameText.getText());
- } catch (PatternSyntaxException e) {
- setErrorMessage(WizardMessages.getFormattedString(FIELD_ERROR,
- new String[]{WizardMessages.getString(NAME_LABEL),
- e.getLocalizedMessage()}));
- error = true;
- }
- try {
- @SuppressWarnings("unused")
- Pattern p = Pattern.compile(idText.getText());
- } catch (PatternSyntaxException e) {
- setErrorMessage(WizardMessages.getFormattedString(FIELD_ERROR,
- new String[]{WizardMessages.getString(ID_LABEL),
- e.getLocalizedMessage()}));
- error = true;
- }
- try {
- @SuppressWarnings("unused")
- Pattern p = Pattern.compile(archText.getText());
- } catch (PatternSyntaxException e) {
- setErrorMessage(WizardMessages.getFormattedString(FIELD_ERROR,
- new String[]{WizardMessages.getString(ARCH_LABEL),
- e.getLocalizedMessage()}));
- error = true;
- }
- try {
- @SuppressWarnings("unused")
- Pattern p = Pattern.compile(descText.getText());
- } catch (PatternSyntaxException e) {
- setErrorMessage(WizardMessages.getFormattedString(FIELD_ERROR,
- new String[]{WizardMessages.getString(DESC_LABEL),
- e.getLocalizedMessage()}));
- error = true;
- }
-
if (!error)
setErrorMessage(null);
setPageComplete(complete && !error);
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilter.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilter.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilter.java 2010-10-08
23:05:06 UTC (rev 25660)
@@ -0,0 +1,48 @@
+package org.jboss.tools.internal.deltacloud.ui.wizards;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+
+public class InstanceFilter extends Wizard {
+
+ private DeltaCloud cloud;
+ private InstanceFilterPage mainPage;
+
+ public InstanceFilter(DeltaCloud cloud) {
+ this.cloud = cloud;
+ }
+
+ @Override
+ public void addPages() {
+ // TODO Auto-generated method stub
+ mainPage = new InstanceFilterPage(cloud);
+ addPage(mainPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return mainPage.isPageComplete();
+ }
+
+ @Override
+ public boolean performFinish() {
+ String nameRule = mainPage.getNameRule();
+ String idRule = mainPage.getIdRule();
+ String imageIdRule = mainPage.getImageIdRule();
+ String ownerIdRule = mainPage.getOwnerIdRule();
+ String keyNameRule = mainPage.getKeyNameRule();
+ String realmRule = mainPage.getRealmRule();
+ String profileRule = mainPage.getProfileRule();
+
+ cloud.createInstanceFilter(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); //$NON-NLS-1$
+
+ return true;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java 2010-10-08
23:05:06 UTC (rev 25660)
@@ -0,0 +1,366 @@
+package org.jboss.tools.internal.deltacloud.ui.wizards;
+
+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.ui.SWTImagesFactory;
+
+public class InstanceFilterPage extends WizardPage {
+
+ private final static String NAME = "InstanceFilter.name"; //$NON-NLS-1$
+ private final static String TITLE = "InstanceFilter.title"; //$NON-NLS-1$
+ private final static String DESC = "InstanceFilter.desc"; //$NON-NLS-1$
+ private final static String FILTER_LABEL = "InstanceFilter.label";
//$NON-NLS-1$
+ private final static String EMPTY_RULE = "ErrorFilterEmptyRule.msg";
//$NON-NLS-1$
+ 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 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 imageIdText;
+ private Text ownerIdText;
+ private Text keyNameText;
+ private Text realmText;
+ private Text profileText;
+
+ private Button defaultName;
+ private Button defaultId;
+ 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;
+ setDescription(WizardMessages.getString(DESC));
+ setTitle(WizardMessages.getString(TITLE));
+ setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
+ setPageComplete(false);
+ }
+
+ public String getNameRule() {
+ return nameText.getText();
+ }
+
+ public String getIdRule() {
+ return idText.getText();
+ }
+
+ public String getImageIdRule() {
+ return imageIdText.getText();
+ }
+
+ public String getOwnerIdRule() {
+ return ownerIdText.getText();
+ }
+
+ public String getKeyNameRule() {
+ return keyNameText.getText();
+ }
+
+ public String getRealmRule() {
+ return realmText.getText();
+ }
+
+ public String getProfileRule() {
+ return profileText.getText();
+ }
+
+ private ModifyListener Listener = new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ // TODO Auto-generated method stub
+ validate();
+ }
+ };
+
+ 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$
+ }
+
+ };
+
+ private void validate() {
+ boolean complete = true;
+ boolean error = false;
+
+ if (nameText.getText().length() == 0 ||
+ idText.getText().length() == 0 ||
+ imageIdText.getText().length() == 0 ||
+ ownerIdText.getText().length() == 0 ||
+ keyNameText.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(";") ||
+ imageIdText.getText().contains(";") ||
+ ownerIdText.getText().contains(";") ||
+ keyNameText.getText().contains(";") ||
+ realmText.getText().contains(";") ||
+ profileText.getText().contains(";")) {
+ setErrorMessage(WizardMessages.getString(INVALID_SEMICOLON));
+ error = true;
+ }
+
+ if (!error)
+ setErrorMessage(null);
+ setPageComplete(complete && !error);
+ }
+
+ @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);
+
+ Label label = new Label(container, SWT.NULL);
+ label.setText(WizardMessages.getString(FILTER_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);
+
+ Label idLabel = new Label(container, SWT.NULL);
+ idLabel.setText(WizardMessages.getString(ID_LABEL));
+
+ idText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ idText.setText(cloud.getInstanceFilter().getIdRule().toString());
+ idText.addModifyListener(Listener);
+
+ defaultId = new Button(container, SWT.NULL);
+ defaultId.setText(WizardMessages.getString(DEFAULT_LABEL));
+ defaultId.addSelectionListener(ButtonListener);
+
+ 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 ownerIdLabel = new Label(container, SWT.NULL);
+ ownerIdLabel.setText(WizardMessages.getString(OWNER_ID_LABEL));
+
+ 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 = new Label(container, SWT.NULL);
+ keyNameLabel.setText(WizardMessages.getString(KEYNAME_LABEL));
+
+ 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 realmLabel = new Label(container, SWT.NULL);
+ realmLabel.setText(WizardMessages.getString(REALM_LABEL));
+
+ 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));
+
+ 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;
+
+ FormData f = new FormData();
+ f.top = new FormAttachment(0);
+ label.setLayoutData(f);
+
+ 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);
+ }
+
+}
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 2010-10-08
23:00:27 UTC (rev 25659)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-10-08
23:05:06 UTC (rev 25660)
@@ -24,6 +24,8 @@
TestButton.label=Test
UnknownType.label=Unknown
Id.label=ID:
+ImageId.label=Image ID:
+OwnerId.label=Owner ID:
Image.label=Image:
Arch.label=Architecture:
Desc.label=Description:
@@ -77,11 +79,16 @@
ImageFilter.title=Image Filter
ImageFilter.name=Image Filter
-ImageFilter.label=Show all images which match the following regex rules:
+ImageFilter.label=Show all images which match the following rules (* = wildcard):
ErrorFilterEmptyRule.msg=Rules cannot be empty strings
ErrorFilterSemicolon.msg=Rules cannot contain a semi-colon character
ErrorFieldError.msg={0} {1}
+InstanceFilter.desc=Specify rules to determine which Instances will appear in the
dialog.
+InstanceFilter.title=Instance Filter
+InstanceFilter.name=Instance Filter
+InstanceFilter.label=Show all instances which match the following rules (* = wildcard):
+
ErrorInvalidDirectory.text=Specified directory is not a valid existing directory
Directory.label=Directory