List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration
BaseConfiguration
From source file:pl.otros.logview.gui.actions.ConnectToSocketHubAppenderActionTest.java
@Test public void tryToConnect() throws IOException { OtrosApplication otrosApplication = new OtrosApplication(); ConnectToSocketHubAppenderAction action = new ConnectToSocketHubAppenderAction(otrosApplication); DataConfiguration dc = new DataConfiguration(new BaseConfiguration()); String hostAndPort = "abc:50"; SocketFactory socketFactory = mock(SocketFactory.class); Socket mockSocket = mock(Socket.class); when(socketFactory.createSocket("abc", 50)).thenReturn(mockSocket); Socket socket = action.tryToConnectToSocket(dc, hostAndPort, socketFactory); assertEquals(mockSocket, socket);/*from w w w . j a va 2 s . c om*/ assertEquals(1, dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).size()); assertEquals("abc:50", dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).get(0)); }
From source file:pl.otros.logview.gui.actions.ConnectToSocketHubAppenderActionTest.java
@Test public void tryToConnectFail() throws IOException { OtrosApplication otrosApplication = new OtrosApplication(); ConnectToSocketHubAppenderAction action = new ConnectToSocketHubAppenderAction(otrosApplication); DataConfiguration dc = new DataConfiguration(new BaseConfiguration()); String hostAndPort = "abc:50"; SocketFactory socketFactory = mock(SocketFactory.class); Socket mockSocket = mock(Socket.class); when(socketFactory.createSocket("abc", 50)).thenThrow(new UnknownHostException()); try {/* w w w. java2 s . c o m*/ action.tryToConnectToSocket(dc, hostAndPort, socketFactory); Assert.fail(); } catch (UnknownHostException e) { //success } assertEquals(0, dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).size()); }
From source file:pl.otros.logview.gui.actions.StartSocketListener.java
@Override public void actionPerformed(ActionEvent arg0) { LogImporterAndPort chooseLogImporter = chooseLogImporter(); if (chooseLogImporter == null) { return;/*from w w w. ja v a2s . co m*/ } StatusObserver observer = getOtrosApplication().getStatusObserver(); if (logViewPanelWrapper == null) { logViewPanelWrapper = new LogViewPanelWrapper("Socket", null, TableColumns.values(), getOtrosApplication()); logViewPanelWrapper.goToLiveMode(); BaseConfiguration configuration = new BaseConfiguration(); configuration.addProperty(ConfKeys.TAILING_PANEL_PLAY, true); configuration.addProperty(ConfKeys.TAILING_PANEL_FOLLOW, true); logDataCollector = new BufferingLogDataCollectorProxy(logViewPanelWrapper.getDataTableModel(), 4000, configuration); } getOtrosApplication().addClosableTab("Socket listener", "Socket listener", Icons.PLUGIN_CONNECT, logViewPanelWrapper, true); SocketLogReader logReader = null; if (logReader == null || logReader.isClosed()) { logReader = new SocketLogReader(chooseLogImporter.logImporter, logDataCollector, observer, chooseLogImporter.port); try { logReader.start(); logReaders.add(logReader); observer.updateStatus(String.format("Socket opened on port %d with %s.", chooseLogImporter.port, chooseLogImporter.logImporter)); } catch (Exception e) { e.printStackTrace(); observer.updateStatus("Failed to open listener " + e.getMessage(), StatusObserver.LEVEL_ERROR); } } }
From source file:pl.otros.logview.gui.actions.TailMultipleFilesIntoOneView.java
public void openFileObjectsIntoOneView(FileObject[] files, Object guiSource) { ArrayList<LoadingInfo> list = new ArrayList<LoadingInfo>(); for (final FileObject file : files) { try {//from w ww.j a v a2 s.c o m list.add(Utils.openFileObject(file, true)); } catch (Exception e1) { LOGGER.warning( String.format("Can't open file %s: %s", file.getName().getFriendlyURI(), e1.getMessage())); } } if (list.size() == 0) { JOptionPane.showMessageDialog((Component) guiSource, "No files can be opened :(", "Open error", JOptionPane.ERROR_MESSAGE); return; } LoadingInfo[] loadingInfos = new LoadingInfo[list.size()]; loadingInfos = list.toArray(loadingInfos); Collection<LogImporter> elements = AllPluginables.getInstance().getLogImportersContainer().getElements(); LogImporter[] importers = elements.toArray(new LogImporter[0]); String[] names = new String[elements.size()]; for (int i = 0; i < names.length; i++) { names[i] = importers[i].getName(); } TableColumns[] visibleColumns = new TableColumns[] { TableColumns.ID, // TableColumns.TIME, // TableColumns.LEVEL, // TableColumns.MESSAGE, // TableColumns.CLASS, // TableColumns.METHOD, // TableColumns.THREAD, // TableColumns.MARK, // TableColumns.NOTE, // TableColumns.LOG_SOURCE }; final LogViewPanelWrapper logViewPanelWrapper = new LogViewPanelWrapper( "Multiple log files " + loadingInfos.length, null, visibleColumns, getOtrosApplication()); logViewPanelWrapper.goToLiveMode(); BaseConfiguration configuration = new BaseConfiguration(); configuration.addProperty(ConfKeys.TAILING_PANEL_PLAY, true); configuration.addProperty(ConfKeys.TAILING_PANEL_FOLLOW, true); BufferingLogDataCollectorProxy logDataCollector = new BufferingLogDataCollectorProxy( logViewPanelWrapper.getDataTableModel(), 4000, configuration); StringBuilder sb = new StringBuilder(); sb.append("<html>Multiple files:<br>"); for (LoadingInfo loadingInfo : loadingInfos) { sb.append(loadingInfo.getFriendlyUrl()); sb.append("<BR>"); } sb.append("</html>"); getOtrosApplication().addClosableTab(String.format("Multiple logs [%d]", loadingInfos.length), sb.toString(), Icons.ARROW_REPEAT, logViewPanelWrapper, true); LogImporter importer = new DetectOnTheFlyLogImporter(elements); try { importer.init(new Properties()); } catch (InitializationException e1) { LOGGER.severe("Cant initialize DetectOnTheFlyLogImporter: " + e1.getMessage()); JOptionPane.showMessageDialog((Component) guiSource, "Cant initialize DetectOnTheFlyLogImporter: " + e1.getMessage(), "Open error", JOptionPane.ERROR_MESSAGE); } for (LoadingInfo loadingInfo : loadingInfos) { TailLogActionListener tailLogActionListener = new TailLogActionListener(getOtrosApplication(), importer); tailLogActionListener.openFileObjectInTailMode(logViewPanelWrapper, loadingInfo, logDataCollector); ParsingContext parsingContext = new ParsingContext( loadingInfo.getFileObject().getName().getFriendlyURI(), loadingInfo.getFileObject().getName().getBaseName()); logViewPanelWrapper .addHierarchyListener(new ReadingStopperForRemove(loadingInfo.getObserableInputStreamImpl(), logDataCollector, new ParsingContextStopperForClosingTab(parsingContext))); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { logViewPanelWrapper.switchToContentView(); } }); }
From source file:pl.otros.logview.pluginsimpl.OpenLogsSwingWorker.java
@Override protected Void doInBackground() throws Exception { LoadingInfo[] loadingInfos = getLoadingInfo(); Collection<LogImporter> elements = pluginContext.getOtrosApplication().getAllPluginables() .getLogImportersContainer().getElements(); LogImporter[] importers = elements.toArray(new LogImporter[0]); String[] names = new String[elements.size()]; for (int i = 0; i < names.length; i++) { names[i] = importers[i].getName(); }/* w ww .ja va 2 s.co m*/ TableColumns[] visibleColumns = new TableColumns[] { TableColumns.ID, // TableColumns.TIME, // TableColumns.LEVEL, // TableColumns.MESSAGE, // TableColumns.CLASS, // TableColumns.METHOD, // TableColumns.THREAD, // TableColumns.MARK, // TableColumns.NOTE, // TableColumns.LOG_SOURCE }; BaseConfiguration configuration = new BaseConfiguration(); configuration.addProperty(ConfKeys.TAILING_PANEL_PLAY, true); configuration.addProperty(ConfKeys.TAILING_PANEL_FOLLOW, true); logViewPanelWrapper = new LogViewPanelWrapper(tabName, null, visibleColumns, pluginContext.getOtrosApplication()); BufferingLogDataCollectorProxy logDataCollector = new BufferingLogDataCollectorProxy( logViewPanelWrapper.getDataTableModel(), 4000, configuration); LogImporter importer = getLogImporter(elements); for (LoadingInfo loadingInfo : loadingInfos) { openLog(logDataCollector, importer, loadingInfo); } publish("All log files loaded"); return null; }
From source file:pl.otros.vfs.browser.JOtrosVfsBrowserDialog.java
public JOtrosVfsBrowserDialog(final String initialPath) { this(new DataConfiguration(new BaseConfiguration()), initialPath); }
From source file:pl.otros.vfs.browser.JOtrosVfsBrowserDialog.java
public JOtrosVfsBrowserDialog() { this(new DataConfiguration(new BaseConfiguration())); }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
public VfsBrowser() { this(new BaseConfiguration()); }
From source file:revaligner.service.FileAligner.java
private void reformatTargetFile(com.aspose.words.Document doc_trg) throws Exception { ExtractionSupportImpl extractionSupportImpl = new ExtractionSupportImpl( Locale.makeLocale(this.sourcelanguage), Locale.makeLocale(this.targetlanguage)); Configuration config = new BaseConfiguration(); config.setProperty("extraction.tokens.extract", "all"); extractionSupportImpl.setConfiguration(config); normalizeSpaceAfterESM(doc_trg, Locale.makeLocale(this.targetlanguage)); DeleteCommentsAndShapeAltText(doc_trg); convertMoveToIDTracks(doc_trg);/* www . j a v a2 s .c o m*/ while (doc_trg.getRevisions().getCount() != 0) { Revision rev = doc_trg.getRevisions().get(0); rev.reject(); } }
From source file:revaligner.service.FileAligner.java
private void mergeParagraphsInDocuemnt(com.aspose.words.Document doc) throws Exception { ExtractionSupportImpl extractionSupportImpl = new ExtractionSupportImpl( Locale.makeLocale(this.sourcelanguage), Locale.makeLocale(this.targetlanguage)); Configuration config = new BaseConfiguration(); config.setProperty("extraction.tokens.extract", "all"); extractionSupportImpl.setConfiguration(config); Paragraph prev_para = null;//from w w w. j av a2s . c om Paragraph sample = new Paragraph(doc); Shape shape = null; boolean isStillSplitting = false; boolean ismoveaway = false; boolean ismoveto = false; int toskip = 0; List<Paragraph> toremove = new ArrayList(); for (int i = 0; i < doc.getChildNodes(0, true).getCount(); i++) { com.aspose.words.Node node = doc.getChildNodes(0, true).get(i); if (node.getNodeType() == 18) { shape = (Shape) node; } else if (node.getNodeType() == 13) { ismoveaway = true; } else if (node.getNodeType() == 14) { ismoveaway = false; } else if (node.getNodeType() == 15) { ismoveto = true; } else if (node.getNodeType() == 16) { ismoveto = false; } else if (node.getNodeType() == 8) { if (toskip > 0) { toskip--; } else { Paragraph para = (Paragraph) node; if ((para.isEndOfSection()) && ((para.isInsertRevision()) || (para.isDeleteRevision()))) { this.isSectionBreakDeletedORInserted = true; } if ((para.isInCell()) && (para.getPreviousSibling() == null)) { prev_para = null; isStillSplitting = false; } if ((shape != null) && (shape.getChildNodes(8, true).getCount() > 0) && (shape.getChildNodes(8, true).get(0) == para)) { prev_para = null; isStillSplitting = false; } if (prev_para != null) { if (isStillSplitting) { if ((prev_para.isInsertRevision()) || (ismoveto)) { if (extractionSupportImpl.isExtractable(getParaText(para))) { para.appendChild(new Run(doc, "¶ins;")); } } else { isStillSplitting = false; } } else if (((prev_para.isInsertRevision()) || (ismoveto)) && (!isWholeParaInserted(prev_para))) { if (extractionSupportImpl.isExtractable(getParaText(para))) { para.appendChild(new Run(doc, "¶ins;")); } isStillSplitting = true; } if ((para.isEndOfCell()) || (para.isEndOfHeaderFooter()) || (para.isEndOfSection())) { isStillSplitting = false; } if ((shape != null) && (shape.getChildNodes(8, true).getCount() > 0) && (shape .getChildNodes(8, true).get(shape.getChildNodes(8, true).getCount() - 1) == para)) { isStillSplitting = false; } if (((prev_para.isDeleteRevision()) || (ismoveaway)) && (!isWholeParaDeleted(prev_para))) { if ((para.getChildNodes(21, true).getCount() != 0) || (para.isDeleteRevision())) { prev_para.appendChild(new Run(doc, "¶del;")); i++; for (int j = 0; j < para.getChildNodes().getCount(); j++) { com.aspose.words.Node nd = para.getChildNodes().get(j); if ((nd.getNodeType() != 21) || (!((Run) nd).isDeleteRevision()) || (!((Run) nd).getText().contains(ControlChar.PAGE_BREAK))) { prev_para.appendChild(nd.deepClone(true)); i++; } } if (para.getChildNodes(14, true).getCount() != 0) { ismoveaway = false; } } prev_para.setDeleteRevision(para.getDeleteRevision()); prev_para.setInsertRevision(para.getInsertRevision()); if (!para.isInsertRevision()) { for (int z = 0; z < para.getChildNodes().getCount(); z++) { com.aspose.words.Node temp_nd = para.getChildNodes().get(z); if (temp_nd.getNodeType() == 15) { ismoveto = true; } else if (temp_nd.getNodeType() == 16) { ismoveto = false; } } para.remove(); i--; } else { toremove.add(para); prev_para = para; } } else if ((prev_para.isDeleteRevision()) && (isWholeParaDeleted(prev_para))) { prev_para.setDeleteRevision(sample.getDeleteRevision()); prev_para = para; } else if ((para.isEndOfCell()) || (para.isEndOfHeaderFooter())) { para.setDeleteRevision(sample.getDeleteRevision()); prev_para = null; } else if ((shape != null) && (shape.getChildNodes(8, true).getCount() > 0) && (shape .getChildNodes(8, true).get(shape.getChildNodes(8, true).getCount() - 1) == para)) { para.setDeleteRevision(sample.getDeleteRevision()); prev_para = null; } else { prev_para = para; } } else { if ((isStillSplitting) && (extractionSupportImpl.isExtractable(getParaText(para)))) { para.appendChild(new Run(doc, "¶ins;")); i++; } if (para.isInsertRevision()) { if ((extractionSupportImpl.isExtractable(getParaText(para))) && (!isWholeParaInserted(para))) { isStillSplitting = true; } } else { isStillSplitting = false; } if ((para.isEndOfCell()) || (para.isEndOfHeaderFooter())) { if ((para.getNextSibling() == null) && (para.getPreviousSibling() == null) && (para.isDeleteRevision()) && (isWholeParaDeleted(para))) { para.setDeleteRevision(sample.getDeleteRevision()); } prev_para = null; } else if ((shape != null) && (shape.getChildNodes(8, true).getCount() > 0) && (shape .getChildNodes(8, true).get(shape.getChildNodes(8, true).getCount() - 1) == para)) { if ((para.getNextSibling() == null) && (para.getPreviousSibling() == null) && (para.isDeleteRevision()) && (isWholeParaDeleted(para))) { para.setDeleteRevision(sample.getDeleteRevision()); } prev_para = null; } else { prev_para = para; } } } } else if (node.getNodeType() == 5) { Table tb = (Table) node; if (isWholeTableDeleted(tb, doc)) { toskip = tb.getChildNodes(8, true).getCount(); } } } for (Paragraph p : toremove) { if (p != null) { p.removeAllChildren(); } } doc.save("C:\\Program Files (x86)\\pa\\paprjs\\testprj23\\test.docx"); }