List of usage examples for org.json.simple.parser ParseException getMessage
public String getMessage()
From source file:org.alfresco.repo.web.scripts.comments.AbstractCommentsWebScript.java
/** * parse JSON for a given input string/*w w w .j ava 2 s .co m*/ * @param input * @return */ protected JSONObject parseJSONFromString(String input) { JSONObject json = null; JSONParser parser = new JSONParser(); try { if (input != null) { json = (JSONObject) parser.parse(input); return json; } } catch (ParseException pe) { if (logger.isDebugEnabled()) { logger.debug("Invalid JSON: " + pe.getMessage()); } } return null; }
From source file:org.alfresco.repo.web.scripts.discussion.AbstractDiscussionWebScript.java
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); if (templateVars == null) { String error = "No parameters supplied"; throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); }/* w w w .j a va2 s . co m*/ // Parse the JSON, if supplied JSONObject json = null; String contentType = req.getContentType(); if (contentType != null && contentType.indexOf(';') != -1) { contentType = contentType.substring(0, contentType.indexOf(';')); } if (MimetypeMap.MIMETYPE_JSON.equals(contentType)) { JSONParser parser = new JSONParser(); try { json = (JSONObject) parser.parse(req.getContent().getContent()); } catch (IOException io) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + io.getMessage()); } catch (ParseException pe) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + pe.getMessage()); } } // Did they request it by node reference or site? NodeRef nodeRef = null; SiteInfo site = null; TopicInfo topic = null; PostInfo post = null; if (templateVars.containsKey("site")) { // Site, and optionally topic String siteName = templateVars.get("site"); site = siteService.getSite(siteName); if (site == null) { String error = "Could not find site: " + siteName; throw new WebScriptException(Status.STATUS_NOT_FOUND, error); } // Did they give a topic name too? if (templateVars.containsKey("path")) { String name = templateVars.get("path"); topic = discussionService.getTopic(site.getShortName(), name); if (topic == null) { String error = "Could not find topic '" + name + "' for site '" + site.getShortName() + "'"; throw new WebScriptException(Status.STATUS_NOT_FOUND, error); } nodeRef = topic.getNodeRef(); } else { // The NodeRef is the container (if it exists) if (siteService.hasContainer(siteName, DiscussionServiceImpl.DISCUSSION_COMPONENT)) { nodeRef = siteService.getContainer(siteName, DiscussionServiceImpl.DISCUSSION_COMPONENT); } } } else if (templateVars.containsKey("store_type") && templateVars.containsKey("store_id") && templateVars.containsKey("id")) { // NodeRef, normally Topic or Discussion StoreRef store = new StoreRef(templateVars.get("store_type"), templateVars.get("store_id")); nodeRef = new NodeRef(store, templateVars.get("id")); if (!nodeService.exists(nodeRef)) { String error = "Could not find node: " + nodeRef; throw new WebScriptException(Status.STATUS_NOT_FOUND, error); } // Try to build the appropriate object for it Pair<TopicInfo, PostInfo> objects = discussionService.getForNodeRef(nodeRef); if (objects != null) { topic = objects.getFirst(); post = objects.getSecond(); } // See if it's actually attached to a site if (topic != null) { NodeRef container = topic.getContainerNodeRef(); if (container != null) { NodeRef maybeSite = nodeService.getPrimaryParent(container).getParentRef(); if (maybeSite != null) { // Try to make it a site, will return Null if it isn't one site = siteService.getSite(maybeSite); } } } } else { String error = "Unsupported template parameters found"; throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); } // Have the real work done return executeImpl(site, nodeRef, topic, post, req, json, status, cache); }
From source file:org.alfresco.repo.web.scripts.links.AbstractLinksWebScript.java
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); if (templateVars == null) { String error = "No parameters supplied"; throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); }/* w w w.ja v a 2 s.com*/ // Parse the JSON, if supplied JSONObject json = null; String contentType = req.getContentType(); if (contentType != null && contentType.indexOf(';') != -1) { contentType = contentType.substring(0, contentType.indexOf(';')); } if (MimetypeMap.MIMETYPE_JSON.equals(contentType)) { JSONParser parser = new JSONParser(); try { json = (JSONObject) parser.parse(req.getContent().getContent()); } catch (IOException io) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + io.getMessage()); } catch (ParseException pe) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + pe.getMessage()); } } // Get the site short name. Try quite hard to do so... String siteName = templateVars.get("site"); if (siteName == null) { siteName = req.getParameter("site"); } if (siteName == null && json != null) { if (json.containsKey("siteid")) { siteName = (String) json.get("siteid"); } else if (json.containsKey("site")) { siteName = (String) json.get("site"); } } if (siteName == null) { String error = "No site given"; throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); } // Grab the requested site SiteInfo site = siteService.getSite(siteName); if (site == null) { String error = "Could not find site: " + siteName; throw new WebScriptException(Status.STATUS_NOT_FOUND, error); } // Link name is optional String linkName = templateVars.get("path"); //sanitise url if (json != null) { String url = getOrNull(json, "url"); if (!isUrlCorrect(url)) { String error = "Url not allowed"; throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); } } // Have the real work done return executeImpl(site, linkName, req, json, status, cache); }
From source file:org.alfresco.web.cmm.CMMService.java
/** * Read, process and transform the JSON entity that represents the generic Aikau Form widget tree. * The elements are nested within panels with varying numbers of column. Each widget within the column * has a number of configuration parameters. * <p>/*from w w w .jav a 2 s .c om*/ * Consume the JSON entity and transform the generic tree into a template model for rendering Share Forms * configuration for properties and rendering sets of associated fields. * <p> * See module-configuration.ftl * * @param forms List of current Form state * @param entity JSON object containing Form widget hiearchy * * @return Template wrapper objects containing the hierarchical model ready for template rendering */ protected TWrapper processFormWidgets(Map<String, String> forms, JSONObject entity) { TWrapper formPropertyWrappers = new TWrapper(8); String entityName = (String) entity.get(TEMPLATE_NAME); String formDef = forms.get(entityName); if (formDef != null) { // form definition present for this type - transform it into Share Forms Runtime configuration try { Object o = new JSONParser().parse(formDef); if (o instanceof JSONArray) { JSONArray formElements = (JSONArray) o; if (formElements.size() != 0) { // construct the wrapper collections to hold our properties, sets and field wrappers List<TWrapper> properties = new ArrayList<>(); formPropertyWrappers.put(TEMPLATE_PROPERTIES, properties); List<TWrapper> sets = new ArrayList<>(); formPropertyWrappers.put(TEMPLATE_SETS, sets); List<TWrapper> fields = new ArrayList<>(); formPropertyWrappers.put(TEMPLATE_FIELDS, fields); // used to ensure a single Set of fields i.e. one per property id Map<String, TWrapper> fieldMap = new HashMap<>(); // process well known component names and output wrappers for (Object item : formElements) { // avoid garbage - there should not be any arrays etc. at root if (!(item instanceof JSONObject)) { throw new IllegalStateException("Unexpected item in form structure: " + formDef); } // prepare state - set by lookup table against the various column layout options int numCols = 0; String columnSetTemplate = null; final String name = (String) ((JSONObject) item).get(JSON_PSEUDONYM); switch (name) { case "cmm/editor/layout/1cols": { numCols = 1; break; } case "cmm/editor/layout/2cols": { numCols = 2; columnSetTemplate = "/org/alfresco/components/form/2-column-set.ftl"; break; } case "cmm/editor/layout/2colswideleft": { numCols = 2; columnSetTemplate = "/org/alfresco/components/form/2-column-wide-left-set.ftl"; break; } case "cmm/editor/layout/3cols": { numCols = 3; columnSetTemplate = "/org/alfresco/components/form/3-column-set.ftl"; break; } } if (numCols != 0) { // process properties containing within the column child object List<TWrapper> colProperties = new ArrayList<>(); JSONArray column = (JSONArray) ((JSONObject) item).get(JSON_COLUMN); if (column != null) { // process widget list within each column - form fields automatically wrap // at the appropriate column index when rendered by the Forms Runtime template for (Object w : column) { // process widget list - wraps automatically at column index JSONObject widget = ((JSONObject) w); String pseudonym = (String) widget.get(JSON_PSEUDONYM); String id = (String) widget.get(JSON_ID); if (logger.isDebugEnabled()) logger.debug("Processing widget: " + id + " of type: " + pseudonym); // generate a template wrapper for the property widget Form config TWrapper controlProperties = new TWrapper(4).put(TEMPLATE_NAME, id); colProperties.add(controlProperties); final JSONObject config = (JSONObject) widget.get(JSON_ELEMENTCONFIG); if (config != null) { if (logger.isDebugEnabled()) logger.debug("Found 'elementconfig' for widget - processing..."); // generate wrappers for control params and field properties Map<String, Object> controlParams = new HashMap<>(4); TWrapper fieldWrapper = new TWrapper(4).put(TEMPLATE_ID, id) .put(TEMPLATE_PARAMS, controlParams); fieldMap.put(id, fieldWrapper); // map element config to Forms Config values // this is fiddly - the simple list of properties is remapped to attributes on // both the control property and on the associated field mapping for it String controlType = (String) config.get(JSON_CONTROLTYPE); String mode = (String) config.get(JSON_FOR_MODE); if (mode != null && !mode.equals(JSON_ANY)) controlProperties.put(TEMPLATE_MODE, mode); // deal with annoying checkbox = string when not used, but boolean when clicked nonsense if (config.get(JSON_FORCE) instanceof Boolean) { Boolean force = (Boolean) config.get(JSON_FORCE); if (Boolean.TRUE == force) controlProperties.put(TEMPLATE_FORCE, true); } if (config.get(JSON_HIDDEN) instanceof Boolean) { Boolean hidden = (Boolean) config.get(JSON_HIDDEN); if (Boolean.TRUE == hidden) controlType = CONTROLTYPE_HIDDEN; } if (config.get(JSON_READ_ONLY) instanceof Boolean) { Boolean readOnly = (Boolean) config.get(JSON_READ_ONLY); if (Boolean.TRUE == readOnly) fieldWrapper.put(TEMPLATE_READONLY, true); } Number maxLength = (Number) config.get(JSON_MAXLENGTH); if (maxLength != null) controlParams.put(TEMPLATE_MAXLENGTH, maxLength); String style = (String) config.get(JSON_STYLE); if (style != null && style.length() != 0) controlParams.put(TEMPLATE_STYLE, style); String styleClass = (String) config.get(JSON_STYLECLASS); if (styleClass != null && styleClass.length() != 0) controlParams.put(TEMPLATE_STYLECLASS, styleClass); // control type for field wrapper - each control type maps to a wrapper template and params as per Share Forms config String template = null; if (controlType != null) { switch (controlType) { case CONTROLTYPE_TEXTFIELD: template = "/org/alfresco/components/form/controls/textfield.ftl"; break; case CONTROLTYPE_TEXTAREA: template = "/org/alfresco/components/form/controls/textarea.ftl"; break; case CONTROLTYPE_CONTENT: template = "/org/alfresco/components/form/controls/content.ftl"; break; case CONTROLTYPE_RICHTEXT: template = "/org/alfresco/components/form/controls/richtext.ftl"; break; case CONTROLTYPE_PASSWORD: template = "/org/alfresco/components/form/controls/textfield.ftl"; controlParams.put(TEMPLATE_PASSWORD, "true"); break; case CONTROLTYPE_HIDDEN: template = "/org/alfresco/components/form/controls/hidden.ftl"; break; case CONTROLTYPE_SIZE: template = "/org/alfresco/components/form/controls/size.ftl"; break; case CONTROLTYPE_MIMETYPE: template = "/org/alfresco/components/form/controls/mimetype.ftl"; break; case CONTROLTYPE_TAGGABLE: controlParams.put("compactMode", "true"); controlParams.put("params", "aspect=cm:taggable"); controlParams.put("createNewItemUri", "/api/tag/workspace/SpacesStore"); controlParams.put("createNewItemIcon", "tag"); break; case CONTROLTYPE_CATEGORIES: controlParams.put("compactMode", "true"); break; case CONTROLTYPE_DEFAULT: break; default: if (logger.isDebugEnabled()) logger.debug( "WARNING: unknown control type for template mapping: " + controlType); } if (template != null) { fieldWrapper.put(TEMPLATE_TEMPLATE, template); if (logger.isDebugEnabled()) logger.debug("Widget control template: " + template); } } } } } // output a layout set - if number of columns > 1 then output a set template to render columns // Example: // <set template="/org/alfresco/components/form/2-column-set.ftl" appearance="title" label-id="CMM Reference Model" id="refmodel"/> // also see web-framework-commons/.../form.lib.ftl final JSONObject config = (JSONObject) ((JSONObject) item).get(JSON_ELEMENTCONFIG); String panelLabel = (String) config.get(JSON_LABEL); boolean hasLabel = (panelLabel != null && panelLabel.length() != 0); final String setId = entity.get(JSON_PREFIXEDNAME) + "_cmm_set" + sets.size(); TWrapper setWrapper = new TWrapper(8); setWrapper .put(TEMPLATE_APPEARANCE, hasLabel ? config.get(JSON_APPEARANCE) : "whitespace") .put(TEMPLATE_ID, setId); if (numCols > 1) setWrapper.put(TEMPLATE_TEMPLATE, columnSetTemplate); if (hasLabel) setWrapper.put(TEMPLATE_LABEL, config.get(JSON_LABEL)); sets.add(setWrapper); // bind properties via fields to the column set // Example: // <field set="refmodel" id="cmm:simple_string" /> for (TWrapper property : colProperties) { String id = (String) property.get(TEMPLATE_NAME); TWrapper fieldWrapper = fieldMap.get(id); if (fieldWrapper == null) { fieldWrapper = new TWrapper(4).put(TEMPLATE_ID, id); fieldMap.put(id, fieldWrapper); } fieldWrapper.put(TEMPLATE_SET, setId); if (logger.isDebugEnabled()) logger.debug("Field mapping of: " + id + " mapped to set:" + setId); } // add all the properties gathered for this column set properties.addAll(colProperties); } // end num cols != check } // end form elements processing loop // add all fields from the map to the list structure used by the template fields.addAll(fieldMap.values()); } } } catch (ParseException e) { logger.warn("Unable to parse Form definition for entity: " + entityName + "\n" + formDef + "\n" + e.getMessage()); } } return formPropertyWrappers; }
From source file:org.apache.hadoop.fs.http.client.HttpFSUtils.java
/** * Convenience method that JSON Parses the <code>InputStream</code> of a * <code>HttpURLConnection</code>. * * @param conn the <code>HttpURLConnection</code>. * * @return the parsed JSON object./*ww w . j ava2 s . co m*/ * * @throws IOException thrown if the <code>InputStream</code> could not be * JSON parsed. */ static Object jsonParse(HttpURLConnection conn) throws IOException { try { JSONParser parser = new JSONParser(); return parser.parse(new InputStreamReader(conn.getInputStream(), Charsets.UTF_8)); } catch (ParseException ex) { throw new IOException("JSON parser error, " + ex.getMessage(), ex); } }
From source file:org.apache.wink.rest.ClockinResource.java
@Path(PATH_DATABASE_EDIT) @POST/*from w w w. j ava2 s .c o m*/ @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response editData(@QueryParam("table") String table, String obj) { Status status = Response.Status.NO_CONTENT; Connection con = null; String result = null; OraclePreparedStatement stmt = null; try { //prevent sql injection String sqlStatement = null; try { System.out.println("table: " + table); DATABASE_TABLES.valueOf(table.toLowerCase()); System.out.println("Table exists. Mapping to table now."); } catch (IllegalArgumentException e) { throw new Exception("Table does not exist in the database."); } JSONObject jsonObject = (JSONObject) new JSONParser().parse(obj); System.out.println("jsonObject.toJSONString() " + jsonObject.toJSONString()); //parse column names JSONArray colNames = (JSONArray) jsonObject.get("columnNames"); Iterator<String> iter = colNames.iterator(); sqlStatement = "UPDATE " + table + " set "; while (iter.hasNext()) { sqlStatement += (String) iter.next() + " = ?"; if (iter.hasNext()) { sqlStatement += ", "; } } //connect to database via connection pool DatabaseConnectionPool dbpool = DatabaseConnectionPool.getInstance(); con = dbpool.getConnection(); JSONArray colData = (JSONArray) jsonObject.get("columnData"); sqlStatement += " where ID = '" + colData.get(0) + "'"; stmt = (OraclePreparedStatement) con.prepareStatement(sqlStatement); System.out.println("sqlStatement " + sqlStatement); //parse update data Iterator<String> iterData = colData.iterator(); int countPlace = 1; while (iterData.hasNext()) { String d = iterData.next(); try { System.out.println("Trying: " + d); int di = Integer.parseInt(d); stmt.setInt(countPlace, di); } catch (NumberFormatException nfe) { System.out.println("Not an integer..."); stmt.setString(countPlace, d); } countPlace++; } int i = stmt.executeUpdate(); if (i <= 0) { status = Response.Status.BAD_REQUEST; } else { status = Response.Status.OK; } } catch (ParseException pe) { System.out.println("Catching parse exception: " + pe.getMessage()); status = Response.Status.INTERNAL_SERVER_ERROR; result = pe.getMessage(); } catch (Exception e) { System.out.println("Catching exception: " + e.getMessage()); status = Response.Status.INTERNAL_SERVER_ERROR; result = e.getMessage(); } finally { //step5 close the connection object try { con.close(); } catch (Exception e) { System.out.println("Finally: " + e.getMessage()); } } if (result == null) { result = "{\"Data\":\"Ok\"}"; } return Response.status(status).entity(result).header("Content-Type", "application/json").build(); }
From source file:org.apache.wink.rest.ClockinResource.java
@Path(PATH_DATABASE_DELETE) @POST//from w w w.j a va 2 s. c o m @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response deleteData(@QueryParam("table") String table, String obj) { Status status = Response.Status.NO_CONTENT; Connection con = null; String result = null; OraclePreparedStatement stmt = null; try { //prevent sql injection String sqlStatement = null; try { System.out.println("table: " + table); DATABASE_TABLES.valueOf(table.toLowerCase()); System.out.println("Table exists. Mapping to table now."); } catch (IllegalArgumentException e) { throw new Exception("Table does not exist in the database."); } JSONObject jsonObject = (JSONObject) new JSONParser().parse(obj); System.out.println("jsonObject.toJSONString() " + jsonObject.toJSONString()); //connect to database via connection pool DatabaseConnectionPool dbpool = DatabaseConnectionPool.getInstance(); con = dbpool.getConnection(); sqlStatement = "delete from " + table + " where " + jsonObject.get("rowId") + " = ?"; stmt = (OraclePreparedStatement) con.prepareStatement(sqlStatement); System.out.println("sqlStatement " + sqlStatement); try { int di = Integer.parseInt((String) jsonObject.get("id")); stmt.setInt(1, di); } catch (NumberFormatException nfe) { System.out.println("Not an integer..."); } int i = stmt.executeUpdate(); if (i <= 0) { status = Response.Status.BAD_REQUEST; } else { status = Response.Status.OK; } } catch (ParseException pe) { System.out.println("Catching parse exception: " + pe.getMessage()); status = Response.Status.INTERNAL_SERVER_ERROR; result = pe.getMessage(); } catch (Exception e) { System.out.println("Catching exception: " + e.getMessage()); status = Response.Status.INTERNAL_SERVER_ERROR; result = e.getMessage(); } finally { //step5 close the connection object try { con.close(); } catch (Exception e) { System.out.println("Finally: " + e.getMessage()); } } if (result == null) { result = "{\"Data\":\"Ok\"}"; } return Response.status(status).entity(result).header("Content-Type", "application/json").build(); }
From source file:org.apache.wink.rest.ClockinResource.java
@Path(PATH_DATABASE_ADD) @POST/*from ww w . j ava2s.c om*/ @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addData(@QueryParam("table") String table, String obj) { Status status = Response.Status.NO_CONTENT; Connection con = null; String result = null; OraclePreparedStatement stmt = null; try { //prevent sql injection String sqlStatement = null; try { System.out.println("table: " + table); DATABASE_TABLES.valueOf(table.toLowerCase()); System.out.println("Table exists. Mapping to table now."); } catch (IllegalArgumentException e) { throw new Exception("Table does not exist in the database."); } JSONObject jsonObject = (JSONObject) new JSONParser().parse(obj); System.out.println("jsonObject.toJSONString() " + jsonObject.toJSONString()); //parse column names JSONArray colNames = (JSONArray) jsonObject.get("columnNames"); Iterator<String> iter = colNames.iterator(); /* INSERT INTO worked_shifts(start_time,scheduled_shift_ID,employee_ID, location_ID) VALUES ('20-NOV-16 15:54:30','1','1','1'); */ sqlStatement = "INSERT INTO " + table + "("; String paramSpace = ""; while (iter.hasNext()) { sqlStatement += (String) iter.next(); paramSpace += "?"; if (iter.hasNext()) { sqlStatement += ", "; paramSpace += ", "; } } sqlStatement += ") VALUES (" + paramSpace + ")"; //connect to database via connection pool DatabaseConnectionPool dbpool = DatabaseConnectionPool.getInstance(); con = dbpool.getConnection(); JSONArray colData = (JSONArray) jsonObject.get("columnData"); stmt = (OraclePreparedStatement) con.prepareStatement(sqlStatement); System.out.println("sqlStatement " + sqlStatement); //parse update data Iterator<String> iterData = colData.iterator(); int countPlace = 1; while (iterData.hasNext()) { String d = iterData.next(); try { System.out.println("Trying: " + d); int di = Integer.parseInt(d); stmt.setInt(countPlace, di); } catch (NumberFormatException nfe) { System.out.println("Not an integer..."); stmt.setString(countPlace, d); } countPlace++; } int i = stmt.executeUpdate(); if (i <= 0) { status = Response.Status.BAD_REQUEST; } else { status = Response.Status.OK; } } catch (ParseException pe) { System.out.println("Catching parse exception: " + pe.getMessage()); status = Response.Status.INTERNAL_SERVER_ERROR; result = pe.getMessage(); } catch (Exception e) { System.out.println("Catching exception: " + e.getMessage()); status = Response.Status.INTERNAL_SERVER_ERROR; result = e.getMessage(); } finally { //step5 close the connection object try { con.close(); } catch (Exception e) { System.out.println("Finally: " + e.getMessage()); } } if (result == null) { result = "{\"Data\":\"Ok\"}"; } return Response.status(status).entity(result).header("Content-Type", "application/json").build(); }
From source file:org.clipsmonitor.gui.MapGeneratorTopComponent.java
private void LoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoadButtonActionPerformed int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try {//from w ww .j a va 2s . c o m model.setSizeScreen(PreviewMap.getWidth(), PreviewMap.getHeight()); File file = fc.getSelectedFile(); model.LoadFiles(file); if (!MoveButton.isEnabled()) { InitColorComboBox(); if (getActiveColorMap()) { InsertionOptionComboBox.enable(true); Icons.enable(true); Icons.repaint(); model.CopySceneToMove(); actualPath = model.getLastPathOfPerson(state); String[][] move = model.getMoveCellMap(actualPath, -1); model.ApplyUpdateOnMoveMap(move); model.CopyToActive(model.getMove()); } else { InsertionOptionComboBox.enable(true); Icons.enable(true); model.CopySceneToMove(); model.CopyToActive(model.getMove()); } } PreviewMap.repaint(); MakePersonList(); MakeStepList(-1); MakeMoveList(-1, -1, "all"); setListEnable(); } catch (ParseException ex) { model.error(ex.getMessage()); } } updateLogArea(); }
From source file:org.clipsmonitor.gui.MapGeneratorTopComponent.java
private void LoadButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LoadButtonMouseClicked int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try {//from w w w.j av a 2 s . c o m File file = fc.getSelectedFile(); model.LoadFiles(file); if (!MoveButton.isEnabled()) { InitColorComboBox(); if (getActiveColorMap()) { InsertionOptionComboBox.enable(true); Icons.enable(true); Icons.repaint(); model.CopySceneToMove(); actualPath = model.getLastPathOfPerson(state); String[][] move = model.getMoveCellMap(actualPath, -1); model.ApplyUpdateOnMoveMap(move); model.CopyToActive(model.getMove()); } else { InsertionOptionComboBox.enable(true); Icons.enable(true); model.CopySceneToMove(); model.CopyToActive(model.getMove()); } } PreviewMap.repaint(); MakePersonList(); MakeStepList(-1); MakeMoveList(-1, -1, "all"); setListEnable(); } catch (ParseException ex) { model.error(ex.getMessage()); } } updateLogArea(); }