List of usage examples for org.apache.commons.lang StringUtils trimToEmpty
public static String trimToEmpty(String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null
.
From source file:com.prowidesoftware.swift.model.field.Field70C.java
/** * Get the Narrative as a concatenation of component2 to component5. * @return the Narrative from components *///from w w w . j a v a 2 s .c om public String getNarrative() { StringBuilder result = new StringBuilder(); for (int i = 2; i < 6; i++) { if (StringUtils.isNotBlank(getComponent(i))) { if (result.length() > 0) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); } result.append(StringUtils.trimToEmpty(getComponent(i))); } } return result.toString(); }
From source file:com.hangum.tadpole.rdb.erd.core.dnd.TableTransferDropTargetListener.java
/** * painting model // w w w.java2 s . c o m * * @param nextTableX * @param nextTableY * @param arryTables * @param mapTable */ private void paintingModel(int nextTableX, int nextTableY, String[] arryTables, Map<String, List<TableColumnDAO>> mapTable) { Rectangle prevRectangle = null; int originalX = nextTableX; int intCount = 1; for (String strTable : arryTables) { String[] arryTable = StringUtils.splitByWholeSeparator(strTable, PublicTadpoleDefine.DELIMITER); if (arryTable.length == 0) continue; String tableName = arryTable[1]; String refTableNames = "'" + tableName + "',"; //$NON-NLS-1$ //$NON-NLS-2$ // ? editor ?? ? . Map<String, Table> mapDBTables = new HashMap<String, Table>(); for (Table table : db.getTables()) { mapDBTables.put(table.getName(), table); refTableNames += "'" + table.getName() + "',"; //$NON-NLS-1$ //$NON-NLS-2$ } refTableNames = StringUtils.chompLast(refTableNames, ","); //$NON-NLS-1$ // ? ?? ? ? if (mapDBTables.get(tableName) == null) { // ? ? ? Table tableModel = tadpoleFactory.createTable(); tableModel.setName(tableName); tableModel.setDb(db); String tableComment = StringUtils.trimToEmpty(arryTable[2]); tableComment = StringUtils.substring(tableComment, 0, 10); tableModel.setComment(tableComment); // ?? ?. prevRectangle = new Rectangle(nextTableX, nextTableY, TadpoleModelUtils.END_TABLE_WIDTH, TadpoleModelUtils.END_TABLE_HIGHT); tableModel.setConstraints(prevRectangle); // ? . nextTableX = originalX + (TadpoleModelUtils.GAP_WIDTH * intCount); intCount++; try { // ? ? for (TableColumnDAO columnDAO : mapTable.get(tableName)) { Column column = tadpoleFactory.createColumn(); column.setDefault(columnDAO.getDefault()); column.setExtra(columnDAO.getExtra()); column.setField(columnDAO.getField()); column.setNull(columnDAO.getNull()); column.setKey(columnDAO.getKey()); column.setType(columnDAO.getType()); String strComment = columnDAO.getComment(); if (strComment == null) strComment = ""; strComment = StringUtils.substring(strComment, 0, 10); column.setComment(strComment); column.setTable(tableModel); tableModel.getColumns().add(column); } mapDBTables.put(tableName, tableModel); RelationUtil.calRelation(userDB, mapDBTables, db, refTableNames);//RelationUtil.getReferenceTable(userDB, refTableNames)); } catch (Exception e) { logger.error("GEF Table Drag and Drop Exception", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.get().Error, Messages.get().TadpoleModelUtils_2, errStatus); //$NON-NLS-1$ } transferFactory.setTable(tableModel); } else { transferFactory.setTable(mapDBTables.get(tableName)); } } // end tables // super.handleDrop(); }
From source file:com.edgenius.wiki.search.service.AbstractSearchService.java
/** * /* w w w.j a va 2 s .c o m*/ * @param keyword * @param advance * @return 2 elements: first is keyword query with advance query criteria. Last is highlight query. * @throws ParseException */ private Query[] createQuery(String keyword, String... advance) throws ParseException { //default value int advKeyword = 0; String space = null; int srcType = 0; long from = 0, to = 0; //group by space - need filter out some special type boolean groupBySpace = false; if (advance != null) { //parse all possible type for (String str : advance) { if (str.length() < 2) continue; if (str.charAt(0) == SearchService.ADV_KEYWORD_TYPE) advKeyword = NumberUtils.toInt(str.substring(1)); if (str.charAt(0) == SearchService.ADV_SPACE) space = str.substring(1); if (str.charAt(0) == SearchService.ADV_SOURCE_TYPES) srcType = NumberUtils.toInt(str.substring(1)); if (str.charAt(0) == SearchService.ADV_DATE_SCOPE) { String fromStr = str.substring(1); int sep = fromStr.indexOf(":"); if (sep != -1) { from = NumberUtils.toLong(fromStr.substring(0, sep)); to = NumberUtils.toLong(fromStr.substring(sep + 1)); if (from != 0 && to == 0) { //from: (to is missed) to = new Date().getTime(); } } else { from = NumberUtils.toLong(fromStr); to = new Date().getTime(); } } if (str.charAt(0) == SearchService.ADV_GROUP_BY && NumberUtils .toInt(Character.valueOf(str.charAt(1)).toString()) == SearchService.GROUP_SPACE) { groupBySpace = true; } } } keyword = QueryParser.escape(StringUtils.trimToEmpty(keyword)); QueryParser parser = new QueryParser(LuceneConfig.VERSION, FieldName.CONTENT, searcherFactory.getAnalyzer()); if (advKeyword == SearchService.KEYWORD_EXACT) keyword = "\"" + keyword + "\""; else if (advKeyword == SearchService.KEYWORD_ALL) { String[] words = keyword.split(" "); StringBuffer buf = new StringBuffer(); for (String word : words) { buf.append("+").append(word).append(" "); } keyword = buf.toString().trim(); } //highlight query on return result, could be null Query hlQuery = null; if (keyword.length() > 0) { //Lucene throw exception if keyword is empty hlQuery = parser.parse(keyword); } //date scope if (from != 0 && to != 0) { keyword += " [" + from + " TO " + to + "]"; } Query keyQuery = parser.parse(keyword); Query spaceQuery = null; //space scope if (!StringUtils.isBlank(space)) { //as here is not necessary to limit search type: as only page, comment, pageTag, attachment //has UNSEARCH_SPACE_UNIXNAME field, so the search type is already restrict these four types spaceQuery = new TermQuery(new Term(FieldName.UNSEARCH_SPACE_UNIXNAME, space.trim().toLowerCase())); } //type filter List<Query> typeQueries = null; if (srcType != 0) { typeQueries = new ArrayList<Query>(); TermQuery tq; if ((srcType & SearchService.INDEX_PAGE) > 0) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_PAGE + "")); typeQueries.add(tq); } if ((srcType & SearchService.INDEX_SPACE) > 0 && !groupBySpace) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_SPACE + "")); typeQueries.add(tq); } if ((srcType & SearchService.INDEX_COMMENT) > 0) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_COMMENT + "")); typeQueries.add(tq); } if ((srcType & SearchService.INDEX_ROLE) > 0 && !groupBySpace) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_ROLE + "")); typeQueries.add(tq); } if ((srcType & SearchService.INDEX_USER) > 0 && !groupBySpace) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_USER + "")); typeQueries.add(tq); } if ((srcType & SearchService.INDEX_TAGONPAGE) > 0) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_PAGE_TAG + "")); typeQueries.add(tq); } if ((srcType & SearchService.INDEX_TAGONSPACE) > 0 && !groupBySpace) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_SPACE_TAG + "")); typeQueries.add(tq); } if ((srcType & SearchService.INDEX_ATTACHMENT) > 0) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_ATTACHMENT + "")); typeQueries.add(tq); } if ((srcType & SearchService.INDEX_WIDGET) > 0 && !groupBySpace) { tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_WIDGET + "")); typeQueries.add(tq); } } BooleanQuery query = new BooleanQuery(); boolean queryIsEmpty = true; if (keyQuery != null) { queryIsEmpty = false; query.add(keyQuery, Occur.MUST); } if (spaceQuery != null) { queryIsEmpty = false; query.add(spaceQuery, Occur.MUST); } if (groupBySpace && (typeQueries == null || typeQueries.size() == 0)) { //users don't choose any special type, but sort by space, so it need give limitation on search type //so far - page, comment, attachment, tag on page are for Space type typeQueries = new ArrayList<Query>(); TermQuery tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_PAGE + "")); typeQueries.add(tq); tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_COMMENT + "")); typeQueries.add(tq); tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_COMMENT + "")); typeQueries.add(tq); tq = new TermQuery(new Term(FieldName.DOC_TYPE, SharedConstants.SEARCH_PAGE_TAG + "")); typeQueries.add(tq); } if (typeQueries != null && typeQueries.size() > 0) { BooleanQuery typeQuery = new BooleanQuery(); for (Query typeQ : typeQueries) { typeQuery.add(typeQ, Occur.SHOULD); } queryIsEmpty = false; query.add(typeQuery, Occur.MUST); } return new Query[] { queryIsEmpty ? null : query, hlQuery }; }
From source file:com.hangum.tadpole.manager.core.dialogs.users.NewUserDialog.java
@Override protected void okPressed() { String strEmail = StringUtils.trimToEmpty(textEMail.getText()); String passwd = StringUtils.trimToEmpty(textPasswd.getText()); String rePasswd = StringUtils.trimToEmpty(textRePasswd.getText()); String name = StringUtils.trimToEmpty(textName.getText()); if (!validation(strEmail, passwd, rePasswd, name)) return;// w w w .jav a 2s . c o m if (btnGetOptCode.getSelection()) { if ("".equals(textOTPCode.getText())) { //$NON-NLS-1$ MessageDialog.openError(getShell(), "Error", Messages.NewUserDialog_40); //$NON-NLS-1$ textOTPCode.setFocus(); return; } if (!GoogleAuthManager.getInstance().isValidate(secretKey, NumberUtils.toInt(textOTPCode.getText()))) { MessageDialog.openError(getShell(), "Error", Messages.NewUserDialog_42); //$NON-NLS-1$ textOTPCode.setFocus(); return; } } try { /** * ? ?? ? ? NO , YES . */ String approvalYn = ApplicationArgumentUtils.getNewUserPermit() ? PublicTadpoleDefine.YES_NO.NO.toString() : PublicTadpoleDefine.YES_NO.YES.toString(); String strEmailConformKey = Utils.getUniqueDigit(7); TadpoleSystem_UserQuery.newUser(PublicTadpoleDefine.INPUT_TYPE.NORMAL.toString(), strEmail, strEmailConformKey, PublicTadpoleDefine.YES_NO.NO.toString(), passwd, PublicTadpoleDefine.USER_ROLE_TYPE.ADMIN.toString(), name, comboLanguage.getText(), approvalYn, btnGetOptCode.getSelection() ? "YES" : "NO", textSecretKey.getText()); //$NON-NLS-1$ //$NON-NLS-2$ sendEmailAccessKey(name, strEmail, strEmailConformKey); MessageDialog.openInformation(null, "Confirm", Messages.NewUserDialog_31); //$NON-NLS-1$ } catch (Exception e) { logger.error(Messages.NewUserDialog_8, e); MessageDialog.openError(getParentShell(), Messages.NewUserDialog_14, e.getMessage()); return; } super.okPressed(); }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.composite.PostgresLoginComposite.java
@Override public boolean makeUserDBDao(boolean isTest) { if (!isValidateInput(isTest)) return false; String dbUrl = String.format(getSelectDB().getDB_URL_INFO(), StringUtils.trimToEmpty(textHost.getText()), StringUtils.trimToEmpty(textPort.getText()), StringUtils.trimToEmpty(textDatabase.getText())); if (PublicTadpoleDefine.YES_NO.YES.name().equals(comboSSL.getText())) { dbUrl += "?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"; //$NON-NLS-1$ if (!"".equals(textJDBCOptions.getText())) { //$NON-NLS-1$ dbUrl += "&" + textJDBCOptions.getText(); //$NON-NLS-1$ }/*from ww w .j a v a2s . co m*/ } else { if (!"".equals(textJDBCOptions.getText())) { //$NON-NLS-1$ dbUrl += "?" + textJDBCOptions.getText(); //$NON-NLS-1$ } } userDB = new UserDBDAO(); userDB.setDbms_type(getSelectDB().getDBToString()); userDB.setUrl(dbUrl); userDB.setUrl_user_parameter(textJDBCOptions.getText()); userDB.setDb(StringUtils.trimToEmpty(textDatabase.getText())); userDB.setGroup_name(StringUtils.trimToEmpty(preDBInfo.getComboGroup().getText())); userDB.setDisplay_name(StringUtils.trimToEmpty(preDBInfo.getTextDisplayName().getText())); String dbOpType = PublicTadpoleDefine.DBOperationType .getNameToType(preDBInfo.getComboOperationType().getText()).name(); userDB.setOperation_type(dbOpType); if (dbOpType.equals(PublicTadpoleDefine.DBOperationType.PRODUCTION.name()) || dbOpType.equals(PublicTadpoleDefine.DBOperationType.BACKUP.name())) { userDB.setIs_lock(PublicTadpoleDefine.YES_NO.YES.name()); } userDB.setHost(StringUtils.trimToEmpty(textHost.getText())); userDB.setPort(StringUtils.trimToEmpty(textPort.getText())); userDB.setUsers(StringUtils.trimToEmpty(textUser.getText())); userDB.setPasswd(StringUtils.trimToEmpty(textPassword.getText())); userDB.setExt1(comboSSL.getText()); // ? ?? ? . userDB.setRole_id(PublicTadpoleDefine.USER_ROLE_TYPE.ADMIN.toString()); // others connection . setOtherConnectionInfo(); return true; }
From source file:de.fhg.iais.cortex.search.IndexerImpl.java
private static String stripHtmlAndPrune(final String input, final int maxlength) { String label = StringUtils.trimToEmpty(input.replaceAll("\\<.*?>", "")); final int securesize = maxlength * 2; if (label.length() > securesize) { //to avoid useless computation in next step label = label.substring(0, securesize); }// w w w . ja v a 2s. com char[] chars = label.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (Character.isWhitespace(c) && (' ' != c)) { chars[i] = ' '; } } label = new String(chars).replaceAll(" {2,}", " "); final int finalsize = label.length(); if (finalsize >= maxlength) { if (maxlength > 12) { return label.substring(0, maxlength - 3) + "..."; } else { return label.substring(0, maxlength); } } else { return label; } }
From source file:gtu._work.ui.RegexDirReplacer.java
private void initGUI() { try {//from w w w . java 2 s. c om { } BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("source", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { ListModel srcListModel = new DefaultListModel(); srcList = new JList(); jScrollPane1.setViewportView(srcList); srcList.setModel(srcListModel); { panel = new JPanel(); jScrollPane1.setRowHeaderView(panel); panel.setLayout(new FormLayout( new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); { childrenDirChkbox = new JCheckBox("??"); childrenDirChkbox.setSelected(true); panel.add(childrenDirChkbox, "1, 1"); } { subFileNameText = new JTextField(); panel.add(subFileNameText, "1, 2, fill, default"); subFileNameText.setColumns(10); subFileNameText.setText("(txt|java)"); } { replaceOldFileChkbox = new JCheckBox(""); replaceOldFileChkbox.setSelected(true); panel.add(replaceOldFileChkbox, "1, 3"); } { charsetText = new JTextField(); panel.add(charsetText, "1, 5, fill, default"); charsetText.setColumns(10); charsetText.setText("UTF8"); } } srcList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JListUtil.newInstance(srcList).defaultMouseClickOpenFile(evt); JPopupMenuUtil.newInstance(srcList).applyEvent(evt)// .addJMenuItem("load files from clipboard", new ActionListener() { public void actionPerformed(ActionEvent arg0) { String content = ClipboardUtil.getInstance().getContents(); DefaultListModel model = (DefaultListModel) srcList.getModel(); StringTokenizer tok = new StringTokenizer(content, "\t\n\r\f", false); for (; tok.hasMoreElements();) { String val = ((String) tok.nextElement()).trim(); model.addElement(new File(val)); } } }).show(); } }); srcList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(srcList).defaultJListKeyPressed(evt); } }); } } { addDirFiles = new JButton(); jPanel1.add(addDirFiles, BorderLayout.NORTH); addDirFiles.setText("add dir files"); addDirFiles.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null || !file.isDirectory()) { return; } List<File> fileLst = new ArrayList<File>(); String subName = StringUtils.trimToEmpty(subFileNameText.getText()); if (StringUtils.isBlank(subName)) { subName = ".*"; } String patternStr = ".*\\." + subName; if (childrenDirChkbox.isSelected()) { FileUtil.searchFileMatchs(file, patternStr, fileLst); } else { for (File f : file.listFiles()) { if (f.isFile() && f.getName().matches(patternStr)) { fileLst.add(f); } } } DefaultListModel model = new DefaultListModel(); for (File f : fileLst) { model.addElement(f); } srcList.setModel(model); } }); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("param", null, jPanel2, null); { exeucte = new JButton(); jPanel2.add(exeucte, BorderLayout.SOUTH); exeucte.setText("exeucte"); exeucte.setPreferredSize(new java.awt.Dimension(491, 125)); exeucte.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exeucteActionPerformed(evt); } }); } { jPanel3 = new JPanel(); GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel2.add(jPanel3, BorderLayout.CENTER); { repFromText = new JTextField(); } { repToText = new JTextField(); } jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup() .addContainerGap(25, 25) .addGroup(jPanel3Layout.createParallelGroup() .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))) .addContainerGap(20, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); } { addToTemplate = new JButton(); jPanel2.add(addToTemplate, BorderLayout.NORTH); addToTemplate.setText("add to template"); addToTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { prop.put(repFromText.getText(), repToText.getText()); reloadTemplateList(); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("result", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.CENTER); { ListModel newRepListModel = new DefaultListModel(); newRepList = new JList(); jScrollPane2.setViewportView(newRepList); newRepList.setModel(newRepListModel); newRepList.addMouseListener(new MouseAdapter() { static final String tortoiseMergeExe = "TortoiseMerge.exe"; static final String commandFormat = "cmd /c call \"%s\" /base:\"%s\" /theirs:\"%s\""; public void mouseClicked(MouseEvent evt) { if (!JListUtil.newInstance(newRepList).isCorrectMouseClick(evt)) { return; } OldNewFile oldNewFile = (OldNewFile) JListUtil .getLeadSelectionObject(newRepList); String base = oldNewFile.newFile.getAbsolutePath(); String theirs = oldNewFile.oldFile.getAbsolutePath(); String command = String.format(commandFormat, tortoiseMergeExe, base, theirs); System.out.println(command); try { Runtime.getRuntime().exec(command); } catch (IOException e) { JCommonUtil.handleException(e); } } }); newRepList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { Object[] objects = (Object[]) newRepList.getSelectedValues(); if (objects == null || objects.length == 0) { return; } DefaultListModel model = (DefaultListModel) newRepList.getModel(); int lastIndex = model.getSize() - 1; Object swap = null; StringBuilder dsb = new StringBuilder(); for (Object current : objects) { int index = model.indexOf(current); switch (evt.getKeyCode()) { case 38:// up if (index != 0) { swap = model.getElementAt(index - 1); model.setElementAt(swap, index); model.setElementAt(current, index - 1); } break; case 40:// down if (index != lastIndex) { swap = model.getElementAt(index + 1); model.setElementAt(swap, index); model.setElementAt(current, index + 1); } break; case 127:// del OldNewFile current_ = (OldNewFile) current; dsb.append(current_.newFile.getName() + "\t" + (current_.newFile.delete() ? "T" : "F") + "\n"); current_.newFile.delete(); model.removeElement(current); } } if (dsb.length() > 0) { JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("del result!\n" + dsb, "DELETE"); } } }); } } { replaceOrignFile = new JButton(); jPanel4.add(replaceOrignFile, BorderLayout.SOUTH); replaceOrignFile.setText("replace orign file"); replaceOrignFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DefaultListModel model = (DefaultListModel) newRepList.getModel(); StringBuilder sb = new StringBuilder(); for (int ii = 0; ii < model.size(); ii++) { OldNewFile file = (OldNewFile) model.getElementAt(ii); boolean delSuccess = false; boolean renameSuccess = false; if (delSuccess = file.oldFile.delete()) { renameSuccess = file.newFile.renameTo(file.oldFile); } sb.append(file.oldFile.getName() + " del:" + (delSuccess ? "T" : "F") + " rename:" + (renameSuccess ? "T" : "F") + "\n"); } JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(sb, getTitle()); } }); } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jTabbedPane1.addTab("template", null, jPanel5, null); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); { templateList = new JList(); reloadTemplateList(); jScrollPane3.setViewportView(templateList); templateList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (templateList.getLeadSelectionIndex() == -1) { return; } Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil .getLeadSelectionObject(templateList); repFromText.setText((String) entry.getKey()); repToText.setText((String) entry.getValue()); } }); templateList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(templateList).defaultJListKeyPressed(evt); } }); } } { scheduleExecute = new JButton(); jPanel5.add(scheduleExecute, BorderLayout.SOUTH); scheduleExecute.setText("schedule execute"); scheduleExecute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { scheduleExecuteActionPerformed(evt); } }); } } } this.setSize(512, 350); JCommonUtil.setFontAll(this.getRootPane()); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { if (StringUtils.isNotBlank(repFromText.getText())) { prop.put(repFromText.getText(), repToText.getText()); } try { prop.store(new FileOutputStream(propFile), "regexText"); } catch (Exception e) { JCommonUtil.handleException("properties store error!", e); } setVisible(false); dispose(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.haulmont.restapi.auth.ClientProxyTokenStore.java
protected String makeClientInfo(String userAgent) { //noinspection UnnecessaryLocalVariable String serverInfo = String.format("REST API (%s:%s/%s) %s", globalConfig.getWebHostName(), globalConfig.getWebPort(), globalConfig.getWebContextName(), StringUtils.trimToEmpty(userAgent)); return serverInfo; }
From source file:com.hangum.tadpole.rdb.core.actions.oracle.TableSapceManageEditor.java
@Override public void createPartControl(Composite parent) { GridLayout gl_parent = new GridLayout(1, false); gl_parent.verticalSpacing = 1;/*w w w. j a va2 s. c o m*/ gl_parent.marginHeight = 1; gl_parent.horizontalSpacing = 1; gl_parent.marginWidth = 1; parent.setLayout(gl_parent); Composite compositeToolbar = new Composite(parent, SWT.NONE); compositeToolbar.setLayout(new GridLayout(2, false)); compositeToolbar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); ToolBar toolBar = new ToolBar(compositeToolbar, SWT.FLAT | SWT.RIGHT); GridData gd_toolBar = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_toolBar.widthHint = 267; toolBar.setLayoutData(gd_toolBar); ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE); tltmRefresh.setToolTipText(CommonMessages.get().Refresh); tltmRefresh.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "resources/icons/refresh.png")); //$NON-NLS-1$ tltmRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { refreshTablespaceList(); } }); lblDbname = new Label(compositeToolbar, SWT.NONE); lblDbname.setText(""); //$NON-NLS-1$ columnFilter = new DefaultTableColumnFilter(); Composite compositeTablespaceList = new Composite(parent, SWT.NONE); GridData gd_compositeTablespaceList = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_compositeTablespaceList.minimumHeight = 200; compositeTablespaceList.setLayoutData(gd_compositeTablespaceList); compositeTablespaceList.setLayout(new GridLayout(1, false)); tableViewer = new TableViewer(compositeTablespaceList, SWT.BORDER | SWT.FULL_SELECTION); Table tableTablespace = tableViewer.getTable(); tableTablespace.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tableTablespace.setHeaderVisible(true); tableTablespace.setLinesVisible(true); tableViewer.addFilter(columnFilter); tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (tableViewer.getSelection().isEmpty()) { return; } StructuredSelection ss = (StructuredSelection) tableViewer.getSelection(); tablespaceDao = (OracleTablespaceDAO) ss.getFirstElement(); List<HashMap<String, String>> datafileList = new ArrayList<HashMap<String, String>>(); try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); datafileList = (List<HashMap<String, String>>) sqlClient .queryForList("getTablespaceDataFileList", tablespaceDao.getTablespace_name()); //$NON-NLS-1$ } catch (Exception e) { logger.error("Tablespace detail information loading...", e); //$NON-NLS-1$ } textDropScript.setText(StringUtils.trimToEmpty(getDropScript())); makeCreateScript(); tableViewer_datafiles.setInput(datafileList); tableViewer_datafiles.refresh(); if (datafileList.size() > 0) { tableViewer_datafiles .setSelection(new StructuredSelection(tableViewer_datafiles.getElementAt(0)), true); refreshDatafileInformation(); } else { // ?? ?? ?? . tableViewer_property.setInput(new ArrayList<Map<String, String>>()); tableViewer_property.refresh(); } } }); Group grpQuery = new Group(parent, SWT.NONE); grpQuery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); grpQuery.setText("Detail Information"); GridLayout gl_grpQuery = new GridLayout(1, false); gl_grpQuery.verticalSpacing = 1; gl_grpQuery.horizontalSpacing = 1; gl_grpQuery.marginHeight = 1; gl_grpQuery.marginWidth = 1; grpQuery.setLayout(gl_grpQuery); Composite composite = new Composite(grpQuery, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); composite.setLayout(new FillLayout(SWT.HORIZONTAL)); SashForm sashForm = new SashForm(composite, SWT.NONE); SashForm sashForm_1 = new SashForm(sashForm, SWT.VERTICAL); Composite composite_2 = new Composite(sashForm_1, SWT.BORDER); GridLayout gl_composite_2 = new GridLayout(1, false); gl_composite_2.verticalSpacing = 0; gl_composite_2.horizontalSpacing = 0; gl_composite_2.marginHeight = 0; gl_composite_2.marginWidth = 0; composite_2.setLayout(gl_composite_2); tableViewer_datafiles = new TableViewer(composite_2, SWT.BORDER | SWT.FULL_SELECTION); table_datafiles = tableViewer_datafiles.getTable(); table_datafiles.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); table_datafiles.setLinesVisible(true); table_datafiles.setHeaderVisible(true); tableViewer_datafiles.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (tableViewer_datafiles.getSelection().isEmpty()) { return; } refreshDatafileInformation(); makeCreateScript(); } }); Composite composite_6 = new Composite(composite_2, SWT.NONE); composite_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); GridLayout gl_composite_6 = new GridLayout(2, false); composite_6.setLayout(gl_composite_6); btnDatafileName = new Button(composite_6, SWT.CHECK); btnDatafileName.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { textDataFileName.setEnabled(btnDatafileName.getSelection()); if (btnDatafileName.getSelection()) { StructuredSelection ss = (StructuredSelection) tableViewer_datafiles.getSelection(); if (ss != null) { HashMap<String, Object> datafileMap = (HashMap<String, Object>) ss.getFirstElement(); String fileName = (String) datafileMap.get("FILE_NAME"); int cnt = tableViewer_datafiles.getTable().getItemCount() + 1; fileName = StringUtils.replaceOnce(fileName, ".", "_Copy" + cnt + "."); textDataFileName.setText(fileName); } else { textDataFileName.setFocus(); } } makeAddDatafileScript(); } }); btnDatafileName.setText("Datafile Name"); textDataFileName = new Text(composite_6, SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE); textDataFileName.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent event) { makeAddDatafileScript(); } }); textDataFileName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textDataFileName.setText("Auto"); textDataFileName.setEnabled(false); Label lblNewLabel_2 = new Label(composite_6, SWT.NONE); lblNewLabel_2.setText("Datafile Size(MB)"); Composite composite_7 = new Composite(composite_6, SWT.NONE); GridLayout gl_composite_7 = new GridLayout(2, false); gl_composite_7.verticalSpacing = 0; gl_composite_7.horizontalSpacing = 0; gl_composite_7.marginWidth = 0; gl_composite_7.marginHeight = 0; composite_7.setLayout(gl_composite_7); textDatafileSize = new Text(composite_7, SWT.BORDER | SWT.RIGHT); textDatafileSize.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent event) { makeAddDatafileScript(); } }); GridData gd_textDatafileSize = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_textDatafileSize.widthHint = 60; textDatafileSize.setLayoutData(gd_textDatafileSize); textDatafileSize.setText("5"); btnReuse = new Button(composite_7, SWT.CHECK); btnReuse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { makeAddDatafileScript(); } }); btnReuse.setText("Reuse"); Composite composite_5 = new Composite(composite_2, SWT.NONE); composite_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); composite_5.setLayout(new GridLayout(4, false)); btnAutoExtend = new Button(composite_5, SWT.CHECK); btnAutoExtend.setSelection(true); btnAutoExtend.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { textAutoExtendSize.setEnabled(btnAutoExtend.getSelection()); btnMaximumSize.setEnabled(btnAutoExtend.getSelection()); textMaximumSize.setEnabled(btnAutoExtend.getSelection()); makeAddDatafileScript(); } }); btnAutoExtend.setText("Auto Extend"); Label lblExtendSize = new Label(composite_5, SWT.NONE); lblExtendSize.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblExtendSize.setText("Extend Size(MB)"); textAutoExtendSize = new Text(composite_5, SWT.BORDER | SWT.RIGHT); textAutoExtendSize.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent event) { makeAddDatafileScript(); } }); textAutoExtendSize.setText("5"); textAutoExtendSize.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(composite_5, SWT.NONE); btnMaximumSize = new Button(composite_5, SWT.CHECK); btnMaximumSize.setSelection(true); btnMaximumSize.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { textMaximumSize.setEnabled(!btnMaximumSize.getSelection()); textMaximumSize.setText((1024 * 5) + ""); //5GB textMaximumSize.setFocus(); textMaximumSize.setSelection(0, textMaximumSize.getText().length()); makeAddDatafileScript(); } }); btnMaximumSize.setText("Maximum Unlimited"); Label lblMaximumSizemb = new Label(composite_5, SWT.NONE); lblMaximumSizemb.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblMaximumSizemb.setText("Maximum Size(MB)"); textMaximumSize = new Text(composite_5, SWT.BORDER | SWT.RIGHT); textMaximumSize.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent event) { makeAddDatafileScript(); } }); textMaximumSize.setEnabled(false); textMaximumSize.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button btnAddDatafile = new Button(composite_5, SWT.NONE); btnAddDatafile.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { makeAddDatafileScript(); } }); btnAddDatafile.setText("Add Datafile"); tableViewer_property = new TableViewer(sashForm_1, SWT.BORDER | SWT.FULL_SELECTION); table = tableViewer_property.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); TableViewerColumn tvPropertyName = new TableViewerColumn(tableViewer_property, SWT.NONE); TableColumn tcPropertyName = tvPropertyName.getColumn(); tcPropertyName.setWidth(180); tcPropertyName.setText("Property"); TableViewerColumn tvPropertyValue = new TableViewerColumn(tableViewer_property, SWT.NONE); TableColumn tcPropertyValue = tvPropertyValue.getColumn(); tcPropertyValue.setWidth(300); tcPropertyValue.setText("Value"); tableViewer_property.setContentProvider(new ArrayContentProvider()); tableViewer_property.setLabelProvider(new TablespaceExtInfoLabelProvider()); sashForm_1.setWeights(new int[] { 1, 1 }); Composite composite_1 = new Composite(sashForm, SWT.BORDER); composite_1.setLayout(new GridLayout(1, false)); Label lblNewLabel_1 = new Label(composite_1, SWT.NONE); lblNewLabel_1.setText("Drop Tablespace"); textDropScript = new Text(composite_1, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI); textDropScript.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); GridData gd_textDropScript = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_textDropScript.minimumHeight = 20; textDropScript.setLayoutData(gd_textDropScript); Composite composite_4 = new Composite(composite_1, SWT.NONE); composite_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); composite_4.setLayout(new GridLayout(3, false)); btnIncludingContents = new Button(composite_4, SWT.CHECK); btnIncludingContents.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // ?? ?? . btnCascadeConstraints.setEnabled(btnIncludingContents.getSelection()); textDropScript.setText(getDropScript()); } }); btnIncludingContents.setText("Including Contents?"); btnCascadeConstraints = new Button(composite_4, SWT.CHECK); btnCascadeConstraints.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // ? . textDropScript.setText(getDropScript()); } }); btnCascadeConstraints.setEnabled(false); btnCascadeConstraints.setText("Cascade Constraints?"); Button btnDrop = new Button(composite_4, SWT.NONE); btnDrop.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { //Excute script RequestResultDAO reqReResultDAO = new RequestResultDAO(); try { ExecuteDDLCommand.executSQL(userDB, reqReResultDAO, textDropScript.getText().trim()); } catch (Exception ex) { logger.error(ex); } //$NON-NLS-1$ if (PublicTadpoleDefine.SUCCESS_FAIL.F.name().equals(reqReResultDAO.getResult())) { MessageDialog.openError(getSite().getShell(), CommonMessages.get().Error, Messages.get().RiseError + reqReResultDAO.getMesssage() + reqReResultDAO.getException().getMessage()); } else { MessageDialog.openInformation(getSite().getShell(), CommonMessages.get().Information, Messages.get().WorkHasCompleted); refreshTablespaceList(); } } }); btnDrop.setSize(94, 28); btnDrop.setText("Drop Tablespace"); Label lblNewLabel = new Label(composite_1, SWT.NONE); lblNewLabel.setText("Create Tablespace && Add Datafile"); textScript = new Text(composite_1, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); textScript.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite composite_3 = new Composite(composite_1, SWT.NONE); composite_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); Button btnExecute = new Button(composite_3, SWT.NONE); btnExecute.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { //Excute script RequestResultDAO reqReResultDAO = new RequestResultDAO(); try { ExecuteDDLCommand.executSQL(userDB, reqReResultDAO, textScript.getText().trim()); } catch (Exception ex) { logger.error(ex); } //$NON-NLS-1$ if (PublicTadpoleDefine.SUCCESS_FAIL.F.name().equals(reqReResultDAO.getResult())) { MessageDialog.openError(getSite().getShell(), CommonMessages.get().Error, Messages.get().RiseError + reqReResultDAO.getMesssage() + reqReResultDAO.getException().getMessage()); } else { MessageDialog.openInformation(getSite().getShell(), CommonMessages.get().Information, Messages.get().WorkHasCompleted); refreshTablespaceList(); refreshDatafileInformation(); } } }); btnExecute.setBounds(0, 0, 150, 28); btnExecute.setText("Execute Script"); sashForm.setWeights(new int[] { 1, 1 }); createTableColumn(); createTableDataFileColumn(); initUI(); }
From source file:com.egt.core.db.util.Exporter.java
static ExporterMessage export(String report, String number, String userid, String target, String format, String select, Object[] args, boolean logging) { Bitacora.trace(Exporter.class, "export", report, number, target, format); String informe = StringUtils.trimToEmpty(report); Long rastro = trimToNullNumber(number); Long usuario = StringUtils.isNotBlank(userid) && StringUtils.isNumeric(userid) ? Long.valueOf(userid) : null;//from w w w .ja v a 2s. co m String destino = trimToNullTarget(target); EnumFormatoArchivo tipo = getExportType(format); String decode = Utils.decodeSelect(trimToNullSelect(select)); return export(informe, rastro, usuario, destino, tipo, decode, args, logging); }