Author: adietish
Date: 2012-05-23 04:48:16 -0400 (Wed, 23 May 2012)
New Revision: 41272
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/CartridgeNameComparator.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
Log:
[JBIDE-11221] moved cartridge sorting to model
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/CartridgeNameComparator.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/CartridgeNameComparator.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/CartridgeNameComparator.java 2012-05-23
08:48:16 UTC (rev 41272)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core;
+
+import java.text.Collator;
+import java.util.Comparator;
+
+import com.openshift.client.ICartridge;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CartridgeNameComparator implements Comparator<ICartridge> {
+
+ private Collator collator;
+
+ public CartridgeNameComparator() {
+ this.collator = Collator.getInstance();
+ }
+
+ @Override
+ public int compare(ICartridge thisCartridge, ICartridge thatCartridge) {
+ if (thisCartridge == null) {
+ if (thatCartridge == null) {
+ return 0;
+ } else {
+ return -1;
+ }
+ } else if (thatCartridge == null) {
+ if (thisCartridge == null) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ return collator.compare(thisCartridge.getName(), thatCartridge.getName());
+ }
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/CartridgeNameComparator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-05-23
07:05:18 UTC (rev 41271)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-05-23
08:48:16 UTC (rev 41272)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
+ * Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -12,7 +12,6 @@
import java.lang.reflect.InvocationTargetException;
import java.net.SocketTimeoutException;
-import java.util.Arrays;
import java.util.Collection;
import org.eclipse.core.databinding.DataBindingContext;
@@ -639,27 +638,12 @@
// reacting to model changes while wizard runnable is
// run. We force another update
dbc.updateModels();
- // sort
- String[] items = newAppCartridgeCombo.getItems();
- Arrays.sort(items);
- newAppCartridgeCombo.setItems(items);
- selectJBossAS7();
}
});
}
}.start();
}
}
-
- private void selectJBossAS7(){
- String[] items = newAppCartridgeCombo.getItems();
- for(int index = 0; index < items.length; index++){
- if("jbossas-7".equals(items[index])){
- newAppCartridgeCombo.select(index);
- }
- }
- }
-
@Override
protected void onPageWillGetActivated(Direction direction, PageChangingEvent event,
DataBindingContext dbc) {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-05-23
07:05:18 UTC (rev 41271)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-05-23
08:48:16 UTC (rev 41272)
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.express.internal.core.CartridgeNameComparator;
import org.jboss.tools.openshift.express.internal.core.CreateApplicationOperation;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
@@ -206,9 +207,14 @@
}
public void setCartridges(List<ICartridge> cartridges) {
+ sort(cartridges);
firePropertyChange(PROPERTY_CARTRIDGES, this.cartridges, this.cartridges =
cartridges);
}
+ private void sort(List<ICartridge> cartridges) {
+ Collections.sort(cartridges, new CartridgeNameComparator());
+ }
+
public List<ICartridge> getCartridges() {
return cartridges;
}
@@ -419,6 +425,7 @@
return wizardModel.getUser().getDefaultDomain();
}
+ @Override
public IApplication createJenkinsApplication(String name, IProgressMonitor monitor)
throws OpenShiftException {
IApplication application =
new CreateApplicationOperation(getUser()).execute(
@@ -429,5 +436,4 @@
monitor);
return application;
}
-
}