Author: ayukhovich
Date: 2007-07-09 03:43:01 -0400 (Mon, 09 Jul 2007)
New Revision: 2356
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
Log:
add some comments for functions
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2007-07-08
07:28:36 UTC (rev 2355)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2007-07-09
07:43:01 UTC (rev 2356)
@@ -86,13 +86,15 @@
setView(new ReportProblemWizardView());
}
-
}
-class ReportProblemWizardView extends AbstractQueryWizardView {
-
+/**
+ * @author yukhovich
+ *
+ */
+class ReportProblemWizardView extends AbstractQueryWizardView {
/** LOG_DATE_FORMAT */
- final private SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat(
+ final private static SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat(
"yyyyMMddHHmmss");
/** log file name */
@@ -101,6 +103,35 @@
/** Browse button */
private Button browseButton;
+ /** LINE_LIMIT */
+ final private static int LINE_LIMIT = 70;
+
+
+ int stackTracesCount;
+ Text problemDescription;
+ XAttributeSupport sendSupport;
+ XAttributeSupport infoSupport;
+
+ XModelObject reportOptions = PreferenceModelUtilities.getPreferenceModel()
+ .getByPath(ReportPreference.OPTIONS_REPORT_PROBLEM_PATH);
+
+ XModelObject exceptionsObject = PreferenceModelUtilities
+ .getPreferenceModel()
+ .createModelObject("ProblemBufferEditor", null);
+
+ XEntityData sendData = XEntityDataImpl.create(new String[][] {
+ { "SharableReportProblem" },
+ { ReportPreference.ATT_ATTACH_REDHAT_LOG, "no" },
+ // {ReportPreference.ATT_ATTACH_ECLIPSE_LOG, "no"}
+ });
+ XEntityData sendData2 = XEntityDataImpl
+ .create(new String[][] { { "SharableReportProblem" },
+ // {ReportPreference.ATT_ATTACH_ECLIPSE_LOG, "no"}
+ });
+ XEntityData infoData = XEntityDataImpl.create(new String[][] {
+ { "SharableReportProblem" }, { ReportPreference.ATT_E_MAIL, "no"
},
+ { ReportPreference.ATT_OTHER, "no" } });
+
class PixelConverter {
private FontMetrics fFontMetrics;
@@ -127,29 +158,6 @@
}
}
- int stackTracesCount;
- Text problemDescription;
- XAttributeSupport sendSupport;
- XAttributeSupport infoSupport;
- XModelObject reportOptions = PreferenceModelUtilities.getPreferenceModel()
- .getByPath(ReportPreference.OPTIONS_REPORT_PROBLEM_PATH);
- XModelObject exceptionsObject = PreferenceModelUtilities
- .getPreferenceModel()
- .createModelObject("ProblemBufferEditor", null);
-
- XEntityData sendData = XEntityDataImpl.create(new String[][] {
- { "SharableReportProblem" },
- { ReportPreference.ATT_ATTACH_REDHAT_LOG, "no" },
- // {ReportPreference.ATT_ATTACH_ECLIPSE_LOG, "no"}
- });
- XEntityData sendData2 = XEntityDataImpl
- .create(new String[][] { { "SharableReportProblem" },
- // {ReportPreference.ATT_ATTACH_ECLIPSE_LOG, "no"}
- });
- XEntityData infoData = XEntityDataImpl.create(new String[][] {
- { "SharableReportProblem" }, { ReportPreference.ATT_E_MAIL, "no"
},
- { ReportPreference.ATT_OTHER, "no" } });
-
public ReportProblemWizardView() {
//folderLogFileName = Platform.getLocation().toOSString() + SEPARATOR;
}
@@ -168,6 +176,44 @@
return composite;
}
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#updateBar()
+ */
+ public void updateBar() {
+ getCommandBar().setEnabled("Ok", !isMessageEmpty());
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#getPreferredSize()
+ */
+ public Point getPreferredSize() {
+ return new Point(400, 500);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#getCommands()
+ */
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#getCommands()
+ */
+ public String[] getCommands() {
+ return new String[] { "Ok", CANCEL };
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#action(java.lang.String)
+ */
+ public void action(String command) {
+ if (command.equals("Ok")) {
+ submitProblems();
+ super.action(OK);
+ } else {
+ super.action(command);
+ }
+ }
+
+
/**
*
*/
@@ -177,7 +223,7 @@
}
/**
- *
+ * @return
*/
private byte[] getEclipseLogContent() {
StringBuffer sb = new StringBuffer();
@@ -200,7 +246,7 @@
};
/**
- *
+ * @return
*/
private byte[] getUserCommentContent() {
StringBuffer sb = new StringBuffer();
@@ -215,78 +261,8 @@
return sb.toString().getBytes();
}
- private IConfigurationElement[] getSortedExtensions() {
- IConfigurationElement[] configElements = Platform
- .getExtensionRegistry().getConfigurationElementsFor(
- PlatformUI.PLUGIN_ID,
- IWorkbenchRegistryConstants.PL_SYSTEM_SUMMARY_SECTIONS);
-
- Arrays.sort(configElements, new Comparator() {
- Collator collator = Collator.getInstance(Locale.getDefault());
-
- public int compare(Object a, Object b) {
- IConfigurationElement element1 = (IConfigurationElement) a;
- IConfigurationElement element2 = (IConfigurationElement) b;
-
- String id1 = element1.getAttribute("id"); //$NON-NLS-1$
- String id2 = element2.getAttribute("id"); //$NON-NLS-1$
-
- if (id1 != null && id2 != null && !id1.equals(id2)) {
- return collator.compare(id1, id2);
- }
-
- String title1 = element1.getAttribute("sectionTitle"); //$NON-NLS-1$
- String title2 = element2.getAttribute("sectionTitle"); //$NON-NLS-1$
-
- if (title1 == null) {
- title1 = ""; //$NON-NLS-1$
- }
- if (title2 == null) {
- title2 = ""; //$NON-NLS-1$
- }
-
- return collator.compare(title1, title2);
- }
- });
-
- return configElements;
- }
-
- /*
- * Appends the contents of all extensions to the configurationLogSections
- * extension point.
- */
- private void appendExtensions(PrintWriter writer) {
- IConfigurationElement[] configElements = getSortedExtensions();
- for (int i = 0; i < configElements.length; ++i) {
- IConfigurationElement element = configElements[i];
-
- Object obj = null;
- try {
- obj = WorkbenchPlugin.createExtension(element,
- IWorkbenchConstants.TAG_CLASS);
- } catch (CoreException e) {
- WorkbenchPlugin.log(
- "could not create class attribute for extension", //$NON-NLS-1$
- e.getStatus());
- }
-
- writer.println();
- writer.println(NLS.bind(
- WorkbenchMessages.SystemSummary_sectionTitle, element
- .getAttribute("sectionTitle"))); //$NON-NLS-1$
-
- if (obj instanceof ISystemSummarySection) {
- ISystemSummarySection logSection = (ISystemSummarySection) obj;
- logSection.write(writer);
- } else {
- writer.println(WorkbenchMessages.SystemSummary_sectionError);
- }
- }
- }
-
/**
- *
+ * @return
*/
private byte[] getEclipsePropertiesContent() {
StringWriter out = new StringWriter();
@@ -318,12 +294,15 @@
} finally {
zout.close();
}
-
- //
- // return byteBuffer.toString();
- //
}
+ /**
+ * Add bytes form tempBuffer in zipOutputStream with name from fileName
+ * @param tempBuffer tempolary-buffer
+ * @param fileName
+ * @param zout
+ * @throws IOException
+ */
private void addFileToZip(byte[] tempBuffer, String fileName,
ZipOutputStream zout) throws IOException {
@@ -346,7 +325,7 @@
currentDate = LOG_DATE_FORMAT.format(today);
return "jbosstools-diagnostics-" + currentDate.toString() +
".zip";
}
-
+
private void createStackTracesControl(Composite parent) {
stackTracesCount = ProblemReportingHelper.buffer.getSize();
exceptionsObject.setAttributeValue("exceptions",
@@ -379,104 +358,10 @@
}
}
- /**
- * Creates a new label widget
- *
- * @param parent
- * the parent composite to add this label widget to
- * @param text
- * the text for the label
- * @param hspan
- * the horizontal span to take up in the parent composite
- * @return the new label
- */
- public static Label createLabel(Composite parent, String text, int hspan) {
- Label l = new Label(parent, SWT.NONE);
- l.setFont(parent.getFont());
- l.setText(text);
- GridData gd = new GridData();
- gd.horizontalSpan = hspan;
- l.setLayoutData(gd);
- return l;
- }
/**
- * Creates a new text widget
*
* @param parent
- * the parent composite to add this text widget to
- * @param hspan
- * the horizontal span to take up on the parent composite
- * @return the new text widget
- */
- public static Text createSingleText(Composite parent, int hspan) {
- Text t = new Text(parent, SWT.SINGLE | SWT.BORDER);
- t.setFont(parent.getFont());
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = hspan;
- gd.widthHint = 100;
- t.setLayoutData(gd);
- return t;
- }
-
- /**
- * Returns a width hint for a button control.
- */
- public int getButtonWidthHint(Button button) {
- button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter = new PixelConverter(button);
- int widthHint = converter
- .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- true).x);
- }
-
- /**
- * Sets width and height hint for the button control. <b>Note:</b> This is
- * a NOP if the button's layout data is not an instance of
- * <code>GridData</code>.
- *
- * @param the
- * button for which to set the dimension hint
- */
- public void setButtonDimensionHint(Button button) {
- Object gd = button.getLayoutData();
- if (gd instanceof GridData) {
- ((GridData) gd).widthHint = getButtonWidthHint(button);
- ((GridData) gd).horizontalAlignment = GridData.FILL;
- }
- }
-
- /**
- * Creates and returns a new push button with the given label and/or image.
- *
- * @param parent
- * parent control
- * @param label
- * button label or <code>null</code>
- * @param image
- * image or <code>null</code>
- *
- * @return a new push button
- */
- public Button createPushButton(Composite parent, String label, Image image) {
- Button button = new Button(parent, SWT.PUSH);
- button.setFont(parent.getFont());
- if (image != null) {
- button.setImage(image);
- }
- if (label != null) {
- button.setText(label);
- }
- GridData gd = new GridData();
- button.setLayoutData(gd);
- setButtonDimensionHint(button);
- return button;
- }
-
- /**
- *
- * @param parent
* a parent Composite object
*/
private void createFilenameLogControl(final Composite parent) {
@@ -572,32 +457,6 @@
});
}
- public Point getPreferredSize() {
- return new Point(400, 500);
- }
-
- protected GridLayout getDefaultSupportLayout() {
- GridLayout gridLayout = new GridLayout(2, false);
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- gridLayout.horizontalSpacing = 0;
- gridLayout.verticalSpacing = 5;
- return gridLayout;
- }
-
- public String[] getCommands() {
- return new String[] { "Ok", CANCEL };
- }
-
- public void action(String command) {
- if (command.equals("Ok")) {
- submitProblems();
- super.action(OK);
- } else {
- super.action(command);
- }
- }
-
private void submitProblems() {
if (sendSupport != null)
sendSupport.store();
@@ -638,7 +497,6 @@
}
}
- static int LINE_LIMIT = 70;
private String formatContent(String content) {
StringBuffer sb = new StringBuffer();
@@ -662,11 +520,12 @@
return sb.toString();
}
- public void updateBar() {
- getCommandBar().setEnabled("Ok", !isMessageEmpty());
- }
- boolean isMessageEmpty() {
+ /**
+ *
+ * @return
+ */
+ private boolean isMessageEmpty() {
if (sendSupport != null) {
IModelPropertyEditorAdapter a = sendSupport
.getPropertyEditorAdapterByName(ReportPreference.ATT_ATTACH_REDHAT_LOG);
@@ -683,4 +542,179 @@
return false;
}
+
+ /**
+ * Creates a new label widget
+ *
+ * @param parent
+ * the parent composite to add this label widget to
+ * @param text
+ * the text for the label
+ * @param hspan
+ * the horizontal span to take up in the parent composite
+ * @return the new label
+ */
+ private Label createLabel(Composite parent, String text, int hspan) {
+ Label l = new Label(parent, SWT.NONE);
+ l.setFont(parent.getFont());
+ l.setText(text);
+ GridData gd = new GridData();
+ gd.horizontalSpan = hspan;
+ l.setLayoutData(gd);
+ return l;
+ }
+
+ /**
+ * Creates a new text widget
+ *
+ * @param parent
+ * the parent composite to add this text widget to
+ * @param hspan
+ * the horizontal span to take up on the parent composite
+ * @return the new text widget
+ */
+ private Text createSingleText(Composite parent, int hspan) {
+ Text t = new Text(parent, SWT.SINGLE | SWT.BORDER);
+ t.setFont(parent.getFont());
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = hspan;
+ gd.widthHint = 100;
+ t.setLayoutData(gd);
+ return t;
+ }
+
+ /**
+ * Returns a width hint for a button control.
+ */
+ private int getButtonWidthHint(Button button) {
+ button.setFont(JFaceResources.getDialogFont());
+ PixelConverter converter = new PixelConverter(button);
+ int widthHint = converter
+ .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
+ true).x);
+ }
+
+ /**
+ * Sets width and height hint for the button control. <b>Note:</b> This is
+ * a NOP if the button's layout data is not an instance of
+ * <code>GridData</code>.
+ *
+ * @param the
+ * button for which to set the dimension hint
+ */
+ private void setButtonDimensionHint(Button button) {
+ Object gd = button.getLayoutData();
+ if (gd instanceof GridData) {
+ ((GridData) gd).widthHint = getButtonWidthHint(button);
+ ((GridData) gd).horizontalAlignment = GridData.FILL;
+ }
+ }
+
+ /**
+ * Creates and returns a new push button with the given label and/or image.
+ *
+ * @param parent
+ * parent control
+ * @param label
+ * button label or <code>null</code>
+ * @param image
+ * image or <code>null</code>
+ *
+ * @return a new push button
+ */
+ private Button createPushButton(Composite parent, String label, Image image) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setFont(parent.getFont());
+ if (image != null) {
+ button.setImage(image);
+ }
+ if (label != null) {
+ button.setText(label);
+ }
+ GridData gd = new GridData();
+ button.setLayoutData(gd);
+ setButtonDimensionHint(button);
+ return button;
+ }
+
+ private IConfigurationElement[] getSortedExtensions() {
+ IConfigurationElement[] configElements = Platform
+ .getExtensionRegistry().getConfigurationElementsFor(
+ PlatformUI.PLUGIN_ID,
+ IWorkbenchRegistryConstants.PL_SYSTEM_SUMMARY_SECTIONS);
+
+ Arrays.sort(configElements, new Comparator() {
+ Collator collator = Collator.getInstance(Locale.getDefault());
+
+ public int compare(Object a, Object b) {
+ IConfigurationElement element1 = (IConfigurationElement) a;
+ IConfigurationElement element2 = (IConfigurationElement) b;
+
+ String id1 = element1.getAttribute("id"); //$NON-NLS-1$
+ String id2 = element2.getAttribute("id"); //$NON-NLS-1$
+
+ if (id1 != null && id2 != null && !id1.equals(id2)) {
+ return collator.compare(id1, id2);
+ }
+
+ String title1 = element1.getAttribute("sectionTitle"); //$NON-NLS-1$
+ String title2 = element2.getAttribute("sectionTitle"); //$NON-NLS-1$
+
+ if (title1 == null) {
+ title1 = ""; //$NON-NLS-1$
+ }
+ if (title2 == null) {
+ title2 = ""; //$NON-NLS-1$
+ }
+
+ return collator.compare(title1, title2);
+ }
+ });
+
+ return configElements;
+ }
+
+ /*
+ * Appends the contents of all extensions to the configurationLogSections
+ * extension point.
+ */
+ private void appendExtensions(PrintWriter writer) {
+ IConfigurationElement[] configElements = getSortedExtensions();
+ for (int i = 0; i < configElements.length; ++i) {
+ IConfigurationElement element = configElements[i];
+
+ Object obj = null;
+ try {
+ obj = WorkbenchPlugin.createExtension(element,
+ IWorkbenchConstants.TAG_CLASS);
+ } catch (CoreException e) {
+ WorkbenchPlugin.log(
+ "could not create class attribute for extension", //$NON-NLS-1$
+ e.getStatus());
+ }
+
+ writer.println();
+ writer.println(NLS.bind(
+ WorkbenchMessages.SystemSummary_sectionTitle, element
+ .getAttribute("sectionTitle"))); //$NON-NLS-1$
+
+ if (obj instanceof ISystemSummarySection) {
+ ISystemSummarySection logSection = (ISystemSummarySection) obj;
+ logSection.write(writer);
+ } else {
+ writer.println(WorkbenchMessages.SystemSummary_sectionError);
+ }
+ }
+ }
+
+ protected GridLayout getDefaultSupportLayout() {
+ GridLayout gridLayout = new GridLayout(2, false);
+ gridLayout.marginHeight = 0;
+ gridLayout.marginWidth = 0;
+ gridLayout.horizontalSpacing = 0;
+ gridLayout.verticalSpacing = 5;
+ return gridLayout;
+ }
+
}