@Override public void actionPerformed(AnActionEvent anActionEvent) { Project project = anActionEvent.getProject(); if (project != null) { String packageName = Messages.showInputDialog( Strings.MESSAGE_ASK_PACKAGE_NAME_TO_FILTER, Strings.TITLE_ASK_PACKAGE_NAME_TO_FILTER, Messages.getQuestionIcon(), PropertiesManager.getData(project, PropertyKeys.PACKAGE_NAME), new NonEmptyInputValidator()); if (!TextUtils.isEmpty(packageName)) { PropertiesManager.putData(project, PropertyKeys.PACKAGE_NAME, packageName); } } }
@Override public void setValueAt(int column, String text) { switch (column) { case 2: break; case 3: String result; if (!TextUtils.isEmpty(fieldTypeSuffix)) { result = fieldTypeSuffix + "." + text; } else { result = text; } if (CheckUtil.getInstant().containsDeclareClassName(result)) { return; } CheckUtil.getInstant().removeDeclareClassName(getQualifiedName()); setClassName(text); break; } }
private String createSubClassName(String key, Object o) { String name = ""; if (o instanceof JSONObject) { if (TextUtils.isEmpty(key)) { return key; } String[] strings = key.split("_"); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < strings.length; i++) { stringBuilder.append(StringUtils.captureName(strings[i])); } name = stringBuilder.toString() + Config.getInstant().getSuffixStr(); } return name; }
private String generateLombokFieldText(ClassEntity classEntity, FieldEntity fieldEntity, String fixme) { fixme = fixme == null ? "" : fixme; StringBuilder fieldSb = new StringBuilder(); String filedName = fieldEntity.getGenerateFieldName(); if (!TextUtils.isEmpty(classEntity.getExtra())) { fieldSb.append(classEntity.getExtra()).append("\n"); classEntity.setExtra(null); } if (fieldEntity.getTargetClass() != null) { fieldEntity.getTargetClass().setGenerate(true); } if (Config.getInstant().isFieldPrivateMode()) { fieldSb.append("private ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } else { fieldSb.append("public ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } return fieldSb.append(fixme).toString(); }
private String generateFieldText(ClassEntity classEntity, FieldEntity fieldEntity, String fixme) { fixme = fixme == null ? "" : fixme; StringBuilder fieldSb = new StringBuilder(); String fieldName = fieldEntity.getGenerateFieldName(); if (!TextUtils.isEmpty(classEntity.getExtra())) { fieldSb.append(classEntity.getExtra()).append("\n"); classEntity.setExtra(null); } if (!fieldName.equals(fieldEntity.getKey()) || Config.getInstant().isUseSerializedName()) { fieldSb.append(Constant.gsonFullNameAnnotation.replaceAll("\\{filed\\}", fieldEntity.getKey())); } if (fieldEntity.getTargetClass() != null) { fieldEntity.getTargetClass().setGenerate(true); } return fieldSb.append(String.format("public abstract %s %s(); " + fixme, fieldEntity.getFullNameType(), fieldName)).toString(); }
private String generateFieldText(ClassEntity classEntity, FieldEntity fieldEntity, String fixme) { fixme = fixme == null ? "" : fixme; StringBuilder fieldSb = new StringBuilder(); String filedName = fieldEntity.getGenerateFieldName(); if (!TextUtils.isEmpty(classEntity.getExtra())) { fieldSb.append(classEntity.getExtra()).append("\n"); classEntity.setExtra(null); } if (fieldEntity.getTargetClass() != null) { fieldEntity.getTargetClass().setGenerate(true); } if (!filedName.equals(fieldEntity.getKey()) || Config.getInstant().isUseSerializedName()) { fieldSb.append(Config.getInstant().geFullNameAnnotation().replaceAll("\\{filed\\}", fieldEntity.getKey())); } if (Config.getInstant().isFieldPrivateMode()) { fieldSb.append("private ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } else { fieldSb.append("public ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } return fieldSb.append(fixme).toString(); }
private void onOK() { this.setAlwaysOnTop(false); String jsonSTR = editTP.getText().trim(); if (TextUtils.isEmpty(jsonSTR)) { return; } String generateClassName = generateClassTF.getText().replaceAll(" ", "").replaceAll(".java$", ""); if (TextUtils.isEmpty(generateClassName) || generateClassName.endsWith(".")) { Toast.make(project, generateClassP, MessageType.ERROR, "the path is not allowed"); return; } PsiClass generateClass = null; if (!currentClass.equals(generateClassName)) { generateClass = PsiClassUtil.exist(file, generateClassTF.getText()); } else { generateClass = cls; } new ConvertBridge(this, jsonSTR, file, project, generateClass, cls, generateClassName).run(); }
/** * 转成驼峰 * * @param text * @return */ public static String captureStringLeaveUnderscore(String text) { if (TextUtils.isEmpty(text)) { return text; } String temp = text.replaceAll("^_+", ""); if (!TextUtils.isEmpty(temp)) { text = temp; } String[] strings = text.split("_"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(strings[0]); for (int i = 1; i < strings.length; i++) { stringBuilder.append(captureName(strings[i])); } return stringBuilder.toString(); }
private <T> T postNormal(String actionName, Class<T> tClass, Object linkBean) { RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(linkBean)); Request request = new Request.Builder().url(getFullUrl(actionName)).post(body).build(); T ret = null; String result = null; try { Response response = getOkHttp().newCall(request).execute(); result = response.body().string(); if (!TextUtils.isEmpty(result)) { // if (result.contains("error_code")) { // mLogger.error("postForm result error ,actionName = " + actionName + " ,detail : " + result); // } else { ret = gson.fromJson(result, tClass); // } } System.out.println("post成功 result = " + result); } catch (Exception e) { mLogger.error("postForm IOException1 action: " + actionName + " ," + tClass.getName() + " ,detail: " + e.getMessage() + ",resultStr = " + result); e.printStackTrace(); } return ret; }
/** * 生成get方法完整url地址: https://www.okcoin.com/api/v1/future_index.do?symbol=btc_usd * * @param actionName 请求动作名称:future_index.do * @param contents 查询参数: symbol,btc_usd */ private String getFullUrl(String actionName, String... contents) { if (TextUtils.isEmpty(Params.accessToken)) { System.out.println("access_token非法 " + Params.accessToken); } // 这个是钉钉要加的,都统一加上吧,暂时没发现问题,就不做特殊处理了 String result = "?access_token=" + Params.accessToken + "&"; if (contents != null && contents.length > 0 && contents.length % 2 == 0) { for (int i = 0; i < contents.length - 1; i += 2) { result += contents[i] + "=" + contents[i + 1] + "&"; } } if (!TextUtils.isEmpty(result)) { result = result.substring(0, result.length() - 1); } return Params.getDingTalkServerUrl() + actionName + result; }
/** * 发送简单的文本通知给部门所有人 * 目前用于merge请求通过的时候通知所有人员的时候 * * @param toSpecialUser 是否只是发给单个用户,若非empty,则发给指定用户,否则发给部门所有人 * @param content 要发送的文本内容 */ public void sendTextMsg(@Nullable String toSpecialUser, String content) { if (Params.userlist != null) { Params.userlist.stream() .filter(bean -> TextUtils.isEmpty(toSpecialUser) || bean.getName().equalsIgnoreCase(toSpecialUser)) .forEach(bean -> { String userId = bean.getUserid(); MessageTextBean textBean = new MessageTextBean(); textBean.setTouser(userId); textBean.setAgentid(Params.agentId); textBean.setMsgtype(MessageType.TEXT); MessageTextBean.TextBean subTextBean = new MessageTextBean.TextBean(); subTextBean.setContent(content); textBean.setText(subTextBean); postNormal("message/send", MessageResponseBean.class, textBean); }); } else { getDepartmentMenberList(); } }
private String generateLombokFieldText(ClassEntity classEntity, FieldEntity fieldEntity,String fixme) { fixme = fixme == null ? "" : fixme; StringBuilder fieldSb = new StringBuilder(); String filedName = fieldEntity.getGenerateFieldName(); if (!TextUtils.isEmpty(classEntity.getExtra())) { fieldSb.append(classEntity.getExtra()).append("\n"); classEntity.setExtra(null); } if (fieldEntity.getTargetClass() != null) { fieldEntity.getTargetClass().setGenerate(true); } if (Config.getInstant().isFieldPrivateMode()) { fieldSb.append("private ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } else { fieldSb.append("public ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } return fieldSb.append(fixme).toString(); }
private void getTranslation(AnActionEvent event) { Editor editor = event.getData(PlatformDataKeys.EDITOR); if (editor == null) { return; } SelectionModel model = editor.getSelectionModel(); String selectedText = model.getSelectedText(); if (TextUtils.isEmpty(selectedText)) { selectedText = getCurrentWords(editor); if (TextUtils.isEmpty(selectedText)) { return; } } String queryText = strip(addBlanks(selectedText)); new Thread(new RequestRunnable(mTranslator, editor, queryText)).start(); }
@Override protected URI createLocationURI(String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(encode(location)).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ROOT)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
private void getTranslation(AnActionEvent event) { Editor mEditor = event.getData(PlatformDataKeys.EDITOR); Project project = event.getData(PlatformDataKeys.PROJECT); String basePath = project.getBasePath(); if (null == mEditor) { return; } SelectionModel model = mEditor.getSelectionModel(); String selectedText = model.getSelectedText(); if (TextUtils.isEmpty(selectedText)) { selectedText = getCurrentWords(mEditor); if (TextUtils.isEmpty(selectedText)) { return; } } String queryText = strip(addBlanks(selectedText)); new Thread(new RequestRunnable(mEditor, queryText,basePath)).start(); }
@Override public void actionPerformed(AnActionEvent anActionEvent) { Project project = anActionEvent.getProject(); if (project != null) { String currentApkPath = PropertiesManager.getData(project, PropertyKeys.APK_PATH); VirtualFile fileToSelectOnCreate = TextUtils.isEmpty(currentApkPath) ? project.getBaseDir() : LocalFileSystem.getInstance().findFileByPath(currentApkPath); VirtualFile apkFile = new FileChooserDialogManager.Builder(project, fileToSelectOnCreate) .setFileTypes(FileTypes.FILE) .setTitle(Strings.TITLE_ASK_APK_FILE) .setDescription(Strings.MESSAGE_ASK_APK_FILE) .withFileFilter("apk") .create() .getSelectedFile(); if (apkFile != null) { PropertiesManager.putData(project, PropertyKeys.APK_PATH, apkFile.getPath()); } } }
/** * valid tag to count */ static boolean isTargetTagToCount(PsiElement tag) { if (tag == null || !(tag instanceof XmlTag) || TextUtils.isEmpty(((XmlTag)tag).getName())) { return false; } String name = ((XmlTag)tag).getName(); return name.equals("array") || name.equals("attr") || name.equals("bool") || name.equals("color") || name.equals("declare-styleable") || name.equals("dimen") || name.equals("drawable") || name.equals("eat-comment") || name.equals("fraction") || name.equals("integer") || name.equals("integer-array") || name.equals("item") || name.equals("plurals") || name.equals("string") || name.equals("string-array") || name.equals("style"); }
@Override public void apply() throws ConfigurationException { try { PropertiesComponent.getInstance().setValue(KEY_RULES_PATH, rulesPath.getText()); if (!TextUtils.isEmpty(rulesPath.getText())) { load(rulesPath.getText()); DirectiveLint.prepare(); } else { DirectiveLint.reset(); } } catch (Exception e) { ProjectUtil.guessCurrentProject(select).getMessageBus().syncPublisher(Notifications.TOPIC).notify( new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Weex language support - bad rules", e.toString(), NotificationType.ERROR)); } savePaths(); }
public boolean match(String value) { if (TextUtils.isEmpty(valuePattern)) { return false; } if (valuePattern.toLowerCase().equals("mustache")) { return Pattern.compile("\\{\\{.*\\}\\}").matcher(value).matches(); } else if (valuePattern.toLowerCase().equals("number")) { return Pattern.compile("[0-9]+([.][0-9]+)?$").matcher(value).matches(); } else if (valuePattern.toLowerCase().equals("boolean")) { return Pattern.compile("(true|false)$").matcher(value).matches(); } else { try { return Pattern.compile(valuePattern).matcher(value).matches(); } catch (Exception e) { return false; } } }
private boolean verifyPortText(){ final String text = mPort.getText(); if(TextUtils.isBlank(text)){ return false; } try { int port = Integer.valueOf(text); if(port >= 0 && port < 65535){ return true; } }catch (Exception e){ e.printStackTrace(); } return false; }
private boolean verifyIpText(){ for (JTextField field : mIPTextFields){ final String text = field.getText(); if(TextUtils.isBlank(text)){ return false; } try{ int ip = Integer.valueOf(text); if(ip < 0 || ip > 255){ return false; } }catch (Exception e){ e.printStackTrace(); return false; } } return true; }
/** * A convenience method that creates a new {@link URI} whose scheme, host, port, path, * query are taken from the existing URI, dropping any fragment or user-information. * The path is set to "/" if not explicitly specified. The existing URI is returned * unmodified if it has no fragment or user-information and has a path. * * @param uri * original URI. * @throws URISyntaxException * If the resulting URI is invalid. */ public static URI rewriteURI(final URI uri) throws URISyntaxException { Args.notNull(uri, "URI"); if (uri.isOpaque()) { return uri; } final URIBuilder uribuilder = new URIBuilder(uri); if (uribuilder.getUserInfo() != null) { uribuilder.setUserInfo(null); } if (TextUtils.isEmpty(uribuilder.getPath())) { uribuilder.setPath("/"); } if (uribuilder.getHost() != null) { uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ENGLISH)); } uribuilder.setFragment(null); return uribuilder.build(); }
/** * @since 4.1 */ protected URI createLocationURI(final String location) throws ProtocolException { try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ENGLISH)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
static String[] extractCNs(final String subjectPrincipal) throws SSLException { if (subjectPrincipal == null) { return null; } final List<String> cns = new ArrayList<String>(); final List<NameValuePair> nvps = DistinguishedNameParser.INSTANCE.parse(subjectPrincipal); for (int i = 0; i < nvps.size(); i++) { final NameValuePair nvp = nvps.get(i); final String attribName = nvp.getName(); final String attribValue = nvp.getValue(); if (TextUtils.isBlank(attribValue)) { throw new SSLException(subjectPrincipal + " is not a valid X500 distinguished name"); } if (attribName.equalsIgnoreCase("cn")) { cns.add(attribValue); } } return cns.isEmpty() ? null : cns.toArray(new String[ cns.size() ]); }
private void doExport(){ if (TextUtils.isEmpty(textFieldInput.getText())){ textHint.setText("Input file path can not be empty!"); btnChooseInputPath.requestFocus(); return; }else if (TextUtils.isEmpty(textFieldOutput.getText())){ textHint.setText("Output path can not be empty!"); btnChooseOutputPath.requestFocus(); return; } String outputFilePath = textFieldOutput.getText() + "/BT_export_string_xml_" + System.currentTimeMillis() + ".xlsx"; boolean exportSuccess = BeTranslateUtil.generateExcel(textFieldInput.getText(), outputFilePath); if (exportSuccess){ Messages.showMessageDialog("Export file '" + outputFilePath + "' success!", "BeTranslate", Messages.getInformationIcon()); dispose(); }else { Messages.showMessageDialog("Export file failed!", "BeTranslate", Messages.getWarningIcon()); } }
@Override public String getBotToken() { if (TextUtils.isEmpty(token)) { final Properties properties = new Properties(); try { properties.load(properties.getClass().getResourceAsStream("/secret.properties")); } catch (IOException e) { throw new RuntimeException("No secret.properties with telegram token found in resources/"); } token = properties.getProperty("token"); if (TextUtils.isEmpty(token)) { throw new RuntimeException("No telegram token found in resources/secret.properties"); } return token; } return token; }
/** * 处理文件上传 * * @param url * @param filePath * @param tableParams */ public void handleUploadFile(String url, String filePath, TableModel tableParams) { if (!VerifyUtil.verifyUrl(url)) { mView.showE("请求的Url无效"); return; } if (TextUtils.isEmpty(filePath)) { mView.showE("请选择一个上传的文件"); return; } File file = new File(filePath); if (!file.exists()) { mView.showE("选择的文件不存在"); return; } LinkedHashMap<String, String> params = ViewUtil.getTableContent(tableParams); mView.startUpload(); upload(url, file, params); }
/** * Get data in JTable * * @param jTable * @return */ private ArrayList<String> getData(JTable jTable) { ArrayList<String> list = new ArrayList<>(); for (int i = 0; i < jTable.getModel().getRowCount(); i++) { TableModel model = jTable.getModel(); String returnStr = (String) model.getValueAt(i, 0); String methodStr = (String) model.getValueAt(i, 1); returnStr = returnStr.trim(); methodStr = methodStr.trim(); if (TextUtils.isEmpty(returnStr) || TextUtils.isEmpty(methodStr)) { return null; } list.add(returnStr + "##" + methodStr); } return list; }
@Override public void onClick(View v) { switch (v.getId()){ case R.id.btnregister: username = edtname.getText().toString(); password = edtpass.getText().toString(); email = edtmail.getText().toString(); if (TextUtils.isEmpty(username)){ edtname.setError(username); } else if(TextUtils.isEmpty(password)){ edtpass.setError("Enter Password"); }else if(TextUtils.isEmpty(email)){ edtmail.setError("Enter Password"); } else SendRegRequest(); } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btnlogin: username = name.getText().toString(); password = pass.getText().toString(); if(TextUtils.isEmpty(username)) { name.setError("Enter Name"); } else if(TextUtils.isEmpty(password)){ pass.setError("Enter Password"); } else { SendJsonRequest(); } break; case R.id.btnregister: Intent it = new Intent(LoginActivity.this,RegistrationActivity.class); startActivity(it); break; } }
public void start() { this.getUuid();// 获取uuid if (!TextUtils.isBlank(uuid)) { this.downQrCode();// 下载二维码图片 this.showQrCode();// 显示二维码图片 } this.login();// 登录操作 if (!TextUtils.isBlank(redirectUri)) {// 跳转到登录后页面 this.wxNewLoginPage(); } if (!TextUtils.isBlank(skey)) {// 初始化微信 this.wxInit(); } if (syncKeyJsonObject != null) {// 开启微信状态通知 this.wxStatusNotify(); this.listenMsg(); } }
/** * A convenience method that creates a new {@link URI} whose scheme, host, port, path, * query are taken from the existing URI, dropping any fragment or user-information. * The path is set to "/" if not explicitly specified. The existing URI is returned * unmodified if it has no fragment or user-information and has a path. * * @param uri * original URI. * @throws URISyntaxException * If the resulting URI is invalid. */ public static URI rewriteURI(final URI uri) throws URISyntaxException { Args.notNull(uri, "URI"); if (uri.isOpaque()) { return uri; } final URIBuilder uribuilder = new URIBuilder(uri); if (uribuilder.getUserInfo() != null) { uribuilder.setUserInfo(null); } if (TextUtils.isEmpty(uribuilder.getPath())) { uribuilder.setPath("/"); } if (uribuilder.getHost() != null) { uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT)); } uribuilder.setFragment(null); return uribuilder.build(); }
@Override public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); if (TextUtils.isBlank(value)) { throw new MalformedCookieException("Blank or null value for domain attribute"); } // Ignore domain attributes ending with '.' per RFC 6265, 4.1.2.3 if (value.endsWith(".")) { return; } String domain = value; if (domain.startsWith(".")) { domain = domain.substring(1); } domain = domain.toLowerCase(Locale.ROOT); cookie.setDomain(domain); }