List of usage examples for org.apache.commons.lang.time DateFormatUtils format
public static String format(Date date, String pattern)
Formats a date/time into a specific pattern.
From source file:com.rayo.client.auth.SASLAuthentication.java
private String bindResourceAndEstablishSession(String resource, int timeout) throws XmppException { try {/*from www . j a va 2 s. c o m*/ bindingLatch.await(timeout, TimeUnit.SECONDS); } catch (InterruptedException e1) { e1.printStackTrace(); } if (!resourceBinded) { // Server never offered resource binding log.trace(String.format("[%s] Bind not received on SASLAuthentication instance [%s]", DateFormatUtils.format(new Date(), "hh:mm:ss.SSS"), this)); log.trace("Count down latch: " + bindingLatch.getCount()); throw new XmppException("Resource binding not offered by server"); } IQ iqBind = new IQ(IQ.Type.set, new Bind().setResource(resource)); XmppObjectFilter filter = new XmppObjectIdFilter(iqBind.getId()); log.trace("Adding bind filter " + filter + " to connection " + connection); connection.addFilter(filter); connection.send(iqBind); IQ response = (IQ) filter.poll(10000); filter.stop(); if (response == null) { log.error("No response for bind message"); throw new XmppException("No response from the server."); } // If the server replied with an error, throw an exception. else if (response.getType() == IQ.Type.error) { throw new XmppException(response.getError()); } Bind bind = response.getBind(); String userJID = bind.getJID(); // with the new async refactoring, session can take a bit to arrive try { sessionLatch.await(2, TimeUnit.SECONDS); } catch (InterruptedException e1) { } if (sessionSupported) { IQ iqSession = new IQ().setChild(new Session()).setType(Type.set); filter = new XmppObjectIdFilter(iqSession.getId()); connection.addFilter(filter); connection.send(iqSession); IQ ack = (IQ) filter.poll(10000); filter.stop(); if (ack == null) { log.error("No response for session message"); throw new XmppException("No response from the server."); } // If the server replied with an error, throw an exception. else if (ack.getType() == IQ.Type.error) { throw new XmppException(ack.getError()); } } else { // Server never offered session establishment throw new XmppException("Session establishment not offered by server"); } return userJID; }
From source file:de.iteratec.iteraplan.businesslogic.service.FastExportServiceImplTest.java
/** * Test method for {@link de.iteratec.iteraplan.businesslogic.service.FastExportServiceImpl#configureMasterplanOptionsForFastExport(de.iteratec.iteraplan.businesslogic.reports.query.options.GraphicalReporting.Masterplan.MasterplanOptionsBean, de.iteratec.iteraplan.model.RuntimePeriod)}. *///from w w w.ja va 2 s . com @Test public void testConfigureMasterplanOptionsForFastExport() { MasterplanOptionsBean bean = new MasterplanOptionsBean(); bean.setLevel0Options( new MasterplanRowTypeOptions("", TypeOfBuildingBlock.INFORMATIONSYSTEMRELEASE.getValue(), 0, new ArrayList<DateInterval>(), new ArrayList<BBAttribute>(), new ArrayList<ColumnEntry>())); bean.getLevel0Options().setHierarchicalSort(true); Date now = new Date(); Date start = DateUtils.addMonths(now, -HALF_YEAR_IN_MONTHS); Date end = DateUtils.addMonths(now, HALF_YEAR_IN_MONTHS); RuntimePeriod period = new RuntimePeriod(start, end); fastExportServiceImpl.configureMasterplanOptionsForFastExport(bean, period); assertTrue(bean.getLevel0Options().isHierarchicalSort()); assertEquals(DateFormatUtils.format(start, "MM/dd/yyyy"), bean.getStartDateString()); assertEquals(DateFormatUtils.format(end, "MM/dd/yyyy"), bean.getEndDateString()); }
From source file:com.turborep.turbotracker.sales.service.Salesserviceimpl.java
@Override public ArrayList<JobsBean> getPending(SalesRepBean theSalesRep, Integer rxCustomerID) { itsLogger.debug("Retrieving getPending"); Integer aSalesRepId = theSalesRep.getSalesRepId(); if (aSalesRepId == 0) { aSalesRepId = null;// w ww .j a v a 2s .co m } String aName = ""; String aname2 = ""; if (rxCustomerID != null && rxCustomerID != 0) { aname2 = " AND joBidder.rxMasterID = " + rxCustomerID; } if (aSalesRepId != -1) { aName = " WHERE jM.jobStatus = 1 AND BidDate < CURDATE() AND joQuoteHistory.joMasterID IS NULL " + "AND (" + "jM.cuAssignmentID0 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID1 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID2 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID3 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID4 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID5 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID6 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID6 = " + theSalesRep.getSalesRepId() + ") " + aname2 + " GROUP BY BidDate ORDER BY BidDate DESC"; /* * aname2 = " WHERE " + "(cu.cuAssignmentID0 = " + * theSalesRep.getSalesRepId() + " OR " + "cu.cuAssignmentID1 = " + * theSalesRep.getSalesRepId() + " OR " + "cu.cuAssignmentID2 = " + * theSalesRep.getSalesRepId() + " OR " + "cu.cuAssignmentID3 = " + * theSalesRep.getSalesRepId() + " OR " + "cu.cuAssignmentID4 = " + * theSalesRep.getSalesRepId() + ")) " + * "GROUP BY biddate ORDER BY biddate DESC"; */ } else { aName = " WHERE jM.jobStatus = 1 AND BidDate < CURDATE() AND joQuoteHistory.joMasterID IS NULL " + aname2 + " GROUP BY BidDate ORDER BY BidDate DESC"; /* aname2 = ") GROUP BY jM.biddate ORDER BY BidDate DESC"; */ } String aPendingQry = "SELECT DISTINCT jM.biddate AS BidDate, " + "jM.jobnumber, " + "jM.description, " + "rxMaster.name, " + "SUM(joQuoteHeader.quoteamount),jM.joMasterID " + "FROM joMaster jM " + "JOIN joQuoteHeader ON jM.joMasterId=joQuoteHeader.joMasterId " + "LEFT JOIN joQuoteHistory ON joQuoteHistory.joMasterID=jM.joMasterID " + "LEFT JOIN joBidder ON joBidder.joMasterID=jM.joMasterID " + "LEFT JOIN rxMaster ON rxMaster.rxMasterID=joBidder.rxMasterID " + aName; Session aSession = null; ArrayList<JobsBean> aPendingQuotes = new ArrayList<JobsBean>(); try { JobsBean aSalesPendingBean = null; aSession = itsSessionFactory.openSession(); Query aQuery = aSession.createSQLQuery(aPendingQry); Iterator<?> aIterator = aQuery.list().iterator(); while (aIterator.hasNext()) { aSalesPendingBean = new JobsBean(); Object[] aObj = (Object[]) aIterator.next(); if (aObj[0] != null) { aSalesPendingBean.setBidDate((String) DateFormatUtils.format((Date) aObj[0], "MM/dd/yyyy")); } aSalesPendingBean.setJobNo((String) aObj[1]); aSalesPendingBean.setJobName((String) aObj[2]); aSalesPendingBean.setAssignedCustomers((String) aObj[3]); aSalesPendingBean.setQuoteAmount((BigDecimal) aObj[4]); aSalesPendingBean.setJoMasterId((Integer) aObj[5]); aPendingQuotes.add(aSalesPendingBean); } } catch (Exception e) { itsLogger.error(e.getMessage(), e); } finally { aSession.flush(); aSession.close(); aPendingQry = null; } return aPendingQuotes; }
From source file:com.sisrni.managedbean.BecaConsultarMB.java
public void preUpdate(Integer id) { inicializador();/*from w w w . j a va2 s . c o m*/ try { Beca aux = becaService.findById(id); if (aux != null) { beca = aux; becario = getPersonaBeca(beca.getPersonaBecaList(), "BECARIO"); asesorInterno = getPersonaBeca(beca.getPersonaBecaList(), "ASESOR INTERNO"); if (asesorInterno == null) { tabInternoBoolean = Boolean.FALSE; mostrarTabInterno = Boolean.FALSE; noEstabaInterno = true; } else { tabInternoBoolean = Boolean.TRUE; mostrarTabInterno = Boolean.TRUE; noEstabaInterno = false; } asesorExterno = getPersonaBeca(beca.getPersonaBecaList(), "ASESOR EXTERNO"); if (asesorExterno == null) { tabExternoBoolean = Boolean.FALSE; mostrarTabExterno = Boolean.FALSE; noEstabaExterno = true; } else { tabExternoBoolean = Boolean.TRUE; mostrarTabExterno = Boolean.TRUE; noEstabaExterno = false; } buscarBecario(becario.getDuiPersona()); if (asesorInterno != null) { buscarInterno(asesorInterno.getDuiPersona()); } else { asesorInterno = new Persona(); } if (asesorExterno != null) { buscarExterno(asesorExterno.getPasaporte()); } else { asesorExterno = new Persona(); } organismoCooperanteSelected = beca.getIdOrganismoCooperante(); organismoCooperanteList.clear(); organismoCooperanteList.add(organismoCooperanteSelected); tipoBecaSelected = beca.getIdTipoBeca(); tipoBecaList.clear(); tipoBecaList.add(tipoBecaSelected); tipoCambioSelected = tipoCambioService.findById(2); tipoCambioList.clear(); tipoCambioList.add(tipoCambioSelected); paisCooperanteSelected = paisService.findById(beca.getIdPaisCooperante()); paisList.clear(); paisList.add(paisCooperanteSelected); programaBecaSelected.setIdPrograma(beca.getIdProgramaBeca().getIdPrograma()); programaBecaList.clear(); programaBecaList.add(beca.getIdProgramaBeca()); paisDestinoSelected.setIdPais(beca.getIdPaisDestino()); universidadSelected = beca.getIdUniversidad(); getUniversidadesPorPais(beca.getIdPaisDestino()); universidadList.clear(); universidadList.add(universidadSelected); tipoModalidaBecaSelected = beca.getIdTipoModalidad(); if (tipoModalidaBecaSelected.getIdTipoModalidad() == 1) { mostrarmonto = Boolean.FALSE; modalidad = "PARCIAL"; } else { mostrarmonto = Boolean.TRUE; modalidad = "TOTAL"; } anio = beca.getAnioGestion() + ""; fechaInicioString = DateFormatUtils.format(beca.getFechaInicio(), "dd/MM/yyyy"); fechaFinString = DateFormatUtils.format(beca.getFechaFin(), "dd/MM/yyyy"); if (beca.getOtorgada() == true) { otorgadaString = "SI"; } if (beca.getOtorgada() == false) { otorgadaString = "NO"; } actualizar = Boolean.TRUE; FacesContext.getCurrentInstance().getExternalContext().redirect("consultar.xhtml"); } } catch (Exception e) { } }
From source file:gtu._work.ui.ExportSVNModificationFilesUI.java
private void initGUI() { try {//from w ww . j ava2 s. c om final SwingActionUtil swingUtil = SwingActionUtil.newInstance(this); BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setTitle("SVN BACKUP"); this.setPreferredSize(new java.awt.Dimension(734, 442)); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { swingUtil.invokeAction("jTabbedPane1_changeEvent", evt); } }); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("src text", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { srcArea = new JTextArea(); jScrollPane1.setViewportView(srcArea); } } { loadSrcTextarea = new JButton(); jPanel1.add(loadSrcTextarea, BorderLayout.SOUTH); loadSrcTextarea.setText("load src textarea"); loadSrcTextarea.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("loadSrcTextarea.actionPerformed", evt); } }); } { srcBaseDir = new JButton(); jPanel1.add(srcBaseDir, BorderLayout.NORTH); srcBaseDir.setText("set src base dir"); srcBaseDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("srcBaseDir.actionPerformed", evt); } }); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("src list", null, jPanel2, null); { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(531, 317)); { ListModel srcListModel = new DefaultListModel(); srcList = new JList(); jScrollPane2.setViewportView(srcList); srcList.setModel(srcListModel); srcList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("srcList.mouseClicked", evt); } }); srcList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { swingUtil.invokeAction("srcList.keyPressed", evt); } }); } } { srcListQuery = new JTextField(); srcListQuery.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { public void process(DocumentEvent event) { String scan = JCommonUtil.getDocumentText(event); DefaultListModel model = new DefaultListModel(); Pattern pat = Pattern.compile(scan); for (LineParser line : copySrcListForQuerySet) { if (!line.file.exists()) { continue; } if (line.file.getAbsolutePath().contains(scan)) { model.addElement(line); continue; } try { if (pat.matcher(line.file.getAbsolutePath()).find()) { model.addElement(line); continue; } } catch (Exception ex) { } } srcList.setModel(model); } })); jPanel2.add(srcListQuery, BorderLayout.NORTH); } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("out list", null, jPanel3, null); { jScrollPane3 = new JScrollPane(); jPanel3.add(jScrollPane3, BorderLayout.CENTER); { ListModel outPutListModel = new DefaultListModel(); outPutList = new JList(); jScrollPane3.setViewportView(outPutList); outPutList.setModel(outPutListModel); outPutList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("outPutList.mouseClicked", evt); } }); outPutList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { swingUtil.invokeAction("outPutList.keyPressed", evt); } }); } } { outPutDir = new JButton(); jPanel3.add(outPutDir, BorderLayout.NORTH); outPutDir.setText("set output dir"); outPutDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("outPutDir.actionPerformed", evt); } }); } { execute = new JButton(); jPanel3.add(execute, BorderLayout.SOUTH); execute.setText("execute backup"); execute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("execute.actionPerformed", evt); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("compre", null, jPanel4, null); { jScrollPane4 = new JScrollPane(); jPanel4.add(jScrollPane4, BorderLayout.CENTER); jScrollPane4.setPreferredSize(new java.awt.Dimension(713, 339)); { TableModel compareTableModel = new DefaultTableModel(); compareTable = new JTable(); jScrollPane4.setViewportView(compareTable); compareTable.setModel(compareTableModel); JTableUtil.defaultSetting(compareTable); compareTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("compareTable.mouseClicked", evt); } }); } } { jPanel5 = new JPanel(); jPanel4.add(jPanel5, BorderLayout.NORTH); jPanel5.setPreferredSize(new java.awt.Dimension(713, 42)); { openExternalSrcFolder = new JButton(); jPanel5.add(openExternalSrcFolder); openExternalSrcFolder.setText("open external src folder"); openExternalSrcFolder.setPreferredSize(new java.awt.Dimension(280, 29)); openExternalSrcFolder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("openExternalSrcFolder.actionPerformed", evt); } }); } { startCompareMatch = new JButton(); jPanel5.add(startCompareMatch); startCompareMatch.setText("start compare source"); startCompareMatch.setPreferredSize(new java.awt.Dimension(280, 29)); startCompareMatch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("startCompareMatch.actionPerformed", evt); } }); } } } { jPanel6 = new JPanel(); GroupLayout jPanel6Layout = new GroupLayout((JComponent) jPanel6); jPanel6.setLayout(jPanel6Layout); jTabbedPane1.addTab("configuration", null, jPanel6, null); { DefaultComboBoxModel exportModeComboModel = new DefaultComboBoxModel(); for (ParseMode mode : ParseMode.values()) { exportModeComboModel.addElement(mode); } exportModeCombo = new JComboBox(); exportModeCombo.setModel(exportModeComboModel); } jPanel6Layout.setHorizontalGroup(jPanel6Layout .createSequentialGroup().addContainerGap(41, 41).addComponent(exportModeCombo, GroupLayout.PREFERRED_SIZE, 167, GroupLayout.PREFERRED_SIZE) .addContainerGap(505, Short.MAX_VALUE)); jPanel6Layout .setVerticalGroup(jPanel6Layout.createSequentialGroup().addContainerGap(30, 30) .addComponent(exportModeCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(321, Short.MAX_VALUE)); } { jPanel7 = new JPanel(); BorderLayout jPanel7Layout = new BorderLayout(); jPanel7.setLayout(jPanel7Layout); jTabbedPane1.addTab("error log", null, jPanel7, null); { jScrollPane5 = new JScrollPane(); jPanel7.add(jScrollPane5, BorderLayout.CENTER); { DefaultListModel errorLogListModel = new DefaultListModel(); errorLogList = new JList(); jScrollPane5.setViewportView(errorLogList); errorLogList.setModel(errorLogListModel); } } } } this.setSize(734, 442); swingUtil.addAction("openExternalSrcFolder.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (dir == null) { JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("file is not correct!", "ERROR"); return; } externalDir = dir; } }); swingUtil.addAction("startCompareMatch.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { Validate.notNull(manualBaseDir, "source folder not set!!"); Validate.notNull(externalDir, "external folder not set!!"); Validate.isTrue(!manualBaseDir.equals(externalDir), "source dir : " + manualBaseDir + "\nexternal dir : " + externalDir + "\n cant be the same!!"); List<File> externalSrcFolderList = new ArrayList<File>(); FileUtil.searchFileMatchs(externalDir, ".*", externalSrcFolderList); System.out.println("externalSrcFolderList = " + externalSrcFolderList.size()); List<File> manualBaseSourceList = new ArrayList<File>(); FileUtil.searchFileMatchs(manualBaseDir, ".*", manualBaseSourceList); System.out.println("manualBaseSourceList = " + manualBaseSourceList.size()); String cutExternalPath = FileUtil.exportReceiveBaseDir(externalSrcFolderList).getAbsolutePath(); System.out.println("cutExternalPath = " + cutExternalPath); int cutExternalLength = cutExternalPath.length(); List<CompareFile> _compareList = new ArrayList<CompareFile>(); CompareFile compare = null; File mostCloseFile = null; List<File> searchMatchSrcList = new ArrayList<File>(); for (File external : externalSrcFolderList) { compare = new CompareFile(); compare.external = external; searchMatchSrcList.clear(); mostCloseFile = new File(manualBaseDir, external.getAbsolutePath().substring(cutExternalLength)); System.out.println(mostCloseFile.exists() + " == close file : " + mostCloseFile); if (mostCloseFile.exists()) { searchMatchSrcList.add(mostCloseFile); } else { for (File src : manualBaseSourceList) { if (src.getName().equalsIgnoreCase(external.getName())) { searchMatchSrcList.add(src); } } } System.out.println(external.getName() + " => match source : " + searchMatchSrcList.size()); compare.srcSet = new HashSet<File>(searchMatchSrcList); _compareList.add(compare); } compareList = _compareList; reloadCompareTable(); } }); swingUtil.addAction("compareTable.mouseClicked", new Action() { String tortoiseMergeFormat = "cmd /c call TortoiseMerge /base:\"%s\" /theirs:\"%s\""; String openFileFormat = "cmd /c call \"%s\""; void openFile(File file) { String command = String.format(openFileFormat, file); System.out.println(command); try { ProcessWatcher.newInstance(Runtime.getRuntime().exec(command)).getStreamSync(); System.out.println("do reload..."); reloadCompareTable(); } catch (IOException e1) { JCommonUtil.handleException(e1); } } public void action(EventObject evt) throws Exception { MouseEvent event = (MouseEvent) evt; int rowPos = JTableUtil.newInstance(compareTable).getSelectedRow(); final File external = (File) JTableUtil.newInstance(compareTable).getModel().getValueAt(rowPos, CompareTableIndex.EXTERNAL_FILE.pos); final File srcFile = (File) JTableUtil.newInstance(compareTable).getModel().getValueAt(rowPos, CompareTableIndex.SOURCE_FILE.pos); System.out.println("external : " + external); System.out.println("srcFile : " + srcFile); if (JMouseEventUtil.buttonLeftClick(2, event)) { String command = String.format(tortoiseMergeFormat, external, srcFile); System.out.println(command); Runtime.getRuntime().exec(command); } if (JMouseEventUtil.buttonRightClick(1, event)) { JMenuItem showInfoMenu = new JMenuItem(); showInfoMenu.setText("information"); showInfoMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(// "source file : \n" + srcFile + "\n" + DateFormatUtils.format(srcFile.lastModified(), "yyyy/MM/dd HH:mm:ss") + "\n" + "size : " + srcFile.length() / 1024 + "\n\n" + "external file : \n" + external + "\n" + DateFormatUtils.format(external.lastModified(), "yyyy/MM/dd HH:mm:ss") + "\n" + "size : " + external.length() / 1024, "INFORMATION"); } }); JMenuItem openFileMenu = new JMenuItem(); openFileMenu.setText("OPEN : source"); openFileMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openFile(srcFile); } }); JMenuItem openExternalMenu = new JMenuItem(); openExternalMenu.setText("OPEN : external"); openExternalMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openFile(external); } }); JMenuItem openPairlMenu = new JMenuItem(); openPairlMenu.setText("OPEN : all"); openPairlMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openFile(srcFile); openFile(external); } }); JPopupMenuUtil.newInstance(compareTable).applyEvent(event) .addJMenuItem(showInfoMenu, openFileMenu, openExternalMenu, openPairlMenu).show(); } } }); swingUtil.addAction("loadSrcTextarea.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { loadSrcTextarea(); } }); swingUtil.addAction("srcList.mouseClicked", new Action() { public void action(EventObject evt) throws Exception { if (JMouseEventUtil.buttonRightClick(1, evt)) { JPopupMenuUtil.newInstance(srcList).applyEvent(evt) .addJMenuItem("mark svn delete", new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().confirmButtonYesNo().showConfirmDialog( "are you sure, mark delete file : " + srcList.getSelectedValues().length, "SVN DELETE")) { return; } StringBuilder sb = new StringBuilder(); Process process = null; InputStream in = null; for (Object obj : srcList.getSelectedValues()) { LineParser l = (LineParser) obj; String command = String.format("svn delete \"%s\"", l.file); System.out.println(command); try { process = Runtime.getRuntime().exec(command); in = process.getInputStream(); for (; in.read() != -1;) ; if (l.file.exists()) { sb.append(l.file.getName() + "\n"); } } catch (IOException e1) { e1.printStackTrace(); sb.append(l.file.getName() + "\n"); } } if (sb.length() > 0) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("error : \n" + sb, "ERROR"); } else { JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("mark delete completed!!", "SUCCESS"); } DefaultListModel model = (DefaultListModel) srcList.getModel(); for (int ii = 0; ii < model.getSize(); ii++) { LineParser l = (LineParser) model.getElementAt(ii); if (!l.file.exists()) { model.remove(ii); ii--; } } } }).show(); } if (!JListUtil.newInstance(srcList).isCorrectMouseClick(evt)) { return; } LineParser lineParser = (LineParser) JListUtil.getLeadSelectionObject(srcList); if (lineParser == null) { return; } Runtime.getRuntime().exec("cmd /c call \"" + lineParser.file + "\""); } }); swingUtil.addAction("srcList.keyPressed", new Action() { public void action(EventObject evt) throws Exception { JListUtil.newInstance(srcList).defaultJListKeyPressed(evt); } }); swingUtil.addAction("outPutList.mouseClicked", new Action() { public void action(EventObject evt) throws Exception { if (!JListUtil.newInstance(outPutList).isCorrectMouseClick(evt)) { return; } } }); swingUtil.addAction("outPutList.keyPressed", new Action() { public void action(EventObject evt) throws Exception { JListUtil.newInstance(outPutList).defaultJListKeyPressed(evt); } }); swingUtil.addAction("outPutDir.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (dir == null) { outputDir = DEFAULT_OUTPUT_DIR; } else { outputDir = dir; } reflushOutputList(); } }); swingUtil.addAction("srcBaseDir.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); Validate.notNull(dir, "src base directory is not correct!"); manualBaseDir = dir; } }); swingUtil.addAction("execute.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { DefaultListModel model = (DefaultListModel) outPutList.getModel(); for (int ii = 0; ii < model.size(); ii++) { OutputFile file = (OutputFile) model.getElementAt(ii); if (!file.destFile.getParentFile().exists()) { file.destFile.getParentFile().mkdirs(); } FileUtil.copyFile(file.srcFile, file.destFile); } JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("copy success!!\nsize = " + model.getSize(), getTitle()); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.turborep.turbotracker.banking.service.BankingServiceImpl.java
@Override public List<Motransaction> getTransactionRegisterList(int theFrom, int theTo, ArrayList<?> theTransactionDetails, int moaccountid) throws BankingException { Session aSession = null;//from w ww . j a va 2 s .c om StringBuilder aStringBuilder = new StringBuilder(""); if (moaccountid != 0) { aStringBuilder.append("WHERE moAccountID =" + moaccountid + ""); } if (theTransactionDetails != null) { /*if(theTransactionDetails.get(0) !="" && theTransactionDetails.get(0) != null){ aStringBuilder.append("WHERE moAccountID ="+theTransactionDetails.get(0)+""); }*/ if (theTransactionDetails.get(1) != "" && theTransactionDetails.get(1) != null && theTransactionDetails.get(2) != "" && theTransactionDetails.get(2) != null) { String aTranDateString = theTransactionDetails.get(1).toString(); String aTranToDateString = theTransactionDetails.get(2).toString(); String[] aTranSactionDate = aTranDateString.split("%2F"); String[] aTranSactionToDate = aTranToDateString.split("%2F"); String aFromTranDate = aTranSactionDate[2] + "-" + aTranSactionDate[0] + "-" + aTranSactionDate[1]; String aToTranDate = aTranSactionToDate[2] + "-" + aTranSactionToDate[0] + "-" + aTranSactionToDate[1]; aStringBuilder.append(" AND date(TransactionDate) >= '" + aFromTranDate + "' AND date(TransactionDate) <= '" + aToTranDate + "'"); } if (theTransactionDetails.get(3) != "" && theTransactionDetails.get(3) != null) { aStringBuilder.append(" AND moTransactionTypeID =" + theTransactionDetails.get(3) + ""); } if (theTransactionDetails.get(4) != "" && theTransactionDetails.get(4) != null) { aStringBuilder.append(" AND moTransactionTypeID =" + theTransactionDetails.get(4) + ""); } if (theTransactionDetails.get(5) != "" && theTransactionDetails.get(5) != null) { aStringBuilder.append(" AND moTransactionTypeID =" + theTransactionDetails.get(5) + ""); } if (theTransactionDetails.get(6) != "" && theTransactionDetails.get(6) != null) { aStringBuilder.append(" AND moTransactionTypeID =" + theTransactionDetails.get(6) + ""); } if (theTransactionDetails.get(7) != "" && theTransactionDetails.get(7) != null) { aStringBuilder.append(" AND moTransactionTypeID =" + theTransactionDetails.get(7) + ""); } if (theTransactionDetails.get(8) != "" && theTransactionDetails.get(8) != null) { aStringBuilder.append(" AND Reconciled =" + theTransactionDetails.get(8) + ""); } if (theTransactionDetails.get(9) != "" && theTransactionDetails.get(9) != null) { aStringBuilder.append(" AND Void =" + theTransactionDetails.get(9) + ""); } } List<Motransaction> aQueryList = new ArrayList<Motransaction>(); String aCustomerQry = "SELECT *,CASE WHEN moTransaction.rxMasterID IS NULL THEN description ELSE IF((moTransaction.Void = 1 OR pageflagVoid = 1) ,description,(SELECT NAME FROM rxMaster WHERE rxMasterID=moTransaction.rxMasterID )) END 'namedescription' FROM moTransaction " + aStringBuilder + " ORDER BY moTransactionID DESC LIMIT " + theFrom + ", " + theTo; Motransaction aMotransaction = null; BigDecimal balance = new BigDecimal("0.00"); try { aSession = itsSessionFactory.openSession(); Query aQuery = aSession.createSQLQuery(aCustomerQry); Iterator<?> aIterator = aQuery.list().iterator(); while (aIterator.hasNext()) { aMotransaction = new Motransaction(); Object[] aObj = (Object[]) aIterator.next(); aMotransaction.setMoTransactionId((Integer) aObj[0]); aMotransaction.setRxMasterId((Integer) aObj[1]); aMotransaction.setRxAddressId((Integer) aObj[2]); aMotransaction.setCoAccountId((Integer) aObj[3]); aMotransaction.setMoAccountId((Integer) aObj[4]); if (aObj[5] != null) aMotransaction.setTransDate((String) DateFormatUtils.format((Date) aObj[5], "MM/dd/yyyy")); aMotransaction.setMoTransactionTypeId((Short) aObj[6]); aMotransaction.setMoTypeId((Short) aObj[6]); aMotransaction.setCheckType((Short) aObj[7]); aMotransaction.setReference((String) aObj[8]); aMotransaction.setDescription((String) aObj[9]); aMotransaction.setVoid_((Byte) aObj[10]); aMotransaction.setReconciled((Byte) aObj[11]); aMotransaction.setTempRec((Byte) aObj[12]); aMotransaction.setPrinted((Byte) aObj[13]); aMotransaction.setAmount((BigDecimal) aObj[14]); aMotransaction.setWithDrawel((BigDecimal) aObj[14]); aMotransaction.setDirectDeposit((Byte) aObj[15]); /*if(aMotransaction.getMoTransactionTypeId()!=null){ if(aMotransaction.getMoTransactionTypeId()==0){ System.out.println("DepositAmount=="+aMotransaction.getAmount()); balance=balance.add(aMotransaction.getAmount()); }else{ System.out.println("WithDrawel=="+aMotransaction.getAmount()); balance=balance.add(aMotransaction.getAmount()); } }*/ //balance=balance.multiply(new BigDecimal(-1)); //aMotransaction.setBalance(balance); aMotransaction.setBalance((BigDecimal) aObj[16]); aMotransaction.setStatus((Boolean) aObj[17]); aMotransaction.setMemo((String) aObj[18]); aMotransaction.setDisplaydiscription((String) aObj[21]); Date myDate = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String dateAsString_format = simpleDateFormat.format(myDate); String futureornot = "Current Transaction"; //System.out.println("Date"+(Date)aObj[5]); if ((Date) aObj[5] != null) { if (myDate.compareTo((Date) aObj[5]) < 0 || myDate.compareTo((Date) aObj[5]) == 0) { futureornot = "Future Transaction"; } else { futureornot = "Current Transaction"; } } aMotransaction.setFutureorcurrent(futureornot); aQueryList.add(aMotransaction); } } catch (Exception e) { itsLogger.error(e.getMessage(), e); BankingException aBankingException = new BankingException(e.getMessage(), e); throw aBankingException; } finally { aSession.flush(); aSession.close(); aStringBuilder = null; } return aQueryList; }
From source file:com.turborep.turbotracker.sales.service.Salesserviceimpl.java
@Override public ArrayList<JobsBean> getQuotedJobs(SalesRepBean theSalesRep, String sortBy, String sortOrder) { itsLogger.debug("Retrieving Quoted Jobs"); Integer aSalesRepId = theSalesRep.getSalesRepId(); if (aSalesRepId == 0) { aSalesRepId = null;//from w ww. j a v a 2s . co m } Integer customerID = theSalesRep.getRxMasterID(); if (customerID == 0) { customerID = null; } String sortByData = "BidDate"; if (sortBy.equals("bidDate")) { sortByData = "BidDate"; } if (sortBy.equals("jobName")) { sortByData = "BidDate"; } if (sortBy.equals("jobNo")) { sortByData = "BidDate"; } if (sortBy.equals("assignedCustomers")) { sortByData = "BidDate"; } if (sortBy.equals("quoteAmount")) { sortByData = "BidDate"; } String aName = ""; String aname2 = ""; if (aSalesRepId != -1) { aName = " WHERE jM.jobStatus = 1 AND joBidder.LowBid <>1 AND BidDate < CURDATE() AND " + "joBidder.QuoteDate = (SELECT MAX(job.QuoteDate) FROM joBidder job WHERE job.joMasterID=jM.joMasterID) " + "AND (" + "jM.cuAssignmentID0 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID1 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID2 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID3 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID4 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID5 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID6 = " + theSalesRep.getSalesRepId() + " OR " + "jM.cuAssignmentID6 = " + theSalesRep.getSalesRepId() + ")"; if (customerID != null) { aName = aName + " AND jM.rxCustomerID=" + customerID + " "; } aName = aName + " GROUP BY biddate ORDER BY " + sortByData + " " + sortOrder.toUpperCase(); aname2 = " WHERE " + "(cu.cuAssignmentID0 = " + theSalesRep.getSalesRepId() + " OR " + "cu.cuAssignmentID1 = " + theSalesRep.getSalesRepId() + " OR " + "cu.cuAssignmentID2 = " + theSalesRep.getSalesRepId() + " OR " + "cu.cuAssignmentID3 = " + theSalesRep.getSalesRepId() + " OR " + "cu.cuAssignmentID4 = " + theSalesRep.getSalesRepId() + ")) " + "GROUP BY biddate ORDER BY " + sortByData + " " + sortOrder.toUpperCase(); } else { aName = "WHERE jM.jobStatus = 1 AND joBidder.LowBid <>1 AND BidDate < CURDATE() AND joBidder.QuoteDate = (SELECT MAX(job.QuoteDate) FROM joBidder job WHERE job.joMasterID=jM.joMasterID) "; if (customerID != null) { aName = aName + " AND joBidder.rxMasterID=" + customerID + " "; } aName = aName + "GROUP BY BidDate ORDER BY " + sortByData + " " + sortOrder.toUpperCase(); aname2 = ") GROUP BY jM.biddate ORDER BY " + sortByData + " " + sortOrder.toUpperCase(); } String aPendingQry = "SELECT DISTINCT " + "jM.biddate AS BidDate, " + "jM.jobnumber, " + "jM.description, " + "rxMaster.name, " + "SUM(joQuoteHeader.quoteamount),jM.joMasterID " + "FROM joMaster jM JOIN joQuoteHeader ON jM.joMasterId=joQuoteHeader.joMasterId " + "LEFT JOIN joBidder ON joBidder.joMasterID=jM.joMasterID " + "LEFT JOIN rxMaster ON rxMaster.rxMasterID=joBidder.rxMasterID " + aName; /* * String aPendingQry = "SELECT DISTINCT " + "jM.biddate AS BidDate, " + * "jM.jobnumber, " + "jM.description, " + * "IF(CONCAT(r.FirstName, ' ', r.LastName) IS NULL,(SELECT tsUserLogin.FullName FROM tsUserLogin WHERE joQuoteHeader.createdbyid=tsUserLogin.userloginid),CONCAT(r.FirstName, ' ', r.LastName)) AS FullNAme, " * + * "SUM(joQuoteHeader.quoteamount),MAX(jb.joBidderID) FROM joMaster jM " * + "JOIN joQuoteHeader ON jM.joMasterId=joQuoteHeader.joMasterId " + * "LEFT JOIN joBidder jb ON jb.joMasterID = jM.joMasterId " + * "LEFT JOIN rxContact r ON jb.rxContactID = r.rxContactID " + aName; * //+ " UNION " + "SELECT DISTINCT " + "jM.biddate AS BidDate, " + * "jM.jobnumber, " + "jM.description, " + "tsUserLogin.FullName, " + * "SUM(joQuoteHeader.quoteamount) FROM joMaster jM " + * "JOIN joQuoteHeader ON jM.joMasterId=joQuoteHeader.joMasterId JOIN tsUserLogin ON " * + * "joQuoteHeader.createdbyid=tsUserLogin.userloginid WHERE jM.jobStatus = 1 AND tsUserLogin.LoginName != 'admin' AND " * + * "jM.joMasterId IN (SELECT jb.joMasterId FROM cuMaster cu JOIN joBidder jb ON " * + "cu.cuMasterId = jb.rxMasterId" + aname2 + ""; */ Session aSession = null; ArrayList<JobsBean> aPendingQuotes = new ArrayList<JobsBean>(); try { JobsBean aSalesPendingBean = null; aSession = itsSessionFactory.openSession(); Query aQuery = aSession.createSQLQuery(aPendingQry); Iterator<?> aIterator = aQuery.list().iterator(); while (aIterator.hasNext()) { aSalesPendingBean = new JobsBean(); Object[] aObj = (Object[]) aIterator.next(); if (aObj[0] != null) { aSalesPendingBean.setBidDate((String) DateFormatUtils.format((Date) aObj[0], "MM/dd/yyyy")); } aSalesPendingBean.setJobNo((String) aObj[1]); aSalesPendingBean.setJobName((String) aObj[2]); aSalesPendingBean.setAssignedCustomers((String) aObj[3]); aSalesPendingBean.setQuoteAmount((BigDecimal) aObj[4]); aSalesPendingBean.setJoMasterId((Integer) aObj[5]); aPendingQuotes.add(aSalesPendingBean); } } catch (Exception e) { itsLogger.error(e.getMessage(), e); } finally { aSession.flush(); aSession.close(); aPendingQry = null; } return aPendingQuotes; }
From source file:com.turborep.turbotracker.banking.service.BankingServiceImpl.java
@Override public List<Motransaction> getChecksLists(int moaccountId, String reference, short checkType) throws BankingException { Session aSession = null;//ww w .ja v a2s .c o m StringBuilder aStringBuilder = new StringBuilder(""); itsLogger.info("MoAccountId: " + moaccountId); itsLogger.info("Reference: " + reference); itsLogger.info("CheckType: " + checkType); if (moaccountId != 0) { aStringBuilder.append(" and moAccountID =" + moaccountId + ""); } if (checkType != 0) { aStringBuilder.append(" AND CheckType = " + checkType); } if (reference != null && !reference.equals("")) { aStringBuilder.append(" AND reference >= " + reference); } //aStringBuilder.append(" ORDER BY TRIM(Reference)"); List<Motransaction> aQueryList = new ArrayList<Motransaction>(); String aCustomerQry = "SELECT * FROM moTransaction WHERE Reconciled = 0 " + aStringBuilder; Motransaction aMotransaction = null; try { aSession = itsSessionFactory.openSession(); Query aQuery = aSession.createSQLQuery(aCustomerQry); Iterator<?> aIterator = aQuery.list().iterator(); while (aIterator.hasNext()) { aMotransaction = new Motransaction(); Object[] aObj = (Object[]) aIterator.next(); aMotransaction.setMoTransactionId((Integer) aObj[0]); aMotransaction.setRxMasterId((Integer) aObj[1]); aMotransaction.setRxAddressId((Integer) aObj[2]); aMotransaction.setCoAccountId((Integer) aObj[3]); aMotransaction.setMoAccountId((Integer) aObj[4]); if (aObj[5] != null) aMotransaction.setTransDate((String) DateFormatUtils.format((Date) aObj[5], "MM/dd/yyyy")); aMotransaction.setMoTransactionTypeId((Short) aObj[6]); aMotransaction.setMoTypeId((Short) aObj[6]); aMotransaction.setCheckType((Short) aObj[7]); aMotransaction.setReference((String) aObj[8]); aMotransaction.setDescription((String) aObj[9]); aMotransaction.setVoid_((Byte) aObj[10]); aMotransaction.setReconciled((Byte) aObj[11]); aMotransaction.setTempRec((Byte) aObj[12]); aMotransaction.setPrinted((Byte) aObj[13]); aMotransaction.setAmount((BigDecimal) aObj[14]); aMotransaction.setWithDrawel((BigDecimal) aObj[14]); aMotransaction.setDirectDeposit((Byte) aObj[15]); aQueryList.add(aMotransaction); } } catch (Exception e) { itsLogger.error(e.getMessage(), e); BankingException aBankingException = new BankingException(e.getMessage(), e); throw aBankingException; } finally { aSession.flush(); aSession.close(); aStringBuilder = null; } return aQueryList; }
From source file:gtu._work.etc._3DSMovieRenamer.java
private void initGUI() { try {/*from w w w . ja v a 2 s.c o m*/ final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this); BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setTitle("3DS Rename"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("vid list", null, jPanel1, null); { openDir = new JButton(); jPanel1.add(openDir, BorderLayout.NORTH); openDir.setText("open dir"); openDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("openDir.actionPerformed", evt); } }); } { ListModel vidListModel = new DefaultListModel(); vidList = new JList(); jPanel1.add(vidList, BorderLayout.CENTER); vidList.setModel(vidListModel); vidList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("vidList.mouseClicked", evt); } }); vidList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { swingUtil.invokeAction("vidList.keyPressed", evt); } }); } { jPanel3 = new JPanel(); jPanel1.add(jPanel3, BorderLayout.SOUTH); jPanel3.setPreferredSize(new java.awt.Dimension(445, 34)); { renameText = new JTextField(); jPanel3.add(renameText); renameText.setPreferredSize(new java.awt.Dimension(187, 24)); } { renameBtn = new JButton(); jPanel3.add(renameBtn); renameBtn.setText("rename"); renameBtn.setPreferredSize(new java.awt.Dimension(106, 24)); renameBtn.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("renameBtn.mouseClicked", evt); } }); } { forceChange = new JCheckBox(); jPanel3.add(forceChange); forceChange.setText("force"); forceChange.setPreferredSize(new java.awt.Dimension(64, 21)); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("copy", null, jPanel2, null); { jScrollPane1 = new JScrollPane(); jPanel2.add(jScrollPane1, BorderLayout.CENTER); { ListModel copyToListModel = new DefaultListModel(); copyToList = new JList(); jScrollPane1.setViewportView(copyToList); copyToList.setModel(copyToListModel); copyToList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("copyToList.mouseClicked", evt); } }); } } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("BT Movie", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.WEST); jScrollPane2.setPreferredSize(new java.awt.Dimension(254, 355)); { btDirTree = new JTree(); jScrollPane2.setViewportView(btDirTree); btDirTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction(evt); } }); btDirTree.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { swingUtil.invokeAction(evt); } }); JTreeUtil.newInstance(btDirTree).fileSystem(DEFAULT_BT_DIR); } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jPanel4.add(jPanel5, BorderLayout.CENTER); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); jScrollPane3.setPreferredSize(new java.awt.Dimension(427, 355)); { DefaultListModel btMovListModel = new DefaultListModel(); btMovList = new JList(); jScrollPane3.setViewportView(btMovList); btMovList.setModel(btMovListModel); btMovList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction(evt); } }); btMovList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(btMovList).defaultJListKeyPressed(evt); } }); } } } } { jPanel6 = new JPanel(); FlowLayout jPanel6Layout = new FlowLayout(); jTabbedPane1.addTab("common", null, jPanel6, null); jPanel6.setLayout(jPanel6Layout); { execute3dsVidTransfer = new JButton(); jPanel6.add(execute3dsVidTransfer); execute3dsVidTransfer.setText("execute 3ds video transfer"); execute3dsVidTransfer.setPreferredSize(new java.awt.Dimension(207, 42)); execute3dsVidTransfer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String bat = "C:/apps/_movie/3DSVideov1.00/3DS Video.exe"; try { Runtime.getRuntime().exec(String.format("cmd /c call \"%s\"", bat)); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } { openMovieAppDir = new JButton(); jPanel6.add(openMovieAppDir); openMovieAppDir.setText("open movie app dir"); openMovieAppDir.setPreferredSize(new java.awt.Dimension(207, 42)); openMovieAppDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { Desktop.getDesktop().open(new File("C:/apps/_movie")); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } } { jPanel7 = new JPanel(); BorderLayout jPanel7Layout = new BorderLayout(); jTabbedPane1.addTab("fake rename", null, jPanel7, null); jPanel7.setLayout(jPanel7Layout); { openFakeRenameDir = new JButton(); jPanel7.add(openFakeRenameDir, BorderLayout.NORTH); openFakeRenameDir.setText("open dir"); openFakeRenameDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); if (file != null) { DefaultListModel model = new DefaultListModel(); for (File f : file.listFiles()) { model.addElement(f); } openFakeRenameDirList.setModel(model); } } }); } { DefaultListModel openFakeRenameDirListModel = new DefaultListModel(); openFakeRenameDirList = new JList(); jPanel7.add(openFakeRenameDirList, BorderLayout.CENTER); openFakeRenameDirList.setModel(openFakeRenameDirListModel); openFakeRenameDirList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { File file = (File) JListUtil.getLeadSelectionObject(openFakeRenameDirList); try { Process process = Runtime.getRuntime() .exec(String.format("cmd /c call \"%s\"", file)); InputStream ins = process.getInputStream(); while (ins.read() != -1) { //TODO } ins.close(); System.out.println("done..."); } catch (IOException e) { e.printStackTrace(); } } }); openFakeRenameDirList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(openFakeRenameDirList).defaultJListKeyPressed(evt); } }); } { jPanel8 = new JPanel(); jPanel7.add(jPanel8, BorderLayout.SOUTH); jPanel8.setPreferredSize(new java.awt.Dimension(681, 43)); { openFakeRenameDir_newName = new JTextField(); jPanel8.add(openFakeRenameDir_newName); openFakeRenameDir_newName.setPreferredSize(new java.awt.Dimension(287, 27)); } { fakeRenameExecute = new JButton(); jPanel8.add(fakeRenameExecute); fakeRenameExecute.setText("execute"); fakeRenameExecute.setPreferredSize(new java.awt.Dimension(95, 27)); fakeRenameExecute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DefaultListModel model = (DefaultListModel) openFakeRenameDirList.getModel(); //TODO } }); } } } swingUtil.addAction("copyToList.mouseClicked", new Action() { public void action(EventObject evt) throws Exception { try { if (((MouseEvent) evt).getButton() == 3) { JMenuItem reloadMenu = new JMenuItem(); reloadMenu.setText("reload SD card directory"); reloadMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultListModel copyToListModel = new DefaultListModel(); for (final File f : load3DSDir.listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { if (paramFile.isDirectory() && paramString.matches(CUSTOM_3DS_DIR_PATTERN)) { return true; } return false; } })) { copyToListModel.addElement(f); } copyToList.setModel(copyToListModel); } }); JMenuItem copyAllToMenu = new JMenuItem(); { copyAllToMenu.setText( String.format("move %d vids to...", vidList.getModel().getSize())); final File toDir = (File) JListUtil.getLeadSelectionObject(copyToList); if (toDir == null || !toDir.exists() || !toDir.isDirectory()) { copyAllToMenu.setEnabled(false); } if (vidList.getModel().getSize() == 0) { copyAllToMenu.setText("copy no file..."); copyAllToMenu.setEnabled(false); } copyAllToMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultListModel model = JListUtil.newInstance(vidList).getModel(); if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconWaringMessage().confirmButtonYesNo() .showConfirmDialog("are you sure copy files : " + model.getSize() + "\n to dir : " + toDir, "COPY VIDS")) { return; } for (int ii = 0; ii < model.getSize(); ii++) { File src = (File) model.getElementAt(ii); src.renameTo(new File(toDir, src.getName())); } JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("copy completed!", "SUCCESS"); loadDirVids(); } }); } JPopupMenuUtil.newInstance(copyToList).applyEvent((MouseEvent) evt) .addJMenuItem(reloadMenu, copyAllToMenu).show(); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); swingUtil.addAction("openDir.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir not corrent!, set desktop", getTitle()); loadDir = FileUtil.DESKTOP_DIR; } else { loadDir = file; } loadDirVids(); } }); swingUtil.addAction("vidList.mouseClicked", new Action() { // final String player = "C:/Program Files (x86)/GRETECH/GomPlayer/GOM.EXE"; public void action(EventObject evt) throws Exception { int pos = -1; if ((pos = vidList.getLeadSelectionIndex()) == -1) { return; } MouseEvent mevt = (MouseEvent) evt; final File selectItem = (File) vidList.getModel().getElementAt(pos); List<JMenuItem> menuList = new ArrayList<JMenuItem>(); JMenuItem simpleRenamer = new JMenuItem(); final String simpleRenamePrefix = RandomUtil.upperCase(3); simpleRenamer.setText("Rename : " + simpleRenamePrefix); simpleRenamer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { String value = StringUtils.defaultString(JOptionPaneUtil.newInstance() .showInputDialog("3 char prefix?", "AVI PREFIX"), simpleRenamePrefix); if (value != null && value.matches("[a-zA-Z]{3}")) { selectItem.renameTo(getNewFile(selectItem.getParentFile(), value)); loadDirVids(); } else { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("prefix is not correct!", "ERROR"); } } }); menuList.add(simpleRenamer); if (load3DSDir == null) { reload3DSDir(); if (load3DSDir == null) { JMenuItem disable = new JMenuItem(); disable.setText("MOVE : SD card is not set!"); disable.setEnabled(false); menuList.add(disable); } } else { for (final File f : load3DSDir.listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { if (paramFile.isDirectory() && paramString.matches(CUSTOM_3DS_DIR_PATTERN)) { return true; } return false; } })) { JMenuItem copyTo = new JMenuItem(); copyTo.setText("MOVE : " + f.getName()); copyTo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION == JOptionPaneUtil .newInstance().iconQuestionMessage().confirmButtonYesNo() .showConfirmDialog(// "are you sure move file\n" + // selectItem + "\n" + // "to\n" + // "dir : " + f + " ??"// , "COPY FILE")) { File copyToNewDirFile = new File(f, selectItem.getName()); if (copyToNewDirFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog( "target dir file already exist!, need rename!", "FILE ALREADY EXIST"); return; } selectItem.renameTo(copyToNewDirFile); loadDirVids(); JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("move completed!", "MOVE FILE"); } } }); menuList.add(copyTo); } } JPopupMenuUtil.newInstance(vidList).applyEvent(mevt) .addJMenuItem(menuList.toArray(new JMenuItem[menuList.size()])).show(); if (mevt.getClickCount() != 2) { return; } String clkItemPath = selectItem.getAbsolutePath(); String command = "cmd /c call \"" + clkItemPath + "\""; System.out.println(command); Runtime.getRuntime().exec(command); } }); swingUtil.addAction("vidList.keyPressed", new Action() { public void action(EventObject evt) throws Exception { JListUtil.newInstance(vidList).defaultJListKeyPressed(evt); } }); swingUtil.addAction("renameBtn.mouseClicked", new Action() { Pattern aviNamePattern = Pattern.compile("^([a-zA-Z]{3})_\\d{4}\\.[aA][vV][iI]$"); public void action(EventObject evt) throws Exception { String name = StringUtils.defaultIfEmpty(renameText.getText(), RandomUtil.upperCase(3)); System.out.println("name = " + name + ", force : " + forceChange.isSelected()); if (!name.matches("[a-zA-Z]{3}")) { renameText.setText(""); JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("rename must eng 3 char!", "ERROR"); return; } DefaultListModel model = (DefaultListModel) vidList.getModel(); boolean matchOk = false; if (model.size() != 0) { File oldFile = null; Matcher matcher = null; for (int ii = 0; ii < model.getSize(); ii++) { oldFile = (File) model.getElementAt(ii); if (!oldFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog( "file not exeist : \n" + oldFile.getAbsolutePath(), getTitle()); return; } matcher = aviNamePattern.matcher(oldFile.getName()); matchOk = matcher.find(); System.out.println("matchOk = " + matchOk); if (matchOk && !forceChange.isSelected()) { oldFile.renameTo(getNewFile(oldFile.getParentFile(), matcher.group(1))); } else { oldFile.renameTo(getNewFile(oldFile.getParentFile(), name)); } } JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog("success!", getTitle()); } loadDirVids(); } }); ToolTipManager.sharedInstance().setInitialDelay(0); swingUtil.addAction(btMovList, MouseEvent.class, new Action() { public void action(EventObject evt) throws Exception { final File file = (File) JListUtil.getLeadSelectionObject(btMovList); if (JMouseEventUtil.buttonLeftClick(1, evt)) { btMovList.setToolTipText( DateFormatUtils.format(file.lastModified(), "yyyy/MM/dd HH:mm:ss") + " length:" + (file.length() / 1024) + "k"); } final Object[] objects = btMovList.getSelectedValues(); JPopupMenuUtil.newInstance(btMovList).applyEvent(evt)// .addJMenuItem("move out", (objects != null && objects.length > 0), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { List<File> list = new ArrayList<File>(); for (Object val : objects) { list.add((File) val); } if (!JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure move file from\n" + list.toString().replace(',', '\n') + "\nto\n" + DEFAULT_BT_DIR, "MOVE")) { return; } StringBuilder sb = new StringBuilder(); File moveTo = null; for (File file : list) { sb.append((file.renameTo( moveTo = new File(DEFAULT_BT_DIR, file.getName())) && moveTo.exists()) ? "" : file + "\n"); } JCommonUtil._jOptionPane_showMessageDialog_info( sb.length() == 0 ? "move success!" : "move failed!\n" + sb); } }) .addJMenuItem("delete this", file.exists(), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (!JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete file \n" + file, "DELETE")) { return; } boolean result = file.delete(); System.out.println("!!!!!" + result + "..." + file.exists()); JCommonUtil._jOptionPane_showMessageDialog_info( result ? "delete success!" : "delete failed!"); } }).show(); if (JMouseEventUtil.buttonLeftClick(2, evt)) { Runtime.getRuntime().exec(String.format("cmd /c call \"%s\"", file)); } } }); swingUtil.addAction(btDirTree, MouseEvent.class, new Action() { File getSingleFile() { return ((JFile) JTreeUtil.newInstance(btDirTree).getSelectItem().getUserObject()).getFile(); } public void action(EventObject evt) throws Exception { int selectCount = btDirTree.getSelectionModel().getSelectionCount(); if (selectCount == 1) { final File file = getSingleFile(); JPopupMenuUtil.newInstance(btDirTree).applyEvent(evt).addJMenuItem("delete this", selectCount == 1 && file.exists(), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (file.isFile()) { if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete FILE : \n" + file, "WARNING")) { file.delete(); JCommonUtil._jOptionPane_showMessageDialog_info( (file.exists() ? "delete failed!" : "delete success!")); } } if (file.isDirectory()) { StringBuilder sb = new StringBuilder(); if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete DIR : \n" + file, "WARNING")) { List<Boolean> delL = new ArrayList<Boolean>(); for (File f : file.listFiles()) { if (fileExtensionPattern.matcher(f.getName()).find() || f.length() > 1000000L) { if (!JCommonUtil ._JOptionPane_showConfirmDialog_yesNoOption( "delete this : \n" + f, "CHECK AGAIN")) { continue; } delL.add(f.delete()); } delL.add(f.delete()); } for (File f : file.listFiles()) { if (f.exists()) { sb.append(f + "\n"); } } System.out.println("delL.contains(false)==================>" + delL.contains(false)); } if (!file.delete()) { sb.append(file + "\n"); } JCommonUtil._jOptionPane_showMessageDialog_info( sb.length() > 0 ? "delete failed!\nlist:\n" + sb : "delete success!"); if (sb.length() == 0) { DefaultMutableTreeNode node = JTreeUtil.newInstance(btDirTree) .getSelectItem(); System.out.println( JTreeUtil.newInstance(btDirTree).removeNode(node)); } } } }).addJMenuItem("open dir", new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { File openTarget = file; if (file.isFile()) { openTarget = file.getParentFile(); } try { Desktop.getDesktop().open(openTarget); } catch (IOException e) { JCommonUtil.handleException(e); } } }).show(); } } }); swingUtil.addAction(btDirTree, PropertyChangeEvent.class, new Action() { public void action(EventObject evt) throws Exception { List<File> list = new ArrayList<File>(); for (DefaultMutableTreeNode node : JTreeUtil.newInstance(btDirTree).getSelectItems()) { JFile jfile = (JFile) node.getUserObject(); if (jfile.getFile().isDirectory()) { for (File f : jfile.getFile().listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { return fileExtensionPattern.matcher(paramString).find(); } })) { System.out.println(f.getName() + "...." + f.length()); list.add(f); } } } Collections.sort(list, new Comparator<File>() { public int compare(File paramT1, File paramT2) { return paramT1.lastModified() > paramT2.lastModified() ? -1 : 1; } }); btMovList.setModel(JListUtil.createModel(list.iterator())); } }); } this.setSize(702, 422); loadDirVids(); reload3DSDir(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.turborep.turbotracker.sales.service.Salesserviceimpl.java
@Override public ArrayList<JobsBean> upcomingForSingleCustomer(SalesRepBean thSalesRep) { itsLogger.debug("Retrieving upcomingForSingleCustomer"); Integer aSalesRepId = thSalesRep.getSalesRepId(); if (aSalesRepId == 0) { aSalesRepId = null;//from w ww.j a va2 s . c om } String aUpcomingQry = "SELECT DISTINCT BidDate, Description, JobNumber, " + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID0 AND LoginName != 'admin') AS asignedSales, " + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID1 AND LoginName != 'admin') AS asignedCust, " + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID2 AND LoginName != 'admin') AS allCust, " + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID3 AND LoginName != 'admin') AS architect, " + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID4 AND LoginName != 'admin') AS engineer, " + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID5 AND LoginName != 'admin') AS generalContract " + " FROM joMaster WHERE " + "(joMaster.cuAssignmentID0 = " + aSalesRepId + " OR " + " joMaster.cuAssignmentID1 = " + aSalesRepId + " OR " + " joMaster.cuAssignmentID2 = " + aSalesRepId + " OR " + " joMaster.cuAssignmentID3 = " + aSalesRepId + " OR " + " joMaster.cuAssignmentID4 = " + aSalesRepId + " OR " + " joMaster.cuAssignmentID5 = " + aSalesRepId + " OR " + " joMaster.cuAssignmentID6 = " + aSalesRepId + " ) AND joMaster.jobStatus = 0 " + " AND BidDate >= CURDATE() ORDER BY joMaster.biddate DESC "; Session aSession = null; ArrayList<JobsBean> aComingQry = new ArrayList<JobsBean>(); try { JobsBean aUpcomingJobs = null; aSession = itsSessionFactory.openSession(); Query aQuery = aSession.createSQLQuery(aUpcomingQry); Iterator<?> aIterator = aQuery.list().iterator(); while (aIterator.hasNext()) { aUpcomingJobs = new JobsBean(); Object[] aObj = (Object[]) aIterator.next(); if (aObj[0] != null) { aUpcomingJobs.setBidDate((String) DateFormatUtils.format((Date) aObj[0], "MM/dd/yyyy")); } aUpcomingJobs.setJobName((String) aObj[1]); aUpcomingJobs.setJobNo((String) aObj[2]); if (aObj[3] != null) { aUpcomingJobs.setAssignedSalesman((String) aObj[3].toString()); } if (aObj[4] != null) { aUpcomingJobs.setAssignedCustomers((String) aObj[4].toString()); } if (aObj[5] != null) { aUpcomingJobs.setAllCustomer((String) aObj[5].toString()); } if (aObj[6] != null) { aUpcomingJobs.setArchitect((String) aObj[6].toString()); } if (aObj[7] != null) { aUpcomingJobs.setEngineer((String) aObj[7].toString()); } if (aObj[8] != null) { aUpcomingJobs.setGeneralContractor((String) aObj[8].toString()); } aComingQry.add(aUpcomingJobs); } } catch (Exception e) { itsLogger.error(e.getMessage(), e); } finally { aSession.flush(); aSession.close(); aUpcomingQry = null; } return aComingQry; }