# HG changeset patch
# Parent 978e340177aeff57ce9ca285150d52d81f3244e2
diff --git a/core.output2/manifest.mf b/core.output2/manifest.mf
--- a/core.output2/manifest.mf
+++ b/core.output2/manifest.mf
@@ -1,5 +1,6 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.core.output2/1
+OpenIDE-Module-Layer: org/netbeans/core/output2/layer.xml
OpenIDE-Module-Localizing-Bundle: org/netbeans/core/output2/Bundle.properties
OpenIDE-Module-Provides: org.openide.windows.IOProvider
AutoUpdate-Essential-Module: true
diff --git a/core.output2/nbproject/project.xml b/core.output2/nbproject/project.xml
--- a/core.output2/nbproject/project.xml
+++ b/core.output2/nbproject/project.xml
@@ -50,6 +50,24 @@
org.netbeans.core.output2
+ org.jdesktop.beansbinding
+
+
+
+ 1
+ 1.16
+
+
+
+ org.netbeans.modules.options.api
+
+
+
+ 1
+ 1.27
+
+
+
org.netbeans.swing.plaf
diff --git a/core.output2/src/org/netbeans/core/output2/AbstractLines.java b/core.output2/src/org/netbeans/core/output2/AbstractLines.java
--- a/core.output2/src/org/netbeans/core/output2/AbstractLines.java
+++ b/core.output2/src/org/netbeans/core/output2/AbstractLines.java
@@ -62,6 +62,7 @@
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import org.netbeans.core.output2.options.OutputOptions;
import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;
import org.openide.util.Mutex;
@@ -836,30 +837,12 @@
if (DEF_COLORS != null) {
return DEF_COLORS;
}
- Color out = UIManager.getColor("nb.output.foreground"); //NOI18N
- if (out == null) {
- out = UIManager.getColor("textText");
- if (out == null) {
- out = Color.BLACK;
- }
- }
-
- Color err = UIManager.getColor("nb.output.err.foreground"); //NOI18N
- if (err == null) {
- err = LFCustoms.shiftColor(Color.red);
- }
-
- Color hyperlink = UIManager.getColor("nb.output.link.foreground"); //NOI18N
- if (hyperlink == null) {
- hyperlink = LFCustoms.shiftColor(Color.blue);
- }
-
- Color hyperlinkImp = UIManager.getColor("nb.output.link.foreground.important"); //NOI18N
- if (hyperlinkImp == null) {
- hyperlinkImp = hyperlink;
- }
-
- return DEF_COLORS = new Color[]{out, err, hyperlink, hyperlinkImp};
+ return DEF_COLORS = new Color[]{
+ OutputOptions.getDefault().getColorStandard(),
+ OutputOptions.getDefault().getColorError(),
+ OutputOptions.getDefault().getColorLink(),
+ OutputOptions.getDefault().getColorLinkImportant()
+ };
}
public void setDefColor(IOColors.OutputType type, Color color) {
diff --git a/core.output2/src/org/netbeans/core/output2/Bundle.properties b/core.output2/src/org/netbeans/core/output2/Bundle.properties
--- a/core.output2/src/org/netbeans/core/output2/Bundle.properties
+++ b/core.output2/src/org/netbeans/core/output2/Bundle.properties
@@ -110,7 +110,7 @@
ACTION_FIND_PREVIOUS=Find Previous
ACTION_LARGER_FONT=Larger Font
ACTION_SMALLER_FONT=Smaller Font
-ACTION_FONT_TYPE=Choose Font...
+ACTION_SETTINGS=Settings...
ACTION_FILTER=Filter...
#Popup menu accelerators
@@ -128,7 +128,7 @@
ACTION_CLEAR.accel=C-L
ACTION_LARGER_FONT.accel=C-EQUALS
ACTION_SMALLER_FONT.accel=C-MINUS
-ACTION_FONT_TYPE.accel=
+ACTION_SETTINGS.accel=
ACTION_FILTER.accel=C-G
#Macintosh popup menu accelerators
@@ -136,7 +136,7 @@
ACTION_PASTE.accel.mac=M-V
ACTION_LARGER_FONT.accel.mac=M-EQUALS
ACTION_SMALLER_FONT.accel.mac=M-MINUS
-ACTION_FONT_TYPE.accel.mac=
+ACTION_SETTINGS.accel.mac=
ACTION_WRAP.accel.mac=M-R
ACTION_SAVEAS.accel.mac=M-S
ACTION_CLOSE.accel.mac=M-F4
diff --git a/core.output2/src/org/netbeans/core/output2/Controller.java b/core.output2/src/org/netbeans/core/output2/Controller.java
--- a/core.output2/src/org/netbeans/core/output2/Controller.java
+++ b/core.output2/src/org/netbeans/core/output2/Controller.java
@@ -64,7 +64,9 @@
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.text.Document;
+import org.netbeans.core.output2.options.OutputOptions;
import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
import org.openide.util.NbPreferences;
import org.openide.windows.IOColors;
import org.openide.windows.IOContainer;
@@ -188,6 +190,15 @@
}
void changeFont(Font font) {
+ updateFontPreferences(font);
+ for (OutputTab tab : getAllTabs()) {
+ if (allMonospaced || !tab.getOutputPane().isWrapped()) {
+ tab.getOutputPane().setViewFont(currentFont);
+ }
+ }
+ }
+
+ private void updateFontPreferences(Font font) {
currentFont = font == null ? getDefaultFont() : font;
allMonospaced = isDefaultFontType(currentFont);
if (allMonospaced) {
@@ -198,9 +209,13 @@
NbPreferences.forModule(Controller.class).putInt(KEY_FONTSIZE, currentFont.getSize());
NbPreferences.forModule(Controller.class).putInt(KEY_FONTSTYLE, currentFont.getStyle());
NbPreferences.forModule(Controller.class).put(KEY_FONTNAME, currentFont.getName());
- for (OutputTab tab : getAllTabs()) {
- if (allMonospaced || !tab.getOutputPane().isWrapped()) {
- tab.getOutputPane().setViewFont(currentFont);
+ }
+
+ public void updateOptions(OutputOptions options) {
+ updateFontPreferences(options.getFont());
+ for (OutputTab ot : getAllTabs()) {
+ if (ot.getIO().getIOContainer().equals(IOContainer.getDefault())) {
+ ot.getIO().getOptions().assign(options);
}
}
}
diff --git a/core.output2/src/org/netbeans/core/output2/ExtPlainView.java b/core.output2/src/org/netbeans/core/output2/ExtPlainView.java
--- a/core.output2/src/org/netbeans/core/output2/ExtPlainView.java
+++ b/core.output2/src/org/netbeans/core/output2/ExtPlainView.java
@@ -52,6 +52,7 @@
import javax.swing.text.*;
import java.awt.*;
import javax.swing.text.Position.Bias;
+import org.netbeans.core.output2.options.OutputOptions;
import org.openide.windows.IOColors;
/**
@@ -193,6 +194,9 @@
}
private void underline(Graphics g, Segment s, int x, int p0, int y) {
+ if (!isLinkUndeliningEnabled(this)) {
+ return;
+ }
int textLen = Utilities.getTabbedTextWidth(s, metrics, tabBase, this, p0);
int underlineShift = g.getFontMetrics().getDescent() - 1;
g.drawLine(x, y + underlineShift, x + textLen, y + underlineShift);
@@ -454,4 +458,20 @@
return pos;
}
+ static boolean isLinkUndeliningEnabled(View v) {
+ Container pane = v.getContainer();
+ if (pane != null) {
+ OutputTab tab = (OutputTab) SwingUtilities.getAncestorOfClass(
+ OutputTab.class, pane);
+ if (tab != null) {
+ OutputTab outputTab = (OutputTab) tab;
+ OutputOptions.LinkStyle linkStyle;
+ linkStyle = outputTab.getIO().getOptions().getLinkStyle();
+ if (linkStyle == OutputOptions.LinkStyle.NONE) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
}
diff --git a/core.output2/src/org/netbeans/core/output2/NbIO.java b/core.output2/src/org/netbeans/core/output2/NbIO.java
--- a/core.output2/src/org/netbeans/core/output2/NbIO.java
+++ b/core.output2/src/org/netbeans/core/output2/NbIO.java
@@ -53,6 +53,7 @@
import java.awt.*;
import java.io.IOException;
import java.io.Reader;
+import org.netbeans.core.output2.options.OutputOptions;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;
@@ -75,6 +76,7 @@
private Boolean focusTaken = null;
private boolean closed = false;
private final String name;
+ private OutputOptions options = OutputOptions.getDefault().makeCopy();
private Action[] actions;
@@ -277,7 +279,9 @@
if (lookup == null) {
ioTab = new IOTabImpl();
ioColors = new IOColorsImpl();
- lookup = Lookups.fixed(ioTab, ioColors, new IOPositionImpl(), new IOColorLinesImpl(), new IOColorPrintImpl(), new IOSelectImpl());
+ lookup = Lookups.fixed(ioTab, ioColors, new IOPositionImpl(),
+ new IOColorLinesImpl(), new IOColorPrintImpl(),
+ new IOSelectImpl(), options);
}
return lookup;
}
@@ -521,7 +525,7 @@
@Override
protected Color getColor(OutputType type) {
- return clrs[type.ordinal()] != null ? clrs[type.ordinal()] : AbstractLines.getDefColors()[type.ordinal()];
+ return clrs[type.ordinal()] != null ? clrs[type.ordinal()] : options.getColorForType(type);
}
@Override
@@ -530,4 +534,19 @@
post(NbIO.this, IOEvent.CMD_DEF_COLORS, type);
}
}
+
+ /**
+ * Set option values. The object itself is not replaced, all registered
+ * listeners remains untouched.
+ */
+ void setOptions(OutputOptions options) {
+ this.options.assign(options);
+ }
+
+ /**
+ * Get Options object.
+ */
+ OutputOptions getOptions() {
+ return this.options;
+ }
}
diff --git a/core.output2/src/org/netbeans/core/output2/OutputTab.java b/core.output2/src/org/netbeans/core/output2/OutputTab.java
--- a/core.output2/src/org/netbeans/core/output2/OutputTab.java
+++ b/core.output2/src/org/netbeans/core/output2/OutputTab.java
@@ -44,6 +44,7 @@
package org.netbeans.core.output2;
+import java.awt.Color;
import java.awt.Dialog;
import java.awt.Component;
import java.awt.Container;
@@ -54,6 +55,7 @@
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
@@ -82,6 +84,7 @@
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.text.Document;
+import org.netbeans.api.options.OptionsDisplayer;
import org.netbeans.core.output2.Controller.ControllerOutputEvent;
import org.netbeans.core.output2.ui.AbstractOutputPane;
import org.netbeans.core.output2.ui.AbstractOutputTab;
@@ -99,7 +102,9 @@
import org.openide.xml.XMLUtil;
import static org.netbeans.core.output2.OutputTab.ACTION.*;
-import org.openide.windows.IOProvider;
+import org.netbeans.core.output2.options.OutputOptions;
+import org.openide.util.WeakListeners;
+import org.openide.windows.IOColors;
/**
@@ -108,6 +113,7 @@
final class OutputTab extends AbstractOutputTab implements IOContainer.CallBacks {
private final NbIO io;
private OutWriter outWriter;
+ private PropertyChangeListener optionsListener;
OutputTab(NbIO io) {
this.io = io;
@@ -122,6 +128,24 @@
getActionMap().put("jumpNext", action(NEXT_ERROR)); // NOI18N
getActionMap().put(FindAction.class.getName(), action(FIND));
getActionMap().put(javax.swing.text.DefaultEditorKit.copyAction, action(COPY));
+ applyOptions();
+ }
+
+ private void applyOptions() {
+ Lines lines = getDocument().getLines();
+ OutputOptions opts = io.getOptions();
+ lines.setDefColor(IOColors.OutputType.OUTPUT,
+ opts.getColorStandard());
+ lines.setDefColor(IOColors.OutputType.ERROR,
+ opts.getColorError());
+ lines.setDefColor(IOColors.OutputType.HYPERLINK,
+ opts.getColorLink());
+ lines.setDefColor(IOColors.OutputType.HYPERLINK_IMPORTANT,
+ opts.getColorLinkImportant());
+ Color bg = io.getOptions().getColorBackground();
+ getOutputPane().getTextView().setBackground(bg);
+ getOutputPane().setViewFont(io.getOptions().getFont());
+ initOptionsListener();
}
private final TabAction action(ACTION a) {
@@ -153,6 +177,7 @@
// get new OutWriter
outWriter = io.out();
setDocument(new OutputDocument(outWriter));
+ applyOptions();
}
public OutputDocument getDocument() {
@@ -593,7 +618,7 @@
popup.add(item);
} else {
if ((popupItems[i] == ACTION.CLOSE && !io.getIOContainer().isCloseable(this))
- || (popupItems[i] == ACTION.FONT_TYPE && getOutputPane().isWrapped())) {
+ || (popupItems[i] == ACTION.SETTINGS && getOutputPane().isWrapped())) {
continue;
}
JMenuItem item = popup.add(ta);
@@ -697,14 +722,55 @@
io.getIOContainer().setTitle(this, escaped.replace("'", "'"));
}
+ private void initOptionsListener() {
+ optionsListener = new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ String pn = evt.getPropertyName();
+ Lines lines = getDocument().getLines();
+ OutputOptions opts = io.getOptions();
+ if (OutputOptions.PROP_COLOR_STANDARD.equals(pn)) {
+ lines.setDefColor(IOColors.OutputType.OUTPUT,
+ opts.getColorStandard());
+ } else if (OutputOptions.PROP_COLOR_ERROR.equals(pn)) {
+ lines.setDefColor(IOColors.OutputType.ERROR,
+ opts.getColorError());
+ } else if (OutputOptions.PROP_COLOR_LINK.equals(pn)) {
+ lines.setDefColor(IOColors.OutputType.HYPERLINK,
+ opts.getColorLink());
+ } else if (OutputOptions.PROP_COLOR_LINK_IMPORTANT.equals(pn)) {
+ lines.setDefColor(IOColors.OutputType.HYPERLINK_IMPORTANT,
+ opts.getColorLinkImportant());
+ } else if (OutputOptions.PROP_COLOR_BACKGROUND.equals(pn)) {
+ Color bg = io.getOptions().getColorBackground();
+ getOutputPane().getTextView().setBackground(bg);
+ } else if (OutputOptions.PROP_FONT.equals(pn)) {
+ Font font = io.getOptions().getFont();
+ if (getOutputPane().isWrapped()
+ && getIO().getIOContainer() == IOContainer.getDefault()) {
+ Font dfltFont = OutputOptions.getDefaultFont();
+ if (!font.getFamily().equals(dfltFont.getFamily())
+ || font.getStyle() != dfltFont.getStyle()) {
+ font = Controller.getDefault().getCurrentFontMS();
+ }
+ }
+ getOutputPane().setViewFont(font);
+ }
+ OutputTab.this.repaint();
+ }
+ };
+ this.io.getOptions().addPropertyChangeListener(
+ WeakListeners.propertyChange(optionsListener, io.getOptions()));
+ }
+
static enum ACTION { COPY, WRAP, SAVEAS, CLOSE, NEXT_ERROR, PREV_ERROR,
SELECT_ALL, FIND, FIND_NEXT, NAVTOLINE, POSTMENU,
FIND_PREVIOUS, CLEAR, NEXTTAB, PREVTAB, LARGER_FONT,
- SMALLER_FONT, FONT_TYPE, FILTER, PASTE }
+ SMALLER_FONT, SETTINGS, FILTER, PASTE }
private static final ACTION[] popupItems = new ACTION[] {
COPY, PASTE, null, FIND, FIND_NEXT, FIND_PREVIOUS, FILTER, null,
- WRAP, LARGER_FONT, SMALLER_FONT, FONT_TYPE, null,
+ WRAP, LARGER_FONT, SMALLER_FONT, SETTINGS, null,
SAVEAS, CLEAR, CLOSE,
};
@@ -733,7 +799,7 @@
case FILTER:
case LARGER_FONT:
case SMALLER_FONT:
- case FONT_TYPE:
+ case SETTINGS:
case CLEAR:
action = new TabAction(a, "ACTION_"+a.name());
break;
@@ -923,8 +989,9 @@
case LARGER_FONT:
Controller.getDefault().changeFontSizeBy(1, getOutputPane().isWrapped());
break;
- case FONT_TYPE:
- showFontChooser();
+ case SETTINGS:
+ OptionsDisplayer.getDefault().open(
+ "Advanced/OutputSettings"); //NOI18N
break;
case FILTER:
if (origPane != null) {
diff --git a/core.output2/src/org/netbeans/core/output2/WrappedTextView.java b/core.output2/src/org/netbeans/core/output2/WrappedTextView.java
--- a/core.output2/src/org/netbeans/core/output2/WrappedTextView.java
+++ b/core.output2/src/org/netbeans/core/output2/WrappedTextView.java
@@ -470,6 +470,9 @@
}
private void underline(Graphics g, Segment seg, int charpos, int lenToDraw, int x, int y) {
+ if (!ExtPlainView.isLinkUndeliningEnabled(this)) {
+ return;
+ }
int underlineStart = margin() + x;
FontMetrics fm = g.getFontMetrics();
int underlineEnd = underlineStart + fm.charsWidth(seg.array, charpos, lenToDraw);
diff --git a/core.output2/src/org/netbeans/core/output2/layer.xml b/core.output2/src/org/netbeans/core/output2/layer.xml
new file mode 100644
--- /dev/null
+++ b/core.output2/src/org/netbeans/core/output2/layer.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core.output2/src/org/netbeans/core/output2/options/Bundle.properties b/core.output2/src/org/netbeans/core/output2/options/Bundle.properties
new file mode 100644
--- /dev/null
+++ b/core.output2/src/org/netbeans/core/output2/options/Bundle.properties
@@ -0,0 +1,21 @@
+OutputSettingsPanel.lblFontFamily.text=&Font:
+OutputSettingsPanel.lblFontSize.text=Font Si&ze:
+OutputSettingsPanel.lblStandardColor.text=&Standard Color:
+OutputSettingsPanel.lblErrorColor.text=&Error Color:
+OutputSettingsPanel.lblBackgroundColor.text=&Background Color:
+OutputSettingsPanel.lblLinkColor.text=&Link Color:
+OutputSettingsPanel.lblLinkStyle.text=Link St&yle:
+OutputSettingsPanel.lblTitle.text=Output Window Settings
+OutputSettingsPanel.btnSelectFont.text=...
+OutputSettingsPanel.fldFontFamily.text=
+OutputSettingsPanel.jLabel1.text=Im&portant Link Color:
+OutputSettingsPanel.btnRestore.text=&Restore
+OutputSettingsPanel.btnSelectFont.toolTipText=Select font family, style and size
+OutputSettingsPanel.btnRestore.toolTipText=Restore default settings
+OutputSettingsPanel.spnFontSize.toolTipText=Adjust font size
+OutputSettingsPanel.cmbBackgroundColor.toolTipText=Select background color
+OutputSettingsPanel.cmbStandardColor.toolTipText=Select standard text foreground color
+OutputSettingsPanel.cmbErrorColor.toolTipText=Select error text foreground color
+OutputSettingsPanel.cmbLinkColor.toolTipText=Select link foreground color
+OutputSettingsPanel.cmbImportantLinkColor.toolTipText=Select important link foreground color
+OutputSettingsPanel.cmbLinkStyle.toolTipText=Select link style
diff --git a/core.output2/src/org/netbeans/core/output2/options/LinkStyleModel.java b/core.output2/src/org/netbeans/core/output2/options/LinkStyleModel.java
new file mode 100644
--- /dev/null
+++ b/core.output2/src/org/netbeans/core/output2/options/LinkStyleModel.java
@@ -0,0 +1,164 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.core.output2.options;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+import org.netbeans.core.output2.options.OutputOptions.LinkStyle;
+import org.openide.util.NbBundle;
+
+/**
+ * List mode for Link Style combo box.
+ *
+ * @author jhavlin
+ */
+@NbBundle.Messages({
+ "LBL_Underline=Underline", //NOI18N
+ "LBL_None=None" //NOI18N
+})
+public class LinkStyleModel implements ComboBoxModel {
+
+ private class LinkStyleItem {
+
+ private LinkStyle linkStyle;
+ private String displayName;
+
+ public LinkStyleItem(LinkStyle linkStyle, String displayName) {
+ this.linkStyle = linkStyle;
+ this.displayName = displayName;
+ }
+
+ public LinkStyle getLinkStyle() {
+ return linkStyle;
+ }
+
+ @Override
+ public String toString() {
+ return displayName;
+ }
+ }
+
+ /* Instances of combo box items. */
+ private LinkStyleItem none = new LinkStyleItem(LinkStyle.NONE,
+ Bundle.LBL_None());
+ private LinkStyleItem underline = new LinkStyleItem(LinkStyle.UNDERLINE,
+ Bundle.LBL_Underline());
+ /**
+ * The currently selected item.
+ */
+ private LinkStyleItem selectedItem = underline;
+
+ @Override
+ public void setSelectedItem(Object anItem) {
+ if (anItem instanceof LinkStyleItem) {
+ selectedItem = (LinkStyleItem) anItem;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ return selectedItem;
+ }
+
+ @Override
+ public int getSize() {
+ return 2;
+ }
+
+ @Override
+ public Object getElementAt(int index) {
+ switch (index) {
+ case 0:
+ return underline;
+ case 1:
+ return none;
+ default:
+ throw new IndexOutOfBoundsException();
+ }
+ }
+
+ @Override
+ public void addListDataListener(ListDataListener l) {
+ // Nothing, model is constant.
+ }
+
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+ // Nothing, model is constant.
+ }
+
+ LinkStyle getLinkStyle() {
+ return selectedItem.getLinkStyle();
+ }
+
+ void setLinkStyle(LinkStyle style) {
+ if (style != selectedItem.getLinkStyle()) {
+ switch (style) {
+ case NONE:
+ selectedItem = none;
+ break;
+ case UNDERLINE:
+ selectedItem = underline;
+ break;
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ private LinkStyleItem linkStyleItemFor(LinkStyle linkStyle) {
+ switch (linkStyle) {
+ case NONE:
+ return none;
+ case UNDERLINE:
+ return underline;
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public Object itemFor(LinkStyle linkStyle) {
+ return linkStyleItemFor(linkStyle);
+ }
+}
diff --git a/core.output2/src/org/netbeans/core/output2/options/OutputOptions.java b/core.output2/src/org/netbeans/core/output2/options/OutputOptions.java
new file mode 100644
--- /dev/null
+++ b/core.output2/src/org/netbeans/core/output2/options/OutputOptions.java
@@ -0,0 +1,439 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.core.output2.options;
+
+import java.awt.Color;
+import java.awt.EventQueue;
+import java.awt.Font;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+import javax.swing.UIManager;
+import org.netbeans.core.output2.Controller;
+import org.netbeans.swing.plaf.LFCustoms;
+import org.openide.util.NbPreferences;
+import org.openide.util.Parameters;
+import org.openide.util.RequestProcessor;
+import org.openide.windows.IOColors;
+
+/**
+ *
+ * @author jhavlin
+ */
+public class OutputOptions {
+
+ public enum LinkStyle {
+ NONE, UNDERLINE
+ }
+
+ private static OutputOptions DEFAULT = null;
+ private boolean initialized = false;
+ private static final Logger LOG = Logger.getLogger(
+ OutputOptions.class.getName());
+ private static final String PREFIX = "output.settings."; //NOI18N
+ public static final String PROP_FONT = "font"; //NOI18N
+ private static final String PROP_FONT_FAMILY = "font.family"; //NOI18N
+ private static final String PROP_FONT_SIZE = "font.size"; //NOI18N
+ private static final String PROP_FONT_STYLE = "font.style"; //NOI18N
+ public static final String PROP_COLOR_STANDARD = "color.standard"; //NOI18N
+ public static final String PROP_COLOR_ERROR = "color.error"; //NOI18N
+ public static final String PROP_COLOR_LINK = "color.link"; //NOI18N
+ public static final String PROP_COLOR_LINK_IMPORTANT =
+ "color.link.important"; //NOI18N
+ public static final String PROP_COLOR_BACKGROUND =
+ "color.backgorund"; //NOI18N
+ public static final String PROP_STYLE_LINK = "style.link"; //NOI18N
+ private static final String PROP_INITIALIZED = "initialized"; //NOI18N
+ private static final int MIN_FONT_SIZE = 3;
+ private static Font defaultFont = null;
+ private Font font = null;
+ private Color colorStandard;
+ private Color colorError;
+ private Color colorLink;
+ private Color colorLinkImportant;
+ private Color colorBackground;
+ private LinkStyle linkStyle = LinkStyle.UNDERLINE;
+ private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ private OutputOptions(boolean initFromDisk) {
+ resetToDefault();
+ if (!initFromDisk) {
+ return;
+ }
+ RequestProcessor.getDefault().post(new Runnable() {
+ @Override
+ public void run() {
+ loadFrom(NbPreferences.forModule(Controller.class));
+ }
+ });
+ }
+
+ final void resetToDefault() {
+ setDefaultFont();
+ setDefaultColors();
+ setLinkStyle(LinkStyle.UNDERLINE);
+ }
+
+ public void loadFrom(Preferences preferences) {
+ assert !EventQueue.isDispatchThread();
+ final OutputOptions diskData = new OutputOptions(false);
+ String fontFamily = preferences.get(PREFIX + PROP_FONT_FAMILY,
+ getDefaultFont().getFamily());
+ int fontSize = preferences.getInt(PREFIX + PROP_FONT_SIZE,
+ getDefaultFont().getSize());
+ int fontStyle = preferences.getInt(PREFIX + PROP_FONT_STYLE,
+ getDefaultFont().getStyle());
+ diskData.setFont(new Font(fontFamily, fontStyle, fontSize));
+ int rgbStandard = preferences.getInt(PREFIX + PROP_COLOR_STANDARD,
+ getDefaultColorStandard().getRGB());
+ diskData.setColorStandard(new Color(rgbStandard));
+ int rgbError = preferences.getInt(PREFIX + PROP_COLOR_ERROR,
+ getDefaultColorError().getRGB());
+ diskData.setColorError(new Color(rgbError));
+ int rgbBackground = preferences.getInt(PREFIX + PROP_COLOR_BACKGROUND,
+ getDefaultColorBackground().getRGB());
+ diskData.setColorBackground(new Color(rgbBackground));
+ int rgbLink = preferences.getInt(PREFIX + PROP_COLOR_LINK,
+ getDefaultColorLink().getRGB());
+ diskData.setColorLink(new Color(rgbLink));
+ int rgbLinkImportant = preferences.getInt(
+ PREFIX + PROP_COLOR_LINK_IMPORTANT,
+ getDefaultColorLinkImportant().getRGB());
+ String linkStyleStr = preferences.get(PREFIX + PROP_STYLE_LINK,
+ "UNDERLINE"); //NOI18N
+ try {
+ diskData.setLinkStyle(LinkStyle.valueOf(linkStyleStr));
+ } catch (Exception e) {
+ LOG.log(Level.INFO, "Invalid link style {0}", linkStyleStr);//NOI18N
+ }
+ diskData.setColorLinkImportant(new Color(rgbLinkImportant));
+ EventQueue.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ assign(diskData);
+ synchronized (OutputOptions.this) {
+ initialized = true;
+ }
+ pcs.firePropertyChange(PROP_INITIALIZED, false, true);
+ }
+ });
+ }
+
+ public void saveTo(Preferences preferences) {
+ assert !EventQueue.isDispatchThread();
+ preferences.putInt(PREFIX + PROP_COLOR_STANDARD,
+ getColorStandard().getRGB());
+ preferences.putInt(PREFIX + PROP_COLOR_ERROR,
+ getColorError().getRGB());
+ preferences.putInt(PREFIX + PROP_COLOR_BACKGROUND,
+ getColorBackground().getRGB());
+ preferences.putInt(PREFIX + PROP_COLOR_LINK,
+ getColorLink().getRGB());
+ preferences.putInt(PREFIX + PROP_COLOR_LINK_IMPORTANT,
+ getColorLinkImportant().getRGB());
+ preferences.putInt(PREFIX + PROP_FONT_SIZE, getFont().getSize());
+ preferences.putInt(PREFIX + PROP_FONT_STYLE, getFont().getStyle());
+ preferences.put(PREFIX + PROP_FONT_FAMILY, getFont().getFamily());
+ preferences.put(PREFIX + PROP_STYLE_LINK, getLinkStyle().name());
+ try {
+ preferences.flush();
+ } catch (BackingStoreException ex) {
+ LOG.log(Level.INFO, null, ex);
+ }
+ }
+
+ private void setDefaultColors() {
+ setColorStandard(getDefaultColorStandard());
+ setColorError(getDefaultColorError());
+ setColorLink(getDefaultColorLink());
+ setColorLinkImportant(getDefaultColorLinkImportant());
+ setColorBackground(getDefaultColorBackground());
+ }
+
+ private void setDefaultFont() {
+ setFont(getDefaultFont());
+ }
+
+ public static Font getDefaultFont() {
+ if (defaultFont == null) {
+ int size = UIManager.getInt("uiFontSize"); //NOI18N
+ if (size < MIN_FONT_SIZE) {
+ size = UIManager.getInt("customFontSize"); //NOI18N
+ }
+ if (size < MIN_FONT_SIZE) {
+ Font f = (Font) UIManager.get("controlFont"); //NOI18N
+ if (f != null) {
+ size = f.getSize();
+ }
+ }
+ if (size < MIN_FONT_SIZE) {
+ size = 11;
+ }
+ defaultFont = new Font("Monospaced", Font.PLAIN, size); //NOI18N
+ }
+ return defaultFont;
+ }
+
+ public Font getFont() {
+ return font;
+ }
+
+ public Color getColorStandard() {
+ return colorStandard;
+ }
+
+ public Color getColorError() {
+ return colorError;
+ }
+
+ public Color getColorLink() {
+ return colorLink;
+ }
+
+ public Color getColorLinkImportant() {
+ return colorLinkImportant;
+ }
+
+ public Color getColorBackground() {
+ return colorBackground;
+ }
+
+ public LinkStyle getLinkStyle() {
+ return linkStyle;
+ }
+
+ public void setFont(Font font) {
+ Font fontToSet = font == null ? getDefaultFont() : font;
+ if (!fontToSet.equals(this.font)) {
+ Font oldFont = this.font;
+ this.font = fontToSet;
+ pcs.firePropertyChange(PROP_FONT, oldFont, fontToSet);
+ }
+ }
+
+ public void setColorStandard(Color colorStandard) {
+ Parameters.notNull("colorStandard", colorStandard); //NOI18N
+ if (!colorStandard.equals(this.colorStandard)) {
+ Color oldColorStandard = this.colorStandard;
+ this.colorStandard = colorStandard;
+ pcs.firePropertyChange(PROP_COLOR_STANDARD, oldColorStandard,
+ colorStandard);
+ }
+ }
+
+ public void setColorError(Color colorError) {
+ Parameters.notNull("colorError", colorError); //NOI18N
+ if (!colorError.equals(this.colorError)) {
+ Color oldColorError = this.colorError;
+ this.colorError = colorError;
+ pcs.firePropertyChange(PROP_COLOR_ERROR, oldColorError, colorError);
+ }
+ }
+
+ public void setColorLink(Color colorLink) {
+ Parameters.notNull("colorLink", colorLink); //NOI18N
+ if (!colorLink.equals(this.colorLink)) {
+ Color oldColorLink = this.colorLink;
+ this.colorLink = colorLink;
+ pcs.firePropertyChange(PROP_COLOR_LINK, oldColorLink, colorLink);
+ }
+ }
+
+ public void setColorLinkImportant(Color colorLinkImportant) {
+ Parameters.notNull("colorLinkImportant", colorLinkImportant); //NOI18N
+ if (!colorLinkImportant.equals(this.colorLinkImportant)) {
+ Color oldColorLinkImportant = this.colorLinkImportant;
+ this.colorLinkImportant = colorLinkImportant;
+ pcs.firePropertyChange(PROP_COLOR_LINK_IMPORTANT,
+ oldColorLinkImportant, colorLinkImportant);
+ }
+ }
+
+ public void setColorBackground(Color colorBackground) {
+ Parameters.notNull("colorBackground", colorBackground); //NOI18N
+ if (!colorBackground.equals(this.colorBackground)) {
+ Color oldColorBackground = this.colorBackground;
+ this.colorBackground = colorBackground;
+ pcs.firePropertyChange(PROP_COLOR_BACKGROUND, oldColorBackground,
+ colorBackground);
+ }
+ }
+
+ public void setLinkStyle(LinkStyle linkStyle) {
+ Parameters.notNull("linkStyle", linkStyle); //NOI18N
+ if (!linkStyle.equals(this.linkStyle)) {
+ LinkStyle oldLinkStyle = this.linkStyle;
+ this.linkStyle = linkStyle;
+ pcs.firePropertyChange(PROP_STYLE_LINK, oldLinkStyle, linkStyle);
+ }
+ }
+
+ public static synchronized OutputOptions getDefault() {
+ if (DEFAULT == null) {
+ DEFAULT = new OutputOptions(true);
+ }
+ return DEFAULT;
+ }
+
+ public void addPropertyChangeListener(
+ PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(
+ PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * Create a copy of this object, with the same options values, but with
+ * separate set of listeners.
+ */
+ public OutputOptions makeCopy() {
+ final OutputOptions copy = new OutputOptions(false);
+ copy.font = font;
+ copy.colorStandard = this.colorStandard;
+ copy.colorError = this.colorError;
+ copy.colorBackground = this.colorBackground;
+ copy.colorLink = this.colorLink;
+ copy.colorLinkImportant = this.colorLinkImportant;
+ copy.initialized = initialized;
+ copy.linkStyle = linkStyle;
+ if (!initialized) {
+ PropertyChangeListener l = new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getPropertyName().equals(PROP_INITIALIZED)) {
+ copy.assign(OutputOptions.this);
+ copy.initialized = true;
+ copy.pcs.firePropertyChange(PROP_INITIALIZED,
+ false, true);
+ OutputOptions.this.removePropertyChangeListener(this);
+ }
+ }
+ };
+ OutputOptions.this.addPropertyChangeListener(l);
+ }
+ return copy;
+ }
+
+ /**
+ * Assign values from another object.
+ */
+ public void assign(OutputOptions outputOptions) {
+ this.setFont(outputOptions.getFont());
+ this.setColorStandard(outputOptions.getColorStandard());
+ this.setColorError(outputOptions.getColorError());
+ this.setColorLink(outputOptions.getColorLink());
+ this.setColorLinkImportant(outputOptions.getColorLinkImportant());
+ this.setColorBackground(outputOptions.getColorBackground());
+ this.setLinkStyle(outputOptions.getLinkStyle());
+ }
+
+ static Color getDefaultColorStandard() {
+ Color out = UIManager.getColor("nb.output.foreground"); //NOI18N
+ if (out == null) {
+ out = UIManager.getColor("textText"); //NOI18N
+ if (out == null) {
+ out = Color.BLACK;
+ }
+ }
+ return out;
+ }
+
+ static Color getDefaultColorBackground() {
+ Color back = UIManager.getColor("nb.output.backgorund"); //NOI18N
+ if (back == null) {
+ back = UIManager.getColor("text"); //NOI18N
+ if (back == null) {
+ back = Color.WHITE;
+ }
+ }
+ return back;
+ }
+
+ static Color getDefaultColorError() {
+ Color err = UIManager.getColor("nb.output.err.foreground"); //NOI18N
+ if (err == null) {
+ err = LFCustoms.shiftColor(Color.red);
+ }
+ return err;
+ }
+
+ static Color getDefaultColorLink() {
+ Color hyperlink = UIManager.getColor(
+ "nb.output.link.foreground"); //NOI18N
+ if (hyperlink == null) {
+ hyperlink = LFCustoms.shiftColor(Color.blue);
+ }
+ return hyperlink;
+ }
+
+ static Color getDefaultColorLinkImportant() {
+ Color hyperlinkImp = UIManager.getColor(
+ "nb.output.link.foreground.important"); //NOI18N
+ if (hyperlinkImp == null) {
+ return getDefaultColorLink();
+ } else {
+ return hyperlinkImp;
+ }
+ }
+
+ public Color getColorForType(IOColors.OutputType type) {
+ switch (type) {
+ case OUTPUT:
+ return getColorStandard();
+ case ERROR:
+ return getColorError();
+ case HYPERLINK:
+ return getColorLink();
+ case HYPERLINK_IMPORTANT:
+ return getColorLinkImportant();
+ default:
+ return getColorStandard();
+ }
+ }
+}
diff --git a/core.output2/src/org/netbeans/core/output2/options/OutputSettingsOptionsPanelController.java b/core.output2/src/org/netbeans/core/output2/options/OutputSettingsOptionsPanelController.java
new file mode 100644
--- /dev/null
+++ b/core.output2/src/org/netbeans/core/output2/options/OutputSettingsOptionsPanelController.java
@@ -0,0 +1,127 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.core.output2.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+@OptionsPanelController.SubRegistration(
+ location = "Advanced",
+displayName = "#AdvancedOption_DisplayName_OutputSettings",
+keywords = "#AdvancedOption_Keywords_OutputSettings",
+keywordsCategory = "Advanced/OutputSettings",
+id="OutputSettings")
+@org.openide.util.NbBundle.Messages({
+ "AdvancedOption_DisplayName_OutputSettings=Output",
+ "AdvancedOption_Keywords_OutputSettings=Output Window Font Color"})
+public final class OutputSettingsOptionsPanelController extends OptionsPanelController {
+
+ private OutputSettingsPanel panel;
+ private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ private boolean changed;
+
+ @Override
+ public void update() {
+ getPanel().load();
+ changed = false;
+ }
+
+ @Override
+ public void applyChanges() {
+ getPanel().store();
+ changed = false;
+ }
+
+ @Override
+ public void cancel() {
+ // need not do anything special, if no changes have been persisted yet
+ }
+
+ @Override
+ public boolean isValid() {
+ return getPanel().valid();
+ }
+
+ @Override
+ public boolean isChanged() {
+ return changed;
+ }
+
+ @Override
+ public HelpCtx getHelpCtx() {
+ return null; // new HelpCtx("...ID") if you have a help set
+ }
+
+ @Override
+ public JComponent getComponent(Lookup masterLookup) {
+ return getPanel();
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener l) {
+ pcs.addPropertyChangeListener(l);
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener l) {
+ pcs.removePropertyChangeListener(l);
+ }
+
+ private OutputSettingsPanel getPanel() {
+ if (panel == null) {
+ panel = new OutputSettingsPanel(this);
+ }
+ return panel;
+ }
+
+ void changed() {
+ if (!changed) {
+ changed = true;
+ pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
+ }
+ pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
+ }
+}
diff --git a/core.output2/src/org/netbeans/core/output2/options/OutputSettingsPanel.form b/core.output2/src/org/netbeans/core/output2/options/OutputSettingsPanel.form
new file mode 100644
--- /dev/null
+++ b/core.output2/src/org/netbeans/core/output2/options/OutputSettingsPanel.form
@@ -0,0 +1,393 @@
+
+
+
diff --git a/core.output2/src/org/netbeans/core/output2/options/OutputSettingsPanel.java b/core.output2/src/org/netbeans/core/output2/options/OutputSettingsPanel.java
new file mode 100644
--- /dev/null
+++ b/core.output2/src/org/netbeans/core/output2/options/OutputSettingsPanel.java
@@ -0,0 +1,542 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.core.output2.options;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.IOException;
+import javax.swing.Action;
+import javax.swing.JComboBox;
+import org.netbeans.core.output2.Controller;
+import org.netbeans.core.output2.NbIOProvider;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.awt.ColorComboBox;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+import org.openide.util.NbPreferences;
+import org.openide.util.RequestProcessor;
+import org.openide.windows.IOColorPrint;
+import org.openide.windows.IOContainer;
+import org.openide.windows.InputOutput;
+import org.openide.windows.OutputEvent;
+import org.openide.windows.OutputListener;
+
+@NbBundle.Messages({
+ "LBL_Description=Output Window Settings"
+})
+public final class OutputSettingsPanel extends javax.swing.JPanel {
+
+ private OutputOptions outputOptions;
+ private InputOutput previewInputOutput = null;
+ private final OutputSettingsOptionsPanelController controller;
+ private LinkStyleModel linkStyleModel = new LinkStyleModel();
+
+ OutputSettingsPanel(OutputSettingsOptionsPanelController controller) {
+ this.controller = controller;
+ initComponents();
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+ bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
+
+ lblTitle = new javax.swing.JLabel();
+ jPanel2 = new javax.swing.JPanel();
+ lblFontFamily = new javax.swing.JLabel();
+ lblStandardColor = new javax.swing.JLabel();
+ lblErrorColor = new javax.swing.JLabel();
+ lblBackgroundColor = new javax.swing.JLabel();
+ lblLinkColor = new javax.swing.JLabel();
+ cmbLinkColor = new ColorComboBox();
+ cmbBackgroundColor = new ColorComboBox();
+ cmbErrorColor = new ColorComboBox();
+ cmbStandardColor = new ColorComboBox();
+ lblFontSize = new javax.swing.JLabel();
+ spnFontSize = new javax.swing.JSpinner();
+ btnSelectFont = new javax.swing.JButton();
+ cmbLinkStyle = new javax.swing.JComboBox();
+ lblLinkStyle = new javax.swing.JLabel();
+ fldFontFamily = new javax.swing.JTextField();
+ cmbImportantLinkColor = new ColorComboBox();
+ jLabel1 = new javax.swing.JLabel();
+ previewPanel = new javax.swing.JPanel();
+ btnRestore = new javax.swing.JButton();
+
+ org.openide.awt.Mnemonics.setLocalizedText(lblTitle, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.lblTitle.text")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(lblFontFamily, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.lblFontFamily.text")); // NOI18N
+
+ org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, btnSelectFont, org.jdesktop.beansbinding.ObjectProperty.create(), lblFontFamily, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
+ bindingGroup.addBinding(binding);
+
+ org.openide.awt.Mnemonics.setLocalizedText(lblStandardColor, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.lblStandardColor.text")); // NOI18N
+
+ binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cmbStandardColor, org.jdesktop.beansbinding.ObjectProperty.create(), lblStandardColor, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
+ bindingGroup.addBinding(binding);
+
+ org.openide.awt.Mnemonics.setLocalizedText(lblErrorColor, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.lblErrorColor.text")); // NOI18N
+
+ binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cmbErrorColor, org.jdesktop.beansbinding.ObjectProperty.create(), lblErrorColor, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
+ bindingGroup.addBinding(binding);
+
+ org.openide.awt.Mnemonics.setLocalizedText(lblBackgroundColor, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.lblBackgroundColor.text")); // NOI18N
+
+ binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cmbBackgroundColor, org.jdesktop.beansbinding.ObjectProperty.create(), lblBackgroundColor, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
+ bindingGroup.addBinding(binding);
+
+ org.openide.awt.Mnemonics.setLocalizedText(lblLinkColor, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.lblLinkColor.text")); // NOI18N
+
+ binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cmbLinkColor, org.jdesktop.beansbinding.ObjectProperty.create(), lblLinkColor, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
+ bindingGroup.addBinding(binding);
+
+ cmbLinkColor.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.cmbLinkColor.toolTipText")); // NOI18N
+ cmbLinkColor.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbLinkColorActionPerformed(evt);
+ }
+ });
+
+ cmbBackgroundColor.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.cmbBackgroundColor.toolTipText")); // NOI18N
+ cmbBackgroundColor.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbBackgroundColorActionPerformed(evt);
+ }
+ });
+
+ cmbErrorColor.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.cmbErrorColor.toolTipText")); // NOI18N
+ cmbErrorColor.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbErrorColorActionPerformed(evt);
+ }
+ });
+
+ cmbStandardColor.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.cmbStandardColor.toolTipText")); // NOI18N
+ cmbStandardColor.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbStandardColorActionPerformed(evt);
+ }
+ });
+
+ org.openide.awt.Mnemonics.setLocalizedText(lblFontSize, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.lblFontSize.text")); // NOI18N
+
+ binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, spnFontSize, org.jdesktop.beansbinding.ObjectProperty.create(), lblFontSize, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
+ bindingGroup.addBinding(binding);
+
+ spnFontSize.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.spnFontSize.toolTipText")); // NOI18N
+ spnFontSize.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ spnFontSizeStateChanged(evt);
+ }
+ });
+
+ org.openide.awt.Mnemonics.setLocalizedText(btnSelectFont, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.btnSelectFont.text")); // NOI18N
+ btnSelectFont.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.btnSelectFont.toolTipText")); // NOI18N
+ btnSelectFont.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnSelectFontActionPerformed(evt);
+ }
+ });
+
+ cmbLinkStyle.setModel(linkStyleModel);
+ cmbLinkStyle.setSelectedIndex(0);
+ cmbLinkStyle.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.cmbLinkStyle.toolTipText")); // NOI18N
+ cmbLinkStyle.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbLinkStyleActionPerformed(evt);
+ }
+ });
+
+ org.openide.awt.Mnemonics.setLocalizedText(lblLinkStyle, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.lblLinkStyle.text")); // NOI18N
+
+ binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cmbLinkStyle, org.jdesktop.beansbinding.ObjectProperty.create(), lblLinkStyle, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
+ bindingGroup.addBinding(binding);
+
+ fldFontFamily.setEditable(false);
+ fldFontFamily.setText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.fldFontFamily.text")); // NOI18N
+
+ cmbImportantLinkColor.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.cmbImportantLinkColor.toolTipText")); // NOI18N
+ cmbImportantLinkColor.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbImportantLinkColorActionPerformed(evt);
+ }
+ });
+
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.jLabel1.text")); // NOI18N
+
+ binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cmbImportantLinkColor, org.jdesktop.beansbinding.ObjectProperty.create(), jLabel1, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
+ bindingGroup.addBinding(binding);
+
+ javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
+ jPanel2.setLayout(jPanel2Layout);
+ jPanel2Layout.setHorizontalGroup(
+ jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(lblLinkColor)
+ .addComponent(lblFontFamily)
+ .addComponent(lblBackgroundColor)
+ .addComponent(lblFontSize)
+ .addComponent(jLabel1)
+ .addComponent(lblLinkStyle))
+ .addGap(79, 79, 79)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(cmbLinkStyle, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(cmbLinkColor, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
+ .addComponent(fldFontFamily)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(btnSelectFont))
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addComponent(spnFontSize, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(0, 46, Short.MAX_VALUE))
+ .addComponent(cmbImportantLinkColor, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(cmbBackgroundColor, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(lblErrorColor)
+ .addComponent(lblStandardColor))
+ .addGap(104, 104, 104)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(cmbErrorColor, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(cmbStandardColor, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
+ .addContainerGap())
+ );
+ jPanel2Layout.setVerticalGroup(
+ jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lblFontFamily)
+ .addComponent(btnSelectFont)
+ .addComponent(fldFontFamily, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lblFontSize)
+ .addComponent(spnFontSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lblBackgroundColor)
+ .addComponent(cmbBackgroundColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(cmbStandardColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblStandardColor))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(cmbErrorColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblErrorColor))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lblLinkColor)
+ .addComponent(cmbLinkColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(cmbImportantLinkColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel1))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(cmbLinkStyle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblLinkStyle))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ previewPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
+ previewPanel.setLayout(new javax.swing.BoxLayout(previewPanel, javax.swing.BoxLayout.LINE_AXIS));
+
+ org.openide.awt.Mnemonics.setLocalizedText(btnRestore, org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.btnRestore.text")); // NOI18N
+ btnRestore.setToolTipText(org.openide.util.NbBundle.getMessage(OutputSettingsPanel.class, "OutputSettingsPanel.btnRestore.toolTipText")); // NOI18N
+ btnRestore.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnRestoreActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(previewPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
+ .addComponent(lblTitle)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(btnRestore)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lblTitle)
+ .addComponent(btnRestore))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(previewPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+
+ bindingGroup.bind();
+ }// //GEN-END:initComponents
+
+ private void btnSelectFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectFontActionPerformed
+ PropertyEditor pe = PropertyEditorManager.findEditor(Font.class);
+ if (pe != null) {
+ pe.setValue(outputOptions.getFont());
+ DialogDescriptor dd = new DialogDescriptor(pe.getCustomEditor(),
+ NbBundle.getMessage(Controller.class,
+ "LBL_Font_Chooser_Title")); //NOI18N
+ String defaultFont = NbBundle.getMessage(Controller.class,
+ "BTN_Defaul_Font"); //NOI18N
+ dd.setOptions(new Object[]{DialogDescriptor.OK_OPTION,
+ defaultFont, DialogDescriptor.CANCEL_OPTION}); //NOI18N
+ DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
+ if (dd.getValue() == DialogDescriptor.OK_OPTION) {
+ Font f = (Font) pe.getValue();
+ outputOptions.setFont(f);
+ } else if (dd.getValue() == defaultFont) {
+ outputOptions.setFont(null);
+ }
+ updateFontField();
+ }
+ }//GEN-LAST:event_btnSelectFontActionPerformed
+
+ private void cmbStandardColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbStandardColorActionPerformed
+ Color std = ((ColorComboBox) cmbStandardColor).getSelectedColor();
+ if (std != null) {
+ outputOptions.setColorStandard(std);
+ }
+ }//GEN-LAST:event_cmbStandardColorActionPerformed
+
+ private void spnFontSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnFontSizeStateChanged
+ int fontSize = (Integer) spnFontSize.getValue();
+ outputOptions.setFont(outputOptions.getFont().deriveFont(
+ (float) fontSize));
+ updateFontField();
+ }//GEN-LAST:event_spnFontSizeStateChanged
+
+ private void cmbBackgroundColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbBackgroundColorActionPerformed
+ Color bg = ((ColorComboBox) cmbBackgroundColor).getSelectedColor();
+ if (bg != null) {
+ outputOptions.setColorBackground(bg);
+ }
+ }//GEN-LAST:event_cmbBackgroundColorActionPerformed
+
+ private void cmbErrorColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbErrorColorActionPerformed
+ Color err = ((ColorComboBox) cmbErrorColor).getSelectedColor();
+ if (err != null) {
+ outputOptions.setColorError(err);
+ }
+ }//GEN-LAST:event_cmbErrorColorActionPerformed
+
+ private void cmbLinkColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbLinkColorActionPerformed
+ Color link = ((ColorComboBox) cmbLinkColor).getSelectedColor();
+ if (link != null) {
+ outputOptions.setColorLink(link);
+ }
+ }//GEN-LAST:event_cmbLinkColorActionPerformed
+
+ private void cmbImportantLinkColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbImportantLinkColorActionPerformed
+ Color iLink = ((ColorComboBox) cmbImportantLinkColor).
+ getSelectedColor();
+ if (iLink != null) {
+ outputOptions.setColorLinkImportant(iLink);
+ }
+ }//GEN-LAST:event_cmbImportantLinkColorActionPerformed
+
+ private void btnRestoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRestoreActionPerformed
+ outputOptions.resetToDefault();
+ updateControlsByModel();
+ }//GEN-LAST:event_btnRestoreActionPerformed
+
+ private void cmbLinkStyleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbLinkStyleActionPerformed
+ outputOptions.setLinkStyle(linkStyleModel.getLinkStyle());
+ }//GEN-LAST:event_cmbLinkStyleActionPerformed
+
+ void load() {
+ if (previewInputOutput == null) {
+ initPreview();
+ }
+ updateControlsByModel();
+ }
+
+ private void selectColor(JComboBox combo, Color color) {
+ ((ColorComboBox) combo).setSelectedColor(color);
+ }
+
+ private void updateFontField() {
+ Font f = outputOptions.getFont();
+ fldFontFamily.setText(f.getFamily() + " " + f.getSize()); //NOI18N
+ }
+
+ void store() {
+ Controller.getDefault().updateOptions(outputOptions);
+ OutputOptions.getDefault().assign(outputOptions);
+ RequestProcessor.getDefault().post(new Runnable() {
+ @Override
+ public void run() {
+ OutputOptions.getDefault().saveTo(
+ NbPreferences.forModule(Controller.class));
+ }
+ });
+ }
+
+ void cancel() {
+ if (previewInputOutput != null) {
+ previewInputOutput.closeInputOutput();
+ }
+ }
+
+ boolean valid() {
+ // TODO check whether form is consistent and complete
+ return true;
+ }
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton btnRestore;
+ private javax.swing.JButton btnSelectFont;
+ private javax.swing.JComboBox cmbBackgroundColor;
+ private javax.swing.JComboBox cmbErrorColor;
+ private javax.swing.JComboBox cmbImportantLinkColor;
+ private javax.swing.JComboBox cmbLinkColor;
+ private javax.swing.JComboBox cmbLinkStyle;
+ private javax.swing.JComboBox cmbStandardColor;
+ private javax.swing.JTextField fldFontFamily;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JLabel lblBackgroundColor;
+ private javax.swing.JLabel lblErrorColor;
+ private javax.swing.JLabel lblFontFamily;
+ private javax.swing.JLabel lblFontSize;
+ private javax.swing.JLabel lblLinkColor;
+ private javax.swing.JLabel lblLinkStyle;
+ private javax.swing.JLabel lblStandardColor;
+ private javax.swing.JLabel lblTitle;
+ private javax.swing.JPanel previewPanel;
+ private javax.swing.JSpinner spnFontSize;
+ private org.jdesktop.beansbinding.BindingGroup bindingGroup;
+ // End of variables declaration//GEN-END:variables
+
+ private void initPreview() {
+ previewInputOutput = initPreviewInputOutput();
+ outputOptions = ((Lookup.Provider) previewInputOutput).
+ getLookup().lookup(OutputOptions.class);
+ previewInputOutput.getOut().println("Standard Output"); //NOI18N
+ previewInputOutput.getErr().println("Error Output"); //NOI18N
+ OutputListener ol = new OutputListenerImpl();
+ try {
+ IOColorPrint.print(previewInputOutput, "Standard Link", //NOI18N
+ ol, false, null);
+ previewInputOutput.getOut().println();
+ IOColorPrint.print(previewInputOutput, "Important Link", //NOI18N
+ ol, true, null);
+ previewInputOutput.getOut().print(" "); //NOI18N
+ } catch (IOException ex) {
+ ex.printStackTrace(previewInputOutput.getErr());
+ }
+ previewInputOutput.getOut().close();
+ previewInputOutput.getErr().close();
+ outputOptions.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ controller.changed();
+ updateControlsByModel();
+ }
+ });
+ }
+
+ private InputOutput initPreviewInputOutput() throws NullPointerException {
+ IOContainer ioContainer = IOContainer.create(
+ new PreviewIOProvider(previewPanel));
+ InputOutput io = NbIOProvider.getDefault().getIO(
+ "Preview", false, new Action[0], ioContainer); //NOI18N
+ return io;
+ }
+
+ private void updateControlsByModel() {
+ updateFontField();
+ spnFontSize.setValue(outputOptions.getFont().getSize());
+ selectColor(cmbStandardColor, outputOptions.getColorStandard());
+ selectColor(cmbErrorColor, outputOptions.getColorError());
+ selectColor(cmbBackgroundColor, outputOptions.getColorBackground());
+ selectColor(cmbLinkColor, outputOptions.getColorLink());
+ selectColor(cmbImportantLinkColor,
+ outputOptions.getColorLinkImportant());
+ cmbLinkStyle.setSelectedItem(
+ linkStyleModel.itemFor(outputOptions.getLinkStyle()));
+ cmbLinkStyle.repaint();
+ }
+
+ private static class OutputListenerImpl implements OutputListener {
+
+ public OutputListenerImpl() {
+ }
+
+ @Override
+ public void outputLineSelected(OutputEvent ev) {
+ }
+
+ @Override
+ public void outputLineAction(OutputEvent ev) {
+ }
+
+ @Override
+ public void outputLineCleared(OutputEvent ev) {
+ }
+ }
+}
diff --git a/core.output2/src/org/netbeans/core/output2/options/PreviewIOProvider.java b/core.output2/src/org/netbeans/core/output2/options/PreviewIOProvider.java
new file mode 100644
--- /dev/null
+++ b/core.output2/src/org/netbeans/core/output2/options/PreviewIOProvider.java
@@ -0,0 +1,121 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.core.output2.options;
+
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import org.openide.windows.IOContainer;
+import org.openide.windows.IOContainer.CallBacks;
+
+/**
+ *
+ * @author jhavlin
+ */
+public class PreviewIOProvider implements IOContainer.Provider {
+
+ JPanel panel;
+
+ public PreviewIOProvider(JPanel panel) {
+ this.panel = panel;
+ }
+
+ @Override
+ public void open() {
+ }
+
+ @Override
+ public void requestActive() {
+ panel.requestFocusInWindow();
+ }
+
+ @Override
+ public void requestVisible() {
+ panel.requestFocusInWindow();
+ }
+
+ @Override
+ public boolean isActivated() {
+ return panel.hasFocus();
+ }
+
+ @Override
+ public void add(JComponent comp, CallBacks cb) {
+ panel.add(comp);
+ }
+
+ @Override
+ public void remove(JComponent comp) {
+ panel.remove(comp);
+ }
+
+ @Override
+ public void select(JComponent comp) {
+ }
+
+ @Override
+ public JComponent getSelected() {
+ return (JComponent) panel.getComponent(0);
+ }
+
+ @Override
+ public void setTitle(JComponent comp, String name) {
+ }
+
+ @Override
+ public void setToolTipText(JComponent comp, String text) {
+ }
+
+ @Override
+ public void setIcon(JComponent comp, Icon icon) {
+ }
+
+ @Override
+ public void setToolbarActions(JComponent comp, Action[] toolbarActions) {
+ }
+
+ @Override
+ public boolean isCloseable(JComponent comp) {
+ return false;
+ }
+}
diff --git a/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputPane.java b/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputPane.java
--- a/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputPane.java
+++ b/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputPane.java
@@ -55,6 +55,7 @@
import java.awt.event.*;
import org.netbeans.core.output2.Controller;
import org.netbeans.core.output2.OutputDocument;
+import org.netbeans.core.output2.options.OutputOptions;
import org.openide.util.Exceptions;
/**
@@ -596,6 +597,12 @@
}
public void mouseClicked(MouseEvent e) {
+ if (e.isAltDown() || e.isAltGraphDown() || e.isControlDown()
+ && SwingUtilities.isMiddleMouseButton(e)) {
+ int currentSize = getViewFont().getSize();
+ int defaultSize = OutputOptions.getDefault().getFont().getSize();
+ changeFontSizeBy(defaultSize - currentSize);
+ }
}
public void mouseEntered(MouseEvent e) {
@@ -735,7 +742,7 @@
protected abstract void changeFontSizeBy(int change);
public final void mouseWheelMoved(MouseWheelEvent e) {
- if (e.isControlDown()) {
+ if (e.isAltDown() || e.isAltGraphDown() || e.isControlDown()) {
int change = -e.getWheelRotation();
changeFontSizeBy(change);
e.consume();
diff --git a/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputTab.java b/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputTab.java
--- a/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputTab.java
+++ b/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputTab.java
@@ -53,6 +53,7 @@
import javax.swing.text.Document;
import java.awt.*;
import org.netbeans.core.output2.OutputDocument;
+import org.netbeans.core.output2.options.OutputOptions;
/**
* A basic output pane. This class implements the non-output window specific