Start of redo of preferences.
This commit is contained in:
parent
cfa00c90e8
commit
f3e493bd9d
27 changed files with 1504 additions and 25 deletions
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
* Copyright (c) 2012 - 2015, Clark & Parsia, LLC. <http://www.clarkparsia.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package edu.utah.ece.async.ibiosim.dataModels.util;
|
||||
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.Infos;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.PersonInfo;
|
||||
|
||||
public enum IBioSimPreferences {
|
||||
INSTANCE;
|
||||
|
||||
private PersonInfo userInfo = null;
|
||||
|
||||
public PersonInfo getUserInfo() {
|
||||
if (userInfo == null) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("user");
|
||||
String name = prefs.get("name", "");
|
||||
String email = prefs.get("email", "");
|
||||
String uri = prefs.get("uri", "http://www.dummy.org");
|
||||
userInfo = Infos.forPerson(uri, name, email);
|
||||
}
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void saveUserInfo(PersonInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("user");
|
||||
|
||||
try {
|
||||
if (userInfo == null) {
|
||||
prefs.removeNode();
|
||||
} else {
|
||||
prefs.put("uri", userInfo.getURI().toString());
|
||||
prefs.put("name", userInfo.getName());
|
||||
if (userInfo.getEmail() != null) {
|
||||
prefs.put("email", userInfo.getEmail().toString());
|
||||
} else {
|
||||
prefs.put("email", "");
|
||||
}
|
||||
}
|
||||
|
||||
prefs.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getValidate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Boolean enableFileDialog = null;
|
||||
|
||||
public boolean isFileDialogEnabled() {
|
||||
if (enableFileDialog == null) {
|
||||
enableFileDialog = Preferences.userRoot().get("biosim.general.file_browser", "").equals("FileDialog");
|
||||
}
|
||||
|
||||
return enableFileDialog;
|
||||
}
|
||||
|
||||
public void setFileDialogEnabled(boolean enableFileDialog) {
|
||||
this.enableFileDialog = enableFileDialog;
|
||||
if (enableFileDialog) {
|
||||
Preferences.userRoot().put("biosim.general.file_browser", "FileDialog");
|
||||
} else {
|
||||
Preferences.userRoot().put("biosim.general.file_browser", "JFileChooser");
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean enablePlusMinusIcons = null;
|
||||
|
||||
public boolean isPlusMinusIconsEnabled() {
|
||||
if (enablePlusMinusIcons == null) {
|
||||
enablePlusMinusIcons = Preferences.userRoot().get("biosim.general.tree_icons", "").equals("plus_minus");
|
||||
}
|
||||
|
||||
return enablePlusMinusIcons;
|
||||
}
|
||||
|
||||
public void setPlusMinusIconsEnabled(boolean enablePlusMinusIcons) {
|
||||
this.enablePlusMinusIcons = enablePlusMinusIcons;
|
||||
if (enablePlusMinusIcons) {
|
||||
Preferences.userRoot().put("biosim.general.tree_icons", "plus_minus");
|
||||
} else {
|
||||
Preferences.userRoot().put("biosim.general.tree_icons", "default");
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean enableNoConfirm = null;
|
||||
|
||||
public boolean isNoConfirmEnabled() {
|
||||
if (enableNoConfirm == null) {
|
||||
enableNoConfirm = Preferences.userRoot().get("biosim.general.delete", "").equals("noconfirm");
|
||||
}
|
||||
|
||||
return enableNoConfirm;
|
||||
}
|
||||
|
||||
public void setNoConfirmEnabled(boolean enableNoConfirm) {
|
||||
this.enableNoConfirm = enableNoConfirm;
|
||||
if (enableNoConfirm) {
|
||||
Preferences.userRoot().put("biosim.general.delete", "noconfirm");
|
||||
} else {
|
||||
Preferences.userRoot().put("biosim.general.delete", "confirm");
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean enableLibSBMLFlatten = null;
|
||||
|
||||
public boolean isLibSBMLFlattenEnabled() {
|
||||
if (enableLibSBMLFlatten == null) {
|
||||
enableLibSBMLFlatten = Preferences.userRoot().get("biosim.general.flatten", "").equals("libsbml");
|
||||
}
|
||||
|
||||
return enableLibSBMLFlatten;
|
||||
}
|
||||
|
||||
public void setLibSBMLFlattenEnabled(boolean enableLibSBMLFlatten) {
|
||||
this.enableLibSBMLFlatten = enableLibSBMLFlatten;
|
||||
if (enableLibSBMLFlatten) {
|
||||
Preferences.userRoot().put("biosim.general.flatten", "libsbml");
|
||||
} else {
|
||||
Preferences.userRoot().put("biosim.general.flatten", "default");
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean enableLibSBMLValidate = null;
|
||||
|
||||
public boolean isLibSBMLValidateEnabled() {
|
||||
if (enableLibSBMLValidate == null) {
|
||||
enableLibSBMLValidate = Preferences.userRoot().get("biosim.general.validate", "").equals("libsbml");
|
||||
}
|
||||
|
||||
return enableLibSBMLValidate;
|
||||
}
|
||||
|
||||
public void setLibSBMLValidateEnabled(boolean enableLibSBMLValidate) {
|
||||
this.enableLibSBMLValidate = enableLibSBMLValidate;
|
||||
if (enableLibSBMLValidate) {
|
||||
Preferences.userRoot().put("biosim.general.validate", "libsbml");
|
||||
} else {
|
||||
Preferences.userRoot().put("biosim.general.validate", "default");
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean enableWarnings = null;
|
||||
|
||||
public boolean isWarningsEnabled() {
|
||||
if (enableWarnings == null) {
|
||||
enableWarnings = Preferences.userRoot().get("biosim.general.warnings", "").equals("true");
|
||||
}
|
||||
|
||||
return enableWarnings;
|
||||
}
|
||||
|
||||
public void setWarningsEnabled(boolean enableWarnings) {
|
||||
this.enableWarnings = enableWarnings;
|
||||
if (enableWarnings) {
|
||||
Preferences.userRoot().put("biosim.general.warnings", "true");
|
||||
} else {
|
||||
Preferences.userRoot().put("biosim.general.warnings", "false");
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean enableBranching = null;
|
||||
private Boolean enableVersioning = null;
|
||||
|
||||
public boolean isBranchingEnabled() {
|
||||
if (enableBranching == null) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("versioning");
|
||||
enableBranching = prefs.getBoolean("enableBranching", false);
|
||||
}
|
||||
|
||||
return enableBranching;
|
||||
}
|
||||
|
||||
public void setBranchingEnabled(boolean enableBranching) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("versioning");
|
||||
prefs.putBoolean("enableBranching", enableBranching);
|
||||
}
|
||||
|
||||
public boolean isVersioningEnabled() {
|
||||
if (enableVersioning == null) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("versioning");
|
||||
// versioning is no longer supported
|
||||
enableVersioning = prefs.getBoolean("enable", false);
|
||||
}
|
||||
|
||||
return enableVersioning;
|
||||
}
|
||||
|
||||
public void setVersioningEnabled(boolean enableVersioning) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("versioning");
|
||||
prefs.putBoolean("enable", enableVersioning);
|
||||
}
|
||||
|
||||
private Integer seqBehavior = null;
|
||||
|
||||
/**
|
||||
* askUser is 0, overwrite is 1, and keep is 2
|
||||
*/
|
||||
public Integer getSeqBehavior() {
|
||||
if (seqBehavior == null) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("settings");
|
||||
seqBehavior = prefs.getInt("seqBehavior", 2);
|
||||
}
|
||||
return seqBehavior;
|
||||
}
|
||||
|
||||
/**
|
||||
* askUser is 0, overwrite is 1, and keep is 2
|
||||
*/
|
||||
public void setSeqBehavior(int seqBehavior) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("settings");
|
||||
prefs.putInt("seqBehavior", seqBehavior);
|
||||
this.seqBehavior = seqBehavior;
|
||||
}
|
||||
|
||||
private Integer nameDisplayIdBehavior = null;
|
||||
|
||||
/**
|
||||
* show name is 0, show displayId is 1
|
||||
*/
|
||||
public Integer getNameDisplayIdBehavior() {
|
||||
if (nameDisplayIdBehavior == null) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("settings");
|
||||
nameDisplayIdBehavior = prefs.getInt("nameDisplayIdBehavior", 0);
|
||||
}
|
||||
return nameDisplayIdBehavior;
|
||||
}
|
||||
|
||||
/**
|
||||
* show name is 0, show displayId is 1
|
||||
*/
|
||||
public void setNameDisplayIdBehavior(int showNameOrDisplayId) {
|
||||
Preferences prefs = Preferences.userNodeForPackage(IBioSimPreferences.class).node("settings");
|
||||
prefs.putInt("nameDisplayIdBehavior", showNameOrDisplayId);
|
||||
this.nameDisplayIdBehavior = showNameOrDisplayId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package edu.utah.ece.async.ibiosim.dataModels.util;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
public class Infos {
|
||||
public static PersonInfo forPerson(String uri) {
|
||||
return forPerson(URI.create(uri), "", null);
|
||||
}
|
||||
|
||||
public static PersonInfo forPerson(URI uri) {
|
||||
return forPerson(uri, "", null);
|
||||
}
|
||||
|
||||
public static PersonInfo forPerson(String uri, String name, String email) {
|
||||
return forPerson(URI.create(uri), name, email);
|
||||
}
|
||||
|
||||
public static PersonInfo forPerson(URI uri, String name, String email) {
|
||||
return new ImmutablePersonInfo(uri, name, email);
|
||||
}
|
||||
|
||||
private static class ImmutablePersonInfo implements PersonInfo {
|
||||
private final URI uri;
|
||||
private final String name;
|
||||
private final String email;
|
||||
|
||||
public ImmutablePersonInfo(URI user, String name, String email) {
|
||||
Preconditions.checkNotNull(user, "Person URI cannot be null");
|
||||
this.uri = user;
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(name);
|
||||
if (email != null) {
|
||||
sb.append(" <").append(email.toString()).append(">");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2012 - 2015, Clark & Parsia, LLC. <http://www.clarkparsia.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package edu.utah.ece.async.ibiosim.dataModels.util;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public interface PersonInfo {
|
||||
public URI getURI();
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getEmail();
|
||||
}
|
||||
|
|
@ -156,7 +156,6 @@ import com.apple.eawt.PreferencesHandler;
|
|||
import com.apple.eawt.QuitHandler;
|
||||
import com.apple.eawt.QuitResponse;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.SBOLDesignerPlugin;
|
||||
|
||||
import uk.ac.ebi.biomodels.ws.BioModelsWSClient;
|
||||
import uk.ac.ebi.biomodels.ws.BioModelsWSException;
|
||||
import de.unirostock.sems.cbarchive.CombineArchive;
|
||||
|
|
@ -186,10 +185,11 @@ import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.Utils;
|
|||
import edu.utah.ece.async.ibiosim.gui.sbolBrowser.SBOLBrowser2;
|
||||
import edu.utah.ece.async.ibiosim.gui.synthesisView.SynthesisView;
|
||||
import edu.utah.ece.async.ibiosim.gui.synthesisView.SynthesisViewATACS;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.FileTree;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.Log;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.Utility;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.tabs.CloseAndMaxTabbedPane;
|
||||
import edu.utah.ece.async.ibiosim.gui.verificationView.AbstractionPanel;
|
||||
import edu.utah.ece.async.ibiosim.gui.verificationView.VerificationView;
|
||||
|
|
@ -339,6 +339,7 @@ public class Gui implements Observer, MouseListener, ActionListener, MouseMotion
|
|||
|
||||
app.setPreferencesHandler(new PreferencesHandler() {
|
||||
public void handlePreferences(PreferencesEvent pe) {
|
||||
PreferencesDialog.showPreferences(frame);
|
||||
EditPreferences editPreferences = new EditPreferences(frame, async, tree);
|
||||
editPreferences.preferences();
|
||||
if (sbolDocument != null) {
|
||||
|
|
@ -2947,6 +2948,7 @@ public class Gui implements Observer, MouseListener, ActionListener, MouseMotion
|
|||
}
|
||||
// if the open project menu item is selected
|
||||
else if (e.getSource() == pref) {
|
||||
PreferencesDialog.showPreferences(frame);
|
||||
EditPreferences editPreferences = new EditPreferences(frame, async, tree);
|
||||
editPreferences.preferences();
|
||||
if (sbolDocument != null) {
|
||||
|
|
@ -6279,6 +6281,7 @@ public class Gui implements Observer, MouseListener, ActionListener, MouseMotion
|
|||
addTab(sbolDesignerPlugin.getRootDisplayId(), sbolDesignerPlugin, "SBOL Designer");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(Gui.frame, "SBOL file at " + fileName + " is invalid.", "Invalid SBOL",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.SBOLException;
|
|||
import edu.utah.ece.async.ibiosim.gui.Gui;
|
||||
import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.ModelEditor;
|
||||
import edu.utah.ece.async.ibiosim.gui.sbolBrowser.SBOLBrowser2;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import edu.utah.ece.async.ibiosim.dataModels.sbol.SBOLIdentityManager;
|
|||
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.SBOLException;
|
||||
import edu.utah.ece.async.ibiosim.gui.Gui;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import edu.utah.ece.async.ibiosim.dataModels.sbol.SBOLUtility;
|
|||
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
|
||||
import edu.utah.ece.async.ibiosim.gui.Gui;
|
||||
import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.ModelEditor;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.dialog.PartEditDialog;
|
||||
|
||||
public class SBOLField2 extends JPanel implements ActionListener {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ import com.mxgraph.view.mxStylesheet;
|
|||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.annotation.AnnotationUtility;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.SBMLutilities;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
|
||||
import edu.utah.ece.async.ibiosim.gui.Gui;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import java.io.PrintStream;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.Scanner;
|
||||
|
|
@ -142,9 +141,9 @@ import edu.utah.ece.async.ibiosim.gui.modelEditor.util.AbstractRunnableNamedButt
|
|||
import edu.utah.ece.async.ibiosim.gui.modelEditor.util.PropertyList;
|
||||
import edu.utah.ece.async.ibiosim.gui.modelEditor.util.Runnable;
|
||||
import edu.utah.ece.async.ibiosim.gui.modelEditor.util.UndoManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.Log;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.SpringUtilities;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.assembly.Assembler2;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.assembly.AssemblyGraph2;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.assembly.SequenceTypeValidator;
|
||||
|
|
@ -725,8 +724,11 @@ public class ModelEditor extends JPanel implements ActionListener, MouseListener
|
|||
//String submissionVersion = cd.isSetVersion() ? cd.getVersion() : "1";
|
||||
|
||||
JComboBox registries = new JComboBox();
|
||||
|
||||
registries.addItem("http://synbiohub.org");
|
||||
registries.addItem("http://synbiohub.utah.edu");
|
||||
registries.addItem("http://cidarlab.org:7777");
|
||||
registries.addItem("https://synbiohub.cidarlab.org");
|
||||
registries.addItem("http://localhost:7777");
|
||||
registries.addItem("http://14compsci099.ncl.ac.uk:7777");
|
||||
JTextField userField = new JTextField(12);
|
||||
|
|
@ -785,7 +787,7 @@ public class ModelEditor extends JPanel implements ActionListener, MouseListener
|
|||
"Submission Error", JOptionPane.ERROR_MESSAGE);
|
||||
error = true;
|
||||
}
|
||||
String password = passwordField.getText().trim();
|
||||
String password = passwordField.getPassword().toString().trim();
|
||||
if (password.equals("")) {
|
||||
JOptionPane.showMessageDialog(Gui.frame, "Password Required",
|
||||
"Submission Error", JOptionPane.ERROR_MESSAGE);
|
||||
|
|
@ -2005,7 +2007,7 @@ public class ModelEditor extends JPanel implements ActionListener, MouseListener
|
|||
|
||||
private static void updateValue(SBMLDocument d,String id,String factor,String paramId,String value,String type) {
|
||||
SBase sbase = SBMLutilities.getElementBySId(d, id);
|
||||
if (d.getModel().getInitialAssignment(id)!=null) {
|
||||
if (d.getModel().getInitialAssignmentBySymbol(id)!=null) {
|
||||
d.getModel().getListOfInitialAssignments().remove(id);
|
||||
}
|
||||
if (sbase != null) {
|
||||
|
|
@ -3362,7 +3364,7 @@ public class ModelEditor extends JPanel implements ActionListener, MouseListener
|
|||
if (lower!=upper) {
|
||||
bound = "[" + lower + "," + upper + "]";
|
||||
}
|
||||
InitialAssignment ia = flatSBML.getModel().getInitialAssignment(p.getId());
|
||||
InitialAssignment ia = flatSBML.getModel().getInitialAssignmentBySymbol(p.getId());
|
||||
if (ia != null) {
|
||||
ASTNode math = ia.getMath();
|
||||
if (math.getType()==ASTNode.Type.FUNCTION && math.getName().equals("uniform")) {
|
||||
|
|
@ -3393,7 +3395,7 @@ public class ModelEditor extends JPanel implements ActionListener, MouseListener
|
|||
if (lrate!=urate) {
|
||||
boundRate = "[" + lrate + "," + urate + "]";
|
||||
}
|
||||
ia = flatSBML.getModel().getInitialAssignment(rp.getId());
|
||||
ia = flatSBML.getModel().getInitialAssignmentBySymbol(rp.getId());
|
||||
if (ia != null) {
|
||||
ASTNode math = ia.getMath();
|
||||
if (math.getType()==ASTNode.Type.FUNCTION && math.getName().equals("uniform")) {
|
||||
|
|
@ -3469,7 +3471,7 @@ public class ModelEditor extends JPanel implements ActionListener, MouseListener
|
|||
for (int j = 0; j < postset.size(); j++) {
|
||||
t.addPostset(lpn.getPlace(postset.get(j)));
|
||||
}
|
||||
Rule r = sbml.getModel().getRule(GlobalConstants.TRIGGER + "_" + e.getId());
|
||||
Rule r = sbml.getModel().getRuleByVariable(GlobalConstants.TRIGGER + "_" + e.getId());
|
||||
if (r != null) {
|
||||
t.setPersistent(true);
|
||||
ASTNode triggerMath = r.getMath();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ import com.mxgraph.util.mxRectangle;
|
|||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.annotation.AnnotationUtility;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.SBMLutilities;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
|
||||
import edu.utah.ece.async.ibiosim.gui.Gui;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
*******************************************************************************/
|
||||
package edu.utah.ece.async.ibiosim.gui.modelEditor.schematic;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
|
@ -59,8 +58,6 @@ import org.sbml.jsbml.ext.arrays.ArraysSBasePlugin;
|
|||
import org.sbml.jsbml.ext.arrays.util.ArraysMath;
|
||||
import org.sbml.jsbml.ext.arrays.validator.ArraysValidator;
|
||||
import org.sbml.jsbml.validator.SBMLValidator;
|
||||
import org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY;
|
||||
import org.sbml.libsbml.SBMLReader;
|
||||
import org.sbml.libsbml.libsbmlConstants;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.SBMLutilities;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.sbolstandard.core2.Collection;
|
|||
import edu.utah.ece.async.ibiosim.dataModels.sbol.SBOLUtility;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
|
||||
import edu.utah.ece.async.ibiosim.gui.Gui;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ import edu.utah.ece.async.ibiosim.dataModels.sbol.SBOLFileManager;
|
|||
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.SBOLException;
|
||||
import edu.utah.ece.async.ibiosim.gui.Gui;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.Log;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.Utility;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBMLTechMapping.SynthesisGraph;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBMLTechMapping.Synthesizer;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,98 @@
|
|||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.IBioSimPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog.PreferencesTab;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Images;
|
||||
import edu.utah.ece.async.sboldesigner.swing.FormBuilder;
|
||||
|
||||
public enum AnalysisPreferencesTab implements PreferencesTab {
|
||||
INSTANCE;
|
||||
|
||||
// askUser is 0, overwrite is 1, and keep is 2
|
||||
private JRadioButton seqAskUser = new JRadioButton("Ask", IBioSimPreferences.INSTANCE.getSeqBehavior() == 0);
|
||||
private JRadioButton seqOverwrite = new JRadioButton("Overwrite",
|
||||
IBioSimPreferences.INSTANCE.getSeqBehavior() == 1);
|
||||
private JRadioButton seqKeep = new JRadioButton("Keep", IBioSimPreferences.INSTANCE.getSeqBehavior() == 2);
|
||||
|
||||
// show name is 0, show displayId is 1
|
||||
private JRadioButton showName = new JRadioButton("Show name when set",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 0);
|
||||
private JRadioButton showDisplayId = new JRadioButton("Show displayId",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 1);
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Analysis";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Default Analysis Settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getImageIcon("simulation.jpg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
JLabel impliedSequence = new JLabel(
|
||||
"<html>Every time the implied sequence is shorter than the original <br>sequence, would you like to overwrite or keep the original sequence?</html>");
|
||||
ButtonGroup seqGroup = new ButtonGroup();
|
||||
seqGroup.add(seqAskUser);
|
||||
seqGroup.add(seqOverwrite);
|
||||
seqGroup.add(seqKeep);
|
||||
|
||||
JLabel showNameOrDisplayId = new JLabel("<html>Always show displayId or always show name when set?</html>");
|
||||
ButtonGroup nameDisplayIdGroup = new ButtonGroup();
|
||||
nameDisplayIdGroup.add(showName);
|
||||
nameDisplayIdGroup.add(showDisplayId);
|
||||
|
||||
FormBuilder builder = new FormBuilder();
|
||||
builder.add("", impliedSequence);
|
||||
builder.add("", seqAskUser);
|
||||
builder.add("", seqOverwrite);
|
||||
builder.add("", seqKeep);
|
||||
builder.add("", showNameOrDisplayId);
|
||||
builder.add("", showName);
|
||||
builder.add("", showDisplayId);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
int seqBehavior = 0;
|
||||
if (seqAskUser.isSelected()) {
|
||||
seqBehavior = 0;
|
||||
} else if (seqOverwrite.isSelected()) {
|
||||
seqBehavior = 1;
|
||||
} else if (seqKeep.isSelected()) {
|
||||
seqBehavior = 2;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setSeqBehavior(seqBehavior);
|
||||
|
||||
int showNameOrDisplayId = 0;
|
||||
if (showName.isSelected()) {
|
||||
showNameOrDisplayId = 0;
|
||||
} else if (showDisplayId.isSelected()) {
|
||||
showNameOrDisplayId = 1;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setNameDisplayIdBehavior(showNameOrDisplayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
* and also available online at <http://www.async.ece.utah.edu/ibiosim/License>.
|
||||
*
|
||||
*******************************************************************************/
|
||||
package edu.utah.ece.async.ibiosim.gui.util;
|
||||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
|
|
@ -44,6 +44,7 @@ import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.CompatibilityFixer;
|
|||
import edu.utah.ece.async.ibiosim.dataModels.sbol.SBOLUtility;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
|
||||
import edu.utah.ece.async.ibiosim.gui.Gui;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.FileTree;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -779,10 +780,10 @@ public class EditPreferences {
|
|||
return biosimrc.get(GlobalConstants.SBOL_AUTHORITY_PREFERENCE, GlobalConstants.SBOL_AUTHORITY_DEFAULT);
|
||||
}
|
||||
|
||||
private JPanel assemblyPreferences(Preferences biosimrc) {
|
||||
private JPanel SBOLPreferences(Preferences biosimrc) {
|
||||
// assembly preferences
|
||||
JPanel assemblyLabels = new JPanel(new GridLayout(13, 1));
|
||||
assemblyLabels.add(new JLabel("URI Authority"));
|
||||
assemblyLabels.add(new JLabel("Namespace"));
|
||||
assemblyLabels.add(new JLabel("Assemble Complete Genetic Construct"));
|
||||
assemblyLabels.add(new JLabel("Regex for Complete Genetic Construct"));
|
||||
assemblyLabels.add(new JLabel("Validate Assembled Constructs"));
|
||||
|
|
@ -1405,7 +1406,7 @@ public class EditPreferences {
|
|||
return problem;
|
||||
}
|
||||
|
||||
private boolean saveAssemblyPreferences(Preferences biosimrc) {
|
||||
private boolean saveSBOLPreferences(Preferences biosimrc) {
|
||||
boolean problem = false;
|
||||
if (!uriField.getText().trim().equals("")) {
|
||||
biosimrc.put(GlobalConstants.SBOL_AUTHORITY_PREFERENCE, uriField.getText().trim());
|
||||
|
|
@ -1456,7 +1457,7 @@ public class EditPreferences {
|
|||
JPanel generalPrefs = generalPreferences(biosimrc);
|
||||
JPanel schematicPrefs = schematicPreferences(biosimrc);
|
||||
JPanel modelPrefs = modelPreferences(biosimrc);
|
||||
JPanel assemblyPrefs = assemblyPreferences(biosimrc);
|
||||
JPanel assemblyPrefs = SBOLPreferences(biosimrc);
|
||||
JPanel analysisPrefs = analysisPreferences(biosimrc);
|
||||
JPanel learnPrefs = learnPreferences(biosimrc);
|
||||
|
||||
|
|
@ -1484,7 +1485,7 @@ public class EditPreferences {
|
|||
if (!problem) problem = saveModelPreferences(biosimrc);
|
||||
if (!problem) problem = saveAnalysisPreferences(biosimrc);
|
||||
if (!problem) problem = saveLearnPreferences(biosimrc);
|
||||
if (!problem) problem = saveAssemblyPreferences(biosimrc);
|
||||
if (!problem) problem = saveSBOLPreferences(biosimrc);
|
||||
try {
|
||||
biosimrc.sync();
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.IBioSimPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog.PreferencesTab;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Images;
|
||||
import edu.utah.ece.async.sboldesigner.swing.FormBuilder;
|
||||
|
||||
public enum GeneralPreferencesTab implements PreferencesTab {
|
||||
INSTANCE;
|
||||
|
||||
// askUser is 0, overwrite is 1, and keep is 2
|
||||
private JRadioButton seqAskUser = new JRadioButton("Ask", IBioSimPreferences.INSTANCE.getSeqBehavior() == 0);
|
||||
private JRadioButton seqOverwrite = new JRadioButton("Overwrite",
|
||||
IBioSimPreferences.INSTANCE.getSeqBehavior() == 1);
|
||||
private JRadioButton seqKeep = new JRadioButton("Keep", IBioSimPreferences.INSTANCE.getSeqBehavior() == 2);
|
||||
|
||||
// show name is 0, show displayId is 1
|
||||
private JRadioButton showName = new JRadioButton("Show name when set",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 0);
|
||||
private JRadioButton showDisplayId = new JRadioButton("Show displayId",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 1);
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "General";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "General Preferences";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getImageIcon("general.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
JLabel impliedSequence = new JLabel(
|
||||
"<html>Every time the implied sequence is shorter than the original <br>sequence, would you like to overwrite or keep the original sequence?</html>");
|
||||
ButtonGroup seqGroup = new ButtonGroup();
|
||||
seqGroup.add(seqAskUser);
|
||||
seqGroup.add(seqOverwrite);
|
||||
seqGroup.add(seqKeep);
|
||||
|
||||
JLabel showNameOrDisplayId = new JLabel("<html>Always show displayId or always show name when set?</html>");
|
||||
ButtonGroup nameDisplayIdGroup = new ButtonGroup();
|
||||
nameDisplayIdGroup.add(showName);
|
||||
nameDisplayIdGroup.add(showDisplayId);
|
||||
|
||||
FormBuilder builder = new FormBuilder();
|
||||
builder.add("", impliedSequence);
|
||||
builder.add("", seqAskUser);
|
||||
builder.add("", seqOverwrite);
|
||||
builder.add("", seqKeep);
|
||||
builder.add("", showNameOrDisplayId);
|
||||
builder.add("", showName);
|
||||
builder.add("", showDisplayId);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
int seqBehavior = 0;
|
||||
if (seqAskUser.isSelected()) {
|
||||
seqBehavior = 0;
|
||||
} else if (seqOverwrite.isSelected()) {
|
||||
seqBehavior = 1;
|
||||
} else if (seqKeep.isSelected()) {
|
||||
seqBehavior = 2;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setSeqBehavior(seqBehavior);
|
||||
|
||||
int showNameOrDisplayId = 0;
|
||||
if (showName.isSelected()) {
|
||||
showNameOrDisplayId = 0;
|
||||
} else if (showDisplayId.isSelected()) {
|
||||
showNameOrDisplayId = 1;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setNameDisplayIdBehavior(showNameOrDisplayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.IBioSimPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog.PreferencesTab;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Images;
|
||||
import edu.utah.ece.async.sboldesigner.swing.FormBuilder;
|
||||
|
||||
public enum LearnPreferencesTab implements PreferencesTab {
|
||||
INSTANCE;
|
||||
|
||||
// askUser is 0, overwrite is 1, and keep is 2
|
||||
private JRadioButton seqAskUser = new JRadioButton("Ask", IBioSimPreferences.INSTANCE.getSeqBehavior() == 0);
|
||||
private JRadioButton seqOverwrite = new JRadioButton("Overwrite",
|
||||
IBioSimPreferences.INSTANCE.getSeqBehavior() == 1);
|
||||
private JRadioButton seqKeep = new JRadioButton("Keep", IBioSimPreferences.INSTANCE.getSeqBehavior() == 2);
|
||||
|
||||
// show name is 0, show displayId is 1
|
||||
private JRadioButton showName = new JRadioButton("Show name when set",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 0);
|
||||
private JRadioButton showDisplayId = new JRadioButton("Show displayId",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 1);
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Learn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Default Learn Settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getImageIcon("learn.jpg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
JLabel impliedSequence = new JLabel(
|
||||
"<html>Every time the implied sequence is shorter than the original <br>sequence, would you like to overwrite or keep the original sequence?</html>");
|
||||
ButtonGroup seqGroup = new ButtonGroup();
|
||||
seqGroup.add(seqAskUser);
|
||||
seqGroup.add(seqOverwrite);
|
||||
seqGroup.add(seqKeep);
|
||||
|
||||
JLabel showNameOrDisplayId = new JLabel("<html>Always show displayId or always show name when set?</html>");
|
||||
ButtonGroup nameDisplayIdGroup = new ButtonGroup();
|
||||
nameDisplayIdGroup.add(showName);
|
||||
nameDisplayIdGroup.add(showDisplayId);
|
||||
|
||||
FormBuilder builder = new FormBuilder();
|
||||
builder.add("", impliedSequence);
|
||||
builder.add("", seqAskUser);
|
||||
builder.add("", seqOverwrite);
|
||||
builder.add("", seqKeep);
|
||||
builder.add("", showNameOrDisplayId);
|
||||
builder.add("", showName);
|
||||
builder.add("", showDisplayId);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
int seqBehavior = 0;
|
||||
if (seqAskUser.isSelected()) {
|
||||
seqBehavior = 0;
|
||||
} else if (seqOverwrite.isSelected()) {
|
||||
seqBehavior = 1;
|
||||
} else if (seqKeep.isSelected()) {
|
||||
seqBehavior = 2;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setSeqBehavior(seqBehavior);
|
||||
|
||||
int showNameOrDisplayId = 0;
|
||||
if (showName.isSelected()) {
|
||||
showNameOrDisplayId = 0;
|
||||
} else if (showDisplayId.isSelected()) {
|
||||
showNameOrDisplayId = 1;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setNameDisplayIdBehavior(showNameOrDisplayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.IBioSimPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog.PreferencesTab;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Images;
|
||||
import edu.utah.ece.async.sboldesigner.swing.FormBuilder;
|
||||
|
||||
public enum ModelEditorPreferencesTab implements PreferencesTab {
|
||||
INSTANCE;
|
||||
|
||||
// askUser is 0, overwrite is 1, and keep is 2
|
||||
private JRadioButton seqAskUser = new JRadioButton("Ask", IBioSimPreferences.INSTANCE.getSeqBehavior() == 0);
|
||||
private JRadioButton seqOverwrite = new JRadioButton("Overwrite",
|
||||
IBioSimPreferences.INSTANCE.getSeqBehavior() == 1);
|
||||
private JRadioButton seqKeep = new JRadioButton("Keep", IBioSimPreferences.INSTANCE.getSeqBehavior() == 2);
|
||||
|
||||
// show name is 0, show displayId is 1
|
||||
private JRadioButton showName = new JRadioButton("Show name when set",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 0);
|
||||
private JRadioButton showDisplayId = new JRadioButton("Show displayId",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 1);
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Model Editor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Preferences for Model Editor Schematic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getImageIcon("sbml.jpg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
JLabel impliedSequence = new JLabel(
|
||||
"<html>Every time the implied sequence is shorter than the original <br>sequence, would you like to overwrite or keep the original sequence?</html>");
|
||||
ButtonGroup seqGroup = new ButtonGroup();
|
||||
seqGroup.add(seqAskUser);
|
||||
seqGroup.add(seqOverwrite);
|
||||
seqGroup.add(seqKeep);
|
||||
|
||||
JLabel showNameOrDisplayId = new JLabel("<html>Always show displayId or always show name when set?</html>");
|
||||
ButtonGroup nameDisplayIdGroup = new ButtonGroup();
|
||||
nameDisplayIdGroup.add(showName);
|
||||
nameDisplayIdGroup.add(showDisplayId);
|
||||
|
||||
FormBuilder builder = new FormBuilder();
|
||||
builder.add("", impliedSequence);
|
||||
builder.add("", seqAskUser);
|
||||
builder.add("", seqOverwrite);
|
||||
builder.add("", seqKeep);
|
||||
builder.add("", showNameOrDisplayId);
|
||||
builder.add("", showName);
|
||||
builder.add("", showDisplayId);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
int seqBehavior = 0;
|
||||
if (seqAskUser.isSelected()) {
|
||||
seqBehavior = 0;
|
||||
} else if (seqOverwrite.isSelected()) {
|
||||
seqBehavior = 1;
|
||||
} else if (seqKeep.isSelected()) {
|
||||
seqBehavior = 2;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setSeqBehavior(seqBehavior);
|
||||
|
||||
int showNameOrDisplayId = 0;
|
||||
if (showName.isSelected()) {
|
||||
showNameOrDisplayId = 0;
|
||||
} else if (showDisplayId.isSelected()) {
|
||||
showNameOrDisplayId = 1;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setNameDisplayIdBehavior(showNameOrDisplayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.IBioSimPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog.PreferencesTab;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Images;
|
||||
import edu.utah.ece.async.sboldesigner.swing.FormBuilder;
|
||||
|
||||
public enum ModelPreferencesTab implements PreferencesTab {
|
||||
INSTANCE;
|
||||
|
||||
// askUser is 0, overwrite is 1, and keep is 2
|
||||
private JRadioButton seqAskUser = new JRadioButton("Ask", IBioSimPreferences.INSTANCE.getSeqBehavior() == 0);
|
||||
private JRadioButton seqOverwrite = new JRadioButton("Overwrite",
|
||||
IBioSimPreferences.INSTANCE.getSeqBehavior() == 1);
|
||||
private JRadioButton seqKeep = new JRadioButton("Keep", IBioSimPreferences.INSTANCE.getSeqBehavior() == 2);
|
||||
|
||||
// show name is 0, show displayId is 1
|
||||
private JRadioButton showName = new JRadioButton("Show name when set",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 0);
|
||||
private JRadioButton showDisplayId = new JRadioButton("Show displayId",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 1);
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Model";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Default Model Parameters";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getImageIcon("dot.jpg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
JLabel impliedSequence = new JLabel(
|
||||
"<html>Every time the implied sequence is shorter than the original <br>sequence, would you like to overwrite or keep the original sequence?</html>");
|
||||
ButtonGroup seqGroup = new ButtonGroup();
|
||||
seqGroup.add(seqAskUser);
|
||||
seqGroup.add(seqOverwrite);
|
||||
seqGroup.add(seqKeep);
|
||||
|
||||
JLabel showNameOrDisplayId = new JLabel("<html>Always show displayId or always show name when set?</html>");
|
||||
ButtonGroup nameDisplayIdGroup = new ButtonGroup();
|
||||
nameDisplayIdGroup.add(showName);
|
||||
nameDisplayIdGroup.add(showDisplayId);
|
||||
|
||||
FormBuilder builder = new FormBuilder();
|
||||
builder.add("", impliedSequence);
|
||||
builder.add("", seqAskUser);
|
||||
builder.add("", seqOverwrite);
|
||||
builder.add("", seqKeep);
|
||||
builder.add("", showNameOrDisplayId);
|
||||
builder.add("", showName);
|
||||
builder.add("", showDisplayId);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
int seqBehavior = 0;
|
||||
if (seqAskUser.isSelected()) {
|
||||
seqBehavior = 0;
|
||||
} else if (seqOverwrite.isSelected()) {
|
||||
seqBehavior = 1;
|
||||
} else if (seqKeep.isSelected()) {
|
||||
seqBehavior = 2;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setSeqBehavior(seqBehavior);
|
||||
|
||||
int showNameOrDisplayId = 0;
|
||||
if (showName.isSelected()) {
|
||||
showNameOrDisplayId = 0;
|
||||
} else if (showDisplayId.isSelected()) {
|
||||
showNameOrDisplayId = 1;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setNameDisplayIdBehavior(showNameOrDisplayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.IBioSimPreferences;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog.PreferencesTab;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Images;
|
||||
import edu.utah.ece.async.sboldesigner.swing.FormBuilder;
|
||||
|
||||
public enum PartEditorPreferencesTab implements PreferencesTab {
|
||||
INSTANCE;
|
||||
|
||||
// askUser is 0, overwrite is 1, and keep is 2
|
||||
private JRadioButton seqAskUser = new JRadioButton("Ask", IBioSimPreferences.INSTANCE.getSeqBehavior() == 0);
|
||||
private JRadioButton seqOverwrite = new JRadioButton("Overwrite",
|
||||
IBioSimPreferences.INSTANCE.getSeqBehavior() == 1);
|
||||
private JRadioButton seqKeep = new JRadioButton("Keep", IBioSimPreferences.INSTANCE.getSeqBehavior() == 2);
|
||||
|
||||
// show name is 0, show displayId is 1
|
||||
private JRadioButton showName = new JRadioButton("Show name when set",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 0);
|
||||
private JRadioButton showDisplayId = new JRadioButton("Show displayId",
|
||||
IBioSimPreferences.INSTANCE.getNameDisplayIdBehavior() == 1);
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Part Editor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Settings for SBOLDesigner Plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getImageIcon("sbol.jpg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
JLabel impliedSequence = new JLabel(
|
||||
"<html>Every time the implied sequence is shorter than the original <br>sequence, would you like to overwrite or keep the original sequence?</html>");
|
||||
ButtonGroup seqGroup = new ButtonGroup();
|
||||
seqGroup.add(seqAskUser);
|
||||
seqGroup.add(seqOverwrite);
|
||||
seqGroup.add(seqKeep);
|
||||
|
||||
JLabel showNameOrDisplayId = new JLabel("<html>Always show displayId or always show name when set?</html>");
|
||||
ButtonGroup nameDisplayIdGroup = new ButtonGroup();
|
||||
nameDisplayIdGroup.add(showName);
|
||||
nameDisplayIdGroup.add(showDisplayId);
|
||||
|
||||
FormBuilder builder = new FormBuilder();
|
||||
builder.add("", impliedSequence);
|
||||
builder.add("", seqAskUser);
|
||||
builder.add("", seqOverwrite);
|
||||
builder.add("", seqKeep);
|
||||
builder.add("", showNameOrDisplayId);
|
||||
builder.add("", showName);
|
||||
builder.add("", showDisplayId);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
int seqBehavior = 0;
|
||||
if (seqAskUser.isSelected()) {
|
||||
seqBehavior = 0;
|
||||
} else if (seqOverwrite.isSelected()) {
|
||||
seqBehavior = 1;
|
||||
} else if (seqKeep.isSelected()) {
|
||||
seqBehavior = 2;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setSeqBehavior(seqBehavior);
|
||||
|
||||
int showNameOrDisplayId = 0;
|
||||
if (showName.isSelected()) {
|
||||
showNameOrDisplayId = 0;
|
||||
} else if (showDisplayId.isSelected()) {
|
||||
showNameOrDisplayId = 1;
|
||||
}
|
||||
IBioSimPreferences.INSTANCE.setNameDisplayIdBehavior(showNameOrDisplayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* Copyright (c) 2012 - 2015, Clark & Parsia, LLC. <http://www.clarkparsia.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Evren Sirin
|
||||
*/
|
||||
public class PreferencesDialog extends JDialog implements ActionListener {
|
||||
private static final String TITLE = "Preferences";
|
||||
|
||||
private static final PreferencesTab[] TABS = { UserInfoTab.INSTANCE, RegistryPreferencesTab.INSTANCE,
|
||||
GeneralPreferencesTab.INSTANCE, PartEditorPreferencesTab.INSTANCE, ModelEditorPreferencesTab.INSTANCE,
|
||||
ModelPreferencesTab.INSTANCE, AnalysisPreferencesTab.INSTANCE, LearnPreferencesTab.INSTANCE
|
||||
/**
|
||||
* SOMappingTab.INSTANCE,
|
||||
* VersioningPreferencesTab.INSTANCE
|
||||
**/
|
||||
};
|
||||
|
||||
public static void showPreferences(Component parent) {
|
||||
showPreferences(parent, null);
|
||||
}
|
||||
|
||||
public static void showPreferences(Component parent, String selectTab) {
|
||||
PreferencesDialog dialog = new PreferencesDialog(parent, selectTab);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
|
||||
private PreferencesDialog(Component parent, String selectTab) {
|
||||
super(JOptionPane.getFrameForComponent(parent), TITLE, true);
|
||||
|
||||
final JButton closeButton = new JButton("Close");
|
||||
closeButton.addActionListener(this);
|
||||
closeButton.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
getRootPane().setDefaultButton(closeButton);
|
||||
|
||||
// Create the panel that contains the "cards".
|
||||
final JPanel cards = new JPanel(new CardLayout());
|
||||
DefaultListModel<PreferencesTab> listModel = new DefaultListModel<PreferencesTab>();
|
||||
int selectedIndex = 0;
|
||||
for (PreferencesTab tab : TABS) {
|
||||
cards.add(new JScrollPane(tab.getComponent()), tab.getTitle());
|
||||
if (Objects.equal(tab.getTitle(), selectTab)) {
|
||||
selectedIndex = listModel.size();
|
||||
}
|
||||
listModel.addElement(tab);
|
||||
}
|
||||
|
||||
final JList<PreferencesTab> list = new JList<PreferencesTab>(listModel);
|
||||
list.setFocusable(false);
|
||||
list.setPreferredSize(new Dimension(100, 100));
|
||||
list.setCellRenderer(new DefaultListCellRenderer() {
|
||||
public Component getListCellRendererComponent(JList<?> list, // the
|
||||
// list
|
||||
Object value, // value to display
|
||||
int index, // cell index
|
||||
boolean isSelected, // is the cell selected
|
||||
boolean cellHasFocus) // does the cell have focus
|
||||
{
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
PreferencesTab tab = (PreferencesTab) value;
|
||||
setText(tab.getTitle());
|
||||
setIcon(tab.getIcon());
|
||||
setToolTipText(tab.getDescription());
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent event) {
|
||||
if (!event.getValueIsAdjusting()) {
|
||||
CardLayout layout = (CardLayout) cards.getLayout();
|
||||
layout.show(cards, ((PreferencesTab) list.getSelectedValue()).getTitle());
|
||||
}
|
||||
}
|
||||
});
|
||||
list.setSelectedIndex(selectedIndex);
|
||||
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
|
||||
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
|
||||
buttonPane.add(Box.createHorizontalGlue());
|
||||
buttonPane.add(closeButton);
|
||||
|
||||
Container contentPane = getContentPane();
|
||||
contentPane.add(new JScrollPane(list), BorderLayout.WEST);
|
||||
contentPane.add(cards, BorderLayout.CENTER);
|
||||
contentPane.add(buttonPane, BorderLayout.SOUTH);
|
||||
|
||||
setSize(600, 450);
|
||||
setLocationRelativeTo(getOwner());
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean restart = false;
|
||||
for (PreferencesTab tab : TABS) {
|
||||
restart = tab.requiresRestart();
|
||||
tab.save();
|
||||
}
|
||||
|
||||
if (restart) {
|
||||
JOptionPane.showMessageDialog(this, "Your changes will take effect next time the program is started");
|
||||
}
|
||||
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
interface PreferencesTab {
|
||||
String getTitle();
|
||||
|
||||
String getDescription();
|
||||
|
||||
Icon getIcon();
|
||||
|
||||
Component getComponent();
|
||||
|
||||
void save();
|
||||
|
||||
boolean requiresRestart();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* Copyright (c) 2012 - 2015, Clark & Parsia, LLC. <http://www.clarkparsia.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog.PreferencesTab;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Images;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Registries;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Registry;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.dialog.RegistryAddDialog;
|
||||
|
||||
public enum RegistryPreferencesTab implements PreferencesTab {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Registries";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Configuration options for part registries";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getImageIcon("registry.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
final RegistryTableModel tableModel = new RegistryTableModel();
|
||||
final JTable table = new JTable(tableModel);
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
RegistryTableModel model = (RegistryTableModel) table.getModel();
|
||||
Action action = Action.valueOf(e.getActionCommand());
|
||||
switch (action) {
|
||||
case ADD:
|
||||
Registry registry = new RegistryAddDialog(table, null).getInput();
|
||||
if (registry != null) {
|
||||
model.add(registry);
|
||||
Registries.get().save();
|
||||
}
|
||||
break;
|
||||
case REMOVE:
|
||||
int row = table.convertRowIndexToModel(table.getSelectedRow());
|
||||
model.remove(row);
|
||||
Registries.get().save();
|
||||
break;
|
||||
case RESTORE:
|
||||
model.restoreDefaults();
|
||||
Registries.get().save();
|
||||
break;
|
||||
case EDIT:
|
||||
row = table.convertRowIndexToModel(table.getSelectedRow());
|
||||
if (row > model.getRowCount()) {
|
||||
return;
|
||||
} else {
|
||||
Registry oldRegistry = model.getComponent(row);
|
||||
registry = new RegistryAddDialog(table, oldRegistry).getInput();
|
||||
if (registry != null) {
|
||||
model.remove(row);
|
||||
model.add(registry);
|
||||
Registries.get().save();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
final JButton addButton = new JButton("Add");
|
||||
addButton.setActionCommand(Action.ADD.toString());
|
||||
addButton.addActionListener(listener);
|
||||
|
||||
final JButton editButton = new JButton("Edit");
|
||||
editButton.setActionCommand(Action.EDIT.toString());
|
||||
editButton.addActionListener(listener);
|
||||
editButton.setEnabled(false);
|
||||
|
||||
final JButton removeButton = new JButton("Remove");
|
||||
removeButton.setActionCommand(Action.REMOVE.toString());
|
||||
removeButton.addActionListener(listener);
|
||||
removeButton.setEnabled(false);
|
||||
|
||||
final JButton restoreButton = new JButton("Restore defaults");
|
||||
restoreButton.setActionCommand(Action.RESTORE.toString());
|
||||
restoreButton.addActionListener(listener);
|
||||
restoreButton.setEnabled(true);
|
||||
|
||||
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent event) {
|
||||
// Everything can be removed/edited except Built-In parts.
|
||||
removeButton.setEnabled(table.getSelectedRow() >= 2);
|
||||
editButton.setEnabled(table.getSelectedRow() >= 2);
|
||||
}
|
||||
});
|
||||
|
||||
//OldInputDialog.setWidthAsPercentages(table, 0.2, 0.2, 0.6);
|
||||
|
||||
TableRowSorter<RegistryTableModel> sorter = new TableRowSorter<RegistryTableModel>(tableModel);
|
||||
table.setRowSorter(sorter);
|
||||
|
||||
JScrollPane tableScroller = new JScrollPane(table);
|
||||
tableScroller.setPreferredSize(new Dimension(450, 200));
|
||||
tableScroller.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
|
||||
JPanel tablePane = new JPanel();
|
||||
tablePane.setLayout(new BoxLayout(tablePane, BoxLayout.PAGE_AXIS));
|
||||
JLabel label = new JLabel("Registry list");
|
||||
label.setLabelFor(table);
|
||||
tablePane.add(label);
|
||||
tablePane.add(Box.createRigidArea(new Dimension(0, 5)));
|
||||
tablePane.add(tableScroller);
|
||||
tablePane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
|
||||
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
|
||||
buttonPane.add(addButton);
|
||||
buttonPane.add(editButton);
|
||||
buttonPane.add(removeButton);
|
||||
buttonPane.add(Box.createHorizontalGlue());
|
||||
buttonPane.add(restoreButton);
|
||||
|
||||
Container contentPane = new JPanel(new BorderLayout());
|
||||
contentPane.add(tablePane, BorderLayout.CENTER);
|
||||
contentPane.add(buttonPane, BorderLayout.SOUTH);
|
||||
return contentPane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresRestart() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static enum Action {
|
||||
ADD, REMOVE, RESTORE, EDIT
|
||||
}
|
||||
|
||||
private static class RegistryTableModel extends AbstractTableModel {
|
||||
private static final String[] COLUMNS = { "Name", "URL/Path", "Description" };
|
||||
private Registries registries;
|
||||
|
||||
public RegistryTableModel() {
|
||||
this.registries = Registries.get();
|
||||
}
|
||||
|
||||
public void restoreDefaults() {
|
||||
registries.restoreDefaults();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void add(Registry registry) {
|
||||
registries.add(registry);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void remove(int row) {
|
||||
registries.remove(row);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return COLUMNS.length;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return registries.size();
|
||||
}
|
||||
|
||||
public String getColumnName(int col) {
|
||||
return COLUMNS[col];
|
||||
}
|
||||
|
||||
public Registry getComponent(int row) {
|
||||
return registries.get(row);
|
||||
}
|
||||
|
||||
public Object getValueAt(int row, int col) {
|
||||
Registry registry = getComponent(row);
|
||||
switch (col) {
|
||||
case 0:
|
||||
return registry.getName();
|
||||
case 1:
|
||||
return registry.getLocation();
|
||||
case 2:
|
||||
return registry.getDescription();
|
||||
default:
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
public Class<?> getColumnClass(int col) {
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright (c) 2012 - 2015, Clark & Parsia, LLC. <http://www.clarkparsia.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package edu.utah.ece.async.ibiosim.gui.util.preferences;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.IBioSimPreferences;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.Infos;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.PersonInfo;
|
||||
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog.PreferencesTab;
|
||||
import edu.utah.ece.async.sboldesigner.sbol.editor.Images;
|
||||
import edu.utah.ece.async.sboldesigner.swing.FormBuilder;
|
||||
|
||||
public enum UserInfoTab implements PreferencesTab {
|
||||
INSTANCE;
|
||||
|
||||
private JTextField name;
|
||||
private JTextField email;
|
||||
private JTextField uri;
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "User";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "User information added to designs";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getImageIcon("user.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
PersonInfo info = IBioSimPreferences.INSTANCE.getUserInfo();
|
||||
FormBuilder builder = new FormBuilder();
|
||||
name = builder.addTextField("Full name", info == null ? null : info.getName());
|
||||
email = builder.addTextField("Email",
|
||||
info == null || info.getEmail() == null ? null : info.getEmail().toString());
|
||||
uri = builder.addTextField("Namespace [required]", info == null ? null : info.getURI().toString());
|
||||
JPanel formPanel = builder.build();
|
||||
|
||||
JButton deleteInfo = new JButton("Delete user info");
|
||||
deleteInfo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PersonInfo userInfo = Infos.forPerson(uri.getText());
|
||||
IBioSimPreferences.INSTANCE.saveUserInfo(userInfo);
|
||||
name.setText(null);
|
||||
email.setText(null);
|
||||
}
|
||||
});
|
||||
deleteInfo.setAlignmentX(Component.RIGHT_ALIGNMENT);
|
||||
deleteInfo.setEnabled(info != null);
|
||||
|
||||
Box buttonPanel = Box.createHorizontalBox();
|
||||
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
|
||||
buttonPanel.add(Box.createHorizontalGlue());
|
||||
buttonPanel.add(deleteInfo);
|
||||
|
||||
JPanel p = new JPanel(new BorderLayout());
|
||||
p.add(formPanel, BorderLayout.NORTH);
|
||||
p.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
boolean noURI = Strings.isNullOrEmpty(uri.getText());
|
||||
boolean noName = Strings.isNullOrEmpty(name.getText());
|
||||
boolean noEmail = Strings.isNullOrEmpty(email.getText());
|
||||
if (!(noURI && noName && noEmail)) {
|
||||
URI personURI = URI.create(uri.getText());
|
||||
String personName = noName ? "" : name.getText();
|
||||
String personEmail = noEmail ? null : email.getText();
|
||||
PersonInfo info = Infos.forPerson(personURI, personName, personEmail);
|
||||
IBioSimPreferences.INSTANCE.saveUserInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1,007 B |
Binary file not shown.
|
After Width: | Height: | Size: 202 B |
Binary file not shown.
|
After Width: | Height: | Size: 296 B |
2
manifast
Normal file
2
manifast
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Manifest-Version: 1.0
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue