Skip to content

Commit

Permalink
Moved Log Viewer output to a separate tab instead of the Ouput tab to…
Browse files Browse the repository at this point in the history
… reduce clutter.
  • Loading branch information
creechy committed Sep 20, 2012
1 parent 79a5ef5 commit fec4948
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 26 deletions.
3 changes: 2 additions & 1 deletion manifest.mf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Manifest-Version: 1.0
OpenIDE-Module: org.fakebelieve.netbeans.plugin.logviewer
OpenIDE-Module-Localizing-Bundle: org/fakebelieve/netbeans/plugin/logviewer/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0.1
OpenIDE-Module-Requires: org.openide.windows.WindowManager
OpenIDE-Module-Specification-Version: 1.1.0

4 changes: 2 additions & 2 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build.xml.data.CRC32=2f414bea
build.xml.data.CRC32=ef12045e
build.xml.script.CRC32=141c9c2f
build.xml.stylesheet.CRC32=[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=2f414bea
nbproject/build-impl.xml.data.CRC32=ef12045e
nbproject/build-impl.xml.script.CRC32=1d202a84
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
17 changes: 17 additions & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
<specification-version>1.31.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.settings</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.35.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.actions</code-name-base>
<build-prerequisite/>
Expand Down Expand Up @@ -121,6 +130,14 @@
<specification-version>8.15.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.windows</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.55.1</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<public-packages/>
</data>
Expand Down
55 changes: 34 additions & 21 deletions src/org/fakebelieve/netbeans/plugin/logviewer/LogViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Action;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
import org.openide.windows.IOContainer;
import org.openide.windows.IOProvider;
import org.openide.windows.InputOutput;

Expand All @@ -25,8 +27,9 @@
*/
public class LogViewer implements Runnable {

protected int maxIoName = 36;
protected static final Logger log = Logger.getLogger(LogViewer.class.getName());
protected static IOContainer ioc = null;
protected int maxIoName = 36;
ContextLogSupport logSupport;
protected InputStream logStream = null;
protected BufferedReader logReader = null;
Expand All @@ -51,14 +54,13 @@ public class LogViewer implements Runnable {
* @param process process whose streams to connect to the output window
* @param ioName name of the output window tab to use
*/

public LogViewer() {
logSupport = new ContextLogSupport("/tmp", null);
}

public LogViewer(String logConfig) {
this();

this.logConfig = logConfig;
this.ioName = logConfig;
}
Expand Down Expand Up @@ -107,23 +109,27 @@ public boolean checkShouldStop() {
public void run() {
log.log(Level.FINE, "{0} - isClosed() = {1}", new Object[]{ioName, io.isClosed()});
if (!checkShouldStop() && !io.isClosed()) {
try {
if (maxLines > 0 && linesRead >= maxLines) {
io.getOut().reset();
linesRead = ring.output();
} // end of if (lines >= MAX_LINES)

String line;
while ((line = lineReader.readLine()) != null) {
if ((line = ring.add(line)) != null) {
//io.getOut().println(line);
processLine(line);
linesRead++;
} // end of if ((line = ring.add(line)) != null)
if (intervalCount == 0) {
init();
} else {
try {
if (maxLines > 0 && linesRead >= maxLines) {
io.getOut().reset();
linesRead = ring.output();
} // end of if (lines >= MAX_LINES)

String line;
while ((line = lineReader.readLine()) != null) {
if ((line = ring.add(line)) != null) {
//io.getOut().println(line);
processLine(line);
linesRead++;
} // end of if ((line = ring.add(line)) != null)
}

} catch (IOException e) {
log.log(Level.SEVERE, "Failed reading log file and printing to output.", e);
}

} catch (IOException e) {
log.log(Level.SEVERE, "Failed reading log file and printing to output.", e);
}

// For the first few intervals, update every second, just to make sure
Expand All @@ -141,7 +147,14 @@ public void configViewer() throws IOException {
*
**/
public void showLogViewer() throws IOException {
io = IOProvider.getDefault().getIO(ioName, true);
if (ioc == null) {
ioc = IOContainer.create(new LogViewerTopComponent());
}
//InputOutput io = IOProvider.getDefault().getIO("test", new Action[0], ioc);
//io.getOut().println("Hi there");
//io.select();

io = IOProvider.getDefault().getIO(ioName, new Action[0], ioc);
io.getOut().reset();
io.select();

Expand All @@ -165,7 +178,7 @@ public void showLogViewer() throws IOException {
log.log(Level.FINE, "Showing error.");
}

init();
//init();
task.schedule(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
id = "org.fakebelieve.netbeans.plugin.logviewer.LogViewerAction")
@ActionRegistration(
iconBase = "org/fakebelieve/netbeans/plugin/logviewer/wilbur.png",
displayName = "#CTL_LogViewerAction")
displayName = "#CTL_LogViewerButtonAction")
@ActionReference(path = "Toolbars/Debug", position = 1050)
@Messages("CTL_LogViewerAction=Log Viewer")
@Messages("CTL_LogViewerButtonAction=Log Viewer")
public class LogViewerButtonAction implements ActionListener {

protected static final Logger log = Logger.getLogger(LogViewer.class.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" alignment="0" pref="400" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" alignment="0" pref="300" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="createTabbedPane();"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
</Container>
</SubComponents>
</Form>
Loading

0 comments on commit fec4948

Please sign in to comment.