JBoss Tools SVN: r40972 - in trunk/openshift/docs/reference/en-US/images: OpenShift_Remote_Console and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2012-05-13 19:14:48 -0400 (Sun, 13 May 2012)
New Revision: 40972
Modified:
trunk/openshift/docs/reference/en-US/images/OpenShift_Express_Profile/openshift_express_profile_01.png
trunk/openshift/docs/reference/en-US/images/OpenShift_Remote_Console/openshift_remote_console_01.png
Log:
updated images for new UI
Modified: trunk/openshift/docs/reference/en-US/images/OpenShift_Express_Profile/openshift_express_profile_01.png
===================================================================
(Binary files differ)
Modified: trunk/openshift/docs/reference/en-US/images/OpenShift_Remote_Console/openshift_remote_console_01.png
===================================================================
(Binary files differ)
12 years, 8 months
JBoss Tools SVN: r40971 - in workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp: 1.0.0-CR4-JBT and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2012-05-13 09:23:59 -0400 (Sun, 13 May 2012)
New Revision: 40971
Added:
workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/
workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/_maven.repositories
workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT-sources.jar
workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT.jar
workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT.pom
Modified:
workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/maven-metadata-local.xml
Log:
Add springmvc archetype compatible with EAP ER6 / WFK ER5 repos
Added: workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/_maven.repositories
===================================================================
--- workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/_maven.repositories (rev 0)
+++ workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/_maven.repositories 2012-05-13 13:23:59 UTC (rev 40971)
@@ -0,0 +1,5 @@
+#NOTE: This is an internal implementation file, its format can be changed without prior notice.
+#Sun May 13 15:17:58 CEST 2012
+spring-mvc-webapp-1.0.0-CR4-JBT.pom>=
+spring-mvc-webapp-1.0.0-CR4-JBT.jar>=
+spring-mvc-webapp-1.0.0-CR4-JBT-sources.jar>=
Added: workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT-sources.jar
===================================================================
(Binary files differ)
Property changes on: workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT-sources.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT.jar
===================================================================
(Binary files differ)
Property changes on: workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT.pom
===================================================================
--- workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT.pom (rev 0)
+++ workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/1.0.0-CR4-JBT/spring-mvc-webapp-1.0.0-CR4-JBT.pom 2012-05-13 13:23:59 UTC (rev 40971)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.spring.archetypes</groupId>
+ <artifactId>spring-mvc-webapp</artifactId>
+ <version>1.0.0-CR4-JBT</version>
+ <packaging>maven-archetype</packaging>
+
+ <name>JBoss AS7 - Spring MVC Application</name>
+ <description>An archetype that generates a starter Spring MVC application with Java EE persistence settings (server bootstrapped JPA, JTA transaction management) for JBoss AS7</description>
+
+ <url>http://jboss.org/jbossas</url>
+
+ <scm>
+ <connection>scm:git:git@github.com:jboss-eap/wfk-archetypes.git</connection>
+ <developerConnection>scm:git:git@github.com:jboss-eap/wfk-archetypes.git</developerConnection>
+ <url>scm:git:git@github.com:jboss-eap/wfk-archetypes.git</url>
+ </scm>
+
+ <developers>
+ <developer>
+ <name>Marius Bogoevici</name>
+ <email>mariusb(a)redhat.com</email>
+ <organization>Red Hat, Inc.</organization>
+ <organizationUrl>http://redhat.com/jboss</organizationUrl>
+ </developer>
+ <developer>
+ <name>Karel Piwko</name>
+ <email>kpiwko(a)redhat.com</email>
+ <organization>Red Hat, Inc.</organization>
+ <organizationUrl>http://redhat.com/jboss</organizationUrl>
+ </developer>
+ </developers>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.1</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <enterprise.available>false</enterprise.available>
+ </properties>
+
+ <profiles>
+ <!-- Build with -Penterprise to test against an EAP / WFK repository -->
+ <profile>
+ <id>enterprise</id>
+ <properties>
+ <enterprise.available>true</enterprise.available>
+ </properties>
+ </profile>
+ </profiles>
+
+</project>
Modified: workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/maven-metadata-local.xml
===================================================================
--- workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/maven-metadata-local.xml 2012-05-13 12:48:10 UTC (rev 40970)
+++ workspace/fred/repositories/snapshot/org/jboss/spring/archetypes/spring-mvc-webapp/maven-metadata-local.xml 2012-05-13 13:23:59 UTC (rev 40971)
@@ -3,9 +3,10 @@
<groupId>org.jboss.spring.archetypes</groupId>
<artifactId>spring-mvc-webapp</artifactId>
<versioning>
+ <release>1.0.0-CR4-JBT</release>
<versions>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0-CR4-JBT</version>
</versions>
- <lastUpdated>20111114162713</lastUpdated>
+ <lastUpdated>20120513131758</lastUpdated>
</versioning>
</metadata>
12 years, 8 months
JBoss Tools SVN: r40970 - in trunk/maven/plugins/org.jboss.tools.maven.ui: src/org/jboss/tools/maven/ui/wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2012-05-13 08:48:10 -0400 (Sun, 13 May 2012)
New Revision: 40970
Added:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/AutoResizeTableLayout.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/RepositoryWrapper.java
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/ConfigureMavenRepositoriesWizard.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/ConfigureMavenRepositoriesWizardPage.java
Log:
JBIDE-11818 - Repository Configurator Wizard deletes existing comments when updating the user settings.xml
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/META-INF/MANIFEST.MF 2012-05-12 00:29:57 UTC (rev 40969)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/META-INF/MANIFEST.MF 2012-05-13 12:48:10 UTC (rev 40970)
@@ -16,7 +16,8 @@
org.eclipse.ui.ide,
org.eclipse.jface.text,
org.eclipse.jdt.ui;bundle-version="3.7.0",
- org.eclipse.jdt;bundle-version="3.7.0"
+ org.eclipse.jdt;bundle-version="3.7.0",
+ org.eclipse.compare;bundle-version="3.5.202"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %Bundle-Vendor
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/AutoResizeTableLayout.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/AutoResizeTableLayout.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/AutoResizeTableLayout.java 2012-05-13 12:48:10 UTC (rev 40970)
@@ -0,0 +1,129 @@
+/*************************************************************************************
+ * Copyright (c) 2010-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.ui.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class AutoResizeTableLayout extends TableLayout implements
+ ControlListener {
+
+ private final Table table;
+ private List<ColumnLayoutData> columns = new ArrayList<ColumnLayoutData>();
+ private boolean autosizing = false;
+
+ public AutoResizeTableLayout(Table table) {
+ this.table = table;
+ table.addControlListener(this);
+ }
+
+ public void addColumnData(ColumnLayoutData data) {
+ columns.add(data);
+ super.addColumnData(data);
+ }
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ if (autosizing) {
+ return;
+ }
+ autosizing = true;
+ try {
+ autoSizeColumns();
+ } finally {
+ autosizing = false;
+ }
+ }
+
+ private void autoSizeColumns() {
+ int width = table.getClientArea().width;
+ if (width <= 1) {
+ return;
+ }
+
+ TableColumn[] tableColumns = table.getColumns();
+ int size =
+ Math.min(columns.size(), tableColumns.length);
+ int[] widths = new int[size];
+ int fixedWidth = 0;
+ int numberOfWeightColumns = 0;
+ int totalWeight = 0;
+
+ // First calc space occupied by fixed columns.
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnPixelData) {
+ int pixels = ((ColumnPixelData)col).width;
+ widths[i] = pixels;
+ fixedWidth += pixels;
+ } else if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ numberOfWeightColumns++;
+ int weight = cw.weight;
+ totalWeight += weight;
+ } else {
+ throw new IllegalStateException("Unknown column layout data");
+ }
+ }
+
+ // Do we have columns that have a weight?
+ if (numberOfWeightColumns > 0) {
+ // Now, distribute the rest
+ // to the columns with weight.
+ int rest = width - fixedWidth;
+ int totalDistributed = 0;
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ int weight = cw.weight;
+ int pixels = totalWeight == 0 ? 0 : weight * rest / totalWeight;
+ totalDistributed += pixels;
+ widths[i] = pixels;
+ }
+ }
+
+ // Distribute any remaining pixels
+ // to columns with weight.
+ int diff = rest - totalDistributed;
+ for (int i = 0; diff > 0; i++) {
+ if (i == size) {
+ i = 0;
+ }
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ++widths[i];
+ --diff;
+ }
+ }
+ }
+
+ for (int i = 0; i < size; i++) {
+ if (tableColumns[i].getWidth() != widths[i]) {
+ tableColumns[i].setWidth(widths[i]);
+ }
+
+ }
+
+ }
+
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/ConfigureMavenRepositoriesWizard.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/ConfigureMavenRepositoriesWizard.java 2012-05-12 00:29:57 UTC (rev 40969)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/ConfigureMavenRepositoriesWizard.java 2012-05-13 12:48:10 UTC (rev 40970)
@@ -1,3 +1,13 @@
+/*************************************************************************************
+ * Copyright (c) 2010-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.maven.ui.wizard;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -7,6 +17,11 @@
import org.eclipse.ui.IWorkbench;
import org.jboss.tools.maven.ui.Activator;
+/**
+ *
+ * @author snjeza
+ *
+ */
public class ConfigureMavenRepositoriesWizard extends Wizard implements
INewWizard {
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/ConfigureMavenRepositoriesWizardPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/ConfigureMavenRepositoriesWizardPage.java 2012-05-12 00:29:57 UTC (rev 40969)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/ConfigureMavenRepositoriesWizardPage.java 2012-05-13 12:48:10 UTC (rev 40970)
@@ -1,42 +1,89 @@
+/*************************************************************************************
+ * Copyright (c) 2010-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.maven.ui.wizard;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Scanner;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.apache.maven.cli.MavenCli;
import org.apache.maven.repository.RepositorySystem;
-import org.apache.maven.settings.Activation;
import org.apache.maven.settings.Profile;
import org.apache.maven.settings.Repository;
import org.apache.maven.settings.RepositoryPolicy;
import org.apache.maven.settings.Settings;
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IEncodedStreamContentAccessor;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.window.ToolTip;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
@@ -46,15 +93,71 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.jboss.tools.maven.ui.Activator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+/**
+ *
+ * @author snjeza
+ *
+ */
public class ConfigureMavenRepositoriesWizardPage extends WizardPage {
- private static final String SEPARATOR = "/"; //$NON-NLS-1$
+ private static final String ERROR_TITLE = "Error";
+
+ private static final String SNAPSHOTS_ELEMENT = "snapshots"; //$NON-NLS-1$
+
+ private static final String UPDATE_POLICY_ELEMENT = "updatePolicy"; //$NON-NLS-1$
+
+ private static final String ENABLED_ELEMENT = "enabled"; //$NON-NLS-1$
+
+ private static final String RELEASES_ELEMENT = "releases"; //$NON-NLS-1$
+
+ private static final String LAYOUT_ELEMENT = "layout"; //$NON-NLS-1$
+
+ private static final String POLICY_NEVER = "never"; //$NON-NLS-1$
+
+ private static final String LAYOUT_DEFAULT = "default"; //$NON-NLS-1$
+
+ private static final String NAME_ELEMENT = "name"; //$NON-NLS-1$
+
+ private static final String URL_ELEMENT = "url"; //$NON-NLS-1$
+
+ private static final String REPOSITORY_ELEMENT = "repository"; //$NON-NLS-1$
+
+ private static final String LASTPATH = "lastPath"; //$NON-NLS-1$
+
+ private static final String CONFIGURE_MAVEN_REPOSITORIES = "ConfigureMavenRepositories"; //$NON-NLS-1$
+
+ private static final String JBOSS_EAP_MAVEN_REPOSITORY = "JBoss EAP Maven Repository"; //$NON-NLS-1$
+
+ private static final String PLUGIN_REPOSITORIES_ELEMENT = "pluginRepositories"; //$NON-NLS-1$
+
+ private static final String REPOSITORIES_ELEMENT = "repositories"; //$NON-NLS-1$
+
+ private static final String ACTIVE_BY_DEFAULT_ELEMENT = "activeByDefault"; //$NON-NLS-1$
+
+ private static final String ACTIVATION_ELEMENT = "activation"; //$NON-NLS-1$
+
+ private static final String ID_ELEMENT = "id"; //$NON-NLS-1$
+
+ private static final String PROFILE_ELEMENT = "profile"; //$NON-NLS-1$
+
+ private static final String PROFILES_ELEMENT = "profiles"; //$NON-NLS-1$
+
+ private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
+ public static final String JBOSSTOOLS_MAVEN_PROFILE_ID = "jbosstools-maven-profile"; //$NON-NLS-1$
+
private static final String JSF_IMPL = "com" + File.separator + "sun" + File.separator + "faces" + File.separator + "jsf-impl"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
private static final String WFK_BOMS = "com" + File.separator + "redhat" + File.separator + "jboss" + File.separator + "wfk" + File.separator + "boms"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
@@ -71,15 +174,33 @@
private IMavenConfiguration mavenConfiguration;
private IMaven maven;
private Image jbossImage;
- private ListViewer includedRepositoriesViewer;
- private List<Repository> includedRepositories;
- private List<Repository> availableRepositories;
- private List<Repository> selectedIncludedRepositories = new ArrayList<Repository>();
- private List<Repository> selectedAvailableRepositories = new ArrayList<Repository>();
- private ListViewer availableRepositoriesViewer;
+ private TableViewer includedRepositoriesViewer;
+ private Set<RepositoryWrapper> includedRepositories;
+ private Set<RepositoryWrapper> availableRepositories;
+ private Set<RepositoryWrapper> selectedIncludedRepositories = new HashSet<RepositoryWrapper>();
+ private Set<RepositoryWrapper> selectedAvailableRepositories = new HashSet<RepositoryWrapper>();
+ private TableViewer availableRepositoriesViewer;
private String localRepository;
+
+ private Document document;
+
+ private CompareConfiguration compareConfiguration;
+
+ private TextMergeViewer previewViewer;
+
+ private String newSettings;
+
+ private String oldSettings;
+
+ private Element jbossMavenProfile;
+
+ private Element repositoriesElement;
+
+ private Element pluginRepositoriesElement;
+ private IDialogSettings dialogSettings;
+
public ConfigureMavenRepositoriesWizardPage() {
super(PAGE_NAME);
setTitle("Configure Maven Repositories");
@@ -127,6 +248,94 @@
String userSettings = getUserSettings();
userSettingsLabel.setText("User settings: " + userSettings);
+ File settingsFile = new File(userSettings);
+ try {
+ if (!settingsFile.exists()) {
+ createDefaultSettings();
+ maven.reloadSettings();
+ oldSettings = ""; //$NON-NLS-1$
+ } else {
+ oldSettings = readFile(settingsFile);
+ newSettings = oldSettings;
+ }
+ } catch (Exception e) {
+ Activator.log(e);
+ MessageDialog.openError(getShell(), ERROR_TITLE, e.getMessage());
+ throw new RuntimeException(e);
+ }
+ DocumentBuilder builder;
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ builder = factory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ Activator.log(e);
+ MessageDialog.openError(getShell(), ERROR_TITLE, e.getMessage());
+ throw new RuntimeException(e);
+ }
+ try {
+ document = builder.parse(new InputSource(new StringReader(
+ newSettings)));
+ } catch (Exception e) {
+ Activator.log(e);
+ try {
+ createDefaultSettings();
+ } catch (Exception e1) {
+ Activator.log(e1);
+ MessageDialog.openError(getShell(), ERROR_TITLE, e1.getMessage());
+ throw new RuntimeException(e1);
+ }
+ try {
+ document = builder.parse(new InputSource(new StringReader(
+ newSettings)));
+ } catch (Exception e1) {
+ Activator.log(e1);
+ MessageDialog.openError(getShell(), ERROR_TITLE, e1.getMessage());
+ throw new RuntimeException(e1);
+ }
+ }
+ NodeList profilesList = document.getElementsByTagName(PROFILES_ELEMENT);
+ Node profiles;
+ if (profilesList.getLength() > 0) {
+ profiles = profilesList.item(0);
+ NodeList profileNodes = profiles.getChildNodes();
+ int length = profileNodes.getLength();
+
+ for (int i = 0; i < length; i++) {
+ Node profile = profileNodes.item(i);
+ if (profile.getNodeType() == Node.ELEMENT_NODE
+ && PROFILE_ELEMENT.equals(profile.getNodeName())) {
+ NodeList profileElements = profile.getChildNodes();
+ for (int j = 0; j < profileElements.getLength(); j++) {
+ Node node = profileElements.item(j);
+ if (node.getNodeType() == Node.ELEMENT_NODE
+ && ID_ELEMENT.equals(node.getNodeName())) {
+ String id = node.getTextContent();
+ if (id != null) {
+ id = id.trim();
+ }
+ if (JBOSSTOOLS_MAVEN_PROFILE_ID.equals(id)) {
+ jbossMavenProfile = (Element) profile;
+ break;
+ }
+ }
+ }
+ }
+ if (jbossMavenProfile != null) {
+ break;
+ }
+ }
+ } else {
+ profiles = document.createElement(PROFILES_ELEMENT);
+ document.getDocumentElement().appendChild(profiles);
+ }
+
+ if (jbossMavenProfile == null) {
+ createJBossMavenProfile(profiles);
+ } else {
+ configureJBossMavenProfile();
+ }
+
Group repositoriesGroup = new Group(composite, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
GridLayout layout = new GridLayout(3, false);
@@ -144,32 +353,42 @@
availableRepositoriesLabel.setLayoutData(gd);
availableRepositoriesLabel.setText("Available Repositories:");
- availableRepositoriesViewer = new ListViewer(availableRepositoriesComposite, SWT.BORDER | SWT.MULTI |SWT.H_SCROLL|SWT.V_SCROLL);
+ availableRepositoriesViewer = new TableViewer(availableRepositoriesComposite, SWT.BORDER | SWT.MULTI |SWT.H_SCROLL|SWT.V_SCROLL);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- gd.heightHint = 300;
- gd.widthHint = 300;
- availableRepositoriesViewer.getList().setLayoutData(gd);
+ gd.heightHint = 150;
+ gd.widthHint = 350;
+ availableRepositoriesViewer.getTable().setLayoutData(gd);
+ availableRepositoriesViewer.getTable().setLinesVisible(false);
+ availableRepositoriesViewer.getTable().setHeaderVisible(false);
+ TableViewerColumn column = new TableViewerColumn(availableRepositoriesViewer, SWT.NONE);
+ column.getColumn().setText("Repository");
+ //column.getColumn().setWidth(350);
+ column.getColumn().setResizable(true);
+ ColumnLayoutData columnLayoutData = new ColumnWeightData(350,350);
+ TableLayout availableLayout = new AutoResizeTableLayout(availableRepositoriesViewer.getTable());
+ availableLayout.addColumnData(columnLayoutData);
availableRepositoriesViewer.setContentProvider(new ArrayContentProvider());
availableRepositoriesViewer.setLabelProvider(new RepositoryLabelProvider());
+ ColumnViewerToolTipSupport.enableFor(availableRepositoriesViewer,ToolTip.NO_RECREATE);
Composite buttonsComposite = new Composite(repositoriesGroup, SWT.NONE);
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd = new GridData(SWT.FILL, SWT.FILL, false, false);
buttonsComposite.setLayoutData(gd);
buttonsComposite.setLayout(new GridLayout(1, false));
Label buttonsLabel = new Label(buttonsComposite, SWT.NONE);
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd = new GridData(SWT.FILL, SWT.FILL, false, false);
buttonsLabel.setLayoutData(gd);
+ GC gc = new GC(buttonsComposite);
+ int maxAddRemoveButtonsWidth = computeMaxAddRemoveButtonsWidth(gc);
+ gc.dispose();
+
Composite buttonsComp = new Composite(buttonsComposite, SWT.NONE);
- gd = new GridData(SWT.FILL, SWT.FILL, false, true);
+ gd = new GridData(SWT.FILL, SWT.FILL, false, false);
buttonsComp.setLayoutData(gd);
buttonsComp.setLayout(new GridLayout());
- GC gc = new GC(buttonsComp);
- int maxAddRemoveButtonsWidth = computeMaxAddRemoveButtonsWidth(gc);
- gc.dispose();
-
removeButton = createButton(buttonsComp, maxAddRemoveButtonsWidth, REMOVE);
removeAllButton = createButton(buttonsComp, maxAddRemoveButtonsWidth, REMOVE_ALL);
addButton = createButton(buttonsComp, maxAddRemoveButtonsWidth, ADD);
@@ -183,18 +402,25 @@
Label includedRepositoriesLabel = new Label(includedRepositoriesComposite, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
includedRepositoriesLabel.setLayoutData(gd);
- includedRepositoriesLabel.setText("Maven Repositories:");
+ includedRepositoriesLabel.setText("Included Repositories:");
- includedRepositoriesViewer = new ListViewer(includedRepositoriesComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL|SWT.V_SCROLL);
+ includedRepositoriesViewer = new TableViewer(includedRepositoriesComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL|SWT.V_SCROLL);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- gd.heightHint = 300;
- gd.widthHint = 300;
+ gd.widthHint = 350;
+ gd.heightHint = 150;
+ includedRepositoriesViewer.getTable().setLayoutData(gd);
+ includedRepositoriesViewer.getTable().setLinesVisible(false);
+ includedRepositoriesViewer.getTable().setHeaderVisible(false);
+ TableViewerColumn c = new TableViewerColumn(includedRepositoriesViewer, SWT.NONE);
+ c.getColumn().setText("Repository");
+ c.getColumn().setResizable(true);
+ TableLayout includedLayout = new AutoResizeTableLayout(includedRepositoriesViewer.getTable());
+ includedLayout.addColumnData(columnLayoutData);
- includedRepositoriesViewer.getList().setLayoutData(gd);
includedRepositoriesViewer.setContentProvider(new ArrayContentProvider());
includedRepositoriesViewer.setLabelProvider(new RepositoryLabelProvider());
+ ColumnViewerToolTipSupport.enableFor(availableRepositoriesViewer, ToolTip.NO_RECREATE);
-
Button recognizeButton = new Button(composite, SWT.PUSH);
recognizeButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true, false));
recognizeButton.setText("Recognize JBoss Maven Enterprise Repositories...");
@@ -208,10 +434,20 @@
directoryDialog.setMessage("Select the directory in which to search for JBoss Maven Enterprise Repositories:");
directoryDialog.setText("Search for JBoss Maven Enterprise Repositories");
+ dialogSettings = Activator.getDefault().getDialogSettings();
+ IDialogSettings configureMavenRepositories = dialogSettings.getSection(CONFIGURE_MAVEN_REPOSITORIES);
+ if (configureMavenRepositories == null) {
+ configureMavenRepositories = dialogSettings.addNewSection(CONFIGURE_MAVEN_REPOSITORIES);
+ }
+ String filterPath = configureMavenRepositories.get(LASTPATH);
+ if (filterPath != null) {
+ directoryDialog.setFilterPath(filterPath);
+ }
String pathStr = directoryDialog.open();
if (pathStr == null)
return;
+ configureMavenRepositories.put(LASTPATH, pathStr);
final IPath path = new Path(pathStr);
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
@@ -220,11 +456,11 @@
dialog.open();
final IProgressMonitor monitor = dialog.getProgressMonitor();
monitor.beginTask("Searching...", 110);
- final List<Repository> list = new ArrayList<Repository>();
+ final Set<RepositoryWrapper> repos = new HashSet<RepositoryWrapper>();
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor2) {
- searchForRepositories(path, list, monitor2);
+ searchForRepositories(path, repos, monitor2);
}
};
try {
@@ -236,70 +472,24 @@
if (monitor.isCanceled()) {
return;
}
- List<Repository> newRepositories = new ArrayList<Repository>();
- if (list.size() > 0) {
- for (Repository repository:list) {
- String url = repository.getUrl();
- if (url == null) {
- continue;
- }
- url = changeUrl(url);
- boolean included = false;
- for (Repository rep:availableRepositories) {
- String url1 = rep.getUrl();
- if (url1 == null) {
- continue;
- }
- url1 = changeUrl(url1);
- if (url1.equals(url)) {
- included = true;
- break;
- }
- }
- for (Repository rep:includedRepositories) {
- String url1 = rep.getUrl();
- if (url1 == null) {
- continue;
- }
- url1 = changeUrl(url1);
- if (url1.equals(url)) {
- included = true;
- break;
- }
- }
- if (!included) {
- newRepositories.add(repository);
- }
+ for (RepositoryWrapper wrapper:repos) {
+ if (!includedRepositories.contains(wrapper)) {
+ availableRepositories.add(wrapper);
}
}
- if (newRepositories.size() > 0) {
- availableRepositories.addAll(newRepositories);
- refreshRepositories();
- }
+ refreshRepositories();
}
});
includedRepositories = getIncludedRepositories();
availableRepositories = getAvailableRepositories();
- List<Repository> remove = new ArrayList<Repository>();
- for (Repository availableRepository:availableRepositories) {
- String url = availableRepository.getUrl();
- if (url == null) {
- continue;
+ List<RepositoryWrapper> remove = new ArrayList<RepositoryWrapper>();
+ for (RepositoryWrapper availableRepository:availableRepositories) {
+ if (includedRepositories.contains(availableRepository)) {
+ remove.add(availableRepository);
}
- url = changeUrl(url);
- for (Repository includedRepository:includedRepositories) {
- String url1 = includedRepository.getUrl();
- if (url1 == null) {
- continue;
- }
- url1 = changeUrl(url1);
- if (url1.equals(url)) {
- remove.add(availableRepository);
- }
- }
}
- for (Repository repository:remove) {
+ for (RepositoryWrapper repository:remove) {
availableRepositories.remove(repository);
}
@@ -313,8 +503,8 @@
Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
- if (object instanceof Repository) {
- selectedAvailableRepositories.add((Repository) object);
+ if (object instanceof RepositoryWrapper) {
+ selectedAvailableRepositories.add((RepositoryWrapper) object);
}
}
}
@@ -331,8 +521,8 @@
Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
- if (object instanceof Repository) {
- selectedIncludedRepositories.add((Repository) object);
+ if (object instanceof RepositoryWrapper) {
+ selectedIncludedRepositories.add((RepositoryWrapper) object);
}
}
}
@@ -343,8 +533,13 @@
@Override
public void widgetSelected(SelectionEvent e) {
- includedRepositories.removeAll(selectedIncludedRepositories);
- availableRepositories.addAll(selectedIncludedRepositories);
+ for (RepositoryWrapper wrapper:selectedIncludedRepositories) {
+ if (wrapper.isJBossRepository()) {
+ includedRepositories.remove(wrapper);
+ availableRepositories.add(wrapper);
+ removeRepository(wrapper);
+ }
+ }
setPageComplete(true);
refreshRepositories();
}
@@ -354,8 +549,15 @@
@Override
public void widgetSelected(SelectionEvent e) {
- availableRepositories.addAll(includedRepositories);
- includedRepositories.clear();
+ List<RepositoryWrapper> list = new ArrayList<RepositoryWrapper>();
+ for (RepositoryWrapper wrapper:includedRepositories) {
+ if (wrapper.isJBossRepository()) {
+ list.add(wrapper);
+ removeRepository(wrapper);
+ }
+ }
+ includedRepositories.removeAll(list);
+ availableRepositories.addAll(list);
setPageComplete(true);
refreshRepositories();
}
@@ -365,8 +567,13 @@
@Override
public void widgetSelected(SelectionEvent e) {
- includedRepositories.addAll(selectedAvailableRepositories);
- availableRepositories.removeAll(selectedAvailableRepositories);
+ for (RepositoryWrapper wrapper:selectedAvailableRepositories) {
+ if (wrapper.isJBossRepository()) {
+ includedRepositories.add(wrapper);
+ availableRepositories.remove(wrapper);
+ addRepository(wrapper);
+ }
+ }
setPageComplete(true);
refreshRepositories();
}
@@ -376,19 +583,219 @@
@Override
public void widgetSelected(SelectionEvent e) {
- includedRepositories.addAll(availableRepositories);
- availableRepositories.clear();
+ List<RepositoryWrapper> list = new ArrayList<RepositoryWrapper>();
+ for (RepositoryWrapper wrapper:availableRepositories) {
+ if (wrapper.isJBossRepository()) {
+ list.add(wrapper);
+ addRepository(wrapper);
+ }
+ }
+ includedRepositories.addAll(list);
+ availableRepositories.removeAll(list);
setPageComplete(true);
refreshRepositories();
}
});
+
+ Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separator.setVisible(false);
+
+ Label previewLabel= new Label(composite, SWT.NULL);
+ previewLabel.setText("Preview:");
+
+ createPreviewer(composite);
+
refreshRepositories();
setPageComplete(false);
}
+ protected void createDefaultSettings() throws CoreException,
+ UnsupportedEncodingException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ maven.writeSettings(new Settings(), out);
+ newSettings = new String(out.toByteArray(), UTF_8);
+ }
+
+ protected void addRepository(RepositoryWrapper wrapper) {
+ addRepository(wrapper, repositoriesElement);
+ addRepository(wrapper, pluginRepositoriesElement);
+
+ }
+
+ private void addRepository(RepositoryWrapper wrapper, Element repos) {
+ Element repository = document.createElement(REPOSITORY_ELEMENT);
+ repos.appendChild(repository);
+ addElement(repository, ID_ELEMENT, wrapper.getRepository().getId());
+ addElement(repository, NAME_ELEMENT, wrapper.getRepository().getName());
+ addElement(repository, URL_ELEMENT, wrapper.getRepository().getUrl());
+ addElement(repository, LAYOUT_ELEMENT, LAYOUT_DEFAULT);
+ RepositoryPolicy policy = wrapper.getRepository().getReleases();
+ if (policy != null) {
+ Element releases = addElement(repository, RELEASES_ELEMENT, null);
+ addElement(releases, ENABLED_ELEMENT, policy.isEnabled() ? "true" : "false"); //$NON-NLS-1$//$NON-NLS-2$
+ addElement(releases, UPDATE_POLICY_ELEMENT, POLICY_NEVER);
+ repository.appendChild(releases);
+ }
+ policy = wrapper.getRepository().getSnapshots();
+ if (policy != null) {
+ Element snapshots = addElement(repository, SNAPSHOTS_ELEMENT, null);
+ addElement(snapshots, ENABLED_ELEMENT, policy.isEnabled() ? "true" : "false"); //$NON-NLS-1$//$NON-NLS-2$
+ addElement(snapshots, UPDATE_POLICY_ELEMENT, POLICY_NEVER);
+ repository.appendChild(snapshots);
+ }
+ }
+
+ protected Element addElement(Element element, String name, String value) {
+ Element child = document.createElement(name);
+ if (value != null) {
+ Text textNode = document.createTextNode(value);
+ child.appendChild(textNode);
+ }
+ element.appendChild(child);
+ return child;
+ }
+
+ protected void removeRepository(RepositoryWrapper wrapper) {
+ String url = wrapper.getRepository().getUrl();
+ removeRepository(url, repositoriesElement);
+ removeRepository(url, pluginRepositoriesElement);
+ }
+
+ protected void removeRepository(String url, Element repos) {
+ NodeList repositoryNodeList = repos.getChildNodes();
+ int len = repositoryNodeList.getLength();
+ Node repository = null;
+ for (int i = 0; i < len; i++) {
+ Node node = repositoryNodeList.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE && REPOSITORY_ELEMENT.equals(node.getNodeName())) {
+ String urlNode = getRepositoryUrl(node);
+ if (urlNode != null && urlNode.equals(url)) {
+ repository = node;
+ break;
+ }
+ }
+ }
+ if (repository != null) {
+ repos.removeChild(repository);
+ }
+ }
+
+ private String getRepositoryUrl(Node repository) {
+ NodeList nodeList = repository.getChildNodes();
+ int len = nodeList.getLength();
+ for (int i = 0; i < len; i++) {
+ Node node = nodeList.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE && URL_ELEMENT.equals(node.getNodeName())) {
+ String value = node.getTextContent();
+ if (value != null) {
+ value = value.trim();
+ if (!value.endsWith(RepositoryWrapper.SEPARATOR)) {
+ value = value + RepositoryWrapper.SEPARATOR;
+ }
+ }
+ return value;
+ }
+ }
+ return null;
+ }
+
+ private void configureJBossMavenProfile() {
+ NodeList nodeList = jbossMavenProfile.getChildNodes();
+ int len = nodeList.getLength();
+ for (int i = 0; i < len; i++) {
+ Node node = nodeList.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE && REPOSITORIES_ELEMENT.equals(node.getNodeName())) {
+ repositoriesElement = (Element) node;
+ }
+ if (node.getNodeType() == Node.ELEMENT_NODE && PLUGIN_REPOSITORIES_ELEMENT.equals(node.getNodeName())) {
+ pluginRepositoriesElement = (Element) node;
+ }
+ if (repositoriesElement != null && pluginRepositoriesElement != null) {
+ return;
+ }
+ }
+ if (repositoriesElement == null) {
+ repositoriesElement = document.createElement(REPOSITORIES_ELEMENT);
+ jbossMavenProfile.appendChild(repositoriesElement);
+ }
+ if (pluginRepositoriesElement == null) {
+ pluginRepositoriesElement = document.createElement(PLUGIN_REPOSITORIES_ELEMENT);
+ jbossMavenProfile.appendChild(pluginRepositoriesElement);
+ }
+ }
+
+ private Element createJBossMavenProfile(Node profiles) {
+ jbossMavenProfile = document.createElement(PROFILE_ELEMENT);
+ profiles.appendChild(jbossMavenProfile);
+ Element id = document.createElement(ID_ELEMENT);
+ id.setTextContent(JBOSSTOOLS_MAVEN_PROFILE_ID);
+ jbossMavenProfile.appendChild(id);
+ Element activation = document.createElement(ACTIVATION_ELEMENT);
+ jbossMavenProfile.appendChild(activation);
+ Element activeByDefault = document.createElement(ACTIVE_BY_DEFAULT_ELEMENT);
+ activeByDefault.setTextContent("true"); //$NON-NLS-1$
+ activation.appendChild(activeByDefault);
+ repositoriesElement = document.createElement(REPOSITORIES_ELEMENT);
+ jbossMavenProfile.appendChild(repositoriesElement);
+ pluginRepositoriesElement = document.createElement(PLUGIN_REPOSITORIES_ELEMENT);
+ jbossMavenProfile.appendChild(pluginRepositoriesElement);
+ return jbossMavenProfile;
+ }
+
+ private void createPreviewer(Composite composite) {
+ compareConfiguration= new CompareConfiguration();
+ compareConfiguration.setAncestorLabel("Preview:");
+
+ compareConfiguration.setLeftLabel("Old settings");
+ compareConfiguration.setLeftEditable(false);
+
+ compareConfiguration.setRightLabel("New settings");
+ compareConfiguration.setRightEditable(false);
+
+ previewViewer= new TextMergeViewer(composite, SWT.BORDER, compareConfiguration);
+
+ previewViewer.setInput(
+ new DiffNode(Differencer.CHANGE,
+ null,
+ new StringPreviewerInput(oldSettings),
+ new PreviewerInput()
+ )
+ );
+
+ Control control = previewViewer.getControl();
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.minimumHeight = 200;
+ control.setLayoutData(gd);
+ control.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ if (compareConfiguration != null)
+ compareConfiguration.dispose();
+ }
+ });
+
+ }
+
+ private String getNewSettings() {
+ try {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ factory.setAttribute("indent-number", 2); //$NON-NLS-1$
+ Transformer transformer = factory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
+ DOMSource source = new DOMSource(document);
+ transformer.transform(source, result);
+ return writer.toString();
+ } catch (Exception e) {
+ Activator.log(e);
+ }
+ return null;
+ }
+
private void searchForRepositories(IPath path,
- List<Repository> list, IProgressMonitor monitor) {
+ Set<RepositoryWrapper> repos, IProgressMonitor monitor) {
File[] files = null;
if (path != null) {
File f = path.toFile();
@@ -409,7 +816,7 @@
if (monitor.isCanceled())
return;
if (files[i] != null && files[i].isDirectory()) {
- searchDir(list, files[i], 4, monitor);
+ searchDir(repos, files[i], 4, monitor);
}
monitor.worked(work);
}
@@ -418,7 +825,7 @@
monitor.worked(100);
}
- private void searchDir(List<Repository> list, File directory, int depth,
+ private void searchDir(Set<RepositoryWrapper> repos, File directory, int depth,
IProgressMonitor monitor) {
String localRepository = getLocalRepository();
@@ -426,11 +833,11 @@
return;
}
monitor.setTaskName("Searching " + directory.getAbsolutePath());
- File comFile = new File(directory, "com");
- if (comFile.isDirectory()) { //$NON-NLS-1$
- Repository repository = getRepositoryFromDir(directory, list, monitor);
+ File comFile = new File(directory, "com"); //$NON-NLS-1$
+ if (comFile.isDirectory()) {
+ RepositoryWrapper repository = getRepositoryFromDir(directory, repos, monitor);
if (repository != null) {
- list.add(repository);
+ repos.add(repository);
return;
}
}
@@ -448,12 +855,12 @@
for (int i = 0; i < size; i++) {
if (monitor.isCanceled())
return;
- searchDir(list, files[i], depth - 1, monitor);
+ searchDir(repos, files[i], depth - 1, monitor);
}
}
}
- private Repository getRepositoryFromDir(File directory,List<Repository> repositories, IProgressMonitor monitor) {
+ private RepositoryWrapper getRepositoryFromDir(File directory, Set<RepositoryWrapper> repos, IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return null;
}
@@ -472,19 +879,20 @@
if (list != null && list.length >= 1) {
// JBoss EAP Maven Repository
Repository repository = getDefaultRepository();
- String id = "jboss-eap-maven-repository";
- List<Repository> allRepositories = new ArrayList<Repository>();
- allRepositories.addAll(repositories);
+ String id = JBOSSTOOLS_MAVEN_PROFILE_ID;
+ Set<RepositoryWrapper> allRepositories = new HashSet<RepositoryWrapper>();
+ allRepositories.addAll(repos);
allRepositories.addAll(includedRepositories);
allRepositories.addAll(availableRepositories);
repository.setId(getUniqueId(id, allRepositories));
- repository.setName("JBoss EAP Maven Repository");
+ repository.setName(JBOSS_EAP_MAVEN_REPOSITORY);
try {
repository.setUrl(directory.toURI().toURL().toString());
} catch (MalformedURLException e) {
Activator.log(e);
}
- return repository;
+ RepositoryWrapper wrapper = new RepositoryWrapper(repository, JBOSSTOOLS_MAVEN_PROFILE_ID);
+ return wrapper;
}
}
file = new File(directory, WFK_BOMS);
@@ -498,18 +906,19 @@
} catch (MalformedURLException e) {
Activator.log(e);
}
- return repository;
+ RepositoryWrapper wrapper = new RepositoryWrapper(repository, JBOSSTOOLS_MAVEN_PROFILE_ID);
+ return wrapper;
}
return null;
}
- private String getUniqueId(String id, List<Repository> allRepositories) {
+ private String getUniqueId(String id, Set<RepositoryWrapper> allRepositories) {
int i = 0;
String startId = id;
while (true) {
boolean found = false;
- for (Repository repository:allRepositories) {
- if (id.equals(repository.getId())) {
+ for (RepositoryWrapper wrapper:allRepositories) {
+ if (id.equals(wrapper.getRepository().getId())) {
id = startId + "." + i++;
found = true;
break;
@@ -521,6 +930,21 @@
}
}
+ private String readFile(File file) throws FileNotFoundException {
+ StringBuilder text = new StringBuilder();
+ String NL = System.getProperty("line.separator");
+ Scanner scanner = new Scanner(new FileInputStream(file), "UTF-8");
+ try {
+ while (scanner.hasNextLine()){
+ text.append(scanner.nextLine() + NL);
+ }
+ }
+ finally{
+ scanner.close();
+ }
+ return text.toString();
+ }
+
private String getUserSettings() {
String userSettings = mavenConfiguration.getUserSettingsFile();
if(userSettings == null || userSettings.length() == 0) {
@@ -530,37 +954,45 @@
}
private void configureButtons() {
- removeButton.setEnabled(selectedIncludedRepositories.size() > 0);
- removeAllButton.setEnabled(includedRepositories.size() > 0);
+ removeAllButton.setEnabled(false);
+ removeButton.setEnabled(false);
+ for (RepositoryWrapper wrapper:selectedIncludedRepositories) {
+ if (JBOSSTOOLS_MAVEN_PROFILE_ID.equals(wrapper.getProfileId())) {
+ removeButton.setEnabled(true);
+ break;
+ }
+ }
+ for (RepositoryWrapper wrapper:includedRepositories) {
+ if (JBOSSTOOLS_MAVEN_PROFILE_ID.equals(wrapper.getProfileId())) {
+ removeAllButton.setEnabled(true);
+ break;
+ }
+ }
addButton.setEnabled(selectedAvailableRepositories.size() > 0);
addAllButton.setEnabled(availableRepositories.size() > 0);
}
private void refreshRepositories() {
- includedRepositoriesViewer.setInput(includedRepositories.toArray(new Repository[0]));
- availableRepositoriesViewer.setInput(availableRepositories.toArray(new Repository[0]));
-
+ includedRepositoriesViewer.setInput(includedRepositories.toArray(new RepositoryWrapper[0]));
+ availableRepositoriesViewer.setInput(availableRepositories.toArray(new RepositoryWrapper[0]));
+ previewViewer.refresh();
selectedIncludedRepositories.clear();
selectedAvailableRepositories.clear();
- includedRepositoriesViewer.setSelection(new StructuredSelection(selectedIncludedRepositories.toArray(new Repository[0])));
- availableRepositoriesViewer.setSelection(new StructuredSelection(selectedAvailableRepositories.toArray(new Repository[0])));
+ includedRepositoriesViewer.setSelection(new StructuredSelection(selectedIncludedRepositories.toArray(new RepositoryWrapper[0])));
+ availableRepositoriesViewer.setSelection(new StructuredSelection(selectedAvailableRepositories.toArray(new RepositoryWrapper[0])));
configureButtons();
}
-
- private String changeUrl(String url) {
- url = url.trim();
- if (!url.endsWith(SEPARATOR)) {
- url = url + SEPARATOR;
- }
- return url;
- }
- private List<Repository> getIncludedRepositories() {
- List<Repository> repositories = new ArrayList<Repository>();
+ private Set<RepositoryWrapper> getIncludedRepositories() {
+ Set<RepositoryWrapper> repositories = new TreeSet<RepositoryWrapper>();
try {
List<Profile> activeProfiles = getActiveProfiles();
for (Profile profile:activeProfiles) {
- repositories.addAll(profile.getRepositories());
+ List<Repository> repos = profile.getRepositories();
+ for (Repository repository:repos) {
+ String profileId = profile.getId() == null ? "" : profile.getId(); //$NON-NLS-1$
+ repositories.add(new RepositoryWrapper(repository, profileId));
+ }
}
} catch (CoreException e) {
Activator.log(e);
@@ -568,58 +1000,52 @@
return repositories;
}
- private List<Repository> getAvailableRepositories() {
- List<Repository> repositories = new ArrayList<Repository>();
+ private Set<RepositoryWrapper> getAvailableRepositories() {
+ Set<RepositoryWrapper> repositories = new TreeSet<RepositoryWrapper>();
Repository repository = getDefaultRepository();
+ repository.setId("jboss-public-repository"); //$NON-NLS-1$
+ repository.setName("JBoss Public"); //$NON-NLS-1$
+ repository.setUrl("https://repository.jboss.org/nexus/content/groups/public-jboss/"); //$NON-NLS-1$
+ repositories.add(new RepositoryWrapper(repository, JBOSSTOOLS_MAVEN_PROFILE_ID));
- repository.setId("jboss-public-repository");
- repository.setName("JBoss Public");
- repository.setUrl("https://repository.jboss.org/nexus/content/groups/public-jboss/");
-
- repositories.add(repository);
-
repository = getDefaultRepository();
- repository.setId("java-net-public");
- repository.setName("Java Net Public");
- repository.setUrl("https://maven.java.net/content/groups/public/");
+ repository.setId("java-net-public"); //$NON-NLS-1$
+ repository.setName("Java Net Public"); //$NON-NLS-1$
+ repository.setUrl("https://maven.java.net/content/groups/public/"); //$NON-NLS-1$
+ repositories.add(new RepositoryWrapper(repository, JBOSSTOOLS_MAVEN_PROFILE_ID));
- repositories.add(repository);
-
repository = getDefaultRepository();
- repository.setId("com.springsource.repository.bundles.release");
- repository.setName("EBR Spring Release");
- repository.setUrl("http://repository.springsource.com/maven/bundles/release/");
+ repository.setId("com.springsource.repository.bundles.release"); //$NON-NLS-1$
+ repository.setName("EBR Spring Release"); //$NON-NLS-1$
+ repository.setUrl("http://repository.springsource.com/maven/bundles/release/"); //$NON-NLS-1$
+ repositories.add(new RepositoryWrapper(repository, JBOSSTOOLS_MAVEN_PROFILE_ID));
- repositories.add(repository);
-
repository = getDefaultRepository();
- repository.setId("com.springsource.repository.bundles.external");
- repository.setName("EBR External Release");
- repository.setUrl("http://repository.springsource.com/maven/bundles/external/");
-
- repositories.add(repository);
+ repository.setId("com.springsource.repository.bundles.external"); //$NON-NLS-1$
+ repository.setName("EBR External Release"); //$NON-NLS-1$
+ repository.setUrl("http://repository.springsource.com/maven/bundles/external/"); //$NON-NLS-1$
+ repositories.add(new RepositoryWrapper(repository, JBOSSTOOLS_MAVEN_PROFILE_ID));
repository = getDefaultRepository();
- repository.setId("repository.apache.org");
- repository.setName("Apache Repository");
- repository.setUrl("https://repository.apache.org/content/groups/public/");
+ repository.setId("repository.apache.org"); //$NON-NLS-1$
+ repository.setName("Apache Repository"); //$NON-NLS-1$
+ repository.setUrl("https://repository.apache.org/content/groups/public/"); //$NON-NLS-1$
+ repositories.add(new RepositoryWrapper(repository, JBOSSTOOLS_MAVEN_PROFILE_ID));
- repositories.add(repository);
-
return repositories;
}
private Repository getDefaultRepository() {
Repository repository = new Repository();
- repository.setLayout("default"); //$NON-NLS-1$
+ repository.setLayout(LAYOUT_DEFAULT);
RepositoryPolicy releases = new RepositoryPolicy();
releases.setEnabled(true);
- releases.setUpdatePolicy("never"); //$NON-NLS-1$
+ releases.setUpdatePolicy(POLICY_NEVER); //$NON-NLS-1$
repository.setReleases(releases);
RepositoryPolicy snapshots = new RepositoryPolicy();
snapshots.setEnabled(false);
- snapshots.setUpdatePolicy("never"); //$NON-NLS-1$
+ snapshots.setUpdatePolicy(POLICY_NEVER); //$NON-NLS-1$
repository.setSnapshots(snapshots);
return repository;
}
@@ -689,49 +1115,131 @@
super.dispose();
}
- class RepositoryLabelProvider extends LabelProvider {
+ class RepositoryLabelProvider extends CellLabelProvider {
+
+ public String getToolTipText(Object element) {
+ if (element instanceof RepositoryWrapper) {
+ return ((RepositoryWrapper) element).getDisplayName();
+ }
+ return null;
+ }
+
+ public Point getToolTipShift(Object object) {
+ return new Point(10, 10);
+ }
+
+ public int getToolTipDisplayDelayTime(Object object) {
+ return 1000;
+ }
+
+ public int getToolTipTimeDisplayed(Object object) {
+ return 5000;
+ }
+
public Image getImage(Object element) {
- return null;
- }
+ return null;
+ }
- public String getText(Object element) {
- if (element instanceof Repository) {
- Repository repository = (Repository) element;
- String name = repository.getName() == null ? "<no-name>" : repository.getName(); //$NON-NLS-1$
- return name + "-" + repository.getUrl(); //$NON-NLS-1$
- }
- return null;
- }
+ public String getText(Object element) {
+ if (element instanceof RepositoryWrapper) {
+ return ((RepositoryWrapper) element).getDisplayName();
+ }
+ return null;
+ }
+
+ @Override
+ public void update(ViewerCell cell) {
+ Object element = cell.getElement();
+ if (element instanceof RepositoryWrapper) {
+ cell.setText(((RepositoryWrapper) element).getDisplayName());
+ }
+ }
}
+ class StringPreviewerInput implements ITypedElement, IEncodedStreamContentAccessor {
+ String fContent;
+
+ StringPreviewerInput(String content) {
+ if (content == null) {
+ content="<null>"; //$NON-NLS-1$
+ }
+ fContent= content;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+ public String getName() {
+ return "no name"; //$NON-NLS-1$
+ }
+ public String getType() {
+ return "xml"; //$NON-NLS-1$
+ }
+ public InputStream getContents() {
+ return new ByteArrayInputStream(getBytes(fContent, UTF_8));
+ }
+ public String getCharset() {
+ return UTF_8;
+ }
+ }
+
+ class PreviewerInput implements ITypedElement, IEncodedStreamContentAccessor {
+
+ PreviewerInput() {
+
+ }
+
+ public Image getImage() {
+ return null;
+ }
+ public String getName() {
+ return "no name"; //$NON-NLS-1$
+ }
+ public String getType() {
+ return "xml"; //$NON-NLS-1$
+ }
+ public InputStream getContents() {
+ return new ByteArrayInputStream(getBytes(getNewSettings(), UTF_8));
+ }
+ public String getCharset() {
+ return UTF_8;
+ }
+ }
+ public static byte[] getBytes(String s, String encoding) {
+ byte[] bytes= null;
+ if (s != null) {
+ try {
+ bytes= s.getBytes(encoding);
+ } catch (UnsupportedEncodingException e) {
+ bytes= s.getBytes();
+ }
+ }
+ return bytes;
+ }
+
public void finishPage() {
+ String userSettings = getUserSettings();
+ File file = new File(userSettings);
+ String outputString = getNewSettings();
+ FileOutputStream out = null;
+
try {
- List<Profile> profiles;
- profiles = getActiveProfiles();
- Profile profile;
- Settings settings = maven.getSettings();
- if (profiles.size() <= 0) {
- profile = new Profile();
- profile.setId("jbosstools-maven-profile");
- Activation activation = new Activation();
- activation.setActiveByDefault(true);
- profile.setActivation(activation);
- settings.addProfile(profile);
- } else {
- profile = profiles.get(0);
- }
- profile.setRepositories(includedRepositories);
- profile.setPluginRepositories(includedRepositories);
- String userSettings = getUserSettings();
- File file = new File(userSettings);
- OutputStream out = new FileOutputStream(file);
- maven.writeSettings(settings, out);
- maven.reloadSettings();
+ out = new FileOutputStream(file);
+ byte[] bytes = outputString.getBytes(UTF_8);
+ out.write(bytes);
+ out.flush();
} catch (Exception e) {
- // FIXME
+ MessageDialog.openError(getShell(), ERROR_TITLE, e.getMessage());
Activator.log(e);
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
-
}
}
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/RepositoryWrapper.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/RepositoryWrapper.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/wizard/RepositoryWrapper.java 2012-05-13 12:48:10 UTC (rev 40970)
@@ -0,0 +1,107 @@
+/*************************************************************************************
+ * Copyright (c) 2010-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.ui.wizard;
+
+import org.apache.maven.settings.Repository;
+import org.eclipse.core.runtime.Assert;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class RepositoryWrapper implements Comparable<RepositoryWrapper>{
+ public static final String SEPARATOR = "/"; //$NON-NLS-1$
+ private Repository repository;
+ private String profileId;
+ private String url;
+
+ public RepositoryWrapper(Repository repository, String profileId) {
+ Assert.isNotNull(repository);
+ Assert.isNotNull(profileId);
+ this.repository = repository;
+ this.profileId = profileId;
+ url = repository.getUrl();
+ if (url != null) {
+ url = url.trim();
+ if (!url.endsWith(SEPARATOR)) {
+ url = url + SEPARATOR;
+ }
+ }
+ }
+
+ public Repository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(Repository repository) {
+ this.repository = repository;
+ }
+
+ public String getProfileId() {
+ return profileId;
+ }
+
+ public void setProfileId(String profileId) {
+ this.profileId = profileId;
+ }
+
+ public boolean isJBossRepository() {
+ return ConfigureMavenRepositoriesWizardPage.JBOSSTOOLS_MAVEN_PROFILE_ID.equals(profileId);
+ }
+
+ public String getDisplayName() {
+ String name = repository.getName() == null ? "<no-name>" : repository.getName(); //$NON-NLS-1$
+ return name + "-" + repository.getUrl(); //$NON-NLS-1$
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((url == null) ? 0 : url.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RepositoryWrapper other = (RepositoryWrapper) obj;
+ if (url == null) {
+ if (other.url != null)
+ return false;
+ } else if (!url.equals(other.url))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ String name = repository.getName() == null ? "<no-name>" : repository.getName(); //$NON-NLS-1$
+ return name + "-" + repository.getUrl(); //$NON-NLS-1$
+ }
+
+ public int compareTo(RepositoryWrapper o) {
+ if (o == null) {
+ return 1;
+ }
+ String s = getDisplayName();
+ if (s == null) {
+ return -1;
+ }
+ return s.compareTo(o.getDisplayName());
+ }
+}
12 years, 8 months
JBoss Tools SVN: r40969 - in trunk/common/tests/org.jboss.tools.common.el.core.test: src/org/jboss/tools/common/el/core/test/resolver and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-05-11 20:29:57 -0400 (Fri, 11 May 2012)
New Revision: 40969
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java
Log:
JBIDE-11838
https://issues.jboss.org/browse/JBIDE-11838
Test is added.
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java 2012-05-12 00:29:57 UTC (rev 40969)
@@ -0,0 +1,48 @@
+package test;
+
+public class TestE {
+
+ /**
+ * String property 'name'
+ * @return
+ */
+ public String getName() {
+ return "";
+ }
+
+ /**
+ * Boolean property 'old'
+ * @return
+ */
+ public boolean isOld() {
+ return false;
+ }
+
+ /**
+ * Not a property, has no return type.
+ */
+ public void getAge() {
+ return "";
+ }
+
+ /**
+ * Not a property, return type is not boolean.
+ * @return
+ */
+ public int isBig() {
+ return 0;
+ }
+
+ /**
+ * Not a property, has a parameter.
+ * @param i
+ * @return
+ */
+ public String getState(int i) {
+ return "";
+ }
+
+ public void setColor(String rgb) {
+
+ }
+}
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java 2012-05-12 00:10:55 UTC (rev 40968)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java 2012-05-12 00:29:57 UTC (rev 40969)
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.common.el.core.test.resolver;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import junit.framework.TestCase;
@@ -97,7 +99,7 @@
public void testMissingInterface() throws CoreException {
IJavaProject jp = JavaCore.create(project2);
- String className = "test.TestD";
+ String className = "test.TestD"; //$NON-NLS-1$
IType bean = jp.findType(className);
TypeInfoCollector.TypeInfo typeInfo = new TypeInfoCollector.TypeInfo(bean, null, false);
TypeInfoCollector collector = typeInfo.getTypeCollector(false, false);
@@ -105,6 +107,38 @@
assertNotNull(collector);
}
+ public void testProperties() throws CoreException {
+ IJavaProject jp = JavaCore.create(project2);
+ String className = "test.TestE"; //$NON-NLS-1$
+ IType bean = jp.findType(className);
+ TypeInfoCollector.TypeInfo typeInfo = new TypeInfoCollector.TypeInfo(bean, null, false);
+ TypeInfoCollector collector = typeInfo.getTypeCollector(false, false);
+ List<MemberInfo> ps = collector.getProperties();
+ //Names of methods, recognized as properties
+ Set<String> ns = getNames(ps);
+ assertTrue(ns.contains("getName")); //$NON-NLS-1$
+ assertFalse(ns.contains("getAge")); //$NON-NLS-1$
+ assertTrue(ns.contains("isOld")); //$NON-NLS-1$
+ assertTrue(ns.contains("setColor")); //$NON-NLS-1$
+ assertFalse(ns.contains("isBig")); //$NON-NLS-1$
+ assertFalse(ns.contains("getState")); //$NON-NLS-1$
+ List<MemberInfo> ms = collector.getMethods();
+ //Names of all methods
+ Set<String> ns2 = getNames(ms);
+ //Make sure that methods that were not recognized as properties, do exist.
+ assertTrue(ns2.contains("getAge")); //$NON-NLS-1$
+ assertTrue(ns2.contains("isBig")); //$NON-NLS-1$
+ assertTrue(ns2.contains("getState")); //$NON-NLS-1$
+ }
+
+ Set<String> getNames(List<MemberInfo> ms) {
+ Set<String> result = new HashSet<String>();
+ for (MemberInfo i: ms) {
+ result.add(i.getName());
+ }
+ return result;
+ }
+
private MemberInfo getMethod(TypeInfoCollector collector, String name) {
collector.collectInfo();
List<MemberInfo> mts = collector.getMethods();
12 years, 8 months
JBoss Tools SVN: r40968 - trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-05-11 20:10:55 -0400 (Fri, 11 May 2012)
New Revision: 40968
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
Log:
https://issues.jboss.org/browse/JBIDE-11815 Default for Configuration on New Seam Project wizard should be Seam 2.3 when JBoss AS 7 is selected as Target runtime
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2012-05-12 00:05:49 UTC (rev 40967)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2012-05-12 00:10:55 UTC (rev 40968)
@@ -16,9 +16,11 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.SortedSet;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -71,6 +73,9 @@
import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerLifecycleListener;
import org.eclipse.wst.server.core.ServerCore;
@@ -511,6 +516,27 @@
return top;
}
+ @Override
+ protected void updatePrimaryVersions() {
+ IFacetedProjectWorkingCopy fpjwc = (IFacetedProjectWorkingCopy) this.model.getProperty( FACETED_PROJECT_WORKING_COPY );
+ IProjectFacetVersion selectedVersion = fpjwc.getProjectFacetVersion(primaryProjectFacet);
+ SortedSet<IProjectFacetVersion> initialVersions = fpjwc.getAvailableVersions(primaryProjectFacet);
+ String [] items = new String[initialVersions.size()];
+ int i=0;
+ int selectedVersionIndex = -1;
+ for(Iterator <IProjectFacetVersion> iterator = initialVersions.iterator(); iterator.hasNext(); i++){
+ items[i] = iterator.next().getVersionString();
+ if(selectedVersionIndex == -1 && items[i].equals(selectedVersion.getVersionString())){
+ selectedVersionIndex = i;
+ }
+ }
+ primaryVersionCombo.clearSelection();
+ primaryVersionCombo.setItems(items);
+ if(!setWebModuleVersion()) {
+ primaryVersionCombo.select(selectedVersionIndex);
+ }
+ }
+
protected void createSeamServerTargetComposite(Composite parent) {
Group group = new Group(parent, SWT.NONE);
group.setText(SeamCoreMessages.SEAM_TARGET_SERVER);
@@ -533,6 +559,7 @@
synchHelper.synchCombo(matchedServerTargetCombo, ISeamFacetDataModelProperties.JBOSS_AS_TARGET_SERVER, dependentServerControls);
if (matchedServerTargetCombo.getSelectionIndex() == -1 && matchedServerTargetCombo.getVisibleItemCount() != 0)
matchedServerTargetCombo.select(0);
+ setWebModuleVersion();
}
protected String[] getValidationPropertyNames() {
@@ -550,6 +577,33 @@
return launchNewServerWizard(shell, model, null);
}
+ private boolean setWebModuleVersion() {
+ String runtimeName = serverRuntimeTargetCombo.getText();
+ if(RuntimeManager.isRuntimeDefined(runtimeName)) {
+ IRuntime targetRuntime = RuntimeManager.getRuntime(runtimeName);
+ if(targetRuntime instanceof BridgedRuntime) {
+ List<IRuntimeComponent> components = ((BridgedRuntime)targetRuntime).getRuntimeComponents();
+ for (IRuntimeComponent component : components) {
+ String typeId = component.getProperty("type-id");
+ if(typeId!=null && typeId.startsWith("org.jboss.ide.eclipse.as.runtime.7")) {
+ if(primaryVersionCombo.getItemCount()>0) {
+// System.out.println(primaryVersionCombo.getItem(primaryVersionCombo.getItemCount()-1));
+ primaryVersionCombo.select(primaryVersionCombo.getItemCount()-1);
+ return true;
+ }
+ break;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public IProjectFacetVersion getPrimaryFacetVersion() {
+ return super.getPrimaryFacetVersion();
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
12 years, 8 months
JBoss Tools SVN: r40967 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-05-11 20:05:49 -0400 (Fri, 11 May 2012)
New Revision: 40967
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.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
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IEmbedCartridgesWizardPageModel.java
Log:
[JBIDE-10852] switched to use databinding: cartridge selection strategy gets simpler, does not have to care about UI-state
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-11 22:24:48 UTC (rev 40966)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-05-12 00:05:49 UTC (rev 40967)
@@ -16,6 +16,7 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateListStrategy;
+import org.eclipse.core.databinding.UpdateSetStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.list.IObservableList;
@@ -321,7 +322,7 @@
dbc.addValidationStatusProvider(newApplicationTypeValidator);
ControlDecorationSupport.create(newApplicationTypeValidator, SWT.LEFT | SWT.TOP, null,
new CustomControlDecorationUpdater());
-
+
// embeddable cartridges
this.newAppEmbeddableCartridgesGroup = new Group(newAppConfigurationGroup, SWT.NONE);
newAppEmbeddableCartridgesGroup.setText("Embeddable Cartridges");
@@ -333,10 +334,14 @@
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(1, 2).hint(400, 250)
.applyTo(tableContainer);
this.viewer = createTable(tableContainer);
- viewer.addCheckStateListener(new EmbedCartridgeStrategy(viewer, pageModel, this));
- dbc.bindSet(ViewerProperties.checkedElements(IEmbeddableCartridge.class).observe(viewer),
- BeanProperties.set(ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES)
- .observe(pageModel));
+ viewer.addCheckStateListener(new EmbedCartridgeStrategy(pageModel, this));
+ dbc.bindSet(
+ ViewerProperties.checkedElements(IEmbeddableCartridge.class).observe(viewer),
+ BeanProperties.set(
+ ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES)
+ .observe(pageModel),
+ new UpdateSetStrategy(UpdateSetStrategy.POLICY_NEVER),
+ null);
this.checkAllButton = new Button(newAppEmbeddableCartridgesGroup, SWT.PUSH);
checkAllButton.setText("&Select All");
@@ -452,14 +457,16 @@
@Override
public void widgetSelected(SelectionEvent e) {
-// viewer.setAllChecked(true);
-// try {
-// addJenkinsCartridge(IEmbeddableCartridge.JENKINS_14);
-// } catch (OpenShiftException ex) {
-// OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
-// } catch (SocketTimeoutException ex) {
-// OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
-// }
+ // viewer.setAllChecked(true);
+ // try {
+ // addJenkinsCartridge(IEmbeddableCartridge.JENKINS_14);
+ // } catch (OpenShiftException ex) {
+ // OpenShiftUIActivator.log("Could not select jenkins cartridge",
+ // ex);
+ // } catch (SocketTimeoutException ex) {
+ // OpenShiftUIActivator.log("Could not select jenkins cartridge",
+ // ex);
+ // }
}
};
@@ -824,8 +831,9 @@
/**
* Validates that the new application type is selected
+ *
* @author Xavier Coulon
- *
+ *
*/
class NewApplicationTypeValidator extends MultiValidator {
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-11 22:24:48 UTC (rev 40966)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-05-12 00:05:49 UTC (rev 40967)
@@ -44,7 +44,6 @@
public static final String PROPERTY_EXISTING_APPLICATION_NAME = "existingApplicationName";
public static final String PROPERTY_CARTRIDGES = "cartridges";
public static final String PROPERTY_EMBEDDED_CARTRIDGES = "embeddedCartridges";
- public static final String PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES = "selectedEmbeddableCartridges";
public static final String PROPERTY_SELECTED_CARTRIDGE = "selectedCartridge";
public static final String PROPERTY_SELECTED_GEAR_PROFILE = "selectedGearProfile";
public static final String PROPERTY_APPLICATION_NAME = "applicationName";
@@ -376,27 +375,38 @@
return embeddedCartridges;
}
- @Override
- public Set<IEmbeddableCartridge> getSelectedEmbeddableCartridges() throws OpenShiftException {
- return wizardModel.getSelectedEmbeddableCartridges();
- }
@Override
- public void selectEmbeddedCartridges(IEmbeddableCartridge cartridge) throws OpenShiftException {
+ public void selectEmbeddedCartridges(IEmbeddableCartridge cartridge)
+ throws OpenShiftException,SocketTimeoutException {
+ Set<IEmbeddableCartridge> oldValue = new HashSet<IEmbeddableCartridge>(getSelectedEmbeddableCartridges());
getSelectedEmbeddableCartridges().add(cartridge);
+ firePropertyChange(PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES, oldValue, getSelectedEmbeddableCartridges());
}
@Override
- public void unselectEmbeddedCartridges(IEmbeddableCartridge cartridge) throws OpenShiftException {
+ public void unselectEmbeddedCartridges(IEmbeddableCartridge cartridge)
+ throws OpenShiftException,SocketTimeoutException {
+ Set<IEmbeddableCartridge> oldValue = new HashSet<IEmbeddableCartridge>(getSelectedEmbeddableCartridges());
getSelectedEmbeddableCartridges().remove(cartridge);
+ firePropertyChange(PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES, oldValue, getSelectedEmbeddableCartridges());
}
+ @Override
+ public Set<IEmbeddableCartridge> getSelectedEmbeddableCartridges() throws OpenShiftException {
+ return wizardModel.getSelectedEmbeddableCartridges();
+ }
+
public void setSelectedEmbeddableCartridges(Set<IEmbeddableCartridge> selectedEmbeddableCartridges) {
firePropertyChange(PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES,
wizardModel.getSelectedEmbeddableCartridges(),
wizardModel.setSelectedEmbeddableCartridges(selectedEmbeddableCartridges));
}
+ public boolean isSelected(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException {
+ return getSelectedEmbeddableCartridges().contains(cartridge);
+ }
+
@Override
public boolean hasApplicationOfType(ICartridge cartridge) throws SocketTimeoutException, OpenShiftException {
return getUser().hasApplicationOfType(cartridge);
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 22:24:48 UTC (rev 40966)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-12 00:05:49 UTC (rev 40967)
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.openshift.express.internal.ui.wizard;
-
-import java.net.SocketTimeoutException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Shell;
-import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
-
-import com.openshift.client.IApplication;
-import com.openshift.client.ICartridge;
-import com.openshift.client.IEmbeddableCartridge;
-import com.openshift.client.OpenShiftException;
-
-/**
- * A UI strategy that is able to add and remove embedded cartridges while
- * fullfilling requirements and resolving conflicts (ex. mutual exclusivity
- * etc.)
- * <p>
- * TODO: replaced this manual code by a generic dependency-tree analysis
- * mechanism as soon as OpenShift completed design of cartridge metamodel
- *
- * @author Andre Dietisheim
- */
-public class EmbedCartridgeStrategy implements ICheckStateListener {
-
- private CheckboxTableViewer viewer;
- private IEmbedCartridgesWizardPageModel pageModel;
- private IWizardPage wizardPage;
-
- public EmbedCartridgeStrategy(CheckboxTableViewer viewer,
- IEmbedCartridgesWizardPageModel pageModel, IWizardPage wizardPage) {
- this.viewer = viewer;
- this.wizardPage = wizardPage;
- this.pageModel = pageModel;
- }
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- try {
- IEmbeddableCartridge cartridge = (IEmbeddableCartridge) event.getElement();
- if (event.getChecked()) {
- addCartridge(cartridge);
- } else {
- removeCartridge(cartridge);
- }
- } catch (OpenShiftException e) {
- OpenShiftUIActivator.log("Could not process embeddable cartridges", e);
- } catch (SocketTimeoutException e) {
- OpenShiftUIActivator.log("Could not process embeddable cartridges", e);
- }
- }
-
- private void addCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException {
- if (IEmbeddableCartridge.PHPMYADMIN_34.equals(cartridge)) {
- addPhpMyAdmin();
- } else if (IEmbeddableCartridge.JENKINS_14.equals(cartridge)) {
- addJenkins(cartridge);
- } else if (IEmbeddableCartridge.MYSQL_51.equals(cartridge)) {
- addMySql();
- } else if (IEmbeddableCartridge.POSTGRESQL_84.equals(cartridge)) {
- addPostgreSql();
- } else if (IEmbeddableCartridge.ROCKMONGO_11.equals(cartridge)) {
- addRockMongo();
- } else if (IEmbeddableCartridge._10GEN_MMS_AGENT_01.equals(cartridge)) {
- add10gen();
- } else {
- pageModel.selectEmbeddedCartridges(cartridge);
- }
- }
-
- private void removeCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException {
- if (IEmbeddableCartridge.MYSQL_51.equals(cartridge)) {
- removeMySQL();
- } else if (IEmbeddableCartridge.MONGODB_20.equals(cartridge)) {
- removeMongoDb();
- } else {
- pageModel.unselectEmbeddedCartridges(cartridge);
- }
- }
-
- private void addJenkins(final IEmbeddableCartridge cartridge) throws OpenShiftException,
- SocketTimeoutException {
- if (pageModel.hasApplicationOfType(ICartridge.JENKINS_14)) {
- pageModel.getSelectedEmbeddableCartridges().add(cartridge);
- } else {
- final JenkinsApplicationDialog dialog = new JenkinsApplicationDialog(getShell());
- if (dialog.open() == Dialog.OK) {
- createJenkinsApplication(cartridge, dialog.getValue());
- } else {
- viewer.setChecked(cartridge, false);
- }
- }
- }
-
- private void createJenkinsApplication(final IEmbeddableCartridge cartridge, final String name) {
- try {
- WizardUtils.runInWizard(new Job(NLS.bind("Creating jenkins application \"{0}\"...", name)) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- IApplication jenkinsApplication = pageModel.createJenkinsApplication(name, monitor);
- pageModel.getSelectedEmbeddableCartridges().add(cartridge);
- openLogDialog(jenkinsApplication);
- return Status.OK_STATUS;
- } catch (Exception e) {
- viewer.getControl().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- viewer.setChecked(cartridge, false);
- }
- });
- return OpenShiftUIActivator.createErrorStatus("Could not create jenkins application", e);
- }
- }
-
- }, getContainer());
- } catch (Exception e) {
- // ignore
- }
- }
-
- private void addPhpMyAdmin() throws OpenShiftException, SocketTimeoutException {
- if (!viewer.getChecked(IEmbeddableCartridge.MYSQL_51)) {
- if (MessageDialog.openQuestion(getShell(), "Embed phpMyAdmin Cartridge",
- "To embed phpMyAdmin, you'd also have to embed MySQL. \n\nAlso embed MySQL?")) {
- viewer.setChecked(IEmbeddableCartridge.MYSQL_51, true);
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
- } else {
- viewer.setChecked(IEmbeddableCartridge.PHPMYADMIN_34, false);
- }
- } else {
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
- }
- }
-
- private void addMySql()
- throws OpenShiftException, SocketTimeoutException {
- if (viewer.getChecked(IEmbeddableCartridge.POSTGRESQL_84)) {
- if (MessageDialog
- .openQuestion(getShell(), "Remove PostgreSQL Cartridge",
- "MySQL and PostgreSQL are mutually exclusive. To embed MySQL, you have to remove PostgreSQL. \n\nRemove PostgreSQL?")) {
- viewer.setChecked(IEmbeddableCartridge.POSTGRESQL_84, false);
- pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.POSTGRESQL_84);
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
- } else {
- viewer.setChecked(IEmbeddableCartridge.MYSQL_51, false);
- }
- } else {
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
- }
- }
-
- private void addPostgreSql()
- throws OpenShiftException, SocketTimeoutException {
- if (viewer.getChecked(IEmbeddableCartridge.MYSQL_51)) {
- if (MessageDialog
- .openQuestion(getShell(), "Remove MySQL Cartridge",
- "MySQL and PostgreSQL are mutually exclusive. To embed PostgreSQL, you have to remove MySQL.\n\nRemove MySQL?")) {
- viewer.setChecked(IEmbeddableCartridge.MYSQL_51, false);
- pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.POSTGRESQL_84);
- } else {
- viewer.setChecked(IEmbeddableCartridge.POSTGRESQL_84, false);
- }
- } else {
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.POSTGRESQL_84);
- }
- }
-
- private void removeMySQL() throws OpenShiftException, SocketTimeoutException {
- if (viewer.getChecked(IEmbeddableCartridge.PHPMYADMIN_34)) {
- if (MessageDialog
- .openQuestion(getShell(), "Remove phpmyadmin cartridge",
- "If you remove the mysql cartridge, you'd also have to remove phpmyadmin.\n\nRemove phpMyAdmin and MySQL?")) {
- pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
- pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
- viewer.setChecked(IEmbeddableCartridge.PHPMYADMIN_34, false);
- } else {
- viewer.setChecked(IEmbeddableCartridge.MYSQL_51, true);
- }
- } else {
- pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
- }
- }
-
- private void addRockMongo() throws OpenShiftException, SocketTimeoutException {
- if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20)) {
- if (MessageDialog.openQuestion(getShell(), "Embed MongoDB Cartridge",
- "To embed RockMongo, you'd also have to embed MongoDB. \n\nAlso embed MongoDB?")) {
- viewer.setChecked(IEmbeddableCartridge.MONGODB_20, true);
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.ROCKMONGO_11);
- } else {
- viewer.setChecked(IEmbeddableCartridge.ROCKMONGO_11, false);
- }
- } else {
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
- }
- }
-
- private void removeMongoDb() throws OpenShiftException, SocketTimeoutException {
- boolean removeMongoDb = true;
- if (viewer.getChecked(IEmbeddableCartridge.ROCKMONGO_11)) {
- if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
- "If you remove the MongoDB cartridge, you'd also have to remove RockMongo.")) {
- pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.ROCKMONGO_11);
- viewer.setChecked(IEmbeddableCartridge.ROCKMONGO_11, false);
- } else {
- removeMongoDb = false;
- }
- }
-
- if (removeMongoDb // mongo to be removed?
- && viewer.getChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01)) {
- if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
- "If you remove the MongoDB cartridge, you'd also have to remove 10gen MMS agent.")) {
- pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge._10GEN_MMS_AGENT_01);
- viewer.setChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01, false);
- } else {
- removeMongoDb = false;
- }
- }
-
- viewer.setChecked(IEmbeddableCartridge.MONGODB_20, !removeMongoDb);
- if (removeMongoDb) { // mongo to be removed?
- pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
- }
- }
-
- private void add10gen() throws OpenShiftException, SocketTimeoutException {
- if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20)) {
- if (MessageDialog.openQuestion(getShell(), "Embed 10gen Cartridge",
- "To embed 10gen cartridge, you'd also have to embed MongoDB. \n\nAlso embed MongoDB?")) {
- viewer.setChecked(IEmbeddableCartridge.MONGODB_20, true);
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge._10GEN_MMS_AGENT_01);
- } else {
- viewer.setChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01, false);
- }
- } else {
- pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
- }
- }
-
- private Shell getShell() {
- return viewer.getControl().getShell();
- }
-
- private IWizardContainer getContainer() {
- return wizardPage.getWizard().getContainer();
- }
-
- private void openLogDialog(final IApplication application) {
- viewer.getControl().getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- new CreationLogDialog(getShell(), application).open();
- }
- });
- }
-
- private static class JenkinsApplicationDialog extends InputDialog {
-
- public JenkinsApplicationDialog(Shell shell) {
- super(
- shell,
- "New Jenkins application",
- "To embed Jenkins into your application, you first have to create a separate Jenkins application. "
- + "Please provide a name for this new Jenkins application (lower-case letters and digits only):"
- , null, new JenkinsNameValidator());
- }
-
- private static class JenkinsNameValidator implements IInputValidator {
-
- @Override
- public String isValid(String input) {
- if (StringUtils.isEmpty(input)) {
- return "You have to provide a name for the jenkins application";
- }
-
- if (!StringUtils.isAlphaNumeric(input)) {
- return "The name may only contain lower-case letters and digits.";
- }
- return null;
- }
- }
- }
-}
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-12 00:05:49 UTC (rev 40967)
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import java.net.SocketTimeoutException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
+
+import com.openshift.client.IApplication;
+import com.openshift.client.ICartridge;
+import com.openshift.client.IEmbeddableCartridge;
+import com.openshift.client.OpenShiftException;
+
+/**
+ * A UI strategy that is able to add and remove embedded cartridges while
+ * fullfilling requirements and resolving conflicts (ex. mutual exclusivity
+ * etc.)
+ * <p>
+ * TODO: replaced this manual code by a generic dependency-tree analysis
+ * mechanism as soon as OpenShift completed design of cartridge metamodel
+ *
+ * @author Andre Dietisheim
+ */
+public class EmbedCartridgeStrategy implements ICheckStateListener {
+
+ private IEmbedCartridgesWizardPageModel pageModel;
+ private IWizardPage wizardPage;
+
+ public EmbedCartridgeStrategy(IEmbedCartridgesWizardPageModel pageModel, IWizardPage wizardPage) {
+ this.wizardPage = wizardPage;
+ this.pageModel = pageModel;
+ }
+
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ try {
+ IEmbeddableCartridge cartridge = (IEmbeddableCartridge) event.getElement();
+ if (event.getChecked()) {
+ addCartridge(cartridge);
+ } else {
+ removeCartridge(cartridge);
+ }
+ } catch (OpenShiftException e) {
+ OpenShiftUIActivator.log("Could not process embeddable cartridges", e);
+ } catch (SocketTimeoutException e) {
+ OpenShiftUIActivator.log("Could not process embeddable cartridges", e);
+ }
+ }
+
+ private void addCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException {
+ if (IEmbeddableCartridge.PHPMYADMIN_34.equals(cartridge)) {
+ addPhpMyAdmin();
+ } else if (IEmbeddableCartridge.JENKINS_14.equals(cartridge)) {
+ addJenkins(cartridge);
+ } else if (IEmbeddableCartridge.MYSQL_51.equals(cartridge)) {
+ addMySql();
+ } else if (IEmbeddableCartridge.POSTGRESQL_84.equals(cartridge)) {
+ addPostgreSql();
+ } else if (IEmbeddableCartridge.ROCKMONGO_11.equals(cartridge)) {
+ addRockMongo();
+ } else if (IEmbeddableCartridge._10GEN_MMS_AGENT_01.equals(cartridge)) {
+ add10gen();
+ } else {
+ pageModel.selectEmbeddedCartridges(cartridge);
+ }
+ }
+
+ private void removeCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException {
+ if (IEmbeddableCartridge.MYSQL_51.equals(cartridge)) {
+ removeMySQL();
+ } else if (IEmbeddableCartridge.MONGODB_20.equals(cartridge)) {
+ removeMongoDb();
+ } else {
+ pageModel.unselectEmbeddedCartridges(cartridge);
+ }
+ }
+
+ private void addJenkins(final IEmbeddableCartridge cartridge) throws OpenShiftException,
+ SocketTimeoutException {
+ if (pageModel.hasApplicationOfType(ICartridge.JENKINS_14)) {
+ pageModel.getSelectedEmbeddableCartridges().add(cartridge);
+ } else {
+ final JenkinsApplicationDialog dialog = new JenkinsApplicationDialog(getShell());
+ if (dialog.open() == Dialog.OK) {
+ createJenkinsApplication(cartridge, dialog.getValue());
+ } else {
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.JENKINS_14);
+ }
+ }
+ }
+
+ private void createJenkinsApplication(final IEmbeddableCartridge cartridge, final String name) {
+ try {
+ WizardUtils.runInWizard(new Job(NLS.bind("Creating jenkins application \"{0}\"...", name)) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ IApplication jenkinsApplication = pageModel.createJenkinsApplication(name, monitor);
+ pageModel.selectEmbeddedCartridges(cartridge);
+ openLogDialog(jenkinsApplication);
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ try {
+ pageModel.selectEmbeddedCartridges(cartridge);
+ } catch (Exception ex) {
+ OpenShiftUIActivator.log(ex);
+ }
+ return OpenShiftUIActivator.createErrorStatus("Could not create jenkins application", e);
+ }
+ }
+
+ }, getContainer());
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ private void addPhpMyAdmin() throws OpenShiftException, SocketTimeoutException {
+ if (!pageModel.isSelected(IEmbeddableCartridge.MYSQL_51)) {
+ if (MessageDialog.openQuestion(getShell(), "Embed phpMyAdmin Cartridge",
+ "To embed phpMyAdmin, you'd also have to embed MySQL. \n\nAlso embed MySQL?")) {
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
+ }
+ } else {
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
+ }
+ }
+
+ private void addMySql()
+ throws OpenShiftException, SocketTimeoutException {
+ if (pageModel.isSelected(IEmbeddableCartridge.POSTGRESQL_84)) {
+ if (MessageDialog
+ .openQuestion(getShell(), "Remove PostgreSQL Cartridge",
+ "MySQL and PostgreSQL are mutually exclusive. To embed MySQL, you have to remove PostgreSQL. \n\nRemove PostgreSQL?")) {
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.POSTGRESQL_84);
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
+ }
+ } else {
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
+ }
+ }
+
+ private void addPostgreSql()
+ throws OpenShiftException, SocketTimeoutException {
+ if (pageModel.isSelected(IEmbeddableCartridge.MYSQL_51)) {
+ if (MessageDialog
+ .openQuestion(getShell(), "Remove MySQL Cartridge",
+ "MySQL and PostgreSQL are mutually exclusive. To embed PostgreSQL, you have to remove MySQL.\n\nRemove MySQL?")) {
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.POSTGRESQL_84);
+ }
+ } else {
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.POSTGRESQL_84);
+ }
+ }
+
+ private void removeMySQL() throws OpenShiftException, SocketTimeoutException {
+ if (pageModel.isSelected(IEmbeddableCartridge.PHPMYADMIN_34)) {
+ if (MessageDialog
+ .openQuestion(getShell(), "Remove phpmyadmin cartridge",
+ "If you remove the mysql cartridge, you'd also have to remove phpmyadmin.\n\nRemove phpMyAdmin and MySQL?")) {
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
+ }
+ } else {
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
+ }
+ }
+
+ private void addRockMongo() throws OpenShiftException, SocketTimeoutException {
+ if (!pageModel.isSelected(IEmbeddableCartridge.MONGODB_20)) {
+ if (MessageDialog.openQuestion(getShell(), "Embed MongoDB Cartridge",
+ "To embed RockMongo, you'd also have to embed MongoDB. \n\nAlso embed MongoDB?")) {
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.ROCKMONGO_11);
+ }
+ } else {
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
+ }
+ }
+
+ private void removeMongoDb() throws OpenShiftException, SocketTimeoutException {
+ boolean removeMongoDb = true;
+ if (pageModel.isSelected(IEmbeddableCartridge.ROCKMONGO_11)) {
+ if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
+ "If you remove the MongoDB cartridge, you'd also have to remove RockMongo.")) {
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.ROCKMONGO_11);
+ } else {
+ removeMongoDb = false;
+ }
+ }
+
+ if (removeMongoDb // mongo to be removed?
+ && pageModel.isSelected(IEmbeddableCartridge._10GEN_MMS_AGENT_01)) {
+ if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
+ "If you remove the MongoDB cartridge, you'd also have to remove 10gen MMS agent.")) {
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge._10GEN_MMS_AGENT_01);
+ } else {
+ removeMongoDb = false;
+ }
+ }
+
+ if (removeMongoDb) { // mongo to be removed?
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
+ }
+ }
+
+ private void add10gen() throws OpenShiftException, SocketTimeoutException {
+ if (!pageModel.isSelected(IEmbeddableCartridge.MONGODB_20)) {
+ if (MessageDialog.openQuestion(getShell(), "Embed 10gen Cartridge",
+ "To embed 10gen cartridge, you'd also have to embed MongoDB. \n\nAlso embed MongoDB?")) {
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge._10GEN_MMS_AGENT_01);
+ }
+ } else {
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
+ }
+ }
+
+ private Shell getShell() {
+ return wizardPage.getControl().getShell();
+ }
+
+ private IWizardContainer getContainer() {
+ return wizardPage.getWizard().getContainer();
+ }
+
+ private void openLogDialog(final IApplication application) {
+ wizardPage.getControl().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ new CreationLogDialog(getShell(), application).open();
+ }
+ });
+ }
+
+ private static class JenkinsApplicationDialog extends InputDialog {
+
+ public JenkinsApplicationDialog(Shell shell) {
+ super(
+ shell,
+ "New Jenkins application",
+ "To embed Jenkins into your application, you first have to create a separate Jenkins application. "
+ + "Please provide a name for this new Jenkins application (lower-case letters and digits only):"
+ , null, new JenkinsNameValidator());
+ }
+
+ private static class JenkinsNameValidator implements IInputValidator {
+
+ @Override
+ public String isValid(String input) {
+ if (StringUtils.isEmpty(input)) {
+ return "You have to provide a name for the jenkins application";
+ }
+
+ if (!StringUtils.isAlphaNumeric(input)) {
+ return "The name may only contain lower-case letters and digits.";
+ }
+ return null;
+ }
+ }
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.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/EmbedCartridgeWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java 2012-05-11 22:24:48 UTC (rev 40966)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPage.java 2012-05-12 00:05:49 UTC (rev 40967)
@@ -19,10 +19,13 @@
import java.util.concurrent.TimeUnit;
import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateSetStrategy;
+import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.databinding.viewers.ViewerProperties;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.layout.TableColumnLayout;
@@ -76,7 +79,15 @@
this.viewer = createTable(tableContainer);
GridDataFactory.fillDefaults()
.span(3, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableContainer);
- viewer.addCheckStateListener(new EmbedCartridgeStrategy(viewer, pageModel, this));
+// viewer.addCheckStateListener(new EmbedCartridgeStrategy(viewer, pageModel, this));
+ dbc.bindSet(
+ ViewerProperties.checkedElements(IEmbeddableCartridge.class).observe(viewer),
+ BeanProperties.set(
+ EmbedCartridgeWizardPageModel.PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES)
+ .observe(pageModel),
+ new UpdateSetStrategy(UpdateSetStrategy.POLICY_NEVER),
+ null);
+ viewer.addCheckStateListener(new EmbedCartridgeStrategy(pageModel, this));
// hiding buttons for now: https://issues.jboss.org/browse/JBIDE-10399
// Button checkAllButton = new Button(embedGroup, SWT.PUSH);
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java 2012-05-11 22:24:48 UTC (rev 40966)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java 2012-05-12 00:05:49 UTC (rev 40967)
@@ -12,6 +12,7 @@
import java.net.SocketTimeoutException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -38,7 +39,7 @@
public static final String PROPERTY_SELECTED_CARTRIDGE = "selectedCartridge";
private ApplicationWizardModel wizardModel;
-
+
private List<IEmbeddableCartridge> embeddedCartridges = new ArrayList<IEmbeddableCartridge>();
private Set<IEmbeddableCartridge> selectedCartridges;
@@ -55,11 +56,6 @@
}
selectedCartridges.addAll(application.getEmbeddedCartridges());
}
-
- protected void setSelectedEmbeddedCartridges(List<IEmbeddedCartridge> cartridges) {
- selectedCartridges.clear();
- selectedCartridges.addAll(cartridges);
- }
public List<IEmbeddableCartridge> loadEmbeddableCartridges() throws OpenShiftException, SocketTimeoutException {
List<IEmbeddableCartridge> cartridges = wizardModel.getUser().getEmbeddableCartridges();
@@ -84,6 +80,21 @@
return selectedCartridges;
}
+ public void setSelectedEmbeddableCartridges(Set<IEmbeddableCartridge> cartridges) throws SocketTimeoutException, OpenShiftException {
+ setSelectedEmbeddableCartridges(cartridges);
+ }
+
+ protected void setSelectedEmbeddedCartridges(Collection<IEmbeddedCartridge> cartridges) throws SocketTimeoutException, OpenShiftException {
+ Set<IEmbeddableCartridge> oldValue = getSelectedEmbeddableCartridges();
+ selectedCartridges.clear();
+ selectedCartridges.addAll(cartridges);
+ firePropertyChange(PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES, oldValue, selectedCartridges);
+ }
+
+ public boolean isSelected(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException {
+ return getSelectedEmbeddableCartridges().contains(cartridge);
+ }
+
public boolean hasApplication(ICartridge cartridge) throws SocketTimeoutException, OpenShiftException {
return wizardModel.getUser().hasApplicationOfType(cartridge);
}
@@ -95,13 +106,17 @@
@Override
public void selectEmbeddedCartridges(IEmbeddableCartridge cartridge)
throws OpenShiftException,SocketTimeoutException {
+ Set<IEmbeddableCartridge> oldValue = new HashSet<IEmbeddableCartridge>(getSelectedEmbeddableCartridges());
getSelectedEmbeddableCartridges().add(cartridge);
+ firePropertyChange(PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES, oldValue, getSelectedEmbeddableCartridges());
}
@Override
public void unselectEmbeddedCartridges(IEmbeddableCartridge cartridge)
throws OpenShiftException,SocketTimeoutException {
+ Set<IEmbeddableCartridge> oldValue = new HashSet<IEmbeddableCartridge>(getSelectedEmbeddableCartridges());
getSelectedEmbeddableCartridges().remove(cartridge);
+ firePropertyChange(PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES, oldValue, getSelectedEmbeddableCartridges());
}
public Set<IEmbeddableCartridge> refreshSelectedEmbeddedCartridges()
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IEmbedCartridgesWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IEmbedCartridgesWizardPageModel.java 2012-05-11 22:24:48 UTC (rev 40966)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IEmbedCartridgesWizardPageModel.java 2012-05-12 00:05:49 UTC (rev 40967)
@@ -25,13 +25,20 @@
*/
public interface IEmbedCartridgesWizardPageModel {
+ public static final String PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES = "selectedEmbeddableCartridges";
+
public Set<IEmbeddableCartridge> getSelectedEmbeddableCartridges() throws OpenShiftException, SocketTimeoutException;
public void selectEmbeddedCartridges(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException;
public void unselectEmbeddedCartridges(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException;
+ public void setSelectedEmbeddableCartridges(Set<IEmbeddableCartridge> selectedEmbeddableCartridges) throws SocketTimeoutException, OpenShiftException;
+
+ public boolean isSelected(IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException;
+
public boolean hasApplicationOfType(ICartridge cartridge) throws SocketTimeoutException, OpenShiftException;
public IApplication createJenkinsApplication(String name, IProgressMonitor monitor) throws OpenShiftException;
+
}
\ No newline at end of file
12 years, 8 months
JBoss Tools SVN: r40966 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-05-11 18:24:48 -0400 (Fri, 11 May 2012)
New Revision: 40966
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
Log:
[JBIDE-10852] added comments
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 22:20:12 UTC (rev 40965)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 22:24:48 UTC (rev 40966)
@@ -40,6 +40,9 @@
* A UI strategy that is able to add and remove embedded cartridges while
* fullfilling requirements and resolving conflicts (ex. mutual exclusivity
* etc.)
+ * <p>
+ * TODO: replaced this manual code by a generic dependency-tree analysis
+ * mechanism as soon as OpenShift completed design of cartridge metamodel
*
* @author Andre Dietisheim
*/
@@ -49,7 +52,7 @@
private IEmbedCartridgesWizardPageModel pageModel;
private IWizardPage wizardPage;
- public EmbedCartridgeStrategy(CheckboxTableViewer viewer,
+ public EmbedCartridgeStrategy(CheckboxTableViewer viewer,
IEmbedCartridgesWizardPageModel pageModel, IWizardPage wizardPage) {
this.viewer = viewer;
this.wizardPage = wizardPage;
@@ -191,8 +194,9 @@
private void removeMySQL() throws OpenShiftException, SocketTimeoutException {
if (viewer.getChecked(IEmbeddableCartridge.PHPMYADMIN_34)) {
- if (MessageDialog.openQuestion(getShell(), "Remove phpmyadmin cartridge",
- "If you remove the mysql cartridge, you'd also have to remove phpmyadmin.\n\nRemove phpMyAdmin and MySQL?")) {
+ if (MessageDialog
+ .openQuestion(getShell(), "Remove phpmyadmin cartridge",
+ "If you remove the mysql cartridge, you'd also have to remove phpmyadmin.\n\nRemove phpMyAdmin and MySQL?")) {
pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
viewer.setChecked(IEmbeddableCartridge.PHPMYADMIN_34, false);
@@ -229,8 +233,8 @@
} else {
removeMongoDb = false;
}
- }
-
+ }
+
if (removeMongoDb // mongo to be removed?
&& viewer.getChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01)) {
if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
@@ -241,7 +245,7 @@
removeMongoDb = false;
}
}
-
+
viewer.setChecked(IEmbeddableCartridge.MONGODB_20, !removeMongoDb);
if (removeMongoDb) { // mongo to be removed?
pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
@@ -263,7 +267,6 @@
}
}
-
private Shell getShell() {
return viewer.getControl().getShell();
}
12 years, 8 months
JBoss Tools SVN: r40965 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-05-11 18:20:12 -0400 (Fri, 11 May 2012)
New Revision: 40965
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
Log:
[JBIDE-10852] corrected corrected removal strategy for mongo (remove 10gen, rockmongo)
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 22:02:41 UTC (rev 40964)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 22:20:12 UTC (rev 40965)
@@ -220,28 +220,30 @@
}
private void removeMongoDb() throws OpenShiftException, SocketTimeoutException {
+ boolean removeMongoDb = true;
if (viewer.getChecked(IEmbeddableCartridge.ROCKMONGO_11)) {
if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
"If you remove the MongoDB cartridge, you'd also have to remove RockMongo.")) {
pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.ROCKMONGO_11);
viewer.setChecked(IEmbeddableCartridge.ROCKMONGO_11, false);
} else {
- viewer.setChecked(IEmbeddableCartridge.MONGODB_20, true);
+ removeMongoDb = false;
}
}
- if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20) // mongo to be removed?
+ if (removeMongoDb // mongo to be removed?
&& viewer.getChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01)) {
if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
"If you remove the MongoDB cartridge, you'd also have to remove 10gen MMS agent.")) {
pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge._10GEN_MMS_AGENT_01);
viewer.setChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01, false);
} else {
- viewer.setChecked(IEmbeddableCartridge.MONGODB_20, true);
+ removeMongoDb = false;
}
}
- if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20)) { // mongo to be removed?
+ viewer.setChecked(IEmbeddableCartridge.MONGODB_20, !removeMongoDb);
+ if (removeMongoDb) { // mongo to be removed?
pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
}
}
12 years, 8 months
JBoss Tools SVN: r40964 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-05-11 18:02:41 -0400 (Fri, 11 May 2012)
New Revision: 40964
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
Log:
[JBIDE-10852] added comments
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 22:00:49 UTC (rev 40963)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 22:02:41 UTC (rev 40964)
@@ -228,7 +228,9 @@
} else {
viewer.setChecked(IEmbeddableCartridge.MONGODB_20, true);
}
- } if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20)
+ }
+
+ if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20) // mongo to be removed?
&& viewer.getChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01)) {
if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
"If you remove the MongoDB cartridge, you'd also have to remove 10gen MMS agent.")) {
@@ -238,7 +240,8 @@
viewer.setChecked(IEmbeddableCartridge.MONGODB_20, true);
}
}
- if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20)) {
+
+ if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20)) { // mongo to be removed?
pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
}
}
12 years, 8 months
JBoss Tools SVN: r40963 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-05-11 18:00:49 -0400 (Fri, 11 May 2012)
New Revision: 40963
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
Log:
[JBIDE-10852] corrected addition strategy for 10gen (also add mongo), corrected removal strategy for mongo (remove 10gen, rockmongo)
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 21:27:33 UTC (rev 40962)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategy.java 2012-05-11 22:00:49 UTC (rev 40963)
@@ -212,7 +212,7 @@
pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.ROCKMONGO_11);
} else {
- viewer.setChecked(IEmbeddableCartridge.MONGODB_20, false);
+ viewer.setChecked(IEmbeddableCartridge.ROCKMONGO_11, false);
}
} else {
pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
@@ -228,7 +228,17 @@
} else {
viewer.setChecked(IEmbeddableCartridge.MONGODB_20, true);
}
- } else {
+ } if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20)
+ && viewer.getChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01)) {
+ if (MessageDialog.openQuestion(getShell(), "Remove MongoDB cartridge",
+ "If you remove the MongoDB cartridge, you'd also have to remove 10gen MMS agent.")) {
+ pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge._10GEN_MMS_AGENT_01);
+ viewer.setChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01, false);
+ } else {
+ viewer.setChecked(IEmbeddableCartridge.MONGODB_20, true);
+ }
+ }
+ if (!viewer.getChecked(IEmbeddableCartridge.MONGODB_20)) {
pageModel.unselectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
}
}
@@ -241,7 +251,7 @@
pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MONGODB_20);
pageModel.selectEmbeddedCartridges(IEmbeddableCartridge._10GEN_MMS_AGENT_01);
} else {
- viewer.setChecked(IEmbeddableCartridge.MONGODB_20, false);
+ viewer.setChecked(IEmbeddableCartridge._10GEN_MMS_AGENT_01, false);
}
} else {
pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.PHPMYADMIN_34);
12 years, 8 months