List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Check to make sure there are no points in the first page that aren't in the second page *//*w w w. jav a 2 s .c om*/ private boolean checkNoMissing() { int currentPageNum = Main.getState().getCurrentPage(); if (currentPageNum == 1) { JOptionPane.showMessageDialog(this, "To data from the first page to the second page, navigate to the second page and click \"Play\".", "Can't data the first page", JOptionPane.ERROR_MESSAGE); return false; } PointConcurrentHashMap<Point, String> currentDots = Main.getCurrentPage().getDots(); PointConcurrentHashMap<Point, String> previousDots = Main.getPages().get(currentPageNum - 1).getDots(); ArrayList<String> badNames = new ArrayList<>(); for (String name : previousDots.values()) { if (!currentDots.containsValue(name)) badNames.add(name); } if (!badNames.isEmpty()) { String str = "The following players from last page have disappeared on this page:\n"; for (String s : badNames) str += s + "\n"; JOptionPane.showMessageDialog(this, str.trim(), "Missing Players!", JOptionPane.INFORMATION_MESSAGE); } return true; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation.java
/** * Check if a List of Literals has any XSS problems. * Return null if there are none and return an error message if there are problems. *///w ww . j a v a 2s.c o m private String literalHasXSS(List<Literal> list) throws ScanException, PolicyException { AntiSamy antiSamy = AntiScript.getAntiSamyScanner(); ArrayList errorMsgs = new ArrayList(); for (Literal literal : list) { if (literal != null) { CleanResults cr = antiSamy.scan(literal.getLexicalForm()); errorMsgs.addAll(cr.getErrorMessages()); String dt = literal.getDatatypeURI(); if (dt != null) { cr = antiSamy.scan(dt); errorMsgs.addAll(cr.getErrorMessages()); } String lang = literal.getLanguage(); if (lang != null) { cr = antiSamy.scan(lang); errorMsgs.addAll(cr.getErrorMessages()); } } } if (errorMsgs.isEmpty()) return null; else return StringUtils.join(errorMsgs, ", "); }
From source file:com.cloudera.impala.planner.PlannerTestBase.java
private void checkScanRangeLocations(TestCase testCase, TExecRequest execRequest, StringBuilder errorLog, StringBuilder actualOutput) { String query = testCase.getQuery(); // Query exec request may not be set for DDL, e.g., CTAS. String locationsStr = null;/*from ww w . j a v a 2 s . co m*/ if (execRequest != null && execRequest.isSetQuery_exec_request()) { buildMaps(execRequest.query_exec_request); // If we optimize the partition key scans, we may get all the partition key values // from the metadata and don't reference any table. Skip the check in this case. TQueryOptions options = execRequest.getQuery_options(); if (!(options.isSetOptimize_partition_key_scans() && options.optimize_partition_key_scans)) { testHdfsPartitionsReferenced(execRequest.query_exec_request, query, errorLog); } locationsStr = printScanRangeLocations(execRequest.query_exec_request).toString(); } // compare scan range locations LOG.info("scan range locations: " + locationsStr); ArrayList<String> expectedLocations = testCase.getSectionContents(Section.SCANRANGELOCATIONS); if (expectedLocations.size() > 0 && locationsStr != null) { // Locations' order does not matter. String result = TestUtils.compareOutput(Lists.newArrayList(locationsStr.split("\n")), expectedLocations, false, false); if (!result.isEmpty()) { errorLog.append("section " + Section.SCANRANGELOCATIONS + " of query:\n" + query + "\n" + result); } actualOutput.append(Section.SCANRANGELOCATIONS.getHeader() + "\n"); // Print the locations out sorted since the order is random and messed up // the diffs. The values in locationStr contains "Node X" labels as well // as paths. ArrayList<String> locations = Lists.newArrayList(locationsStr.split("\n")); ArrayList<String> perNodeLocations = Lists.newArrayList(); for (int i = 0; i < locations.size(); ++i) { if (locations.get(i).startsWith("NODE")) { if (!perNodeLocations.isEmpty()) { Collections.sort(perNodeLocations); actualOutput.append(Joiner.on("\n").join(perNodeLocations)).append("\n"); perNodeLocations.clear(); } actualOutput.append(locations.get(i)).append("\n"); } else { perNodeLocations.add(locations.get(i)); } } if (!perNodeLocations.isEmpty()) { Collections.sort(perNodeLocations); actualOutput.append(Joiner.on("\n").join(perNodeLocations)).append("\n"); } // TODO: check that scan range locations are identical in both cases } }
From source file:jp.or.openid.eiwg.scim.servlet.Users.java
/** * GET?// ww w . java 2 s . c o m * * @param request * @param response ? * @throws ServletException * @throws IOException */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // ? ServletContext context = getServletContext(); // ?? Operation op = new Operation(); boolean result = op.Authentication(context, request); if (!result) { // this.errorResponse(response, op.getErrorCode(), op.getErrorType(), op.getErrorMessage()); } else { // ? String targetId = request.getPathInfo(); String attributes = request.getParameter("attributes"); String filter = request.getParameter("filter"); String sortBy = request.getParameter("sortBy"); String sortOrder = request.getParameter("sortOrder"); String startIndex = request.getParameter("startIndex"); String count = request.getParameter("count"); if (targetId != null && !targetId.isEmpty()) { // ?'/'??? targetId = targetId.substring(1); } // ArrayList<LinkedHashMap<String, Object>> resultList = op.searchUserInfo(context, request, targetId, attributes, filter, sortBy, sortOrder, startIndex, count); if (resultList != null) { ObjectMapper mapper = new ObjectMapper(); StringWriter writer = new StringWriter(); // ?? if (targetId != null && !targetId.isEmpty()) { if (!resultList.isEmpty()) { LinkedHashMap<String, Object> resultObject = resultList.get(0); // javaJSON?? mapper.writeValue(writer, resultObject); response.setContentType("application/scim+json;charset=UTF-8"); response.setHeader("Location", request.getRequestURL().toString()); PrintWriter out = response.getWriter(); out.println(writer); } else { // id????????? this.errorResponse(response, HttpServletResponse.SC_NOT_FOUND, null, MessageConstants.ERROR_NOT_FOUND); } } else { // javaJSON?? mapper.writeValue(writer, resultList); String listResponse = "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:ListResponse\"],"; listResponse += "\"totalResults\":" + Integer.toString(resultList.size()); if (resultList.size() > 0) { listResponse += ",\"Resources\":"; listResponse += writer.toString(); } listResponse += "}"; response.setContentType("application/scim+json;charset=UTF-8"); PrintWriter out = response.getWriter(); out.println(listResponse); } } else { // this.errorResponse(response, op.getErrorCode(), op.getErrorType(), op.getErrorMessage()); } } }
From source file:com.test.hwautotest.emmagee.service.EmmageeService.java
/** * refresh the performance data showing in floating window. * /*from ww w.ja va 2 s .c o m*/ * @throws FileNotFoundException * * @throws IOException */ private void dataRefresh() { int pidMemory = memoryInfo.getPidMemorySize(pid, getBaseContext()); long freeMemory = memoryInfo.getFreeMemorySize(getBaseContext()); String freeMemoryKb = fomart.format((double) freeMemory / 1024); String processMemory = fomart.format((double) pidMemory / 1024); ArrayList<String> processInfo = cpuInfo.getCpuRatioInfo(); if (isFloating) { String processCpuRatio = "0"; String totalCpuRatio = "0"; String trafficSize = "0"; int tempTraffic = 0; double trafficMb = 0; boolean isMb = false; if (!processInfo.isEmpty()) { processCpuRatio = processInfo.get(0); totalCpuRatio = processInfo.get(1); trafficSize = processInfo.get(2); if ("".equals(trafficSize) && !("-1".equals(trafficSize))) { tempTraffic = Integer.parseInt(trafficSize); if (tempTraffic > 1024) { isMb = true; trafficMb = (double) tempTraffic / 1024; } } } if ("0".equals(processMemory) && "0.00".equals(processCpuRatio)) { closeOpenedStream(); isServiceStop = true; return; } if (processCpuRatio != null && totalCpuRatio != null) { txtUnusedMem .setText("?:" + processMemory + "MB" + ",:" + freeMemoryKb + "MB"); txtTotalMem.setText("?CPU:" + processCpuRatio + "%" + ",CPU:" + totalCpuRatio + "%"); if ("-1".equals(trafficSize)) { txtTraffic.setText("?????"); } else if (isMb) txtTraffic.setText("??:" + fomart.format(trafficMb) + "MB"); else txtTraffic.setText("??:" + trafficSize + "KB"); } } }
From source file:com.l2jfree.gameserver.geodata.pathfinding.PathFinding.java
public final Node[] searchByClosest(Node start, Node end, int instanceId) { // Note: This is the version for cell-based calculation, harder // on cpu than from block-based pathnode files. However produces better routes. // Always continues checking from the closest to target non-blocked // node from to_visit list. There's extra length in path if needed // to go backwards/sideways but when moving generally forwards, this is extra fast // and accurate. And can reach insane distances (try it with 8000 nodes..). // Minimum required node count would be around 300-400. // Generally returns a bit (only a bit) more intelligent looking routes than // the basic version. Not a true distance image (which would increase CPU // load) level of intelligence though. // List of Visited Nodes CellNodeMap known = CellNodeMap.newInstance(); // List of Nodes to Visit ArrayList<Node> to_visit = L2Collections.newArrayList(); to_visit.add(start);/* w ww .j a v a 2 s .co m*/ known.add(start); try { int targetx = end.getNodeX(); int targety = end.getNodeY(); int targetz = end.getZ(); int dx, dy, dz; boolean added; int i = 0; while (i < 3500) { if (to_visit.isEmpty()) { // No Path found return null; } Node node = to_visit.remove(0); i++; node.attachNeighbors(instanceId); if (node.equals(end)) { //path found! note that node z coordinate is updated only in attach //to improve performance (alternative: much more checks) //System.out.println("path found, i:"+i); return constructPath(node); } Node[] neighbors = node.getNeighbors(); if (neighbors == null) continue; for (Node n : neighbors) { if (!known.contains(n)) { added = false; n.setParent(node); dx = targetx - n.getNodeX(); dy = targety - n.getNodeY(); dz = targetz - n.getZ(); n.setCost(dx * dx + dy * dy + dz / 2 * dz/*+n.getCost()*/); for (int index = 0; index < to_visit.size(); index++) { // supposed to find it quite early.. if (to_visit.get(index).getCost() > n.getCost()) { to_visit.add(index, n); added = true; break; } } if (!added) to_visit.add(n); known.add(n); } } } //No Path found //System.out.println("no path found"); return null; } finally { CellNodeMap.recycle(known); L2Collections.recycle(to_visit); } }
From source file:com.dh.perfectoffer.event.framework.net.network.NetworkConnectionImpl.java
/** * Call the webservice using the given parameters to construct the request * and return the result./*from ww w . j a va 2 s. com*/ * * @param context * The context to use for this operation. Used to generate the * user agent if needed. * @param urlValue * The webservice URL. * @param method * The request method to use. * @param parameterList * The parameters to add to the request. * @param headerMap * The headers to add to the request. * @param isGzipEnabled * Whether the request will use gzip compression if available on * the server. * @param userAgent * The user agent to set in the request. If null, a default * Android one will be created. * @param postText * The POSTDATA text to add in the request. * @param credentials * The credentials to use for authentication. * @param isSslValidationEnabled * Whether the request will validate the SSL certificates. * @return The result of the webservice call. */ public static ConnectionResult execute(Context context, String urlValue, Method method, ArrayList<BasicNameValuePair> parameterList, HashMap<String, String> headerMap, boolean isGzipEnabled, String userAgent, String postText, UsernamePasswordCredentials credentials, boolean isSslValidationEnabled, String contentType, List<byte[]> fileByteDates, List<String> fileMimeTypes, int httpErrorResCodeFilte, boolean isMulFiles) throws ConnectionException { HttpURLConnection connection = null; try { // Prepare the request information if (userAgent == null) { userAgent = UserAgentUtils.get(context); } if (headerMap == null) { headerMap = new HashMap<String, String>(); } headerMap.put(HTTP.USER_AGENT, userAgent); if (isGzipEnabled) { headerMap.put(ACCEPT_ENCODING_HEADER, "gzip"); } headerMap.put(ACCEPT_CHARSET_HEADER, UTF8_CHARSET); if (credentials != null) { headerMap.put(AUTHORIZATION_HEADER, createAuthenticationHeader(credentials)); } StringBuilder paramBuilder = new StringBuilder(); if (parameterList != null && !parameterList.isEmpty()) { for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String name = parameter.getName(); String value = parameter.getValue(); if (TextUtils.isEmpty(name)) { // Empty parameter name. Check the next one. continue; } if (value == null) { value = ""; } paramBuilder.append(URLEncoder.encode(name, UTF8_CHARSET)); paramBuilder.append("="); paramBuilder.append(URLEncoder.encode(value, UTF8_CHARSET)); paramBuilder.append("&"); } } // ? ByteArrayOutputStream bos = new ByteArrayOutputStream(); // Create the connection object URL url = null; String outputText = null; switch (method) { case GET: case DELETE: String fullUrlValue = urlValue; if (paramBuilder.length() > 0) { fullUrlValue += "?" + paramBuilder.toString(); } url = new URL(fullUrlValue); connection = HttpUrlConnectionHelper.openUrlConnection(url); break; case PUT: case POST: url = new URL(urlValue); connection = HttpUrlConnectionHelper.openUrlConnection(url); connection.setDoOutput(true); if (paramBuilder.length() > 0 && NetworkConnection.CT_DEFALUT.equals(contentType)) { // form // ? // headerMap.put(HTTP.CONTENT_TYPE, // "application/x-www-form-urlencoded"); outputText = paramBuilder.toString(); headerMap.put(HTTP.CONTENT_TYPE, contentType); headerMap.put(HTTP.CONTENT_LEN, String.valueOf(outputText.getBytes().length)); } else if (postText != null && (NetworkConnection.CT_JSON.equals(contentType) || NetworkConnection.CT_XML.equals(contentType))) { // body // ? // headerMap.put(HTTP.CONTENT_TYPE, "application/json"); // //add ?json??? headerMap.put(HTTP.CONTENT_TYPE, contentType); // add // ?json??? headerMap.put(HTTP.CONTENT_LEN, String.valueOf(postText.getBytes().length)); outputText = postText; // Log.e("newtewewerew", // "1111application/json------------------outputText222222:::"+outputText+"-------method::"+method+"----paramBuilder.length() :"+paramBuilder.length()+"----postText:"+postText // ); } else if (NetworkConnection.CT_MULTIPART.equals(contentType)) { // String[] Array = urlValue.split("/"); /*Boolean isFiles = false; if (Array[Array.length - 1].equals("clientRemarkPic")) { isFiles = true; }*/ if (null == fileByteDates || fileByteDates.size() <= 0) { throw new ConnectionException("file formdata no bytes data", NetworkConnection.EXCEPTION_CODE_FORMDATA_NOBYTEDATE); } headerMap.put(HTTP.CONTENT_TYPE, contentType + ";boundary=" + BOUNDARY); String bulidFormText = bulidFormText(parameterList); bos.write(bulidFormText.getBytes()); for (int i = 0; i < fileByteDates.size(); i++) { long currentTimeMillis = System.currentTimeMillis(); StringBuffer sb = new StringBuffer(""); sb.append(PREFIX).append(BOUNDARY).append(LINEND); // sb.append("Content-Type:application/octet-stream" + // LINEND); // sb.append("Content-Disposition: form-data; name=\""+nextInt+"\"; filename=\""+nextInt+".png\"").append(LINEND);; if (isMulFiles) sb.append("Content-Disposition: form-data; name=\"files\";filename=\"pic" + currentTimeMillis + ".png\"").append(LINEND); else sb.append("Content-Disposition: form-data; name=\"file\";filename=\"pic" + currentTimeMillis + ".png\"").append(LINEND); // sb.append("Content-Type:image/png" + LINEND); sb.append("Content-Type:" + fileMimeTypes.get(i) + LINEND); // sb.append("Content-Type:image/png" + LINEND); sb.append(LINEND); bos.write(sb.toString().getBytes()); bos.write(fileByteDates.get(i)); bos.write(LINEND.getBytes()); } byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINEND).getBytes(); bos.write(end_data); bos.flush(); headerMap.put(HTTP.CONTENT_LEN, bos.size() + ""); } // L.e("newtewewerew", // "2222------------------outputText222222:::"+outputText+"-------method::"+method+"----paramBuilder.length() :"+paramBuilder.length()+"----postText:"+postText // ); break; } // Set the request method connection.setRequestMethod(method.toString()); // If it's an HTTPS request and the SSL Validation is disabled if (url.getProtocol().equals("https") && !isSslValidationEnabled) { HttpsURLConnection httpsConnection = (HttpsURLConnection) connection; httpsConnection.setSSLSocketFactory(getAllHostsValidSocketFactory()); httpsConnection.setHostnameVerifier(getAllHostsValidVerifier()); } // Add the headers if (!headerMap.isEmpty()) { for (Entry<String, String> header : headerMap.entrySet()) { connection.addRequestProperty(header.getKey(), header.getValue()); } } // Set the connection and read timeout connection.setConnectTimeout(OPERATION_TIMEOUT); connection.setReadTimeout(OPERATION_TIMEOUT); // Set the outputStream content for POST and PUT requests if ((method == Method.POST || method == Method.PUT)) { OutputStream output = null; try { if (NetworkConnection.CT_MULTIPART.equals(contentType)) { output = connection.getOutputStream(); output.write(bos.toByteArray()); } else { if (null != outputText) { L.e("newtewewerew", method + "------------------outputText:::" + outputText); output = connection.getOutputStream(); output.write(outputText.getBytes()); } } } finally { if (output != null) { try { output.close(); } catch (IOException e) { // Already catching the first IOException so nothing // to do here. } } } } // Log the request if (L.canLog(Log.DEBUG)) { L.d(TAG, "Request url: " + urlValue); L.d(TAG, "Method: " + method.toString()); if (parameterList != null && !parameterList.isEmpty()) { L.d(TAG, "Parameters:"); for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String message = "- \"" + parameter.getName() + "\" = \"" + parameter.getValue() + "\""; L.d(TAG, message); } L.d(TAG, "Parameters String: \"" + paramBuilder.toString() + "\""); } if (postText != null) { L.d(TAG, "Post data: " + postText); } if (headerMap != null && !headerMap.isEmpty()) { L.d(TAG, "Headers:"); for (Entry<String, String> header : headerMap.entrySet()) { L.d(TAG, "- " + header.getKey() + " = " + header.getValue()); } } } String contentEncoding = connection.getHeaderField(HTTP.CONTENT_ENCODING); int responseCode = connection.getResponseCode(); boolean isGzip = contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip"); L.d(TAG, "Response code: " + responseCode); if (responseCode == HttpStatus.SC_MOVED_PERMANENTLY) { String redirectionUrl = connection.getHeaderField(LOCATION_HEADER); throw new ConnectionException("New location : " + redirectionUrl, redirectionUrl); } InputStream errorStream = connection.getErrorStream(); if (errorStream != null) { String error = convertStreamToString(errorStream, isGzip); // L.e("responseCode:"+responseCode+" httpErrorResCodeFilte:"+httpErrorResCodeFilte+" responseCode==httpErrorResCodeFilte:"+(responseCode==httpErrorResCodeFilte)); if (responseCode == httpErrorResCodeFilte) { // 400???... logResBodyAndHeader(connection, error); return new ConnectionResult(connection.getHeaderFields(), error, responseCode); } else { throw new ConnectionException(error, responseCode); } } String body = convertStreamToString(connection.getInputStream(), isGzip); // ?? ? if (null != body && body.contains("\r")) { body = body.replace("\r", ""); } if (null != body && body.contains("\n")) { body = body.replace("\n", ""); } logResBodyAndHeader(connection, body); return new ConnectionResult(connection.getHeaderFields(), body, responseCode); } catch (IOException e) { L.e(TAG, "IOException", e); throw new ConnectionException(e); } catch (KeyManagementException e) { L.e(TAG, "KeyManagementException", e); throw new ConnectionException(e); } catch (NoSuchAlgorithmException e) { L.e(TAG, "NoSuchAlgorithmException", e); throw new ConnectionException(e); } finally { if (connection != null) { connection.disconnect(); } } }
From source file:eu.medsea.mimeutil.detector.MagicMimeMimeDetector.java
private static void parse(final String magicFile, final Reader r) throws IOException { long start = System.currentTimeMillis(); BufferedReader br = new BufferedReader(r); String line;/* www .j a v a2 s .com*/ ArrayList sequence = new ArrayList(); long lineNumber = 0; line = br.readLine(); if (line != null) ++lineNumber; while (true) { if (line == null) { break; } line = line.trim(); if (line.length() == 0 || line.charAt(0) == '#') { line = br.readLine(); if (line != null) ++lineNumber; continue; } sequence.add(line); // read the following lines until a line does not begin with '>' or // EOF while (true) { line = br.readLine(); if (line != null) ++lineNumber; if (line == null) { addEntry(magicFile, lineNumber, sequence); sequence.clear(); break; } line = line.trim(); if (line.length() == 0 || line.charAt(0) == '#') { continue; } if (line.charAt(0) != '>') { addEntry(magicFile, lineNumber, sequence); sequence.clear(); break; } sequence.add(line); } } if (!sequence.isEmpty()) { addEntry(magicFile, lineNumber, sequence); } if (log.isDebugEnabled()) log.debug("Parsing \"" + magicFile + "\" took " + (System.currentTimeMillis() - start) + " msec."); }
From source file:com.strategicgains.docussandra.controller.perf.remote.mongo.PlayByPlayPerfMongo.java
@Test @Override/*from ww w .j a va 2 s . c om*/ public void postQueryTestThreeField() { try { int numQueries = 50; Date start = new Date(); MongoClient mongoClient = new MongoClient(uri); //mongoClient.setWriteConcern(WriteConcern.MAJORITY); DB db = mongoClient.getDB(this.getDb().name()); final DBCollection coll = db.getCollection(this.getDb().name()); for (int i = 0; i < numQueries; i++) { logger.debug("Query: " + i); ArrayList<String> res = new ArrayList<>(); BasicDBObject query = new BasicDBObject(); query.append("dwn", 4); query.append("ytg", 1); query.append("pts", 6); DBCursor curser = coll.find(query); int count = 0; while (curser.hasNext() && count++ < 10000) { DBObject o = curser.next(); assertNotNull(o); assertTrue(o.toString().contains("4")); assertTrue(o.toString().contains("1")); assertTrue(o.toString().contains("6")); res.add(o.toString()); } assertFalse(res.isEmpty()); } Date end = new Date(); long executionTime = end.getTime() - start.getTime(); double inSeconds = (double) executionTime / 1000d; double average = (double) inSeconds / (double) numQueries; output.info("PBP-Mongo: Time to execute (three fields) for " + numQueries + " is: " + inSeconds + " seconds"); output.info("PBP-Mongo: Averge time for three fields is: " + average); } catch (UnknownHostException e) { logger.error("Couldn't run test.", e); throw new RuntimeException(e); } }
From source file:coolmap.application.widget.impl.WidgetUserGroup.java
private void initPopup() { JPopupMenu popup = new JPopupMenu(); table.setComponentPopupMenu(popup);//from w w w. ja v a2s. c om JMenuItem item = new JMenuItem("Rename"); popup.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<String> groupNames = getSelectedGroups(); if (groupNames.isEmpty()) { return; } String returnVal = JOptionPane.showInputDialog(CoolMapMaster.getCMainFrame(), "Please provide a new name:"); if (returnVal == null || returnVal.length() == 0) { returnVal = "Untitled"; } int counter = 0; String newName; for (String groupName : groupNames) { if (counter == 0) { newName = returnVal; } else { newName = returnVal + "_" + counter; } //new name must not exist int subCounter = 0; String name = newName; while (nodeGroups.containsKey(name)) { subCounter++; name = newName + "_" + subCounter; } newName = name; Color c = nodeColor.get(groupName); Set<VNode> nodes = new HashSet(nodeGroups.get(groupName)); nodeColor.remove(groupName); nodeGroups.removeAll(groupName); nodeColor.put(newName, c); nodeGroups.putAll(newName, nodes); // System.out.println(newName + " " + c + " " + nodes); counter++; } updateTable(); } }); //////////////////////////////////////////////////////////////////////// //remove operations item = new JMenuItem("Remove"); popup.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<String> groupNames = getSelectedGroups(); for (String group : groupNames) { nodeColor.remove(group); nodeGroups.removeAll(group); } updateTable(); } }); //add separarator popup.addSeparator(); JMenu insertRow = new JMenu("Add selected to row"); popup.add(insertRow); JMenu insertColumn = new JMenu("Add selected to column"); popup.add(insertColumn); item = new JMenuItem("prepend", UI.getImageIcon("prependRow")); insertRow.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { insertRow(0); } }); item = new JMenuItem("prepend", UI.getImageIcon("prependColumn")); insertColumn.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { insertColumn(0); } }); item = new JMenuItem("insert", UI.getImageIcon("insertRow")); item.setToolTipText("Insert selected groups to the selected region in the active coolmap view"); insertRow.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CoolMapObject obj = CoolMapMaster.getActiveCoolMapObject(); if (obj == null) { return; } int index = 0; ArrayList selectedRows = obj.getCoolMapView().getSelectedRows(); if (!selectedRows.isEmpty()) { index = ((Range<Integer>) selectedRows.iterator().next()).lowerEndpoint(); } insertRow(index); } }); item = new JMenuItem("insert", UI.getImageIcon("insertColumn")); item.setToolTipText("Insert selected groups to the selected region in the active coolmap view"); insertColumn.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CoolMapObject obj = CoolMapMaster.getActiveCoolMapObject(); if (obj == null) { return; } int index = 0; ArrayList selectedColumns = obj.getCoolMapView().getSelectedColumns(); if (!selectedColumns.isEmpty()) { index = ((Range<Integer>) selectedColumns.iterator().next()).lowerEndpoint(); } insertColumn(index); } }); item = new JMenuItem("append", UI.getImageIcon("appendRow")); insertRow.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (CoolMapMaster.getActiveCoolMapObject() == null) { return; } insertRow(CoolMapMaster.getActiveCoolMapObject().getViewNumRows()); } }); item = new JMenuItem("append", UI.getImageIcon("appendColumn")); insertColumn.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (CoolMapMaster.getActiveCoolMapObject() == null) { return; } insertColumn(CoolMapMaster.getActiveCoolMapObject().getViewNumColumns()); } }); item = new JMenuItem("replace", UI.getImageIcon("replaceRow")); insertRow.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { replaceRow(); } }); item = new JMenuItem("replace", UI.getImageIcon("replaceColumn")); insertColumn.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { replaceColumn(); } }); }