[Schmitzm-commits] r1570 - in trunk/schmitzm-core/src/main/java/de/schmitzm: swing swing/input versionnumber
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Apr 28 20:58:30 CEST 2011
Author: alfonx
Date: 2011-04-28 20:58:27 +0200 (Thu, 28 Apr 2011)
New Revision: 1570
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/MultipleOptionPane.java
trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java
Log:
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java 2011-04-28 18:57:30 UTC (rev 1569)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java 2011-04-28 18:58:27 UTC (rev 1570)
@@ -844,13 +844,13 @@
* @param databaseName Default fuer Datenbank-Namen
* @param userName Default fuer User
*/
- public static List<InputOption<?>> createDatabaseLoginDialogOptions(String server, Integer port, String databaseName, String userName) {
+ public static List<InputOption<?>> createDatabaseLoginDialogOptions(String server, Integer port, String databaseName, String userName, String passwd) {
List<InputOption<?>> inputOptions = new ArrayList<InputOption<?>>();
inputOptions.add( new ManualInputOption.Text(SwingUtil.R("DatabaseLoginDialog.Server"),true,server) );
inputOptions.add( new ManualInputOption.Integer(SwingUtil.R("DatabaseLoginDialog.Port"),true,port) );
inputOptions.add( new ManualInputOption.Text(SwingUtil.R("DatabaseLoginDialog.DatabaseName"),true,databaseName) );
inputOptions.add( new ManualInputOption.Text(SwingUtil.R("DatabaseLoginDialog.UserName"),false,userName) );
- inputOptions.add( new ManualInputOption.Password(SwingUtil.R("DatabaseLoginDialog.Password"),false,"") );
+ inputOptions.add( new ManualInputOption.Password(SwingUtil.R("DatabaseLoginDialog.Password"),false,passwd) );
return inputOptions;
}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/MultipleOptionPane.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/MultipleOptionPane.java 2011-04-28 18:57:30 UTC (rev 1569)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/MultipleOptionPane.java 2011-04-28 18:58:27 UTC (rev 1570)
@@ -118,6 +118,9 @@
* verlassen wurde
*/
public static Object[] showMultipleInputDialog(Component parent, String title, InputOption... option) {
+
+ // SwingUtil.checkOnEDT();
+
MultipleOptionPane pane = new MultipleOptionPane(option);
JDialog dialog = pane.createDialog(parent,title);
InputOption invalidOption = null;
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java 2011-04-28 18:57:30 UTC (rev 1569)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java 2011-04-28 18:58:27 UTC (rev 1570)
@@ -2,6 +2,10 @@
import java.io.InputStream;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -49,6 +53,9 @@
#Properties describing this release/build
version=${project.version}
build=${buildNumber}
+ activeProfile1Id=${project.activeProfiles[0].id}
+ activeProfile2Id=${project.activeProfiles[1].id}
+ activeProfile3Id=${project.activeProfiles[3].id}
</code><br/>
* 3. Filtering für die src/main/resources.properties - Datei
* einschalten:<code>
@@ -264,4 +271,51 @@
public static boolean isSnapshot(Class<?> clazz) {
return getVersionInfo(clazz).contains("SNAPSHOT");
}
+
+ /**
+ * Returns a list of up to three maven profiles active during build.
+ */
+ public List<String> getActiveProviles(Class clazz) {
+ ArrayList<String> aps = new ArrayList<String>();
+ try {
+
+ final URL releasePropsURL = clazz
+ .getResource("/release.properties");
+
+ final Properties releaseProps = new Properties();
+ final InputStream openStream = releasePropsURL.openStream();
+ try {
+ releaseProps.load(openStream);
+ } finally {
+ openStream.close();
+ }
+
+ final String ap1 = releaseProps.getProperty("activeprofile1Id");
+ final String ap2 = releaseProps.getProperty("activeprofile2Id");
+ final String ap3 = releaseProps.getProperty("activeprofile3Id");
+
+ if (ap1 != null && !ap1.isEmpty())
+ aps.add(ap1);
+ if (ap2 != null && !ap2.isEmpty())
+ aps.add(ap2);
+ if (ap3 != null && !ap3.isEmpty())
+ aps.add(ap3);
+ return aps;
+
+ } catch (final Exception e) {
+ log.error(
+ "/release.properties could not be read from "
+ + clazz.getSimpleName(), e);
+ return Collections.EMPTY_LIST;
+ }
+
+ }
+
+ /**
+ * Returns true if the project has been build with the queried profile-id
+ * activated.
+ */
+ public boolean isProfileActived(Class clazz, String testProfileId) {
+ return getActiveProviles(clazz).contains(testProfileId);
+ }
}
More information about the Schmitzm-commits
mailing list