Skip to content

Commit

Permalink
Merge fb7c0dc into 6f469a4
Browse files Browse the repository at this point in the history
  • Loading branch information
felixreimann committed Mar 26, 2018
2 parents 6f469a4 + fb7c0dc commit 8f467a0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
/*******************************************************************************
* Copyright (c) 2014 Opt4J
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*******************************************************************************/


package org.opt4j.core.config.annotations;

Expand All @@ -31,8 +25,8 @@
import java.lang.annotation.Target;

/**
* The {@link File} annotation marks a {@link String} property as a file such
* that the {@link String} can be changed by a browser.
* The {@link File} annotation marks a {@link String} property as a file such that the {@link String} can be changed by
* a browser.
*
* @author lukasiewycz
*
Expand All @@ -46,4 +40,18 @@
* @return the file extension string
*/
String value() default "";

/**
* The annotated property is a file. Defaults to {@code true}.
*
* @return {@code true}, if files are selectable
*/
boolean file() default true;

/**
* The annotated property is a folder. Defaults to {@code false}.
*
* @return {@code true}, if folders are selectable
*/
boolean folder() default false;
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
/*******************************************************************************
* Copyright (c) 2014 Opt4J
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*******************************************************************************/

package org.opt4j.core.config.visualization;
Expand Down Expand Up @@ -64,8 +59,8 @@
import org.opt4j.core.config.annotations.File;

/**
* The {@link PropertyPanel} is a panel for the configuration of one module.
* Properties and values are arranged in a table.
* The {@link PropertyPanel} is a panel for the configuration of one module. Properties and values are arranged in a
* table.
*
* @author lukasiewycz
*
Expand All @@ -84,8 +79,7 @@ public class PropertyPanel extends JPanel {
protected final Map<Property, Component> components = new HashMap<Property, Component>();

/**
* Constructs a {@link PropertyPanel} for one {@link PropertyModule}
* instance.
* Constructs a {@link PropertyPanel} for one {@link PropertyModule} instance.
*
* @param module
* the instance of the {@link PropertyModule}
Expand Down Expand Up @@ -288,9 +282,8 @@ public void actionPerformed(ActionEvent e) {
}

/**
* Adds a row showing the {@link Citation}. On the left hand side,
* "reference" is printed while on the right hand side, the {@link Citation}
* is added in a static {@link TextArea}.
* Adds a row showing the {@link Citation}. On the left hand side, "reference" is printed while on the right hand
* side, the {@link Citation} is added in a static {@link TextArea}.
*
* @param citation
* the citation to add
Expand All @@ -310,8 +303,6 @@ protected void addReferenceRow(Citation citation) {
field.setBackground(label.getBackground());
field.setEditable(false);
field.setText(Format.formatJava(citation));
System.out.println("title: " + citation.title());
System.out.println("formatJava: " + Format.formatJava(citation));

if (!citation.doi().isEmpty()) {
final String doi = citation.doi();
Expand Down Expand Up @@ -421,6 +412,15 @@ public String getDescription() {
fileChooser.setFileFilter(null);
}

if (file.folder()) {
if (file.file()) {
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
} else {
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
}
} else {
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
}
fileChooser.setVisible(true);

int status = fileChooser.showOpenDialog(null);
Expand Down

0 comments on commit 8f467a0

Please sign in to comment.