Skip to content

Commit

Permalink
enhancement of download flow
Browse files Browse the repository at this point in the history
-surf and -prop interconnection
version 0.4.1
  • Loading branch information
dsmunev committed Dec 7, 2021
1 parent 93df4f6 commit ce0e09b
Show file tree
Hide file tree
Showing 31 changed files with 325 additions and 47 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.idea/
.gradle
build/
lib/
META-INF/
out/
*.iml
34 changes: 34 additions & 0 deletions INSTALLATION_PACKAGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
The next instruction prepared for IDEA IDE


-- Windows --
Preparing of the installation bundle for Windows is mostly automated:
1) run Gradle task 'packageExecutableDistribution'
2) go to $projectDir/releases and adda-gui_${version}_win64.zip will be prepared (!!IMPORTANT keep 'version' up to date)



-- MacOS --
Preparing of the installation bundle for MacOS is semi-automated:
1) run Ant task 'adda-gui-bundle'
2) copy $projectDir/help into $projectDir/out/adda-gui.app/Contents/help
3) copy with override _PREVIOUS_MAC_RELEASE_ZIP_/adda-gui.app/Contents/PlugIns into $projectDir/out/adda-gui.app/Contents/PlugIns
4) zip folder $projectDir/out/adda-gui.app into adda-gui_${version}_mac_UNSIGNED.zip



-- Linux --
Preparing of the installation bundle for Linux is fully manual (but you could change it).
At first jar artifact must be configured (Project settings -> Artifacts -> adda-gui (JAR))
JAR has to include all external libs + 'resourses' directory + adda-gui.main compile output.
If everything is configured correctly then installation package can be prepared

1) create a new folder for release
2) copy 'jbr' and 'lib' folders and 'adda-gui.sh' from _PREVIOUS_LINUX_RELEASE_ZIP_ to release folder
3) run Build->Build artifacts to create release JAR
4) copy with override $projectDir/out/artifacts/adda-gui/adda-gui.jar into the current release folder/lib
5) copy $projectDir/help into the current release folder
6) check the current release folder, it should contain folders 'help', 'jbr', 'lib' and file 'adda-gui.sh'
7) set 'adda-gui.sh' execution permission: sudo chmod +x ./adda-gui.sh
8) set 'java' execution permission: sudo chmod +x ./jbr/bin/java
9) zip the current release folder into adda-gui_${version}_linux.zip
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ADDA GUI Project
!Under developing now!
!UNDER DEVELOPMENT NOW!
Acceptable for generating adda command line
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'adda'
version = '0.2'
version = '0.4.1'
sourceCompatibility = '8'

