diff --git a/pickcells-container/src/main/java/org/pickcellslab/pickcells/impl/presentation/overview/ExperimentWizard.java b/pickcells-container/src/main/java/org/pickcellslab/pickcells/impl/presentation/overview/ExperimentWizard.java index d535c6623d8e74136fb12f357dff7944b856e125..0e4a484f021814a7fc5c729963a9d3228fee39bf 100644 --- a/pickcells-container/src/main/java/org/pickcellslab/pickcells/impl/presentation/overview/ExperimentWizard.java +++ b/pickcells-container/src/main/java/org/pickcellslab/pickcells/impl/presentation/overview/ExperimentWizard.java @@ -10,12 +10,12 @@ package org.pickcellslab.pickcells.impl.presentation.overview; * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * . @@ -65,7 +65,7 @@ public class ExperimentWizard extends JDialog { public ExperimentWizard(NotificationFactory notif) { this.notif = notif; - + setTitle("Experiment Wizard"); setBounds(100, 100, 387, 252); getContentPane().setLayout(new BorderLayout()); @@ -84,18 +84,19 @@ public class ExperimentWizard extends JDialog { JButton browsebtn = new JButton("Browse..."); browsebtn.addActionListener(a->{ - JFileChooser chooser = new JFileChooser(); - chooser.setDialogTitle("Choose where to create your database for this experiment"); + File workingDirectory = new File(System.getProperty("user.dir")); + JFileChooser chooser = new JFileChooser(workingDirectory.getParentFile().getParent()); + chooser.setDialogTitle("Select the folder in which to create your database for this experiment"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); - if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) locationField.setText(chooser.getSelectedFile().toString()); }); - - - + + + JLabel lblDescription = new JLabel("Description"); JTextArea descriptionField = new JTextArea(); @@ -162,11 +163,11 @@ public class ExperimentWizard extends JDialog { } //Create an empty folder - if(!new File(location).mkdir()){ + if(!new File(location).mkdir()){ notif.display("Access Denied", "Unable to create a directory at "+location, null, Level.SEVERE); return; } - + experiment = new ExperimentImplForAdmins(name, location, description); this.dispose(); diff --git a/pickcells-container/src/main/java/org/pickcellslab/pickcells/impl/presentation/overview/UserSessionView.java b/pickcells-container/src/main/java/org/pickcellslab/pickcells/impl/presentation/overview/UserSessionView.java index 69f94752a501bcf66afcf490a31550e92e1794f9..430c3ba024d07f2ccbbfbbdd69dae091e48672df 100644 --- a/pickcells-container/src/main/java/org/pickcellslab/pickcells/impl/presentation/overview/UserSessionView.java +++ b/pickcells-container/src/main/java/org/pickcellslab/pickcells/impl/presentation/overview/UserSessionView.java @@ -71,7 +71,7 @@ import com.alee.utils.swing.WebDefaultCellEditor; /** * Swing Implementation for the overview of the user session overview - * + * * @author Guillaume Blin * */ @@ -126,9 +126,9 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ // White panel centered dropping shadow - setLayout ( new TableLayout ( new double[][]{ + setLayout ( new TableLayout ( new double[][]{ { TableLayout.FILL, 0.8, TableLayout.FILL }, - { TableLayout.FILL, 0.8, TableLayout.FILL } + { TableLayout.FILL, 0.8, TableLayout.FILL } } ) ); @@ -147,17 +147,17 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ // Get the current user - final UserImplForAdmins user = model.currentUser(); + final UserImplForAdmins user = model.currentUser(); // ========================================================// - // Create the Collapsible pane which contains instructions, + // Create the Collapsible pane which contains instructions, // buttons and experiments of the current user // ========================================================// final WebCollapsiblePane myExpsPane = new WebCollapsiblePane(); - myExpsPane.setLayout(new VerticalFlowLayout()); + myExpsPane.setLayout(new VerticalFlowLayout()); // Header final WebLabel header = new WebLabel(" My Experiments"); @@ -174,7 +174,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ instructionsPanel.setLayout(new ToolbarLayout()); instructionsPanel.setBackground( Color.WHITE ); - // Instructions + // Instructions final WebLabel note = new WebLabel(" Right-click on individual experiments for more options"); instructionsPanel.add(note, ToolbarLayout.START); final WebButton createBtn = new WebButton(FontIcon.of(FontAwesomeRegular.LIGHTBULB, 16)); @@ -213,7 +213,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ model.addUser(new UserImplForAdmins(d.userName(), d.password(), Priviledge.USER)); } catch (DataAccessException e1) { notif.display("User Creation Error", "The new user could not be created", e1, Level.WARNING); - } + } }); @@ -232,12 +232,12 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ // ========================================================// - // Create the Collapsible pane which contains + // Create the Collapsible pane which contains // buttons and experiments shared with current user // ========================================================// final WebCollapsiblePane sharedPane = new WebCollapsiblePane(); - myExpsPane.setLayout(new VerticalFlowLayout()); + myExpsPane.setLayout(new VerticalFlowLayout()); // Header final WebLabel sharedHeader = new WebLabel(" Shared With Me"); @@ -260,13 +260,13 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ // ========================================================// - // Create the Collapsible pane which contains + // Create the Collapsible pane which contains // the Users managed if the current user is admin // ========================================================// if(user.privilege() == Priviledge.ADMIN) { final WebCollapsiblePane usersPane = new WebCollapsiblePane(); - usersPane.setLayout(new VerticalFlowLayout()); + usersPane.setLayout(new VerticalFlowLayout()); // Header final WebLabel usersHeader = new WebLabel(" Managed Users"); @@ -321,20 +321,20 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ if(created) { u.getCreatedExperimentsLinks().forEach(l->{ experimentPanel.add(new WebSeparator(true, true, WebSeparator.HORIZONTAL)); - final Component wl = makeExperimentEntry(u, l); + final Component wl = makeExperimentEntry(u, l); experimentPanel.add(wl); }); } else { u.getExperimentsSharedByOthersLinks().forEach(l->{ experimentPanel.add(new WebSeparator(true, true, WebSeparator.HORIZONTAL)); - final Component wl = makeExperimentEntry(u, l); + final Component wl = makeExperimentEntry(u, l); experimentPanel.add(wl); }); if(u.getExperimentsSharedByOthersLinks().count() == 0) { experimentPanel.add(new WebLabel(" No experiment has been shared with you yet")); experimentPanel.setBorder(BorderFactory.createEmptyBorder(5, 20, 15, 20)); - } + } } return experimentPanel; } @@ -365,7 +365,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ @Override public void mouseEntered(MouseEvent e) { expInfoPane.setBorder(new CompoundBorder( - BorderFactory.createLineBorder(new Color(153,153,153), 1, false), + BorderFactory.createLineBorder(new Color(153,153,153), 1, false), BorderFactory.createEmptyBorder(4,24,4,49))); } @Override @@ -396,7 +396,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ // Now add an extra icon with tooltips to indicate whether the experiment is currently being shared // Do this only for experiments created by the currently logged in user if(u.isCreatedLink(l) && e.isShared()) { - final WebLabel shareInfo = createShareLabel(e); + final WebLabel shareInfo = createShareLabel(e); expInfoPane.add(shareInfo, ToolbarLayout.END); shares.put(e, shareInfo); } @@ -435,7 +435,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ @Override public void mouseEntered(MouseEvent e) { userPane.setBorder(new CompoundBorder( - BorderFactory.createLineBorder(new Color(153,153,153), 1, false), + BorderFactory.createLineBorder(new Color(153,153,153), 1, false), BorderFactory.createEmptyBorder(4,24,4,49))); } @Override @@ -464,8 +464,8 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ popup.add(menuItem); menuItem.addActionListener(l->{ new Thread(()->{ - int response = JOptionPane.showConfirmDialog(null, - "This will delete this user and all associated experiments, Continue?", + int response = JOptionPane.showConfirmDialog(null, + "This will delete this user and all associated experiments, Continue?", "Delete User "+u.userName(), JOptionPane.YES_NO_OPTION); if(response == JOptionPane.YES_OPTION) { try { @@ -513,11 +513,11 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ final JPopupMenu menu = new JPopupMenu (); // Load - final FontIcon loadIcon = FontIcon.of(FontAwesomeSolid.ARROW_ALT_CIRCLE_RIGHT); + final FontIcon loadIcon = FontIcon.of(FontAwesomeSolid.ARROW_ALT_CIRCLE_RIGHT); final JMenuItem loadItem = new JMenuItem ("Load", UITheme.toImageIcon(loadIcon)); loadItem.addActionListener(l-> { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - new Thread(()->{ + new Thread(()->{ try { gtLstr.gotoExperiment(model.currentUser(), e); @@ -537,7 +537,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ // Edit if(isCreated || p==Permission.READ_WRITE) { - final FontIcon editIcon = FontIcon.of(FontAwesomeSolid.EDIT); + final FontIcon editIcon = FontIcon.of(FontAwesomeSolid.EDIT); final JMenuItem editItem = new JMenuItem ("Edit Description", UITheme.toImageIcon(editIcon)); editItem.addActionListener(l->manageEditing(e)); editItem.setMargin ( new Insets ( 8, 8, 8, 8 ) ); @@ -546,7 +546,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ } if(isCreated) { // Share - final Icon shareIcon = theme.icon(IconID.App.SHARE, 16); + final Icon shareIcon = theme.icon(IconID.App.SHARE, 16); final JMenuItem shareItem = new JMenuItem("Share", UITheme.toImageIcon(shareIcon)); shareItem.addActionListener(l->manageSharing(e)); shareItem.setMargin ( new Insets ( 8, 8, 8, 8 ) ); @@ -555,14 +555,14 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ // Delete - final FontIcon delIcon = FontIcon.of(FontAwesomeSolid.TRASH); + final FontIcon delIcon = FontIcon.of(FontAwesomeSolid.TRASH); final JMenuItem delItem = new JMenuItem ( "Delete", UITheme.toImageIcon(delIcon)); delItem.addActionListener(l-> { int sure = JOptionPane.showConfirmDialog(this, "Delete "+e.getName()+" ?" + "
( This will not delete the database on disk ))"); if(sure == JOptionPane.OK_OPTION) { try { - model.deleteExperiment(e); + model.deleteExperiment(e); } catch (DataAccessException e1) { notif.display("Error", "Could not delete this experiment", e1, Level.WARNING); } @@ -587,7 +587,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ tArea.setPreferredSize(new Dimension(250,200)); tArea.setLineWrap(true); final JScrollPane scroll = new JScrollPane(tArea); - final int response = JOptionPane.showConfirmDialog(null, scroll, "Description Editing...", + final int response = JOptionPane.showConfirmDialog(null, scroll, "Description Editing...", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if(response == JOptionPane.OK_OPTION) { try { @@ -616,7 +616,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ final JComboBox combo = new JComboBox<>(Permission.values()); column.setCellEditor (new WebDefaultCellEditor<>(combo)); initColumnSizes(table); - final WebScrollPane scrollPane = new WebScrollPane (table); + final WebScrollPane scrollPane = new WebScrollPane (table); int response = WebOptionPane.showConfirmDialog(null, scrollPane, e.getName()+" : sharing properties", WebOptionPane.OK_CANCEL_OPTION, @@ -667,7 +667,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ @Override - public void experimentDeleted(UserImplForAdmins owner, ExperimentImplForAdmins experiment) { + public void experimentDeleted(UserImplForAdmins owner, ExperimentImplForAdmins experiment) { SwingUtils.invokeLater(()->{ if(expPanel == null) return; if(owner == model.currentUser()){ // current User deleted is own experiment @@ -685,8 +685,8 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ } }); } - - + + @Override public void experimentUpdated(ExperimentImplForAdmins e) { ((WebLabel)exps.get(e).getComponent(0)).setToolTip( @@ -730,7 +730,8 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ private void importExperiment(UserImplForAdmins user) { // First show a File Chooser - final WebFileChooser chooser = new WebFileChooser(); + File workingDirectory = new File(System.getProperty("user.dir")); + final WebFileChooser chooser = new WebFileChooser(workingDirectory.getParentFile().getParent()); chooser.setMultiSelectionEnabled ( false ); chooser.setAcceptAllFileFilterUsed ( false ); chooser.setFileSelectionMode(WebFileChooser.DIRECTORIES_ONLY); @@ -753,7 +754,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ if ( chooser.showOpenDialog((JComponent)null) == WebFileChooser.APPROVE_OPTION ){ file = chooser.getSelectedFile (); this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - new Thread(()->{ + new Thread(()->{ try { model.importExperiment(file); }catch(Exception e) { @@ -773,7 +774,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ private void createExperiment(UserImplForAdmins user) { final ExperimentWizard expWizard = new ExperimentWizard(notif); Optional created = expWizard.showDialog(); - created.ifPresent(e->{ + created.ifPresent(e->{ this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); new Thread(()->{ try { @@ -940,7 +941,7 @@ public class UserSessionView extends WebPanel implements UserEventsListener{ // TODO Auto-generated method stub } - + }