Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMat Booth2016-05-19 14:05:59 +0000
committerMat Booth2016-05-19 17:33:19 +0000
commitd4c08f4fb852279c6fffe2507eaec4017151efad (patch)
tree4ccb2dc9d4a5f0eb14f1479ec1ab70d927551de5
parent4527573de1c1079b8a593783e2ab75a6b2cd4284 (diff)
downloadorg.eclipse.linuxtools-d4c08f4fb852279c6fffe2507eaec4017151efad.tar.gz
org.eclipse.linuxtools-d4c08f4fb852279c6fffe2507eaec4017151efad.tar.xz
org.eclipse.linuxtools-d4c08f4fb852279c6fffe2507eaec4017151efad.zip
Formatting changes only.
Re-format code in man.core plugin to comply with the project's code style configuration. Change-Id: I561926a87b68597e46ef14cd8c2ba9eb9f348f9f Signed-off-by: Mat Booth <mat.booth@redhat.com> Reviewed-on: https://git.eclipse.org/r/73177 Tested-by: Hudson CI
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/Activator.java72
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManDocument.java84
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java278
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/Messages.java16
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/Messages.java30
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java8
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/views/ManTextViewer.java64
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/parser/ManPage.java254
-rw-r--r--man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/views/ManView.java75
9 files changed, 440 insertions, 441 deletions
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/Activator.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/Activator.java
index ee486eb08e..a1b4655f71 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/Activator.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/Activator.java
@@ -18,40 +18,40 @@ import org.osgi.framework.BundleContext;
*/
public class Activator extends AbstractUIPlugin {
- // The shared instance
- private static Activator plugin;
-
- private BundleContext context;
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- this.context = context;
- plugin = this;
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- this.context = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance of the bundle activator.
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * Returns the bundle symbolic name of the plug-in.
- *
- * @return an ID unique to this plug-in
- */
- public String getPluginId() {
- return context.getBundle().getSymbolicName();
- }
+ // The shared instance
+ private static Activator plugin;
+
+ private BundleContext context;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ this.context = context;
+ plugin = this;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ this.context = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance of the bundle activator.
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns the bundle symbolic name of the plug-in.
+ *
+ * @return an ID unique to this plug-in
+ */
+ public String getPluginId() {
+ return context.getBundle().getSymbolicName();
+ }
}
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManDocument.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManDocument.java
index 73253fc202..9327c3c23d 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManDocument.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManDocument.java
@@ -21,50 +21,50 @@ import org.eclipse.jface.text.Document;
// TODO consider bold and underline symbols to handle ranges.
public class ManDocument extends Document {
- private static final String BOLD = "\b"; //$NON-NLS-1$
- private List<Integer> boldSymbols = new ArrayList<>();
- private List<Integer> underlineSymbols = new ArrayList<>();
+ private static final String BOLD = "\b"; //$NON-NLS-1$
+ private List<Integer> boldSymbols = new ArrayList<>();
+ private List<Integer> underlineSymbols = new ArrayList<>();
- /**
- * Creates an IDocument for the given man page and taking care for marking
- * bold and underline symbols.
- *
- * @param manPage
- * The man page to create document for.
- */
- public ManDocument(String manPage) {
- StringBuilder sb = new ManParser().getRawManPage(manPage);
- while (sb.indexOf(BOLD) != -1) {
- int index = sb.indexOf(BOLD);
- if (sb.charAt(index - 1) == '_') {
- sb.replace(index - 1, index + 2,
- sb.substring(index + 1, index + 2));
- underlineSymbols.add(index - 1);
- } else {
- sb.replace(index - 1, index + 1,
- sb.substring(index - 1, index - 1));
- boldSymbols.add(index - 1);
- }
- }
- set(sb.toString());
+ /**
+ * Creates an IDocument for the given man page and taking care for marking
+ * bold and underline symbols.
+ *
+ * @param manPage
+ * The man page to create document for.
+ */
+ public ManDocument(String manPage) {
+ StringBuilder sb = new ManParser().getRawManPage(manPage);
+ while (sb.indexOf(BOLD) != -1) {
+ int index = sb.indexOf(BOLD);
+ if (sb.charAt(index - 1) == '_') {
+ sb.replace(index - 1, index + 2,
+ sb.substring(index + 1, index + 2));
+ underlineSymbols.add(index - 1);
+ } else {
+ sb.replace(index - 1, index + 1,
+ sb.substring(index - 1, index - 1));
+ boldSymbols.add(index - 1);
+ }
+ }
+ set(sb.toString());
- }
+ }
- /**
- * Returns the indexes of bold symbols.
- *
- * @return List of bold symbols.
- */
- public List<Integer> getBoldSymbols() {
- return boldSymbols;
- }
+ /**
+ * Returns the indexes of bold symbols.
+ *
+ * @return List of bold symbols.
+ */
+ public List<Integer> getBoldSymbols() {
+ return boldSymbols;
+ }
- /**
- * Returns the indexes of underline symbols.
- *
- * @return List of underline symbols.
- */
- public List<Integer> getUnderlinedSymbols() {
- return underlineSymbols;
- }
+ /**
+ * Returns the indexes of underline symbols.
+ *
+ * @return List of underline symbols.
+ */
+ public List<Integer> getUnderlinedSymbols() {
+ return underlineSymbols;
+ }
}
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java
index d0e12f736a..da07515366 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java
@@ -35,150 +35,150 @@ import com.jcraft.jsch.JSchException;
*/
public class ManParser {
- /**
- * Gets the list of paths returned when one runs "man -w" with no other
- * parameters. This is the list of directories that is searched by man for
- * man pages.
- *
- * @return the list of paths in which man searches for man pages in same
- * order that man would return them
- */
- public static List<Path> getManPaths() {
- // Build param list
- List<String> params = new ArrayList<>();
- params.add(getManExecutable());
- params.add("-w"); //$NON-NLS-1$
+ /**
+ * Gets the list of paths returned when one runs "man -w" with no other
+ * parameters. This is the list of directories that is searched by man for
+ * man pages.
+ *
+ * @return the list of paths in which man searches for man pages in same
+ * order that man would return them
+ */
+ public static List<Path> getManPaths() {
+ // Build param list
+ List<String> params = new ArrayList<>();
+ params.add(getManExecutable());
+ params.add("-w"); //$NON-NLS-1$
- List<Path> manPaths = new ArrayList<>();
- ProcessBuilder builder = new ProcessBuilder(params);
- try (InputStream stdout = builder.start().getInputStream()) {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- int x;
- while ((x = stdout.read()) != -1) {
- bos.write(x);
- }
- for (String path : bos.toString().trim()
- .split(File.pathSeparator)) {
- manPaths.add(Paths.get(path));
- }
- } catch (IOException e) {
- Status status = new Status(IStatus.ERROR, e.getMessage(),
- Activator.getDefault().getPluginId());
- Activator.getDefault().getLog().log(status);
- }
- return manPaths;
- }
+ List<Path> manPaths = new ArrayList<>();
+ ProcessBuilder builder = new ProcessBuilder(params);
+ try (InputStream stdout = builder.start().getInputStream()) {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ int x;
+ while ((x = stdout.read()) != -1) {
+ bos.write(x);
+ }
+ for (String path : bos.toString().trim()
+ .split(File.pathSeparator)) {
+ manPaths.add(Paths.get(path));
+ }
+ } catch (IOException e) {
+ Status status = new Status(IStatus.ERROR, e.getMessage(),
+ Activator.getDefault().getPluginId());
+ Activator.getDefault().getLog().log(status);
+ }
+ return manPaths;
+ }
- /**
- * Opens a manual page and returns an input stream from which to read it.
- *
- * @param page
- * the name of the man page to open
- * @param html
- * true to open the given man page as an HTML document, false to
- * open it as a plain text document suitable for display in a
- * terminal
- * @param sections
- * a string array of manual sections in which to look for the
- * given man page
- * @return a new input stream, the caller is responsible for closing it
- */
- public InputStream getManPage(String page, boolean html,
- String... sections) {
- StringBuilder sectionParam = new StringBuilder();
- for (String section : sections) {
- if (sectionParam.length() > 0) {
- sectionParam.append(':');
- }
- sectionParam.append(section);
- }
+ /**
+ * Opens a manual page and returns an input stream from which to read it.
+ *
+ * @param page
+ * the name of the man page to open
+ * @param html
+ * true to open the given man page as an HTML document, false to
+ * open it as a plain text document suitable for display in a
+ * terminal
+ * @param sections
+ * a string array of manual sections in which to look for the
+ * given man page
+ * @return a new input stream, the caller is responsible for closing it
+ */
+ public InputStream getManPage(String page, boolean html,
+ String... sections) {
+ StringBuilder sectionParam = new StringBuilder();
+ for (String section : sections) {
+ if (sectionParam.length() > 0) {
+ sectionParam.append(':');
+ }
+ sectionParam.append(section);
+ }
- // Build param list
- List<String> params = new ArrayList<>();
- params.add(getManExecutable());
- if (page != null && !page.isEmpty() && sectionParam.length() > 0) {
- params.add("-S"); //$NON-NLS-1$
- params.add(sectionParam.toString());
- }
- if (html) {
- params.add("-Thtml"); //$NON-NLS-1$
- }
- params.add(page);
+ // Build param list
+ List<String> params = new ArrayList<>();
+ params.add(getManExecutable());
+ if (page != null && !page.isEmpty() && sectionParam.length() > 0) {
+ params.add("-S"); //$NON-NLS-1$
+ params.add(sectionParam.toString());
+ }
+ if (html) {
+ params.add("-Thtml"); //$NON-NLS-1$
+ }
+ params.add(page);
- ProcessBuilder builder = new ProcessBuilder(params);
- InputStream stdout = null;
- try {
- Process process = builder.start();
- stdout = process.getInputStream();
- } catch (IOException e) {
- Status status = new Status(IStatus.ERROR, e.getMessage(),
- Activator.getDefault().getPluginId());
- Activator.getDefault().getLog().log(status);
- }
- return stdout;
- }
+ ProcessBuilder builder = new ProcessBuilder(params);
+ InputStream stdout = null;
+ try {
+ Process process = builder.start();
+ stdout = process.getInputStream();
+ } catch (IOException e) {
+ Status status = new Status(IStatus.ERROR, e.getMessage(),
+ Activator.getDefault().getPluginId());
+ Activator.getDefault().getLog().log(status);
+ }
+ return stdout;
+ }
- /**
- * Returns the raw representation of the man executable for a given man page
- * i.e. `man ls`.
- *
- * @param manPage
- * The man page to fetch.
- * @return Raw output of the man command.
- */
- public StringBuilder getRawManPage(String manPage) {
- StringBuilder sb = new StringBuilder();
- try (InputStream manContent = getManPage(manPage, false);
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(manContent))) {
- String line = null;
- while ((line = reader.readLine()) != null) {
- sb.append(line + "\n"); //$NON-NLS-1$
- }
- } catch (IOException e) {
- Status status = new Status(IStatus.ERROR, e.getMessage(),
- Activator.getDefault().getPluginId());
- Activator.getDefault().getLog().log(status);
- }
- return sb;
- }
+ /**
+ * Returns the raw representation of the man executable for a given man page
+ * i.e. `man ls`.
+ *
+ * @param manPage
+ * The man page to fetch.
+ * @return Raw output of the man command.
+ */
+ public StringBuilder getRawManPage(String manPage) {
+ StringBuilder sb = new StringBuilder();
+ try (InputStream manContent = getManPage(manPage, false);
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(manContent))) {
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ sb.append(line + "\n"); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ Status status = new Status(IStatus.ERROR, e.getMessage(),
+ Activator.getDefault().getPluginId());
+ Activator.getDefault().getLog().log(status);
+ }
+ return sb;
+ }
- /**
- * Returns the raw representation of the man page of an executable on a
- * remote machine.
- *
- * @param manPage
- * The man page to fetch.
- * @param user
- * The name of the user to access the man page as.
- * @param host
- * The name of host where the man page is to be fetched from.
- * @param password
- * The user's login password.
- * @return Raw output of the man command.
- */
- public StringBuilder getRemoteRawManPage(String manPage, String user,
- String host, String password) {
- final StringBuilder sb = new StringBuilder();
- OutputStream out = new OutputStream() {
- @Override
- public void write(int b) throws IOException {
- sb.append((char) b);
- }
- };
- try {
- LinuxtoolsProcessFactory.execRemoteAndWait(
- new String[] { getManExecutable(), manPage }, out, out,
- user, host, password);
- } catch (JSchException e) {
- sb.setLength(0);
- sb.append(Messages.ManParser_RemoteAccessError);
- }
- return sb;
- }
+ /**
+ * Returns the raw representation of the man page of an executable on a
+ * remote machine.
+ *
+ * @param manPage
+ * The man page to fetch.
+ * @param user
+ * The name of the user to access the man page as.
+ * @param host
+ * The name of host where the man page is to be fetched from.
+ * @param password
+ * The user's login password.
+ * @return Raw output of the man command.
+ */
+ public StringBuilder getRemoteRawManPage(String manPage, String user,
+ String host, String password) {
+ final StringBuilder sb = new StringBuilder();
+ OutputStream out = new OutputStream() {
+ @Override
+ public void write(int b) throws IOException {
+ sb.append((char) b);
+ }
+ };
+ try {
+ LinuxtoolsProcessFactory.execRemoteAndWait(
+ new String[] { getManExecutable(), manPage }, out, out,
+ user, host, password);
+ } catch (JSchException e) {
+ sb.setLength(0);
+ sb.append(Messages.ManParser_RemoteAccessError);
+ }
+ return sb;
+ }
- private static String getManExecutable() {
- return Activator.getDefault().getPreferenceStore()
- .getString(PreferenceConstants.P_PATH);
- }
+ private static String getManExecutable() {
+ return Activator.getDefault().getPreferenceStore()
+ .getString(PreferenceConstants.P_PATH);
+ }
}
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/Messages.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/Messages.java
index 990dba5a29..6a9989c7e2 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/Messages.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/Messages.java
@@ -15,13 +15,13 @@ import org.eclipse.osgi.util.NLS;
@SuppressWarnings("javadoc")
public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.man.parser.messages"; //$NON-NLS-1$
- public static String ManParser_RemoteAccessError;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.man.parser.messages"; //$NON-NLS-1$
+ public static String ManParser_RemoteAccessError;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
- private Messages() {
- }
+ private Messages() {
+ }
}
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/Messages.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/Messages.java
index 2e82c542b3..07cda74f21 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/Messages.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/Messages.java
@@ -17,20 +17,20 @@ import org.eclipse.osgi.util.NLS;
*
*/
public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.man.preferences.messages"; //$NON-NLS-1$
- /**
- * Preference page title.
- */
- public static String ManPathPage_0;
- /**
- * Preference page label.
- */
- public static String ManPathPage_1;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.man.preferences.messages"; //$NON-NLS-1$
+ /**
+ * Preference page title.
+ */
+ public static String ManPathPage_0;
+ /**
+ * Preference page label.
+ */
+ public static String ManPathPage_1;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
- private Messages() {
- }
+ private Messages() {
+ }
}
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java
index 2f2a1dcd18..12cbcdbc37 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java
@@ -15,9 +15,9 @@ package org.eclipse.linuxtools.internal.man.preferences;
*/
public class PreferenceConstants {
- /**
- * Path preference constant.
- */
- public static final String P_PATH = "pathPreference"; //$NON-NLS-1$
+ /**
+ * Path preference constant.
+ */
+ public static final String P_PATH = "pathPreference"; //$NON-NLS-1$
}
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/views/ManTextViewer.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/views/ManTextViewer.java
index 208fbef6fc..5b65abad72 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/views/ManTextViewer.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/views/ManTextViewer.java
@@ -23,38 +23,38 @@ import org.eclipse.swt.widgets.Composite;
*/
public class ManTextViewer extends SourceViewer {
- /**
- * Creates a resizable text viewer.
- *
- * @param parent
- */
- public ManTextViewer(Composite parent) {
- super(parent, null, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- // setEditable(false);
- }
+ /**
+ * Creates a resizable text viewer.
+ *
+ * @param parent
+ */
+ public ManTextViewer(Composite parent) {
+ super(parent, null, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ // setEditable(false);
+ }
- /**
- * Sets the document to display.
- *
- * @param document
- * The document to display.
- */
- public void setDocument(ManDocument document) {
- super.setDocument(document);
- TextPresentation style = new TextPresentation();
- for (int underlineSymbol : document.getUnderlinedSymbols()) {
- StyleRange styleRange = new StyleRange(underlineSymbol, 1, null,
- null, SWT.NORMAL);
- styleRange.underline = true;
- style.addStyleRange(styleRange);
- }
- for (int boldSymbol : document.getBoldSymbols()) {
- style.mergeStyleRange(new StyleRange(boldSymbol, 1, null, null,
- SWT.BOLD));
- }
- getTextWidget().setBackground(
- getControl().getDisplay().getSystemColor(SWT.COLOR_GRAY));
- changeTextPresentation(style, true);
- }
+ /**
+ * Sets the document to display.
+ *
+ * @param document
+ * The document to display.
+ */
+ public void setDocument(ManDocument document) {
+ super.setDocument(document);
+ TextPresentation style = new TextPresentation();
+ for (int underlineSymbol : document.getUnderlinedSymbols()) {
+ StyleRange styleRange = new StyleRange(underlineSymbol, 1, null,
+ null, SWT.NORMAL);
+ styleRange.underline = true;
+ style.addStyleRange(styleRange);
+ }
+ for (int boldSymbol : document.getBoldSymbols()) {
+ style.mergeStyleRange(
+ new StyleRange(boldSymbol, 1, null, null, SWT.BOLD));
+ }
+ getTextWidget().setBackground(
+ getControl().getDisplay().getSystemColor(SWT.COLOR_GRAY));
+ changeTextPresentation(style, true);
+ }
}
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/parser/ManPage.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/parser/ManPage.java
index 7d6d64cb3d..0fea81c726 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/parser/ManPage.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/parser/ManPage.java
@@ -18,142 +18,144 @@ import org.eclipse.linuxtools.internal.man.parser.ManParser;
*/
public class ManPage {
- private StringBuilder rawContent;
- private StringBuilder strippedTextPage;
+ private StringBuilder rawContent;
+ private StringBuilder strippedTextPage;
- /**
- * Creates the man page which includes retrieving the raw content and
- * changing format symbols to html.
- *
- * @param manPage
- * The man page.
- */
- public ManPage(String manPage) {
- parse(new ManParser().getRawManPage(manPage));
- }
+ /**
+ * Creates the man page which includes retrieving the raw content and
+ * changing format symbols to html.
+ *
+ * @param manPage
+ * The man page.
+ */
+ public ManPage(String manPage) {
+ parse(new ManParser().getRawManPage(manPage));
+ }
- /**
- * Creates the man page for an executable on the remote machine with the
- * specified credentials.
- *
- * @param manPage
- * The man page.
- * @param user
- * The name of the user to access the man page as.
- * @param host
- * The name of host where the man page is to be fetched from.
- * @param password
- * The user's login password.
- * @since 1.2
- */
- public ManPage(String manPage, String user, String host, String password) {
- parse(new ManParser()
- .getRemoteRawManPage(manPage, user, host, password));
- }
+ /**
+ * Creates the man page for an executable on the remote machine with the
+ * specified credentials.
+ *
+ * @param manPage
+ * The man page.
+ * @param user
+ * The name of the user to access the man page as.
+ * @param host
+ * The name of host where the man page is to be fetched from.
+ * @param password
+ * The user's login password.
+ * @since 1.2
+ */
+ public ManPage(String manPage, String user, String host, String password) {
+ parse(new ManParser().getRemoteRawManPage(manPage, user, host,
+ password));
+ }
- // TODO make bold and underline be ranges instead of separate symbols.
- private void parse(StringBuilder rawManPage) {
- StringBuilder sb = new StringBuilder();
- sb.append(rawManPage);
+ // TODO make bold and underline be ranges instead of separate symbols.
+ private void parse(StringBuilder rawManPage) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(rawManPage);
- while (sb.indexOf("_\b") != -1) { //$NON-NLS-1$
- int index = sb.indexOf("_\b"); //$NON-NLS-1$
- sb.replace(index, index + 3,
- "<u>" + sb.substring(index + 2, index + 3) + "</u>"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- while (sb.indexOf("\b") != -1) { //$NON-NLS-1$
- int index = sb.indexOf("\b"); //$NON-NLS-1$
- sb.replace(index - 1, index + 2,
- "<b>" + sb.substring(index - 1, index) + "</b>"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- rawContent = sb;
- }
+ while (sb.indexOf("_\b") != -1) { //$NON-NLS-1$
+ int index = sb.indexOf("_\b"); //$NON-NLS-1$
+ sb.replace(index, index + 3,
+ "<u>" + sb.substring(index + 2, index + 3) + "</u>"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ while (sb.indexOf("\b") != -1) { //$NON-NLS-1$
+ int index = sb.indexOf("\b"); //$NON-NLS-1$
+ sb.replace(index - 1, index + 2,
+ "<b>" + sb.substring(index - 1, index) + "</b>"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ rawContent = sb;
+ }
- /**
- * Returns html representation of the man page. The whole man page is kept
- * in one giant &lt;pre&gt; block with bold and underline symbols.
- *
- * @return The whole html man page.
- */
- public StringBuilder getHtmlPage() {
- StringBuilder sb = new StringBuilder();
- sb.append("<pre>").append(rawContent).append("</pre>"); //$NON-NLS-1$ //$NON-NLS-2$
- return sb;
- }
+ /**
+ * Returns html representation of the man page. The whole man page is kept
+ * in one giant &lt;pre&gt; block with bold and underline symbols.
+ *
+ * @return The whole html man page.
+ */
+ public StringBuilder getHtmlPage() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<pre>").append(rawContent).append("</pre>"); //$NON-NLS-1$ //$NON-NLS-2$
+ return sb;
+ }
- /**
- * Returns stripped representation of the man page. Stripped parts are:
- * <ul>
- * <li>Header - all the parts before <b>NAME</b></li>
- * <li>Footer - all the parts from <b>AUTHOR</b> till the end</li>
- * </ul>
- *
- * @return The stripped html content of the man page.
- */
- public StringBuilder getStrippedHtmlPage() {
- StringBuilder sb = getStrippedPage();
- sb.insert(0, "<pre>"); //$NON-NLS-1$
- sb.append("</pre>"); //$NON-NLS-1$
- return sb;
- }
+ /**
+ * Returns stripped representation of the man page. Stripped parts are:
+ * <ul>
+ * <li>Header - all the parts before <b>NAME</b></li>
+ * <li>Footer - all the parts from <b>AUTHOR</b> till the end</li>
+ * </ul>
+ *
+ * @return The stripped html content of the man page.
+ */
+ public StringBuilder getStrippedHtmlPage() {
+ StringBuilder sb = getStrippedPage();
+ sb.insert(0, "<pre>"); //$NON-NLS-1$
+ sb.append("</pre>"); //$NON-NLS-1$
+ return sb;
+ }
- /**
- * Returns stripped representation of the man page in the format it was
- * received from executing man. Stripped parts are:
- * <ul>
- * <li>Header - all the parts before <b>NAME</b></li>
- * <li>Footer - all the parts from <b>AUTHOR</b> till the end</li>
- * </ul>
- *
- * @return The stripped plain text content of the man page.
- * @since 1.1
- */
- public StringBuilder getStrippedPage() {
- StringBuilder sb = new StringBuilder();
- sb.append(rawContent);
- // The raw content may or may not be HTML
- if (sb.indexOf("<b>N</b>") != -1) { //$NON-NLS-1$
- sb.delete(0, sb.indexOf("<b>N</b>")); //$NON-NLS-1$
- } else if (sb.indexOf("NAME") != -1) { //$NON-NLS-1$
- sb.delete(0, sb.indexOf("NAME")); //$NON-NLS-1$
- }
+ /**
+ * Returns stripped representation of the man page in the format it was
+ * received from executing man. Stripped parts are:
+ * <ul>
+ * <li>Header - all the parts before <b>NAME</b></li>
+ * <li>Footer - all the parts from <b>AUTHOR</b> till the end</li>
+ * </ul>
+ *
+ * @return The stripped plain text content of the man page.
+ * @since 1.1
+ */
+ public StringBuilder getStrippedPage() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(rawContent);
+ // The raw content may or may not be HTML
+ if (sb.indexOf("<b>N</b>") != -1) { //$NON-NLS-1$
+ sb.delete(0, sb.indexOf("<b>N</b>")); //$NON-NLS-1$
+ } else if (sb.indexOf("NAME") != -1) { //$NON-NLS-1$
+ sb.delete(0, sb.indexOf("NAME")); //$NON-NLS-1$
+ }
- if (sb.indexOf("<b>A</b><b>U</b><b>T</b><b>H</b><b>O</b><b>R</b>") != -1) { //$NON-NLS-1$
- sb.delete(
- sb.indexOf("<b>A</b><b>U</b><b>T</b><b>H</b><b>O</b><b>R</b>"), //$NON-NLS-1$
- sb.length());
- } else if (sb.indexOf("AUTHOR") != -1) { //$NON-NLS-1$
- sb.delete(sb.indexOf("AUTHOR"), //$NON-NLS-1$
- sb.length());
- }
+ if (sb.indexOf(
+ "<b>A</b><b>U</b><b>T</b><b>H</b><b>O</b><b>R</b>") != -1) { //$NON-NLS-1$
+ sb.delete(
+ sb.indexOf(
+ "<b>A</b><b>U</b><b>T</b><b>H</b><b>O</b><b>R</b>"), //$NON-NLS-1$
+ sb.length());
+ } else if (sb.indexOf("AUTHOR") != -1) { //$NON-NLS-1$
+ sb.delete(sb.indexOf("AUTHOR"), //$NON-NLS-1$
+ sb.length());
+ }
- return sb;
- }
+ return sb;
+ }
- /**
- * Removes all HTML markings are returns a text only version.
- *
- * @return a text only version of the manpage
- * @since 1.1
- */
- public StringBuilder getStrippedTextPage() {
- if (this.strippedTextPage == null) {
- this.strippedTextPage = getStrippedPage();
- int index = strippedTextPage.indexOf("<b>"); //$NON-NLS-1$
- while (index != -1) {
- strippedTextPage.replace(index, index + 3, ""); //$NON-NLS-1$
- strippedTextPage.replace(index + 1, index + 5, ""); //$NON-NLS-1$
- index = strippedTextPage.indexOf("<b>"); //$NON-NLS-1$
- }
+ /**
+ * Removes all HTML markings are returns a text only version.
+ *
+ * @return a text only version of the manpage
+ * @since 1.1
+ */
+ public StringBuilder getStrippedTextPage() {
+ if (this.strippedTextPage == null) {
+ this.strippedTextPage = getStrippedPage();
+ int index = strippedTextPage.indexOf("<b>"); //$NON-NLS-1$
+ while (index != -1) {
+ strippedTextPage.replace(index, index + 3, ""); //$NON-NLS-1$
+ strippedTextPage.replace(index + 1, index + 5, ""); //$NON-NLS-1$
+ index = strippedTextPage.indexOf("<b>"); //$NON-NLS-1$
+ }
- index = strippedTextPage.indexOf("<u>"); //$NON-NLS-1$
- while (index != -1) {
- strippedTextPage.replace(index, index + 3, ""); //$NON-NLS-1$
- strippedTextPage.replace(index + 1, index + 5, ""); //$NON-NLS-1$
- index = strippedTextPage.indexOf("<u>"); //$NON-NLS-1$
- }
- }
+ index = strippedTextPage.indexOf("<u>"); //$NON-NLS-1$
+ while (index != -1) {
+ strippedTextPage.replace(index, index + 3, ""); //$NON-NLS-1$
+ strippedTextPage.replace(index + 1, index + 5, ""); //$NON-NLS-1$
+ index = strippedTextPage.indexOf("<u>"); //$NON-NLS-1$
+ }
+ }
- return strippedTextPage;
- }
+ return strippedTextPage;
+ }
}
diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/views/ManView.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/views/ManView.java
index 8e80c3167b..75f07ee8df 100644
--- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/views/ManView.java
+++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/man/views/ManView.java
@@ -22,43 +22,40 @@ import org.eclipse.ui.part.ViewPart;
public class ManView extends ViewPart {
- /**
- * The ID of the view as specified by the extension.
- */
- public static final String ID = "org.eclipse.linuxtools.man.views.ManView"; //$NON-NLS-1$
-
- private ManTextViewer viewer;
-
- /**
- * This is a callback that will allow us to create the viewer and initialize
- * it.
- */
- @Override
- public void createPartControl(Composite parent) {
- viewer = new ManTextViewer(parent);
- // Create the help context id for the viewer's control
- PlatformUI
- .getWorkbench()
- .getHelpSystem()
- .setHelp(viewer.getControl(),
- "org.eclipse.linuxtools.man.viewer"); //$NON-NLS-1$
- }
-
- /**
- * Sets the man page to dispaly
- *
- * @param manPageName
- * The name of the man page to display.
- */
- public void setManPageName(String manPageName) {
- viewer.setDocument(new ManDocument(manPageName));
- }
-
- /**
- * Passing the focus request to the viewer's control.
- */
- @Override
- public void setFocus() {
- viewer.getControl().setFocus();
- }
+ /**
+ * The ID of the view as specified by the extension.
+ */
+ public static final String ID = "org.eclipse.linuxtools.man.views.ManView"; //$NON-NLS-1$
+
+ private ManTextViewer viewer;
+
+ /**
+ * This is a callback that will allow us to create the viewer and initialize
+ * it.
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new ManTextViewer(parent);
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),
+ "org.eclipse.linuxtools.man.viewer"); //$NON-NLS-1$
+ }
+
+ /**
+ * Sets the man page to dispaly
+ *
+ * @param manPageName
+ * The name of the man page to display.
+ */
+ public void setManPageName(String manPageName) {
+ viewer.setDocument(new ManDocument(manPageName));
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
} \ No newline at end of file

Back to the top