repositories {
Expand Down Expand Up @@ -70,7 +70,7 @@ test {
}

task packageExecutableDistribution(type: Zip) {
archiveFileName = "adda-gui_win64.zip"
archiveFileName = "adda-gui_${version}_win64.zip"
destinationDirectory = file("$projectDir/releases")

from "$buildDir/launch4j"
Expand Down
Binary file added lib/appbundler-1.0.jar
Binary file not shown.
Binary file added lib/appbundler-1.1.0.jar
Binary file not shown.
10 changes: 7 additions & 3 deletions src/main/java/adda/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import adda.item.root.projectArea.ProjectAreaBox;
import adda.item.root.projectArea.ProjectAreaModel;
import adda.item.root.projectTree.ProjectTreeModel;
import adda.item.root.shortcut.ShortcutsModel;
import adda.item.root.workspace.WorkspaceModel;
import adda.item.tab.base.refractiveIndexAggregator.RefractiveIndexAggregatorModel;
import adda.settings.formatters.json.JsonFormatter;
import adda.settings.formatters.plaintext.PlainTextFormatter;
import adda.settings.serializer.AddaSerializer;
import adda.settings.serializer.ISerializer;
import adda.utils.OsUtils;

import javax.help.CSH;
import javax.help.HelpBroker;
Expand All @@ -27,7 +26,7 @@

public class Context {

public static final String VERSION = "beta0.3.0";
public static final String VERSION = "0.4.1";

protected JFrame mainFrame;

Expand All @@ -36,6 +35,7 @@ public class Context {
protected WorkspaceModel workspaceModel;

protected ProjectTreeModel projectTreeModel;
protected ShortcutsModel shortcutsModel;

protected String runPath;

Expand All @@ -51,6 +51,10 @@ public ProjectTreeModel getProjectTreeModel() {
return projectTreeModel;
}

public ShortcutsModel getShortcutsModel() {
return shortcutsModel;
}

public MainForm getMainForm() {
return mainForm;
}
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/adda/Main.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package adda;

import adda.application.MainForm;
import adda.application.SettingDialog;
import adda.item.root.projectTree.*;
import adda.item.root.shortcut.ShortcutsModel;
import adda.item.root.workspace.WorkspaceModel;
import adda.settings.SettingsManager;
import adda.utils.Binder;
Expand All @@ -13,21 +13,17 @@

import javax.help.CSH;
import javax.help.HelpBroker;
import javax.help.HelpSet;
import javax.help.HelpSetException;
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;

public class Main {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
Locale.setDefault(Locale.ENGLISH);
if (OsUtils.isMac()) System.setProperty( "jdk.lang.Process.launchMechanism", "FORK" );
try {
UIManager.setLookAndFeel(new FlatLightLaf());
Expand Down Expand Up @@ -78,6 +74,7 @@ public void run() {
Context.getInstance().mainForm = app;
Context.getInstance().workspaceModel = (WorkspaceModel) workspaceBox.getModel();
Context.getInstance().projectTreeModel = (ProjectTreeModel) treeBox.getModel();
Context.getInstance().shortcutsModel = (ShortcutsModel) shortcutsBox.getModel();


//Binder.bind(Context.getInstance().getWorkspaceModel(), shortcutsBox.getModel());
Expand Down Expand Up @@ -116,9 +113,11 @@ public void run() {

javax.swing.SwingUtilities.invokeLater(() -> {
if (isOpenSettings) {

SettingsManager.recreateSettings();
SettingsManager.openSettingsDialog();
}
Context.getInstance().getShortcutsModel().refreshAddaVersion();
});

}
Expand Down
39 changes: 28 additions & 11 deletions src/main/java/adda/application/SettingDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ public void actionPerformed(ActionEvent actionEvent) {
JSONObject json = new JSONObject(response);

String zipUrl = String.valueOf(json.get("zipball_url"));
String tagName = String.valueOf(json.get("tag_name"));

String addaVersion = SettingsManager.getAddaVersion();

if (!StringHelper.isEmpty(addaVersion) && addaVersion.toLowerCase().replace(".", "").contains(tagName.toLowerCase().replace(".", ""))) {

int dialogResult = JOptionPane.showConfirmDialog(
Context.getInstance().getMainFrame(), "ADDA version is up to date. Do you want to continue?",
"Download isn't needed",
JOptionPane.YES_NO_OPTION);
if (dialogResult == JOptionPane.NO_OPTION) {
javax.swing.SwingUtilities.invokeLater(() -> textArea.append("ADDA version is up to date, download isn't needed\n"));
return;
}
}

if (OsUtils.isWindows()) {
zipUrl = String.valueOf(((JSONObject) ((JSONArray) json.get("assets")).get(0)).get("browser_download_url"));
Expand All @@ -175,12 +190,14 @@ public void actionPerformed(ActionEvent actionEvent) {
String downloadDir = OsUtils.getDefaultDirectory() + File.separator + "download";
OsUtils.createFolder(downloadDir);

Date now = new Date();
SimpleDateFormat pattern = new SimpleDateFormat("MMddHHmmss");
String path = downloadDir + File.separator + "adda_release_" + pattern.format(now);


// Date now = new Date();
// SimpleDateFormat pattern = new SimpleDateFormat("MMddHHmmss");
String path = downloadDir + File.separator + "adda_" + tagName.replace(".", "_") ;
OsUtils.createFolder(path);

String zipFileName = path + File.separator + "release.zip";
String zipFileName = path + File.separator + "release_" + tagName.replace(".", "_") + ".zip";

javax.swing.SwingUtilities.invokeLater(() -> textArea.append("Downloading to " + zipFileName + "\n"));
Downloader downloader = new Downloader(new URL(zipUrl), zipFileName);
Expand All @@ -191,7 +208,7 @@ public void actionPerformed(ActionEvent actionEvent) {
javax.swing.SwingUtilities.invokeLater(() -> textArea.append("Downloaded " + downloader.getDownloaded() + " from " + downloader.getSize()));
}

javax.swing.SwingUtilities.invokeLater(() -> textArea.append("Downloaded \nUnzipping \n"));
javax.swing.SwingUtilities.invokeLater(() -> textArea.append("ADDA " + tagName + " downloaded \nUnzipping \n"));

OsUtils.unzip(zipFileName, path);

Expand Down Expand Up @@ -221,6 +238,7 @@ public void actionPerformed(ActionEvent actionEvent) {
{
textArea.append("Succesfully prepared \n");
textArea.append("Now we have to compile ADDA from src code \n");
textArea.append("Please, visit https://github.com/adda-team/adda/wiki/CompilingADDA if something went wrong\n");
textArea.append("ADDA required make, gcc, fftw3 (http://www.fftw.org/) and gfortran \n");

if (OsUtils.isMac()) {
Expand All @@ -238,15 +256,12 @@ public void actionPerformed(ActionEvent actionEvent) {
textArea.append("---------------- \n");
textArea.append("\n");
if (OsUtils.isMac()) {
textArea.append("brew install gcc \n");
textArea.append("brew install gcc fftw \n");
textArea.append("brew install make \n");
textArea.append("cd " + srcPath + " \n");
textArea.append("make seq OPTIONS=\"FFT_TEMPERTON\" FORT_LIB_PATH=/usr/local/gfortran/lib\n");
textArea.append("make seq OPTIONS=HOMEBREW CC=gcc-11\n");
} else {
textArea.append("sudo apt-get install gcc \n");
textArea.append("sudo apt-get install gfortran \n");
textArea.append("sudo apt-get install libfftw3-dev \n");
textArea.append("sudo apt-get install make \n");
textArea.append("sudo apt-get install gcc gfortran make libfftw3-dev \n");
textArea.append("cd " + srcPath + " \n");
textArea.append("make seq\n");
}
Expand All @@ -270,12 +285,14 @@ public void actionPerformed(ActionEvent actionEvent) {

try {
cmd(OsUtils.isMac() ? "open" : "gnome-terminal", seqPath);

} catch (Exception ignored) {
cmd(System.getenv().get("TERM"), seqPath);
}


}
boolean ignored = new File(zipFileName).delete();
}


Expand Down
7 changes: 3 additions & 4 deletions src/main/java/adda/base/controllers/ControllerBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ protected void processComboBox(JComboBox comboBox) {
ComboBoxItem selectedItem = (ComboBoxItem) comboBox.getSelectedItem();
if (selectedItem != null && validate(comboBox, selectedItem)) {
ReflectionHelper.setPropertyValue(model, comboBox.getName(), selectedItem.getKey());

if (comboBox.getInputVerifier() != null) {
comboBox.getInputVerifier().verify(comboBox);
}
}
if (comboBox.getInputVerifier() != null) {
comboBox.getInputVerifier().verify(comboBox);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/adda/base/models/IModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public interface IModel extends Cloneable {

boolean validate();

void forceVerify();

boolean isVisibleIfDisabled();

Map<String, String> getValidationErrors();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/adda/base/models/ModelBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public class ModelBase implements IModel, Serializable {

public static final String LABEL_FIELD_NAME = "label";
public static final String VERIFICATION_FIELD_NAME = "VERIFICATION_FIELD_NAME";
protected transient List<IModelObserver> observers;

protected boolean isVisibleIfDisabled = false;
Expand Down Expand Up @@ -49,6 +50,10 @@ public boolean validate() {
return true;
}

public void forceVerify() {
notifyObservers(VERIFICATION_FIELD_NAME, label);
}

protected void initPropertyInfo() {
Class clazz = this.getClass();

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/adda/base/views/ViewBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import adda.base.models.ModelBase;
import adda.help.HelpProvider;
import adda.help.HelpUtil;
import adda.item.tab.base.propagation.PropagationModel;
import adda.utils.ListUtils;
import adda.utils.ReflectionHelper;
import adda.utils.StringHelper;
Expand Down Expand Up @@ -376,9 +377,20 @@ public void modelPropertyChanged(IModel sender, IModelPropertyChangeEvent event)
}
//return;
}
}

if (ModelBase.VERIFICATION_FIELD_NAME.equals(event.getPropertyName())) {
for (Component component : components.values()) {
if (component.getClass().equals(JComboBox.class)) {
final JComboBox comboBox = (JComboBox) component;
comboBox.getInputVerifier().verify(comboBox);
}
if (component.getClass().equals(JNumericField.class)) {
final JNumericField numericField = (JNumericField) component;
numericField.getInputVerifier().verify(numericField);
}


}
}
}
}
7 changes: 7 additions & 0 deletions src/main/java/adda/help/HelpProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import adda.item.tab.internals.jagged.JaggedModel;
import adda.item.tab.internals.maxIterations.MaxIterationsModel;
import adda.item.tab.internals.optimization.OptimizationModel;
import adda.item.tab.internals.reducedFFT.ReducedFftModel;
import adda.item.tab.internals.symmetry.SymmetryModel;
import adda.item.tab.internals.volCorrection.VolCorrectionModel;
import adda.item.tab.output.asymParams.AsymParamsSaveModel;
Expand Down Expand Up @@ -122,6 +123,7 @@ public class HelpProvider {
idMapper.put(PrismModel.class, Arrays.asList("predefined_shapes", StringHelper.toDisplayString("about prism")));
idMapper.put(RbcModel.class, Arrays.asList("predefined_shapes", StringHelper.toDisplayString("about rbc")));
idMapper.put(SphereCuboidModel.class, Arrays.asList("predefined_shapes", StringHelper.toDisplayString("about spherebox")));
idMapper.put(ReducedFftModel.class, Arrays.asList("fast_fourier_transform", StringHelper.toDisplayString("about FFT")));

}

Expand Down Expand Up @@ -219,6 +221,11 @@ public static List<String> getHelpID(IModel model) {
}

public static String getShortDescByClass(Class clazz) {
if (ReducedFftModel.class.equals(clazz)) {
return StringHelper.toDisplayString(
"Using symmetry of the interaction matrix to reduce the storage space for the Fourier transformed matrix"
);
}
if (RefractiveIndexAggregatorModel.class.equals(clazz)) {
return StringHelper.toDisplayString(
"Sets refractive " +
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/adda/item/root/projectArea/ProjectAreaBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import adda.base.models.IModel;
import adda.item.tab.base.BaseTabBox;
import adda.item.tab.base.beam.BeamModel;
import adda.item.tab.base.propagation.PropagationModel;
import adda.item.tab.base.refractiveIndexAggregator.RefractiveIndexAggregatorModel;
import adda.item.tab.base.size.SizeModel;
import adda.item.tab.internals.InternalsTabBox;
Expand Down Expand Up @@ -224,6 +225,11 @@ private void bindChildren() {

Binder.bindBoth(orientationModel, polarizationSaveModel);

PropagationModel propagationModel = (PropagationModel) models.stream()
.filter(entity -> entity instanceof PropagationModel)
.findFirst()
.get();
Binder.bind(surfaceModel, propagationModel);

((ProjectAreaModel) model).setNestedModelList(models);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public JPanel getPanelOptions() {
}

public ProjectAreaForm() {
// centerPanel.setMaximumSize(new Dimension(220, 9999));
//centerPanel.setMinimumSize(new Dimension(250, 100));
scrollShape.setMinimumSize(new Dimension(250, 100));
panelShape.setMinimumSize(new Dimension(250, 100));
panelOptions.setMinimumSize(new Dimension(100, 100));
// panelOutput.setMaximumSize(new Dimension(220, 9999));
// panelDdaInternal.setMaximumSize(new Dimension(220, 9999));
// panelBasic.setMaximumSize(new Dimension(220, 9999));
Expand Down
Loading

0 comments on commit ce0e09b

Please sign in to comment.