Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-04-25 14:05:37 +0000
committerAlexander Kurtakov2014-04-26 05:35:49 +0000
commit9f5e0ed5dfda7ac2bf14f4b59228135bdbcb6a10 (patch)
tree6460ae9326e2948a1c746798febd00f82321f638 /changelog
parentfe48cecc1b6ba671cf0a70014e760413dae4cce9 (diff)
downloadorg.eclipse.linuxtools-9f5e0ed5dfda7ac2bf14f4b59228135bdbcb6a10.tar.gz
org.eclipse.linuxtools-9f5e0ed5dfda7ac2bf14f4b59228135bdbcb6a10.tar.xz
org.eclipse.linuxtools-9f5e0ed5dfda7ac2bf14f4b59228135bdbcb6a10.zip
Change tabs to spaces; elim trailing whitespace.
To comply with Sonar style requirements, replace all tab characters with four whitespace characters/spaces, and remove all trailing whitespace. Perform this change to all Java and XML files. Also replace tabs with "\t" in test strings that require tabs, and edit STPIndenterTest so that it doesn't rely on indented comments. Change-Id: I48c3c5449a58fe5310967d998a05df1a28fbcbb0 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/25561 Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'changelog')
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.c-feature/pom.xml2
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/plugin.xml124
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib.java62
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib2.java12
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IFormatterChangeLogContrib.java6
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IParserChangeLogContrib.java40
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogExtensionManager.java416
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java458
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogWriter.java158
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPlugin.java40
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPreferenceInitializer.java90
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java114
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/Messages.java42
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogAction.java578
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java38
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java30
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java464
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogRootContainer.java18
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java22
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java278
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java238
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java8
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchRangeElement.java48
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java1032
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java178
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java404
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java26
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java148
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentProvider.java8
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java96
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java156
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java420
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ColorManager.java28
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java62
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java282
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUElementScanner.java170
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryDamagerRepairer.java42
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java246
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java298
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUPartitionScanner.java52
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/IChangeLogColorConstants.java16
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/MultilineRuleDamagerRepairer.java48
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java738
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ui/ChangeLogActionProvider.java56
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.cparser/src/org/eclipse/linuxtools/internal/changelog/parsers/CParser.java330
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.doc/build-helper.xml86
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.doc/toc-doc.xml2
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.doc/toc.xml22
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.javaparser/src/org/eclipse/linuxtools/internal/changelog/parsers/java/JavaParser.java264
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/pom.xml2
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/formatters/tests/GNUFormatTest.java948
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/AllTests.java16
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/ChangeLogWriterTest.java518
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/CParserTest.java776
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/JavaParserTest.java844
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorage.java62
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorageInput.java82
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/ChangeLogTestProject.java222
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/TestChangeLogTestProject.java232
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/helpers/EditorHelper.java94
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/pom.xml2
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/log4j.xml110
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java380
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AllSWTBotTests.java14
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java270
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java114
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java172
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java390
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ChangeLogTestProject.java204
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ContextMenuHelper.java292
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorer.java130
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorerTreeItemAppearsCondition.java66
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java258
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProjectCreatedCondition.java52
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNReporsitoriesView.java72
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TableAppearsCondition.java46
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TreeItemAppearsCondition.java60
77 files changed, 7462 insertions, 7462 deletions
diff --git a/changelog/org.eclipse.linuxtools.changelog.c-feature/pom.xml b/changelog/org.eclipse.linuxtools.changelog.c-feature/pom.xml
index e0863480de..542931d78b 100644
--- a/changelog/org.eclipse.linuxtools.changelog.c-feature/pom.xml
+++ b/changelog/org.eclipse.linuxtools.changelog.c-feature/pom.xml
@@ -22,7 +22,7 @@
<packaging>eclipse-feature</packaging>
<name>Linux Tools ChangeLog Feature for C/C++</name>
-
+
<build>
<plugins>
<plugin>
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/plugin.xml b/changelog/org.eclipse.linuxtools.changelog.core/plugin.xml
index 05cda5bf9a..ec5db8ff89 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/plugin.xml
+++ b/changelog/org.eclipse.linuxtools.changelog.core/plugin.xml
@@ -5,34 +5,34 @@
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
-
+
Contributors:
Alexander Kurtakov (Red Hat) - initial API and implementation
-->
<plugin>
- <extension-point id="parserContribution"
- name="%extension-point.name"
- schema="schema/parserContribution.exsd"/>
+ <extension-point id="parserContribution"
+ name="%extension-point.name"
+ schema="schema/parserContribution.exsd"/>
<extension-point id="formatterContribution" name="%extension-point.name.0" schema="schema/formatterContribution.exsd"/>
<extension-point id="editorContribution" name="%extension-point.name.1" schema="schema/editorContribution.exsd"/>
-
+
<extension
- point="org.eclipse.ui.commands">
-
- <category
- name="%category.name"
- description="%category.description"
- id="org.eclipse.linuxtools.changelog">
- </category>
+ point="org.eclipse.ui.commands">
- <command
+ <category
+ name="%category.name"
+ description="%category.description"
+ id="org.eclipse.linuxtools.changelog">
+ </category>
+
+ <command
categoryId="org.eclipse.linuxtools.changelog"
description="%insertCLEntryDesc"
id="org.eclipse.linuxtools.changelog.core.actions.KeyActionCommand"
name="%insertCLEntry">
- </command>
+ </command>
<command
categoryId="org.eclipse.linuxtools.changelog"
description="%command.description"
@@ -54,16 +54,16 @@
id="org.eclipse.linuxtools.changelog.core.preparechangelog2"
name="%command.name.2">
</command>
- </extension>
-
- <extension point = "org.eclipse.ui.preferencePages">
- <page
- id="org.eclipse.linuxtools.changelog.core.Page1"
- class="org.eclipse.linuxtools.internal.changelog.core.ChangeLogPreferencesPage"
- name="%prefTitle">
- </page>
- </extension>
-
+ </extension>
+
+ <extension point = "org.eclipse.ui.preferencePages">
+ <page
+ id="org.eclipse.linuxtools.changelog.core.Page1"
+ class="org.eclipse.linuxtools.internal.changelog.core.ChangeLogPreferencesPage"
+ name="%prefTitle">
+ </page>
+ </extension>
+
<extension
point="org.eclipse.linuxtools.changelog.core.formatterContribution">
@@ -72,8 +72,8 @@
class="org.eclipse.linuxtools.internal.changelog.core.formatters.GNUFormat"
id="org.eclipse.linuxtools.changelog.GNUFormat"
name="%gnuFormatter">
- <fileName name="ChangeLog" />
- </formatter>
+ <fileName name="ChangeLog" />
+ </formatter>
</extension>
<extension
id="org.eclipse.linuxtools.changelog.core.editor"
@@ -191,20 +191,20 @@
</participant>
</extension>
<extension point="org.eclipse.core.runtime.preferences">
- <initializer
- class="org.eclipse.linuxtools.internal.changelog.core.ChangelogPreferenceInitializer" />
- </extension>
-
- <extension
- point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets">
-<target id="org.eclipse.changelog.editor.target"
- name="%target.name">
+ <initializer
+ class="org.eclipse.linuxtools.internal.changelog.core.ChangelogPreferenceInitializer" />
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets">
+<target id="org.eclipse.changelog.editor.target"
+ name="%target.name">
<context type="org.eclipse.ui.texteditor.ITextEditor"/>
</target>
</extension>
-
- <extension
+
+ <extension
point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
<hyperlinkDetector
id="org.eclipse.linuxtools.changelog.GNUHyperlinkDetector"
@@ -216,14 +216,14 @@
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:#TextEditorContext?endof=group.edit">
<command commandId="org.eclipse.linuxtools.changelog.core.formatChangeLog">
- <visibleWhen
+ <visibleWhen
checkEnabled="false">
<and>
- <with variable="activeEditorId">
- <equals value="org.eclipse.linuxtools.changelog.core.editor6"/>
- </with>
- </and>
- </visibleWhen>
+ <with variable="activeEditorId">
+ <equals value="org.eclipse.linuxtools.changelog.core.editor6"/>
+ </with>
+ </and>
+ </visibleWhen>
</command>
</menuContribution>
<menuContribution
@@ -244,50 +244,50 @@
checkEnabled="false">
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <or>
+ <or>
<adapt
type="java.lang.Object">
</adapt>
- <adapt type="org.eclipse.core.resources.IResource">
- <test
- property="org.eclipse.core.resources.projectNature"
- value="org.eclipse.cdt.core.cnature"/>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.cdt.core.cnature"/>
</adapt>
<adapt type="org.eclipse.core.resources.IResource">
<test
property="org.eclipse.core.resources.projectNature"
value="org.eclipse.jdt.core.javanature"/>
</adapt>
- </or>
- <or>
- <adapt type="org.eclipse.core.resources.IResource">
- <test
+ </or>
+ <or>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test
args="org.eclipse.team.core.repository"
property="org.eclipse.core.resources.projectPersistentProperty"
value="org.eclipse.team.svn.core.svnnature"/>
</adapt>
- <adapt type="org.eclipse.core.resources.IResource">
- <test
- args="org.eclipse.team.core.repository"
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test
+ args="org.eclipse.team.core.repository"
property="org.eclipse.core.resources.projectPersistentProperty"
value="org.eclipse.team.cvs.core.cvsnature"/>
</adapt>
- <adapt type="org.eclipse.core.resources.IResource">
- <test
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test
args="org.eclipse.team.core.repository"
property="org.eclipse.core.resources.projectPersistentProperty"
value="org.tigris.subversion.subclipse.core.svnnature"/>
</adapt>
- <adapt type="org.eclipse.core.resources.IResource">
- <test
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test
args="org.eclipse.team.core.repository"
property="org.eclipse.core.resources.projectPersistentProperty"
value="org.eclipse.egit.core.GitProvider"/>
</adapt>
- </or>
- </iterate>
- </with>
- </visibleWhen>
+ </or>
+ </iterate>
+ </with>
+ </visibleWhen>
</command>
</menuContribution>
</extension>
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib.java
index 3240271e43..0b9a4c0045 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib.java
@@ -21,39 +21,39 @@ import org.eclipse.ui.editors.text.TextEditor;
*/
public interface IEditorChangeLogContrib {
- /**
- * Set TextEditor that this configuration is going to be used.
- *
- * @param editor The text editor for this configuration.
- */
- void setTextEditor(TextEditor editor);
+ /**
+ * Set TextEditor that this configuration is going to be used.
+ *
+ * @param editor The text editor for this configuration.
+ */
+ void setTextEditor(TextEditor editor);
- /**
- * Set default content type. GNU Changelog only has one type.
- *
- * @return default content type.
- */
- String[] getConfiguredContentTypes(ISourceViewer sourceViewer);
+ /**
+ * Set default content type. GNU Changelog only has one type.
+ *
+ * @return default content type.
+ */
+ String[] getConfiguredContentTypes(ISourceViewer sourceViewer);
- /**
- * Detects hyperlinks in GNU formatted changelogs.
- *
- * @return link detector for GNU format.
- */
- IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer);
+ /**
+ * Detects hyperlinks in GNU formatted changelogs.
+ *
+ * @return link detector for GNU format.
+ */
+ IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer);
- /**
- * Hyperlink presenter (decorator).
- *
- * @return default presenter.
- */
- IHyperlinkPresenter getHyperlinkPresenter(ISourceViewer sourceViewer);
+ /**
+ * Hyperlink presenter (decorator).
+ *
+ * @return default presenter.
+ */
+ IHyperlinkPresenter getHyperlinkPresenter(ISourceViewer sourceViewer);
- /**
- * Highlights GNU format changelog syntaxes.
- *
- * @return reconciler for GNU format changelog.
- */
- IPresentationReconciler getPresentationReconciler(
- ISourceViewer sourceViewer);
+ /**
+ * Highlights GNU format changelog syntaxes.
+ *
+ * @return reconciler for GNU format changelog.
+ */
+ IPresentationReconciler getPresentationReconciler(
+ ISourceViewer sourceViewer);
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib2.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib2.java
index d1619c7901..257e4b07ce 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib2.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IEditorChangeLogContrib2.java
@@ -14,10 +14,10 @@ import org.eclipse.jface.text.IDocument;
public interface IEditorChangeLogContrib2 {
- /**
- * Perform documentation setup. Use this to specify partitioning.
- *
- * @param document to set up.
- */
- void setup(IDocument document);
+ /**
+ * Perform documentation setup. Use this to specify partitioning.
+ *
+ * @param document to set up.
+ */
+ void setup(IDocument document);
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IFormatterChangeLogContrib.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IFormatterChangeLogContrib.java
index 92141aa524..eafb0729d5 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IFormatterChangeLogContrib.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IFormatterChangeLogContrib.java
@@ -17,7 +17,7 @@ import org.eclipse.ui.IEditorPart;
*/
public interface IFormatterChangeLogContrib {
- String formatDateLine(String authorName, String authorEmail);
- String mergeChangelog(String dateLine, String functionGuess,String defaultContent,
- IEditorPart changelog, String changeLogLocation, String fileLocation);
+ String formatDateLine(String authorName, String authorEmail);
+ String mergeChangelog(String dateLine, String functionGuess,String defaultContent,
+ IEditorPart changelog, String changeLogLocation, String fileLocation);
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IParserChangeLogContrib.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IParserChangeLogContrib.java
index 6ae9a1f1b6..2150714d1b 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IParserChangeLogContrib.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/IParserChangeLogContrib.java
@@ -19,26 +19,26 @@ import org.eclipse.ui.IEditorPart;
*/
public interface IParserChangeLogContrib {
- /**
- * Used to determine function name from a currently open editor, where the
- * cursor is at. Used by KeyAction.
- *
- * @param editor The editor to check for the function.
- * @return The name of the function.
- * @throws CoreException If unexpected error happens in the underlying Eclipse APIs.
- */
- String parseCurrentFunction(IEditorPart editor) throws CoreException;
+ /**
+ * Used to determine function name from a currently open editor, where the
+ * cursor is at. Used by KeyAction.
+ *
+ * @param editor The editor to check for the function.
+ * @return The name of the function.
+ * @throws CoreException If unexpected error happens in the underlying Eclipse APIs.
+ */
+ String parseCurrentFunction(IEditorPart editor) throws CoreException;
- /**
- * Used to determine function name from and editor input, with offset
- * supplied manualy. Used by prepare changelog.
- *
- * @param input If unexpected error happens in the underlying Eclipse APIs.
- * @param offset The offset at which to start.
- * @return The name of the function.
- * @throws CoreException If unexpected error happens in the underlying Eclipse APIs.
- */
- String parseCurrentFunction(IEditorInput input, int offset)
- throws CoreException;
+ /**
+ * Used to determine function name from and editor input, with offset
+ * supplied manualy. Used by prepare changelog.
+ *
+ * @param input If unexpected error happens in the underlying Eclipse APIs.
+ * @param offset The offset at which to start.
+ * @return The name of the function.
+ * @throws CoreException If unexpected error happens in the underlying Eclipse APIs.
+ */
+ String parseCurrentFunction(IEditorInput input, int offset)
+ throws CoreException;
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogExtensionManager.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogExtensionManager.java
index 237b17d5e0..d80647adf9 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogExtensionManager.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogExtensionManager.java
@@ -38,223 +38,223 @@ public final class ChangeLogExtensionManager {
private static final ChangeLogExtensionManager EXM = new ChangeLogExtensionManager();
- // These are used as a simple cache so we don't have to iterate over
- // all extensions to formatContribution every time the action is invoked.
- private IConfigurationElement cachedPrefFormatter = null;
+ // These are used as a simple cache so we don't have to iterate over
+ // all extensions to formatContribution every time the action is invoked.
+ private IConfigurationElement cachedPrefFormatter = null;
- private IConfigurationElement[] cachedInFileFormateters = null;
+ private IConfigurationElement[] cachedInFileFormateters = null;
- private IExtensionPoint parserExtensions = null;
+ private IExtensionPoint parserExtensions = null;
- private IExtensionPoint formatterExtensions = null;
+ private IExtensionPoint formatterExtensions = null;
- private IParserChangeLogContrib parserContributor = null;
+ private IParserChangeLogContrib parserContributor = null;
- private IConfigurationElement formatterConfigElementToUse = null;
+ private IConfigurationElement formatterConfigElementToUse = null;
- private ChangeLogExtensionManager() {
- getParserContributions();
- getFormatterContributions();
- }
+ private ChangeLogExtensionManager() {
+ getParserContributions();
+ getFormatterContributions();
+ }
- public static ChangeLogExtensionManager getExtensionManager() {
- return EXM;
- }
+ public static ChangeLogExtensionManager getExtensionManager() {
+ return EXM;
+ }
- private void getFormatterContributions() {
- formatterExtensions = Platform
- .getExtensionRegistry()
- .getExtensionPoint(
- "org.eclipse.linuxtools.changelog.core", "formatterContribution"); //$NON-NLS-1$
- }
+ private void getFormatterContributions() {
+ formatterExtensions = Platform
+ .getExtensionRegistry()
+ .getExtensionPoint(
+ "org.eclipse.linuxtools.changelog.core", "formatterContribution"); //$NON-NLS-1$
+ }
- private void getParserContributions() {
+ private void getParserContributions() {
- parserExtensions = Platform.getExtensionRegistry().getExtensionPoint(
- "org.eclipse.linuxtools.changelog.core", "parserContribution"); //$NON-NLS-1$
+ parserExtensions = Platform.getExtensionRegistry().getExtensionPoint(
+ "org.eclipse.linuxtools.changelog.core", "parserContribution"); //$NON-NLS-1$
- }
-
- public IParserChangeLogContrib getParserContributor(String editorName) {
-
- if (parserExtensions != null) {
- IConfigurationElement[] elements = parserExtensions
- .getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getName().equals("parser") // $NON-NLS-1$
- && (elements[i].getAttribute("editor") // $NON-NLS-1$
- .equals(editorName))) {
- //$NON-NLS-1$
- try {
- IConfigurationElement bob = elements[i];
- parserContributor = (IParserChangeLogContrib) bob
- .createExecutableExtension("class"); // $NON-NLS-1$
- return parserContributor;
- } catch (CoreException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
- IStatus.ERROR, e.getMessage(), e));
- }
-
- }
- }
- }
-
-
-
- return null;
- }
-
-
-
-
- public IConfigurationElement getFormatterConfigElement() {
- return formatterConfigElementToUse;
- }
-
- /**
- * Fetches formatterName formatter from extension, but if there exists a inline
- * formatter for entryFileName, then it uses that inline formatter.
- */
- public IFormatterChangeLogContrib getFormatterContributor(String entryFilePath, String formatterName) {
-
-
- // extract just file name;
- String fileName;
-
- int lastDir = entryFilePath.lastIndexOf('/');
- if ((lastDir >= 0) && (lastDir +1 <= entryFilePath.length()))
- fileName = entryFilePath.substring(lastDir + 1, entryFilePath.length());
- else
- fileName = entryFilePath;
-
- // We don't yet know which formatter to use
- formatterConfigElementToUse = null;
-
- // IFile file = null;
-
- if (formatterExtensions != null) {
- IConfigurationElement[] elements = formatterExtensions
- .getConfigurationElements();
-
- // cache the in-file formatters on the first run
- if (cachedInFileFormateters == null) {
- List<IConfigurationElement> inFileFormatters = new LinkedList<>();
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement formatterConfigElement = elements[i];
- if (formatterConfigElement.getName().equals("formatter") // $NON-NLS-1$
- && formatterConfigElement.getAttribute("inFile") // $NON-NLS-1$
- .equalsIgnoreCase("true")) { // $NON-NLS-1$
- inFileFormatters.add(elements[i]);
- }
- }
- cachedInFileFormateters = inFileFormatters
- .toArray(new IConfigurationElement[] {});
- }
-
- // check if there is an in-file changelog formatter for the
- // currently
- // edited file
- for (int i = 0; i < cachedInFileFormateters.length; i++) {
- IConfigurationElement formatterConfigElement = cachedInFileFormateters[i];
-
- IConfigurationElement[] patternElementTmp = formatterConfigElement
- .getChildren();
-
- // error check
- if (patternElementTmp == null)
- continue;
- IConfigurationElement patternElement = patternElementTmp[0];
-
- if (patternElement.getAttribute("pattern") == null) { // $NON-NLS-1$
- ChangelogPlugin
- .getDefault()
- .getLog()
- .log(
- new Status(
- IStatus.ERROR,
- ChangelogPlugin.PLUGIN_ID,
- IStatus.ERROR,
- Messages.getString("ChangeLog.ErrNonPattern"), // $NON-NLS-1$
- new Exception(Messages.getString("ChangeLog.ErrNonPattern")))); // $NON-NLS-1$
- } else {
- String filePattern = patternElement.getAttribute("pattern"); // $NON-NLS-1$
-
- try {
- Pattern pattern = Pattern.compile(filePattern);
- Matcher fileMatcher = pattern.matcher(fileName);
-
- // if the filename of the current editor matches the
- // file
- // pattern then we're done
- if (fileMatcher.matches()) {
- formatterConfigElementToUse = formatterConfigElement;
- break;
- }
- } catch (PatternSyntaxException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
- IStatus.ERROR, e.getMessage(), e));
- }
- }
-
- }
-
- // if we haven't found an in-file formatter we try to get the user's
- // prefered formatter
- if (formatterConfigElementToUse == null) {
-
- // we cache the user's preferred formatter on the first run, and
- // whenever it changes
- if (cachedPrefFormatter == null
- || !cachedPrefFormatter.getAttribute("name").equals( // $NON-NLS-1$
- formatterName)) {
-
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement formatterConfigElement = elements[i];
- if (formatterConfigElement.getName()
- .equals("formatter") && formatterConfigElement.getAttribute("inFile").equalsIgnoreCase("false")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (formatterConfigElement.getAttribute("name") // $NON-NLS-1$
- .equals(formatterName))
- cachedPrefFormatter = formatterConfigElement;
- break;
-
- }
- }
- }
-
- formatterConfigElementToUse = cachedPrefFormatter;
-
- if (formatterConfigElementToUse == null) {
- ChangelogPlugin
- .getDefault()
- .getLog()
- .log(
- new Status(
- IStatus.ERROR,
- ChangelogPlugin.PLUGIN_ID,
- IStatus.ERROR,
- Messages.getString("ChangeLog.ErrRetrieveFormatter"), // $NON-NLS-1$
- new Exception(Messages.getString("ChangeLog.ErrRetrieveFormatter")))); // $NON-NLS-1$
-
- return null;
- }
-
- }
- }
-
-
-
- try {
- return (IFormatterChangeLogContrib) formatterConfigElementToUse
- .createExecutableExtension("class"); // $NON-NLS-1$
-
- } catch (CoreException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
- .getMessage(), e));
- e.printStackTrace();
- }
- return null;
- }
+ }
+
+ public IParserChangeLogContrib getParserContributor(String editorName) {
+
+ if (parserExtensions != null) {
+ IConfigurationElement[] elements = parserExtensions
+ .getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i].getName().equals("parser") // $NON-NLS-1$
+ && (elements[i].getAttribute("editor") // $NON-NLS-1$
+ .equals(editorName))) {
+ //$NON-NLS-1$
+ try {
+ IConfigurationElement bob = elements[i];
+ parserContributor = (IParserChangeLogContrib) bob
+ .createExecutableExtension("class"); // $NON-NLS-1$
+ return parserContributor;
+ } catch (CoreException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
+ IStatus.ERROR, e.getMessage(), e));
+ }
+
+ }
+ }
+ }
+
+
+
+ return null;
+ }
+
+
+
+
+ public IConfigurationElement getFormatterConfigElement() {
+ return formatterConfigElementToUse;
+ }
+
+ /**
+ * Fetches formatterName formatter from extension, but if there exists a inline
+ * formatter for entryFileName, then it uses that inline formatter.
+ */
+ public IFormatterChangeLogContrib getFormatterContributor(String entryFilePath, String formatterName) {
+
+
+ // extract just file name;
+ String fileName;
+
+ int lastDir = entryFilePath.lastIndexOf('/');
+ if ((lastDir >= 0) && (lastDir +1 <= entryFilePath.length()))
+ fileName = entryFilePath.substring(lastDir + 1, entryFilePath.length());
+ else
+ fileName = entryFilePath;
+
+ // We don't yet know which formatter to use
+ formatterConfigElementToUse = null;
+
+ // IFile file = null;
+
+ if (formatterExtensions != null) {
+ IConfigurationElement[] elements = formatterExtensions
+ .getConfigurationElements();
+
+ // cache the in-file formatters on the first run
+ if (cachedInFileFormateters == null) {
+ List<IConfigurationElement> inFileFormatters = new LinkedList<>();
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement formatterConfigElement = elements[i];
+ if (formatterConfigElement.getName().equals("formatter") // $NON-NLS-1$
+ && formatterConfigElement.getAttribute("inFile") // $NON-NLS-1$
+ .equalsIgnoreCase("true")) { // $NON-NLS-1$
+ inFileFormatters.add(elements[i]);
+ }
+ }
+ cachedInFileFormateters = inFileFormatters
+ .toArray(new IConfigurationElement[] {});
+ }
+
+ // check if there is an in-file changelog formatter for the
+ // currently
+ // edited file
+ for (int i = 0; i < cachedInFileFormateters.length; i++) {
+ IConfigurationElement formatterConfigElement = cachedInFileFormateters[i];
+
+ IConfigurationElement[] patternElementTmp = formatterConfigElement
+ .getChildren();
+
+ // error check
+ if (patternElementTmp == null)
+ continue;
+ IConfigurationElement patternElement = patternElementTmp[0];
+
+ if (patternElement.getAttribute("pattern") == null) { // $NON-NLS-1$
+ ChangelogPlugin
+ .getDefault()
+ .getLog()
+ .log(
+ new Status(
+ IStatus.ERROR,
+ ChangelogPlugin.PLUGIN_ID,
+ IStatus.ERROR,
+ Messages.getString("ChangeLog.ErrNonPattern"), // $NON-NLS-1$
+ new Exception(Messages.getString("ChangeLog.ErrNonPattern")))); // $NON-NLS-1$
+ } else {
+ String filePattern = patternElement.getAttribute("pattern"); // $NON-NLS-1$
+
+ try {
+ Pattern pattern = Pattern.compile(filePattern);
+ Matcher fileMatcher = pattern.matcher(fileName);
+
+ // if the filename of the current editor matches the
+ // file
+ // pattern then we're done
+ if (fileMatcher.matches()) {
+ formatterConfigElementToUse = formatterConfigElement;
+ break;
+ }
+ } catch (PatternSyntaxException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
+ IStatus.ERROR, e.getMessage(), e));
+ }
+ }
+
+ }
+
+ // if we haven't found an in-file formatter we try to get the user's
+ // prefered formatter
+ if (formatterConfigElementToUse == null) {
+
+ // we cache the user's preferred formatter on the first run, and
+ // whenever it changes
+ if (cachedPrefFormatter == null
+ || !cachedPrefFormatter.getAttribute("name").equals( // $NON-NLS-1$
+ formatterName)) {
+
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement formatterConfigElement = elements[i];
+ if (formatterConfigElement.getName()
+ .equals("formatter") && formatterConfigElement.getAttribute("inFile").equalsIgnoreCase("false")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (formatterConfigElement.getAttribute("name") // $NON-NLS-1$
+ .equals(formatterName))
+ cachedPrefFormatter = formatterConfigElement;
+ break;
+
+ }
+ }
+ }
+
+ formatterConfigElementToUse = cachedPrefFormatter;
+
+ if (formatterConfigElementToUse == null) {
+ ChangelogPlugin
+ .getDefault()
+ .getLog()
+ .log(
+ new Status(
+ IStatus.ERROR,
+ ChangelogPlugin.PLUGIN_ID,
+ IStatus.ERROR,
+ Messages.getString("ChangeLog.ErrRetrieveFormatter"), // $NON-NLS-1$
+ new Exception(Messages.getString("ChangeLog.ErrRetrieveFormatter")))); // $NON-NLS-1$
+
+ return null;
+ }
+
+ }
+ }
+
+
+
+ try {
+ return (IFormatterChangeLogContrib) formatterConfigElementToUse
+ .createExecutableExtension("class"); // $NON-NLS-1$
+
+ } catch (CoreException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
+ .getMessage(), e));
+ e.printStackTrace();
+ }
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java
index 13c02eacb1..2489b9f37a 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java
@@ -38,233 +38,233 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
* preference dialog based on the registration.
*/
public class ChangeLogPreferencesPage extends PreferencePage implements
- IWorkbenchPreferencePage {
-
- private Text emailField;
-
- private Text nameField;
-
- private List formatterList;
-
- private List editorList;
-
- private Composite createComposite(Composite parent, int numColumns) {
- Composite composite = new Composite(parent, SWT.NULL);
-
- // GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- // GridData
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
- return composite;
- }
-
- private Label createLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
- GridData data = new GridData();
- data.horizontalSpan = 2;
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
- return label;
- }
-
- private Text createTextField(Composite parent) {
- Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.verticalAlignment = GridData.CENTER;
- data.grabExcessVerticalSpace = false;
- text.setLayoutData(data);
- return text;
- }
-
- private List createListBox(Composite parent, int sizeHint) {
- List list = new List(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.verticalAlignment = GridData.CENTER;
- data.grabExcessVerticalSpace = false;
- data.heightHint = list.getItemHeight() * sizeHint;
- list.setLayoutData(data);
-
- return list;
- }
-
- @Override
- public void init(IWorkbench workbench) {
- }
-
- @Override
- protected IPreferenceStore doGetPreferenceStore() {
- return ChangelogPlugin.getDefault().getPreferenceStore();
- }
-
- private void initializeDefaults() {
- IPreferenceStore store = getPreferenceStore();
- emailField.setText(store
- .getDefaultString("IChangeLogConstants.AUTHOR_EMAIL")); //$NON-NLS-1$
- nameField.setText(store
- .getDefaultString("IChangeLogConstants.AUTHOR_NAME")); //$NON-NLS-1$
- setDefaultFormatter(store);
- setDefaultEditor(store);
- storeValues();
- }
-
- private void setDefaultFormatter(IPreferenceStore store) {
-
- String defaultFormatter = store
- .getDefaultString("IChangeLogConstants.DEFAULT_FORMATTER"); //$NON-NLS-1$
- for (int i = 0; i < formatterList.getItemCount(); i++) {
- if (formatterList.getItem(i).equals(defaultFormatter)) {
- formatterList.setSelection(i);
- return;
- }
- }
- }
-
- private void setDefaultEditor(IPreferenceStore store) {
-
- String defaultEditor = store
- .getDefaultString("IChangeLogConstants.DEFAULT_EDITOR"); //$NON-NLS-1$
- for (int i = 0; i < editorList.getItemCount(); i++) {
- if (editorList.getItem(i).equals(defaultEditor)) {
- editorList.setSelection(i);
- return;
- }
- }
- }
-
- private void populateFormatList(IPreferenceStore store) {
- IExtensionPoint parserExtensions = Platform
- .getExtensionRegistry()
- .getExtensionPoint(
- "org.eclipse.linuxtools.changelog.core", "formatterContribution"); //$NON-NLS-1$ //$NON-NLS-2$
- if (parserExtensions != null) {
- IConfigurationElement[] elements = parserExtensions
- .getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (element.getName().equals("formatter")) {//$NON-NLS-1$
-
- String fname = element.getAttribute("name"); //$NON-NLS-1$\
- // only add formatters for external files, not in-file formatters.
- if (element.getAttribute("inFile").equalsIgnoreCase("false")) {
- formatterList.add(fname);
- }
-
- if (fname
- .equals(store
- .getString("IChangeLogConstants.DEFAULT_FORMATTER"))) { //$NON-NLS-1$
- formatterList
- .setSelection(formatterList.getItemCount() - 1);
- }
- }
- }
-
- }
- }
-
- private void populateEditorList(IPreferenceStore store) {
- IExtensionPoint editorExtensions = Platform
- .getExtensionRegistry()
- .getExtensionPoint(
- "org.eclipse.linuxtools.changelog.core", "editorContribution"); //$NON-NLS-1$ //$NON-NLS-2$
- if (editorExtensions != null) {
- IConfigurationElement[] elements = editorExtensions
- .getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (element.getName().equals("editor")) {//$NON-NLS-1$
- String fname = element.getAttribute("name"); //$NON-NLS-1$
- editorList.add(fname);
- if (fname.equals(store
- .getString("IChangeLogConstants.DEFAULT_EDITOR"))) {//$NON-NLS-1$
- editorList.setSelection(editorList.getItemCount() - 1);
- }
- }
- }
-
- }
- }
-
- private void initializeValues() {
- IPreferenceStore store = getPreferenceStore();
-
- emailField.setText(store.getString("IChangeLogConstants.AUTHOR_EMAIL")); //$NON-NLS-1$
- nameField.setText(store.getString("IChangeLogConstants.AUTHOR_NAME")); //$NON-NLS-1$
- populateFormatList(store);
- populateEditorList(store);
- }
-
- private void storeValues() {
- IPreferenceStore store = getPreferenceStore();
-
- store.setValue("IChangeLogConstants.AUTHOR_NAME", nameField.getText()); //$NON-NLS-1$
- store
- .setValue(
- "IChangeLogConstants.AUTHOR_EMAIL", emailField.getText()); //$NON-NLS-1$
- String[] selection = formatterList.getSelection();
- if (selection != null && selection.length > 0) {
- store.setValue("IChangeLogConstants.DEFAULT_FORMATTER", selection[0]); //$NON-NLS-1$
- }
- String[] selection2 = editorList.getSelection();
- if (selection2 != null && selection2.length > 0) {
- store.setValue("IChangeLogConstants.DEFAULT_EDITOR", selection2[0]); //$NON-NLS-1$
- }
-
- }
-
- /*
- * (non-Javadoc) Method declared on PreferencePage
- */
- @Override
- protected void performDefaults() {
- super.performDefaults();
- initializeDefaults();
-
- }
-
- /*
- * (non-Javadoc) Method declared on PreferencePage
- */
- @SuppressWarnings("deprecation")
- @Override
- public boolean performOk() {
- storeValues();
- ChangelogPlugin.getDefault().savePluginPreferences();
- return true;
- }
-
- @Override
- protected Control createContents(Composite parent) {
- // composite_textField << parent
- Composite composite_textField = createComposite(parent, 2);
- createLabel(composite_textField, Messages
- .getString("ChangeLogPreferencesPage.AuthorName")); //$NON-NLS-1$
- nameField = createTextField(composite_textField);
-
- // composite_textField << parent
-
- createLabel(composite_textField, Messages
- .getString("ChangeLogPreferencesPage.AuthorEmail")); //$NON-NLS-1$
- emailField = createTextField(composite_textField);
-
- createLabel(composite_textField, Messages
- .getString("ChangeLogPreferencesPage.Formatters")); //$NON-NLS-1$
- formatterList = createListBox(composite_textField, 3);
-
- createLabel(composite_textField, Messages
- .getString("ChangeLogPreferencesPage.Editors")); //$NON-NLS-1$
- editorList = createListBox(composite_textField, 3);
-
- initializeValues();
-
- return new Composite(parent, SWT.NULL);
- }
+ IWorkbenchPreferencePage {
+
+ private Text emailField;
+
+ private Text nameField;
+
+ private List formatterList;
+
+ private List editorList;
+
+ private Composite createComposite(Composite parent, int numColumns) {
+ Composite composite = new Composite(parent, SWT.NULL);
+
+ // GridLayout
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ composite.setLayout(layout);
+
+ // GridData
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+ return composite;
+ }
+
+ private Label createLabel(Composite parent, String text) {
+ Label label = new Label(parent, SWT.LEFT);
+ label.setText(text);
+ GridData data = new GridData();
+ data.horizontalSpan = 2;
+ data.horizontalAlignment = GridData.FILL;
+ label.setLayoutData(data);
+ return label;
+ }
+
+ private Text createTextField(Composite parent) {
+ Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ data.verticalAlignment = GridData.CENTER;
+ data.grabExcessVerticalSpace = false;
+ text.setLayoutData(data);
+ return text;
+ }
+
+ private List createListBox(Composite parent, int sizeHint) {
+ List list = new List(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ data.verticalAlignment = GridData.CENTER;
+ data.grabExcessVerticalSpace = false;
+ data.heightHint = list.getItemHeight() * sizeHint;
+ list.setLayoutData(data);
+
+ return list;
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ protected IPreferenceStore doGetPreferenceStore() {
+ return ChangelogPlugin.getDefault().getPreferenceStore();
+ }
+
+ private void initializeDefaults() {
+ IPreferenceStore store = getPreferenceStore();
+ emailField.setText(store
+ .getDefaultString("IChangeLogConstants.AUTHOR_EMAIL")); //$NON-NLS-1$
+ nameField.setText(store
+ .getDefaultString("IChangeLogConstants.AUTHOR_NAME")); //$NON-NLS-1$
+ setDefaultFormatter(store);
+ setDefaultEditor(store);
+ storeValues();
+ }
+
+ private void setDefaultFormatter(IPreferenceStore store) {
+
+ String defaultFormatter = store
+ .getDefaultString("IChangeLogConstants.DEFAULT_FORMATTER"); //$NON-NLS-1$
+ for (int i = 0; i < formatterList.getItemCount(); i++) {
+ if (formatterList.getItem(i).equals(defaultFormatter)) {
+ formatterList.setSelection(i);
+ return;
+ }
+ }
+ }
+
+ private void setDefaultEditor(IPreferenceStore store) {
+
+ String defaultEditor = store
+ .getDefaultString("IChangeLogConstants.DEFAULT_EDITOR"); //$NON-NLS-1$
+ for (int i = 0; i < editorList.getItemCount(); i++) {
+ if (editorList.getItem(i).equals(defaultEditor)) {
+ editorList.setSelection(i);
+ return;
+ }
+ }
+ }
+
+ private void populateFormatList(IPreferenceStore store) {
+ IExtensionPoint parserExtensions = Platform
+ .getExtensionRegistry()
+ .getExtensionPoint(
+ "org.eclipse.linuxtools.changelog.core", "formatterContribution"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (parserExtensions != null) {
+ IConfigurationElement[] elements = parserExtensions
+ .getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if (element.getName().equals("formatter")) {//$NON-NLS-1$
+
+ String fname = element.getAttribute("name"); //$NON-NLS-1$\
+ // only add formatters for external files, not in-file formatters.
+ if (element.getAttribute("inFile").equalsIgnoreCase("false")) {
+ formatterList.add(fname);
+ }
+
+ if (fname
+ .equals(store
+ .getString("IChangeLogConstants.DEFAULT_FORMATTER"))) { //$NON-NLS-1$
+ formatterList
+ .setSelection(formatterList.getItemCount() - 1);
+ }
+ }
+ }
+
+ }
+ }
+
+ private void populateEditorList(IPreferenceStore store) {
+ IExtensionPoint editorExtensions = Platform
+ .getExtensionRegistry()
+ .getExtensionPoint(
+ "org.eclipse.linuxtools.changelog.core", "editorContribution"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (editorExtensions != null) {
+ IConfigurationElement[] elements = editorExtensions
+ .getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if (element.getName().equals("editor")) {//$NON-NLS-1$
+ String fname = element.getAttribute("name"); //$NON-NLS-1$
+ editorList.add(fname);
+ if (fname.equals(store
+ .getString("IChangeLogConstants.DEFAULT_EDITOR"))) {//$NON-NLS-1$
+ editorList.setSelection(editorList.getItemCount() - 1);
+ }
+ }
+ }
+
+ }
+ }
+
+ private void initializeValues() {
+ IPreferenceStore store = getPreferenceStore();
+
+ emailField.setText(store.getString("IChangeLogConstants.AUTHOR_EMAIL")); //$NON-NLS-1$
+ nameField.setText(store.getString("IChangeLogConstants.AUTHOR_NAME")); //$NON-NLS-1$
+ populateFormatList(store);
+ populateEditorList(store);
+ }
+
+ private void storeValues() {
+ IPreferenceStore store = getPreferenceStore();
+
+ store.setValue("IChangeLogConstants.AUTHOR_NAME", nameField.getText()); //$NON-NLS-1$
+ store
+ .setValue(
+ "IChangeLogConstants.AUTHOR_EMAIL", emailField.getText()); //$NON-NLS-1$
+ String[] selection = formatterList.getSelection();
+ if (selection != null && selection.length > 0) {
+ store.setValue("IChangeLogConstants.DEFAULT_FORMATTER", selection[0]); //$NON-NLS-1$
+ }
+ String[] selection2 = editorList.getSelection();
+ if (selection2 != null && selection2.length > 0) {
+ store.setValue("IChangeLogConstants.DEFAULT_EDITOR", selection2[0]); //$NON-NLS-1$
+ }
+
+ }
+
+ /*
+ * (non-Javadoc) Method declared on PreferencePage
+ */
+ @Override
+ protected void performDefaults() {
+ super.performDefaults();
+ initializeDefaults();
+
+ }
+
+ /*
+ * (non-Javadoc) Method declared on PreferencePage
+ */
+ @SuppressWarnings("deprecation")
+ @Override
+ public boolean performOk() {
+ storeValues();
+ ChangelogPlugin.getDefault().savePluginPreferences();
+ return true;
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ // composite_textField << parent
+ Composite composite_textField = createComposite(parent, 2);
+ createLabel(composite_textField, Messages
+ .getString("ChangeLogPreferencesPage.AuthorName")); //$NON-NLS-1$
+ nameField = createTextField(composite_textField);
+
+ // composite_textField << parent
+
+ createLabel(composite_textField, Messages
+ .getString("ChangeLogPreferencesPage.AuthorEmail")); //$NON-NLS-1$
+ emailField = createTextField(composite_textField);
+
+ createLabel(composite_textField, Messages
+ .getString("ChangeLogPreferencesPage.Formatters")); //$NON-NLS-1$
+ formatterList = createListBox(composite_textField, 3);
+
+ createLabel(composite_textField, Messages
+ .getString("ChangeLogPreferencesPage.Editors")); //$NON-NLS-1$
+ editorList = createListBox(composite_textField, 3);
+
+ initializeValues();
+
+ return new Composite(parent, SWT.NULL);
+ }
} \ No newline at end of file
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogWriter.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogWriter.java
index fe65976b65..04ce9da110 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogWriter.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogWriter.java
@@ -17,114 +17,114 @@ import org.eclipse.ui.IEditorPart;
/**
* Writes changelog using extension point IFormatterChangeLogContrib.
- *
+ *
* @author klee
*
*/
public class ChangeLogWriter {
-
- private String defaultContent = ""; // $NON-NLS-1$
- private String entryFilePath = null;
+ private String defaultContent = ""; // $NON-NLS-1$
+
+ private String entryFilePath = null;
- private String guessedFName = null;
+ private String guessedFName = null;
- private IFormatterChangeLogContrib formatter = null;
+ private IFormatterChangeLogContrib formatter = null;
- private IEditorPart changelog = null;
+ private IEditorPart changelog = null;
- private String dateLine = null;
+ private String dateLine = null;
- private String changelogLocation = null;
+ private String changelogLocation = null;
- public IEditorPart getChangelog() {
- return changelog;
- }
+ public IEditorPart getChangelog() {
+ return changelog;
+ }
- public void setChangelog(IEditorPart changelog) {
- this.changelog = changelog;
- }
+ public void setChangelog(IEditorPart changelog) {
+ this.changelog = changelog;
+ }
- public String getChangelogLocation() {
- return changelogLocation;
- }
+ public String getChangelogLocation() {
+ return changelogLocation;
+ }
- public void setChangelogLocation(String changelogLocation) {
- this.changelogLocation = changelogLocation;
- }
+ public void setChangelogLocation(String changelogLocation) {
+ this.changelogLocation = changelogLocation;
+ }
- public String getDateLine() {
- return dateLine;
- }
+ public String getDateLine() {
+ return dateLine;
+ }
- public void setDateLine(String dateLine) {
- this.dateLine = dateLine;
- }
+ public void setDateLine(String dateLine) {
+ this.dateLine = dateLine;
+ }
- public String getEntryFilePath() {
- return entryFilePath;
- }
+ public String getEntryFilePath() {
+ return entryFilePath;
+ }
- public void setEntryFilePath(String entryFilePath) {
- // Replace characters in the name that are supposed to be
- // token markers such as blanks, parentheses, and colon with
- // escaped characters so they won't fool the colorization or
- // other parsing.
- String resolvedPath = entryFilePath.replace("(", "\\(");
- resolvedPath = resolvedPath.replace(")", "\\)");
- resolvedPath = resolvedPath.replace(":", "\\:");
- resolvedPath = resolvedPath.replace(" ", "\\ ");
- this.entryFilePath = resolvedPath;
- }
+ public void setEntryFilePath(String entryFilePath) {
+ // Replace characters in the name that are supposed to be
+ // token markers such as blanks, parentheses, and colon with
+ // escaped characters so they won't fool the colorization or
+ // other parsing.
+ String resolvedPath = entryFilePath.replace("(", "\\(");
+ resolvedPath = resolvedPath.replace(")", "\\)");
+ resolvedPath = resolvedPath.replace(":", "\\:");
+ resolvedPath = resolvedPath.replace(" ", "\\ ");
+ this.entryFilePath = resolvedPath;
+ }
- public IFormatterChangeLogContrib getFormatter() {
- return formatter;
- }
+ public IFormatterChangeLogContrib getFormatter() {
+ return formatter;
+ }
- public void setFormatter(IFormatterChangeLogContrib formatter) {
- this.formatter = formatter;
- }
+ public void setFormatter(IFormatterChangeLogContrib formatter) {
+ this.formatter = formatter;
+ }
- public String getGuessedFName() {
- return guessedFName;
- }
+ public String getGuessedFName() {
+ return guessedFName;
+ }
- public void setGuessedFName(String guessedFName) {
- this.guessedFName = guessedFName;
- }
+ public void setGuessedFName(String guessedFName) {
+ this.guessedFName = guessedFName;
+ }
- public void writeChangeLog() {
+ public void writeChangeLog() {
- // System.out.println("Debug Output :");
- // System.out.println(entryFilePath);
- // System.out.println(guessedFName);
- // System.out.println(formatter);
- // System.out.println(changelog);
- // System.out.println(dateLine);
- // System.out.println(changelogLocation);
- // System.out.println("\n");
+ // System.out.println("Debug Output :");
+ // System.out.println(entryFilePath);
+ // System.out.println(guessedFName);
+ // System.out.println(formatter);
+ // System.out.println(changelog);
+ // System.out.println(dateLine);
+ // System.out.println(changelogLocation);
+ // System.out.println("\n");
- if (entryFilePath == null || guessedFName == null || formatter == null
- || changelog == null || dateLine == null
- || changelogLocation == null) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
- Messages.getString("ChangeLogWriter.ErrUninitialized"), null)); // $NON-NLS-1$
+ if (entryFilePath == null || guessedFName == null || formatter == null
+ || changelog == null || dateLine == null
+ || changelogLocation == null) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
+ Messages.getString("ChangeLogWriter.ErrUninitialized"), null)); // $NON-NLS-1$
- return;
- }
+ return;
+ }
- formatter.mergeChangelog(dateLine, guessedFName, defaultContent, changelog,
- changelogLocation, entryFilePath);
+ formatter.mergeChangelog(dateLine, guessedFName, defaultContent, changelog,
+ changelogLocation, entryFilePath);
- }
+ }
- public String getDefaultContent() {
- return defaultContent;
- }
+ public String getDefaultContent() {
+ return defaultContent;
+ }
- public void setDefaultContent(String defaultContent) {
- this.defaultContent = defaultContent;
- }
+ public void setDefaultContent(String defaultContent) {
+ this.defaultContent = defaultContent;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPlugin.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPlugin.java
index 28dcb5c2b3..bb5c376e7f 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPlugin.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPlugin.java
@@ -22,25 +22,25 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
* The main plugin class to be used in the desktop.
*/
public class ChangelogPlugin extends AbstractUIPlugin {
-
- public static final String PLUGIN_ID = "org.eclipse.linuxtools.changelog.core"; // $NON-NLS-1$
-
- // The shared instance.
- private static ChangelogPlugin plugin;
-
- /**
- * The constructor.
- */
- public ChangelogPlugin() {
- // super();
- plugin = this;
- }
-
- /**
- * Returns the shared instance.
- */
- public static ChangelogPlugin getDefault() {
- return plugin;
- }
+
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.changelog.core"; // $NON-NLS-1$
+
+ // The shared instance.
+ private static ChangelogPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public ChangelogPlugin() {
+ // super();
+ plugin = this;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static ChangelogPlugin getDefault() {
+ return plugin;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPreferenceInitializer.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPreferenceInitializer.java
index dfc2f65a3f..a5f8e2137e 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPreferenceInitializer.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangelogPreferenceInitializer.java
@@ -16,56 +16,56 @@ import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
public class ChangelogPreferenceInitializer extends
- AbstractPreferenceInitializer {
+ AbstractPreferenceInitializer {
- @Override
- public void initializeDefaultPreferences() {
- IPreferenceStore store = ChangelogPlugin.getDefault()
- .getPreferenceStore();
- store.setDefault("IChangeLogConstants.DATE_FORMAT", "true"); // $NON-NLS-1$
- // //
- // $NON-NLS-2$
- store.setDefault("IChangeLogConstants.APPEND_RESOURCE_PATH", "false"); // $NON-NLS-1$
- // //
- // $NON-NLS-2$
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = ChangelogPlugin.getDefault()
+ .getPreferenceStore();
+ store.setDefault("IChangeLogConstants.DATE_FORMAT", "true"); // $NON-NLS-1$
+ // //
+ // $NON-NLS-2$
+ store.setDefault("IChangeLogConstants.APPEND_RESOURCE_PATH", "false"); // $NON-NLS-1$
+ // //
+ // $NON-NLS-2$
- store.setDefault("IChangeLogConstants.AUTHOR_NAME", // $NON-NLS-1$
- getUserRealName());
- store.setDefault("IChangeLogConstants.AUTHOR_EMAIL", // $NON-NLS-2$
- getUserEmail());
- store.setDefault("IChangeLogConstants.DEFAULT_FORMATTER", // $NON-NLS-1$
- Messages.getString("ChangeLogPreferencesPage.gnuFormatter")); // $NON-NLS-1$
- store.setDefault("IChangeLogConstants.DEFAULT_EDITOR", // $NON-NLS-1$
- Messages.getString("ChangeLogPreferencesPage.gnuEditorConfig")); // $NON-NLS-1$
- }
+ store.setDefault("IChangeLogConstants.AUTHOR_NAME", // $NON-NLS-1$
+ getUserRealName());
+ store.setDefault("IChangeLogConstants.AUTHOR_EMAIL", // $NON-NLS-2$
+ getUserEmail());
+ store.setDefault("IChangeLogConstants.DEFAULT_FORMATTER", // $NON-NLS-1$
+ Messages.getString("ChangeLogPreferencesPage.gnuFormatter")); // $NON-NLS-1$
+ store.setDefault("IChangeLogConstants.DEFAULT_EDITOR", // $NON-NLS-1$
+ Messages.getString("ChangeLogPreferencesPage.gnuEditorConfig")); // $NON-NLS-1$
+ }
- private String getUserRealName() {
- String realUserName = System.getenv("ECLIPSE_CHANGELOG_REALNAME"); // $NON-NLS-1$
- if (realUserName != null)
- return realUserName;
- return System.getProperty("gnu.gcj.user.realname", //$NON-NLS-1$
- getUserName());
- }
+ private String getUserRealName() {
+ String realUserName = System.getenv("ECLIPSE_CHANGELOG_REALNAME"); // $NON-NLS-1$
+ if (realUserName != null)
+ return realUserName;
+ return System.getProperty("gnu.gcj.user.realname", //$NON-NLS-1$
+ getUserName());
+ }
- private String getUserEmail() {
- String emailID = System.getenv("ECLIPSE_CHANGELOG_EMAIL"); // $NON-NLS-1$
- if (emailID != null)
- return emailID;
- return getUserName() + "@" + getHostName(); // $NON-NLS-1$
- }
+ private String getUserEmail() {
+ String emailID = System.getenv("ECLIPSE_CHANGELOG_EMAIL"); // $NON-NLS-1$
+ if (emailID != null)
+ return emailID;
+ return getUserName() + "@" + getHostName(); // $NON-NLS-1$
+ }
- private String getUserName() {
- return System.getProperty("user.name"); //$NON-NLS-1$
- }
+ private String getUserName() {
+ return System.getProperty("user.name"); //$NON-NLS-1$
+ }
- private String getHostName() {
- try {
- return java.net.InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- // instead of throwing exception, return default host name
- // RH bug#194406
- return "localhost.localdomain"; //$NON-NLS-1$
- }
- }
+ private String getHostName() {
+ try {
+ return java.net.InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ // instead of throwing exception, return default host name
+ // RH bug#194406
+ return "localhost.localdomain"; //$NON-NLS-1$
+ }
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java
index 45168fc8ac..dadedd7a34 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java
@@ -39,75 +39,75 @@ public class LineComparator implements IRangeComparator {
*/
private static class TrailingLineFeedDetector extends FilterInputStream {
- boolean trailingLF = false;
-
- protected TrailingLineFeedDetector(InputStream in) {
- super(in);
- }
-
- @Override
- public int read() throws IOException {
- int c = super.read();
- trailingLF = isLineFeed(c);
- return c;
- }
-
- /*
- * We don't need to override read(byte[] buffer) as the javadoc of
- * FilterInputStream states that it will call read(byte[] buffer, int off, int len)
- */
- @Override
- public int read(byte[] buffer, int off, int len) throws IOException {
- int length = super.read(buffer, off, len);
- if (length != -1) {
- int index = off + length - 1;
- if (index >= buffer.length)
- index = buffer.length - 1;
- trailingLF = isLineFeed(buffer[index]);
- }
- return length;
- }
-
- private boolean isLineFeed(int c) {
- return c != -1 && c == '\n';
- }
-
- public boolean hadTrailingLineFeed() {
- return trailingLF;
- }
+ boolean trailingLF = false;
+
+ protected TrailingLineFeedDetector(InputStream in) {
+ super(in);
+ }
+
+ @Override
+ public int read() throws IOException {
+ int c = super.read();
+ trailingLF = isLineFeed(c);
+ return c;
+ }
+
+ /*
+ * We don't need to override read(byte[] buffer) as the javadoc of
+ * FilterInputStream states that it will call read(byte[] buffer, int off, int len)
+ */
+ @Override
+ public int read(byte[] buffer, int off, int len) throws IOException {
+ int length = super.read(buffer, off, len);
+ if (length != -1) {
+ int index = off + length - 1;
+ if (index >= buffer.length)
+ index = buffer.length - 1;
+ trailingLF = isLineFeed(buffer[index]);
+ }
+ return length;
+ }
+
+ private boolean isLineFeed(int c) {
+ return c != -1 && c == '\n';
+ }
+
+ public boolean hadTrailingLineFeed() {
+ return trailingLF;
+ }
}
public static LineComparator create(IStorage storage, String outputEncoding) throws CoreException {
- try (InputStream is = new BufferedInputStream(storage.getContents())) {
- String encoding = getEncoding(storage, outputEncoding);
- return new LineComparator(is, encoding);
- } catch (IOException e) {
- return null;
- }
+ try (InputStream is = new BufferedInputStream(storage.getContents())) {
+ String encoding = getEncoding(storage, outputEncoding);
+ return new LineComparator(is, encoding);
+ } catch (IOException e) {
+ return null;
+ }
}
- private static String getEncoding(IStorage storage, String outputEncoding) throws CoreException {
- if (storage instanceof IEncodedStorage) {
- IEncodedStorage es = (IEncodedStorage) storage;
- String charset = es.getCharset();
- if (charset != null)
- return charset;
- }
- return outputEncoding;
- }
+ private static String getEncoding(IStorage storage, String outputEncoding) throws CoreException {
+ if (storage instanceof IEncodedStorage) {
+ IEncodedStorage es = (IEncodedStorage) storage;
+ String charset = es.getCharset();
+ if (charset != null)
+ return charset;
+ }
+ return outputEncoding;
+ }
public LineComparator(InputStream is, String encoding) throws UnsupportedEncodingException {
TrailingLineFeedDetector trailingLineFeedDetector = new TrailingLineFeedDetector(is);
- BufferedReader br = new BufferedReader(new InputStreamReader(trailingLineFeedDetector, encoding));
+ BufferedReader br = new BufferedReader(new InputStreamReader(trailingLineFeedDetector, encoding));
String line;
ArrayList<String> ar = new ArrayList<>();
try {
while ((line = br.readLine()) != null)
ar.add(line);
} catch (IOException e) {
- // silently ignored
+ // silently ignored
}
try {
is.close();
@@ -117,7 +117,7 @@ public class LineComparator implements IRangeComparator {
// We do this because a BufferedReader doesn't distinguish the case
// where the last line has or doesn't have a trailing line separator
if (trailingLineFeedDetector.hadTrailingLineFeed()) {
- ar.add(""); //$NON-NLS-1$
+ ar.add(""); //$NON-NLS-1$
}
fLines = ar.toArray(new String[ar.size()]);
}
@@ -126,7 +126,7 @@ public class LineComparator implements IRangeComparator {
* @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount()
*/
@Override
- public int getRangeCount() {
+ public int getRangeCount() {
return fLines.length;
}
@@ -134,7 +134,7 @@ public class LineComparator implements IRangeComparator {
* @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int)
*/
@Override
- public boolean rangesEqual(int thisIndex, IRangeComparator other,
+ public boolean rangesEqual(int thisIndex, IRangeComparator other,
int otherIndex) {
String s1 = fLines[thisIndex];
String s2 = ((LineComparator) other).fLines[otherIndex];
@@ -145,7 +145,7 @@ public class LineComparator implements IRangeComparator {
* @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator)
*/
@Override
- public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
+ public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
return false;
}
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/Messages.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/Messages.java
index b1c18c83fd..37171d613a 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/Messages.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/Messages.java
@@ -19,27 +19,27 @@ import java.util.ResourceBundle;
*/
public final class Messages {
- private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.changelog.core.strings"; //$NON-NLS-1$
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.changelog.core.strings"; //$NON-NLS-1$
- private static final ResourceBundle RESOURCE_BUNDLE =
- ResourceBundle.getBundle(BUNDLE_NAME);
+ private static final ResourceBundle RESOURCE_BUNDLE =
+ ResourceBundle.getBundle(BUNDLE_NAME);
- /**
- *
- */
- private Messages() {
- // It shouldn't be instantiated.
- }
- /**
- * Returns the message for the given key.
- * @param key The key of the message looking for.
- * @return The found message or "!key!" if no such key.
- */
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
+ /**
+ *
+ */
+ private Messages() {
+ // It shouldn't be instantiated.
+ }
+ /**
+ * Returns the message for the given key.
+ * @param key The key of the message looking for.
+ * @return The found message or "!key!" if no such key.
+ */
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogAction.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogAction.java
index c4b4f114d1..146b36e00f 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogAction.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogAction.java
@@ -53,294 +53,294 @@ import org.eclipse.ui.part.MultiPageEditorPart;
public abstract class ChangeLogAction extends Action {
- protected ChangeLogExtensionManager extensionManager = null;
-
- // Preference variables
- protected String pref_AuthorName;
-
- protected String pref_AuthorEmail;
-
- protected String pref_ChangeLogName = "ChangeLog"; // $NON-NLS-1$
-
- protected String pref_Formatter;
-
- // set selection here
- // selection can be either IEditorPart / IProject / IStructuredSelection
- // IEditorPart and IProject will be adapted to IStructuredSelection.
-
- public ChangeLogAction() {
- extensionManager = ChangeLogExtensionManager.getExtensionManager();
- }
-
- protected void reportErr(String msg, Exception e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, msg, e));
- }
-
- private IWorkspaceRoot getWorkspaceRoot() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
- protected IEditorPart openEditor(IFile diskresource) {
- IWorkbench ws = PlatformUI.getWorkbench();
-
- try {
- return org.eclipse.ui.ide.IDE.openEditor(ws
- .getActiveWorkbenchWindow().getActivePage(), diskresource,
- true);
- } catch (PartInitException e) {
- e.printStackTrace();
-
- return null;
- }
- }
-
- protected IFile createChangeLog(IPath changelog) {
- IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
- IWorkbench ws = PlatformUI.getWorkbench();
-
- final IFile changelog_File = myWorkspaceRoot.getFile(changelog);
- final InputStream initialContents = new ByteArrayInputStream(
- new byte[0]);
-
- WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
- @Override
- public void execute(IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask(Messages.getString("ChangeLog.AddingChangeLog"), 2000); //$NON-NLS-1$
- changelog_File.create(initialContents, false, monitor);
-
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
-
- } finally {
- monitor.done();
- }
- }
- };
-
- try {
- new ProgressMonitorDialog(ws.getActiveWorkbenchWindow().getShell())
- .run(true, true, operation);
- } catch (InterruptedException e) {
- reportErr(Messages.getString("ChangeLog.ErrInterrupted"), e); // $NON-NLS-1$
- return null;
- } catch (InvocationTargetException e) {
- reportErr(Messages.getString("ChangeLog.ErrInvocation"), e); // $NON-NLS-1$
- return null;
- }
-
- // FIXME: we should put this refreshLocal call into a thread (filed as bug #256180)
- try {
- IContainer changelogContainer = myWorkspaceRoot.getContainerForLocation(changelog);
- if (changelogContainer != null)
- changelogContainer.refreshLocal(2, null);
- } catch (CoreException e) {
- reportErr(Messages.getString("ChangeLog.ErrRefresh"), e); // $NON-NLS-1$
- return null;
- }
-
- return changelog_File;
- }
-
- protected IEditorPart askChangeLogLocation(String editorLoc) {
- IWorkbench ws = PlatformUI.getWorkbench();
- IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
-
- IResource given_resource = myWorkspaceRoot.findMember(editorLoc);
-
- if (given_resource == null)
- return null;
-
- ChangeLogContainerSelectionDialog dialog = new ChangeLogContainerSelectionDialog(ws
- .getActiveWorkbenchWindow().getShell(), given_resource
- .getParent(), false, Messages
- .getString("AddAction.str_ChangeLog_Location")); //$NON-NLS-1$
- dialog.showClosedProjects(false);
-
- dialog.open();
-
- Object[] result = dialog.getResult();
- if (result == null)
- return null;
- final IPath result_path = new Path(result[0]
- + System.getProperty("file.separator") + pref_ChangeLogName); //$NON-NLS-1$ //$NON-NLS-2$
- IFile newChangeLog = createChangeLog(result_path);
-
- return openEditor(newChangeLog);
-
- }
-
- protected IEditorPart getChangelog(String currentEditorloc) {
- // Scenario 1: The Changelog is in in the current project file
- IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
- IResource given_resource = myWorkspaceRoot.findMember(currentEditorloc);
-
- if (given_resource != null) {
- IResource parent_dec = given_resource;
-
- while (parent_dec != null) {
- String parent_node = parent_dec.getFullPath()
- .removeLastSegments(1).toOSString();
- parent_node = parent_node
- + System.getProperty("file.separator") + pref_ChangeLogName; //$NON-NLS-1$
-
- IResource change_log_res = myWorkspaceRoot
- .findMember(parent_node);
-
- if (change_log_res != null) {
- IProject proj_loc = given_resource.getProject();
- IPath modified_changelog_path = change_log_res
- .getFullPath().removeFirstSegments(1);
- IFile change_log_file = proj_loc
- .getFile(modified_changelog_path);
-
- return openEditor(change_log_file);
- }
-
- parent_dec = parent_dec.getParent();
-
- if (parent_dec == null) {
- break;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Find the ChangeLog for a file that is being removed. It can't be found and
- * it is possible that the directory it is in has also been removed.
- *
- * @param path Path of removed file
- * @return ChangeLog editor part that must be used to report removed file
- */
- protected IEditorPart getChangelogForRemovePath(IPath path) {
- IResource parent_resource = null;
- IPath loc_path = path;
- // Look from current loc up to find first folder that is still existing
- IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
- while (loc_path.segmentCount() > 0) {
- parent_resource = myWorkspaceRoot.findMember(loc_path);
- if (parent_resource != null)
- break;
- loc_path = loc_path.removeLastSegments(1);
- }
-
- if (parent_resource != null) {
- IResource parent_dec = parent_resource;
-
- while (parent_dec != null) {
- String parent_node = parent_dec.getFullPath().toOSString();
- parent_node = parent_node
- + System.getProperty("file.separator") + pref_ChangeLogName; //$NON-NLS-1$
-
- IResource change_log_res = myWorkspaceRoot
- .findMember(parent_node);
-
- if (change_log_res != null) {
- IProject proj_loc = parent_resource.getProject();
- IPath modified_changelog_path = change_log_res
- .getFullPath().removeFirstSegments(1);
- IFile change_log_file = proj_loc
- .getFile(modified_changelog_path);
-
- return openEditor(change_log_file);
- }
-
- parent_dec = parent_dec.getParent();
-
- if (parent_dec == null) {
- break;
- }
- }
- }
-
- return null;
- }
-
- private IFile getDocumentIFile(IEditorPart currentEditor) {
- IEditorInput cc = currentEditor.getEditorInput();
-
- if (cc instanceof IFileEditorInput) {
- return ((IFileEditorInput) cc).getFile();
- }
- return null;
- }
-
- protected String getDocumentLocation(IEditorPart currentEditor,
- boolean appendRoot) {
-
-
- IFile loc = getDocumentIFile(currentEditor);
- IEditorInput cc = null;
- String WorkspaceRoot;
-
- IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
- WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
-
- if (currentEditor instanceof MultiPageEditorPart) {
- Object ed = ((MultiPageEditorPart) currentEditor).getSelectedPage();
- if (ed instanceof IEditorPart)
- cc = ((IEditorPart) ed).getEditorInput();
- if (cc instanceof FileEditorInput)
- return (appendRoot) ? WorkspaceRoot + ((FileEditorInput) cc).getFile().getFullPath().toOSString() :
- ((FileEditorInput) cc).getFile().getFullPath().toOSString();
- }
-
- cc = currentEditor.getEditorInput();
-
-
- if (cc == null)
- return "";
-
- if ((cc instanceof SyncInfoCompareInput)
- || (cc instanceof CompareEditorInput)) {
-
- CompareEditorInput test = (CompareEditorInput) cc;
- if (test.getCompareResult() == null) {
- return "";
- } else if (test.getCompareResult() instanceof ICompareInput) {
- ITypedElement leftCompare = ((ICompareInput) test.getCompareResult())
- .getLeft();
- if (leftCompare instanceof IResourceProvider){
- String localPath = ((IResourceProvider)leftCompare).getResource().getFullPath().toString();
- if (appendRoot) {
- return WorkspaceRoot + localPath;
- }
- return localPath;
- }
- } else {
- if (appendRoot)
- return WorkspaceRoot + test.getCompareResult().toString();
- return test.getCompareResult().toString();
- }
- } else if (cc instanceof FileStoreEditorInput) {
- return ((FileStoreEditorInput)cc).getName();
- }
-
-
-
- if (appendRoot) {
- return WorkspaceRoot + loc.getFullPath().toOSString();
- } else if (loc != null) {
- return loc.getFullPath().toOSString();
- } else {
- return "";
- }
- }
-
- protected void loadPreferences() {
- IPreferenceStore store = ChangelogPlugin.getDefault()
- .getPreferenceStore();
-
- pref_AuthorName = store.getString("IChangeLogConstants.AUTHOR_NAME"); //$NON-NLS-1$
- pref_AuthorEmail = store.getString("IChangeLogConstants.AUTHOR_EMAIL"); //$NON-NLS-1$
-
- pref_Formatter = store
- .getString("IChangeLogConstants.DEFAULT_FORMATTER"); // $NON-NLS-1$
- }
+ protected ChangeLogExtensionManager extensionManager = null;
+
+ // Preference variables
+ protected String pref_AuthorName;
+
+ protected String pref_AuthorEmail;
+
+ protected String pref_ChangeLogName = "ChangeLog"; // $NON-NLS-1$
+
+ protected String pref_Formatter;
+
+ // set selection here
+ // selection can be either IEditorPart / IProject / IStructuredSelection
+ // IEditorPart and IProject will be adapted to IStructuredSelection.
+
+ public ChangeLogAction() {
+ extensionManager = ChangeLogExtensionManager.getExtensionManager();
+ }
+
+ protected void reportErr(String msg, Exception e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, msg, e));
+ }
+
+ private IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ protected IEditorPart openEditor(IFile diskresource) {
+ IWorkbench ws = PlatformUI.getWorkbench();
+
+ try {
+ return org.eclipse.ui.ide.IDE.openEditor(ws
+ .getActiveWorkbenchWindow().getActivePage(), diskresource,
+ true);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+
+ return null;
+ }
+ }
+
+ protected IFile createChangeLog(IPath changelog) {
+ IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
+ IWorkbench ws = PlatformUI.getWorkbench();
+
+ final IFile changelog_File = myWorkspaceRoot.getFile(changelog);
+ final InputStream initialContents = new ByteArrayInputStream(
+ new byte[0]);
+
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ @Override
+ public void execute(IProgressMonitor monitor) throws CoreException {
+ try {
+ monitor.beginTask(Messages.getString("ChangeLog.AddingChangeLog"), 2000); //$NON-NLS-1$
+ changelog_File.create(initialContents, false, monitor);
+
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+
+ try {
+ new ProgressMonitorDialog(ws.getActiveWorkbenchWindow().getShell())
+ .run(true, true, operation);
+ } catch (InterruptedException e) {
+ reportErr(Messages.getString("ChangeLog.ErrInterrupted"), e); // $NON-NLS-1$
+ return null;
+ } catch (InvocationTargetException e) {
+ reportErr(Messages.getString("ChangeLog.ErrInvocation"), e); // $NON-NLS-1$
+ return null;
+ }
+
+ // FIXME: we should put this refreshLocal call into a thread (filed as bug #256180)
+ try {
+ IContainer changelogContainer = myWorkspaceRoot.getContainerForLocation(changelog);
+ if (changelogContainer != null)
+ changelogContainer.refreshLocal(2, null);
+ } catch (CoreException e) {
+ reportErr(Messages.getString("ChangeLog.ErrRefresh"), e); // $NON-NLS-1$
+ return null;
+ }
+
+ return changelog_File;
+ }
+
+ protected IEditorPart askChangeLogLocation(String editorLoc) {
+ IWorkbench ws = PlatformUI.getWorkbench();
+ IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
+
+ IResource given_resource = myWorkspaceRoot.findMember(editorLoc);
+
+ if (given_resource == null)
+ return null;
+
+ ChangeLogContainerSelectionDialog dialog = new ChangeLogContainerSelectionDialog(ws
+ .getActiveWorkbenchWindow().getShell(), given_resource
+ .getParent(), false, Messages
+ .getString("AddAction.str_ChangeLog_Location")); //$NON-NLS-1$
+ dialog.showClosedProjects(false);
+
+ dialog.open();
+
+ Object[] result = dialog.getResult();
+ if (result == null)
+ return null;
+ final IPath result_path = new Path(result[0]
+ + System.getProperty("file.separator") + pref_ChangeLogName); //$NON-NLS-1$ //$NON-NLS-2$
+ IFile newChangeLog = createChangeLog(result_path);
+
+ return openEditor(newChangeLog);
+
+ }
+
+ protected IEditorPart getChangelog(String currentEditorloc) {
+ // Scenario 1: The Changelog is in in the current project file
+ IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
+ IResource given_resource = myWorkspaceRoot.findMember(currentEditorloc);
+
+ if (given_resource != null) {
+ IResource parent_dec = given_resource;
+
+ while (parent_dec != null) {
+ String parent_node = parent_dec.getFullPath()
+ .removeLastSegments(1).toOSString();
+ parent_node = parent_node
+ + System.getProperty("file.separator") + pref_ChangeLogName; //$NON-NLS-1$
+
+ IResource change_log_res = myWorkspaceRoot
+ .findMember(parent_node);
+
+ if (change_log_res != null) {
+ IProject proj_loc = given_resource.getProject();
+ IPath modified_changelog_path = change_log_res
+ .getFullPath().removeFirstSegments(1);
+ IFile change_log_file = proj_loc
+ .getFile(modified_changelog_path);
+
+ return openEditor(change_log_file);
+ }
+
+ parent_dec = parent_dec.getParent();
+
+ if (parent_dec == null) {
+ break;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Find the ChangeLog for a file that is being removed. It can't be found and
+ * it is possible that the directory it is in has also been removed.
+ *
+ * @param path Path of removed file
+ * @return ChangeLog editor part that must be used to report removed file
+ */
+ protected IEditorPart getChangelogForRemovePath(IPath path) {
+ IResource parent_resource = null;
+ IPath loc_path = path;
+ // Look from current loc up to find first folder that is still existing
+ IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
+ while (loc_path.segmentCount() > 0) {
+ parent_resource = myWorkspaceRoot.findMember(loc_path);
+ if (parent_resource != null)
+ break;
+ loc_path = loc_path.removeLastSegments(1);
+ }
+
+ if (parent_resource != null) {
+ IResource parent_dec = parent_resource;
+
+ while (parent_dec != null) {
+ String parent_node = parent_dec.getFullPath().toOSString();
+ parent_node = parent_node
+ + System.getProperty("file.separator") + pref_ChangeLogName; //$NON-NLS-1$
+
+ IResource change_log_res = myWorkspaceRoot
+ .findMember(parent_node);
+
+ if (change_log_res != null) {
+ IProject proj_loc = parent_resource.getProject();
+ IPath modified_changelog_path = change_log_res
+ .getFullPath().removeFirstSegments(1);
+ IFile change_log_file = proj_loc
+ .getFile(modified_changelog_path);
+
+ return openEditor(change_log_file);
+ }
+
+ parent_dec = parent_dec.getParent();
+
+ if (parent_dec == null) {
+ break;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private IFile getDocumentIFile(IEditorPart currentEditor) {
+ IEditorInput cc = currentEditor.getEditorInput();
+
+ if (cc instanceof IFileEditorInput) {
+ return ((IFileEditorInput) cc).getFile();
+ }
+ return null;
+ }
+
+ protected String getDocumentLocation(IEditorPart currentEditor,
+ boolean appendRoot) {
+
+
+ IFile loc = getDocumentIFile(currentEditor);
+ IEditorInput cc = null;
+ String WorkspaceRoot;
+
+ IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
+ WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
+
+ if (currentEditor instanceof MultiPageEditorPart) {
+ Object ed = ((MultiPageEditorPart) currentEditor).getSelectedPage();
+ if (ed instanceof IEditorPart)
+ cc = ((IEditorPart) ed).getEditorInput();
+ if (cc instanceof FileEditorInput)
+ return (appendRoot) ? WorkspaceRoot + ((FileEditorInput) cc).getFile().getFullPath().toOSString() :
+ ((FileEditorInput) cc).getFile().getFullPath().toOSString();
+ }
+
+ cc = currentEditor.getEditorInput();
+
+
+ if (cc == null)
+ return "";
+
+ if ((cc instanceof SyncInfoCompareInput)
+ || (cc instanceof CompareEditorInput)) {
+
+ CompareEditorInput test = (CompareEditorInput) cc;
+ if (test.getCompareResult() == null) {
+ return "";
+ } else if (test.getCompareResult() instanceof ICompareInput) {
+ ITypedElement leftCompare = ((ICompareInput) test.getCompareResult())
+ .getLeft();
+ if (leftCompare instanceof IResourceProvider){
+ String localPath = ((IResourceProvider)leftCompare).getResource().getFullPath().toString();
+ if (appendRoot) {
+ return WorkspaceRoot + localPath;
+ }
+ return localPath;
+ }
+ } else {
+ if (appendRoot)
+ return WorkspaceRoot + test.getCompareResult().toString();
+ return test.getCompareResult().toString();
+ }
+ } else if (cc instanceof FileStoreEditorInput) {
+ return ((FileStoreEditorInput)cc).getName();
+ }
+
+
+
+ if (appendRoot) {
+ return WorkspaceRoot + loc.getFullPath().toOSString();
+ } else if (loc != null) {
+ return loc.getFullPath().toOSString();
+ } else {
+ return "";
+ }
+ }
+
+ protected void loadPreferences() {
+ IPreferenceStore store = ChangelogPlugin.getDefault()
+ .getPreferenceStore();
+
+ pref_AuthorName = store.getString("IChangeLogConstants.AUTHOR_NAME"); //$NON-NLS-1$
+ pref_AuthorEmail = store.getString("IChangeLogConstants.AUTHOR_EMAIL"); //$NON-NLS-1$
+
+ pref_Formatter = store
+ .getString("IChangeLogConstants.DEFAULT_FORMATTER"); // $NON-NLS-1$
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java
index eea4328865..c5f58846e5 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java
@@ -39,21 +39,21 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider {
* to be disposed. Deallocate all allocated SWT resources.
*/
@Override
- public void dispose() {
+ public void dispose() {
}
/*
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
@Override
- public Object[] getChildren(Object element) {
+ public Object[] getChildren(Object element) {
if (element instanceof IWorkspace) {
// check if closed projects should be shown
IProject[] allProjects = ((IWorkspace) element).getRoot()
.getProjects();
if (showClosedProjects) {
- return allProjects;
- }
+ return allProjects;
+ }
ArrayList<IProject> accessibleProjects = new ArrayList<>();
for (int i = 0; i < allProjects.length; i++) {
@@ -79,15 +79,15 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider {
}
}
} else if (element instanceof ChangeLogRootContainer) {
- ChangeLogRootContainer container = (ChangeLogRootContainer) element;
- List<IResource> children = new ArrayList<>();
- IResource[] members = container.members();
- for (int i = 0; i < members.length; i++) {
- if (members[i].getType() != IResource.FILE) {
- children.add(members[i]);
- }
- }
- return children.toArray();
+ ChangeLogRootContainer container = (ChangeLogRootContainer) element;
+ List<IResource> children = new ArrayList<>();
+ IResource[] members = container.members();
+ for (int i = 0; i < members.length; i++) {
+ if (members[i].getType() != IResource.FILE) {
+ children.add(members[i]);
+ }
+ }
+ return children.toArray();
}
return new Object[0];
}
@@ -96,7 +96,7 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider {
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
@Override
- public Object[] getElements(Object element) {
+ public Object[] getElements(Object element) {
return getChildren(element);
}
@@ -104,10 +104,10 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider {
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
*/
@Override
- public Object getParent(Object element) {
+ public Object getParent(Object element) {
if (element instanceof IResource) {
- return ((IResource) element).getParent();
- }
+ return ((IResource) element).getParent();
+ }
return null;
}
@@ -115,7 +115,7 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider {
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
@Override
- public boolean hasChildren(Object element) {
+ public boolean hasChildren(Object element) {
return getChildren(element).length > 0;
}
@@ -123,7 +123,7 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider {
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged
*/
@Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
/**
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java
index 623e4a35df..22adc8abd1 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java
@@ -40,20 +40,20 @@ import org.eclipse.ui.dialogs.SelectionDialog;
* <pre>
* ContainerSelectionDialog dialog =
* new ContainerSelectionDialog(getShell(), initialSelection, allowNewContainerName(), msg);
- * dialog.open();
- * Object[] result = dialog.getResult();
+ * dialog.open();
+ * Object[] result = dialog.getResult();
* </pre>
* </p>
* @noextend This class is not intended to be subclassed by clients.
*/
public class ChangeLogContainerSelectionDialog extends SelectionDialog {
- private static final String ContainerSelectionDialog_title = Messages.getString("ChangeLogContainerSelectionDialog.Title"); //$NON-NLS-1$
- private static final String ContainerSelectionDialog_message = Messages.getString("ChangeLogContainerSelectionDialog.Message"); //$NON-NLS-1$
- private static final String CONTAINER_SELECTION_DIALOG = "org.eclipse.ui.ide.container_selection_dialog_context"; //$NON-NLS-1$
+ private static final String ContainerSelectionDialog_title = Messages.getString("ChangeLogContainerSelectionDialog.Title"); //$NON-NLS-1$
+ private static final String ContainerSelectionDialog_message = Messages.getString("ChangeLogContainerSelectionDialog.Message"); //$NON-NLS-1$
+ private static final String CONTAINER_SELECTION_DIALOG = "org.eclipse.ui.ide.container_selection_dialog_context"; //$NON-NLS-1$
- // the widget group;
+ // the widget group;
ChangeLogContainerSelectionGroup group;
// the root resource to populate the viewer with
@@ -87,10 +87,10 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog {
this.initialSelection = initialRoot;
this.allowNewContainerName = allowNewContainerName;
if (message != null) {
- setMessage(message);
- } else {
- setMessage(ContainerSelectionDialog_message);
- }
+ setMessage(message);
+ } else {
+ setMessage(ContainerSelectionDialog_message);
+ }
setShellStyle(getShellStyle() | SWT.SHEET);
}
@@ -98,7 +98,7 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog {
* Method declared in Window.
*/
@Override
- protected void configureShell(Shell shell) {
+ protected void configureShell(Shell shell) {
super.configureShell(shell);
PlatformUI.getWorkbench().getHelpSystem()
.setHelp(shell, CONTAINER_SELECTION_DIALOG);
@@ -108,7 +108,7 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog {
* Method declared on Dialog.
*/
@Override
- protected Control createDialogArea(Composite parent) {
+ protected Control createDialogArea(Composite parent) {
// create composite
Composite area = (Composite) super.createDialogArea(parent);
@@ -133,13 +133,13 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog {
* for later retrieval by the client and closes this dialog.
*/
@Override
- protected void okPressed() {
+ protected void okPressed() {
List<IPath> chosenContainerPathList = new ArrayList<>();
IPath returnValue = group.getContainerFullPath();
if (returnValue != null) {
- chosenContainerPathList.add(returnValue);
- }
+ chosenContainerPathList.add(returnValue);
+ }
setResult(chosenContainerPathList);
super.okPressed();
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java
index 7eff5a9fce..ad914b66ca 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java
@@ -8,8 +8,8 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Igor Fedorenko <igorfie@yahoo.com> -
- * Fix for Bug 136921 [IDE] New File dialog locks for 20 seconds
- * Red Hat Inc. - modified this file to work with ChangeLog Plugin
+ * Fix for Bug 136921 [IDE] New File dialog locks for 20 seconds
+ * Red Hat Inc. - modified this file to work with ChangeLog Plugin
*******************************************************************************/
package org.eclipse.linuxtools.internal.changelog.core.actions;
@@ -46,262 +46,262 @@ import org.eclipse.ui.part.DrillDownComposite;
* Workbench-level composite for choosing a container.
*/
public class ChangeLogContainerSelectionGroup extends Composite {
- // The listener to notify of events
- private Listener listener;
+ // The listener to notify of events
+ private Listener listener;
- // Enable user to type in new container name
- private boolean allowNewContainerName = true;
+ // Enable user to type in new container name
+ private boolean allowNewContainerName = true;
- // show all projects by default
- private boolean showClosedProjects = true;
+ // show all projects by default
+ private boolean showClosedProjects = true;
- // Last selection made by user
- private IContainer selectedContainer;
+ // Last selection made by user
+ private IContainer selectedContainer;
- // handle on parts
- private Text containerNameField;
+ // handle on parts
+ private Text containerNameField;
- TreeViewer treeViewer;
+ TreeViewer treeViewer;
- private IContainer initialSelection;
+ private IContainer initialSelection;
- // the message to display at the top of this dialog
- private static final String DEFAULT_MSG_NEW_ALLOWED = Messages.getString("ChangeLogContainerSelectionGroup.DefaultMessageNewAllowed"); //$NON-NLS-1$
+ // the message to display at the top of this dialog
+ private static final String DEFAULT_MSG_NEW_ALLOWED = Messages.getString("ChangeLogContainerSelectionGroup.DefaultMessageNewAllowed"); //$NON-NLS-1$
- private static final String DEFAULT_MSG_SELECT_ONLY = Messages.getString("ChangeLogContainerSelectionGroup.DefaultMessageSelectOnly"); //$NON-NLS-1$
+ private static final String DEFAULT_MSG_SELECT_ONLY = Messages.getString("ChangeLogContainerSelectionGroup.DefaultMessageSelectOnly"); //$NON-NLS-1$
- // sizing constants
- private static final int SIZING_SELECTION_PANE_WIDTH = 320;
+ // sizing constants
+ private static final int SIZING_SELECTION_PANE_WIDTH = 320;
- private static final int SIZING_SELECTION_PANE_HEIGHT = 300;
+ private static final int SIZING_SELECTION_PANE_HEIGHT = 300;
- /**
- * Creates a new instance of the widget.
- *
- * @param parent
- * The parent widget of the group.
- * @param allowNewContainerName
- * Enable the user to type in a new container name instead of
- * just selecting from the existing ones.
- * @param message
- * The text to present to the user.
- * @param showClosedProjects
- * Whether or not to show closed projects.
- */
- public ChangeLogContainerSelectionGroup(Composite parent, boolean allowNewContainerName, String message,
- boolean showClosedProjects, IContainer initialSelection) {
- this(parent, allowNewContainerName, message,
- showClosedProjects, SIZING_SELECTION_PANE_HEIGHT,
- SIZING_SELECTION_PANE_WIDTH, initialSelection);
- }
+ /**
+ * Creates a new instance of the widget.
+ *
+ * @param parent
+ * The parent widget of the group.
+ * @param allowNewContainerName
+ * Enable the user to type in a new container name instead of
+ * just selecting from the existing ones.
+ * @param message
+ * The text to present to the user.
+ * @param showClosedProjects
+ * Whether or not to show closed projects.
+ */
+ public ChangeLogContainerSelectionGroup(Composite parent, boolean allowNewContainerName, String message,
+ boolean showClosedProjects, IContainer initialSelection) {
+ this(parent, allowNewContainerName, message,
+ showClosedProjects, SIZING_SELECTION_PANE_HEIGHT,
+ SIZING_SELECTION_PANE_WIDTH, initialSelection);
+ }
- /**
- * Creates a new instance of the widget.
- *
- * @param parent
- * The parent widget of the group.
- * @param allowNewContainerName
- * Enable the user to type in a new container name instead of
- * just selecting from the existing ones.
- * @param message
- * The text to present to the user.
- * @param showClosedProjects
- * Whether or not to show closed projects.
- * @param heightHint
- * height hint for the drill down composite
- * @param widthHint
- * width hint for the drill down composite
- */
- public ChangeLogContainerSelectionGroup(Composite parent,
- boolean allowNewContainerName, String message,
- boolean showClosedProjects, int heightHint, int widthHint, IContainer initialSelection) {
- super(parent, SWT.NONE);
- this.allowNewContainerName = allowNewContainerName;
- this.showClosedProjects = showClosedProjects;
- this.initialSelection = initialSelection;
- if (message != null) {
- createContents(message, heightHint, widthHint);
- } else if (allowNewContainerName) {
- createContents(DEFAULT_MSG_NEW_ALLOWED, heightHint, widthHint);
- } else {
- createContents(DEFAULT_MSG_SELECT_ONLY, heightHint, widthHint);
- }
- }
+ /**
+ * Creates a new instance of the widget.
+ *
+ * @param parent
+ * The parent widget of the group.
+ * @param allowNewContainerName
+ * Enable the user to type in a new container name instead of
+ * just selecting from the existing ones.
+ * @param message
+ * The text to present to the user.
+ * @param showClosedProjects
+ * Whether or not to show closed projects.
+ * @param heightHint
+ * height hint for the drill down composite
+ * @param widthHint
+ * width hint for the drill down composite
+ */
+ public ChangeLogContainerSelectionGroup(Composite parent,
+ boolean allowNewContainerName, String message,
+ boolean showClosedProjects, int heightHint, int widthHint, IContainer initialSelection) {
+ super(parent, SWT.NONE);
+ this.allowNewContainerName = allowNewContainerName;
+ this.showClosedProjects = showClosedProjects;
+ this.initialSelection = initialSelection;
+ if (message != null) {
+ createContents(message, heightHint, widthHint);
+ } else if (allowNewContainerName) {
+ createContents(DEFAULT_MSG_NEW_ALLOWED, heightHint, widthHint);
+ } else {
+ createContents(DEFAULT_MSG_SELECT_ONLY, heightHint, widthHint);
+ }
+ }
- /**
- * The container selection has changed in the tree view. Update the
- * container name field value and notify all listeners.
- *
- * @param container
- * The container that changed
- */
- public void containerSelectionChanged(IContainer container) {
- selectedContainer = container;
+ /**
+ * The container selection has changed in the tree view. Update the
+ * container name field value and notify all listeners.
+ *
+ * @param container
+ * The container that changed
+ */
+ public void containerSelectionChanged(IContainer container) {
+ selectedContainer = container;
- if (allowNewContainerName) {
- if (container == null) {
- containerNameField.setText("");//$NON-NLS-1$
- } else {
- String text = TextProcessor.process(container.getFullPath()
- .makeRelative().toString());
- containerNameField.setText(text);
- containerNameField.setToolTipText(text);
- }
- }
+ if (allowNewContainerName) {
+ if (container == null) {
+ containerNameField.setText("");//$NON-NLS-1$
+ } else {
+ String text = TextProcessor.process(container.getFullPath()
+ .makeRelative().toString());
+ containerNameField.setText(text);
+ containerNameField.setToolTipText(text);
+ }
+ }
- // fire an event so the parent can update its controls
- if (listener != null) {
- Event changeEvent = new Event();
- changeEvent.type = SWT.Selection;
- changeEvent.widget = this;
- listener.handleEvent(changeEvent);
- }
- }
+ // fire an event so the parent can update its controls
+ if (listener != null) {
+ Event changeEvent = new Event();
+ changeEvent.type = SWT.Selection;
+ changeEvent.widget = this;
+ listener.handleEvent(changeEvent);
+ }
+ }
- /**
- * Creates the contents of the composite.
- *
- * @param message message
- */
- public void createContents(String message) {
- createContents(message, SIZING_SELECTION_PANE_HEIGHT,
- SIZING_SELECTION_PANE_WIDTH);
- }
+ /**
+ * Creates the contents of the composite.
+ *
+ * @param message message
+ */
+ public void createContents(String message) {
+ createContents(message, SIZING_SELECTION_PANE_HEIGHT,
+ SIZING_SELECTION_PANE_WIDTH);
+ }
- /**
- * Creates the contents of the composite.
- *
- * @param message message
- * @param heightHint height hint for the drill down composite
- * @param widthHint specifies the perfered width in pixels
- */
- private void createContents(String message, int heightHint, int widthHint) {
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- setLayout(layout);
- setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ /**
+ * Creates the contents of the composite.
+ *
+ * @param message message
+ * @param heightHint height hint for the drill down composite
+ * @param widthHint specifies the perfered width in pixels
+ */
+ private void createContents(String message, int heightHint, int widthHint) {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ setLayout(layout);
+ setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Label label = new Label(this, SWT.WRAP);
- label.setText(message);
- label.setFont(this.getFont());
+ Label label = new Label(this, SWT.WRAP);
+ label.setText(message);
+ label.setFont(this.getFont());
- if (allowNewContainerName) {
- containerNameField = new Text(this, SWT.SINGLE | SWT.BORDER);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = widthHint;
- containerNameField.setLayoutData(gd);
- containerNameField.addListener(SWT.Modify, listener);
- containerNameField.setFont(this.getFont());
- } else {
- // filler...
- new Label(this, SWT.NONE);
- }
+ if (allowNewContainerName) {
+ containerNameField = new Text(this, SWT.SINGLE | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = widthHint;
+ containerNameField.setLayoutData(gd);
+ containerNameField.addListener(SWT.Modify, listener);
+ containerNameField.setFont(this.getFont());
+ } else {
+ // filler...
+ new Label(this, SWT.NONE);
+ }
- createTreeViewer(heightHint);
- Dialog.applyDialogFont(this);
- }
+ createTreeViewer(heightHint);
+ Dialog.applyDialogFont(this);
+ }
- /**
- * Returns a new drill down viewer for this dialog.
- *
- * @param heightHint
- * height hint for the drill down composite
- */
- private void createTreeViewer(int heightHint) {
- // Create drill down.
- DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER);
- GridData spec = new GridData(SWT.FILL, SWT.FILL, true, true);
- spec.widthHint = SIZING_SELECTION_PANE_WIDTH;
- spec.heightHint = heightHint;
- drillDown.setLayoutData(spec);
+ /**
+ * Returns a new drill down viewer for this dialog.
+ *
+ * @param heightHint
+ * height hint for the drill down composite
+ */
+ private void createTreeViewer(int heightHint) {
+ // Create drill down.
+ DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER);
+ GridData spec = new GridData(SWT.FILL, SWT.FILL, true, true);
+ spec.widthHint = SIZING_SELECTION_PANE_WIDTH;
+ spec.heightHint = heightHint;
+ drillDown.setLayoutData(spec);
- // Create tree viewer inside drill down.
- treeViewer = new TreeViewer(drillDown, SWT.NONE);
- drillDown.setChildTree(treeViewer);
- ChangeLogContainerContentProvider cp = new ChangeLogContainerContentProvider();
- cp.showClosedProjects(showClosedProjects);
- treeViewer.setContentProvider(cp);
- treeViewer.setLabelProvider(WorkbenchLabelProvider
- .getDecoratingWorkbenchLabelProvider());
- treeViewer.setComparator(new ViewerComparator());
- treeViewer.setUseHashlookup(true);
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event
- .getSelection();
- containerSelectionChanged((IContainer) selection
- .getFirstElement()); // allow null
- }
- });
- treeViewer.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection) {
- Object item = ((IStructuredSelection) selection)
- .getFirstElement();
- if (item == null) {
- return;
- }
- if (treeViewer.getExpandedState(item)) {
- treeViewer.collapseToLevel(item, 1);
- } else {
- treeViewer.expandToLevel(item, 1);
- }
- }
- }
- });
+ // Create tree viewer inside drill down.
+ treeViewer = new TreeViewer(drillDown, SWT.NONE);
+ drillDown.setChildTree(treeViewer);
+ ChangeLogContainerContentProvider cp = new ChangeLogContainerContentProvider();
+ cp.showClosedProjects(showClosedProjects);
+ treeViewer.setContentProvider(cp);
+ treeViewer.setLabelProvider(WorkbenchLabelProvider
+ .getDecoratingWorkbenchLabelProvider());
+ treeViewer.setComparator(new ViewerComparator());
+ treeViewer.setUseHashlookup(true);
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event
+ .getSelection();
+ containerSelectionChanged((IContainer) selection
+ .getFirstElement()); // allow null
+ }
+ });
+ treeViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object item = ((IStructuredSelection) selection)
+ .getFirstElement();
+ if (item == null) {
+ return;
+ }
+ if (treeViewer.getExpandedState(item)) {
+ treeViewer.collapseToLevel(item, 1);
+ } else {
+ treeViewer.expandToLevel(item, 1);
+ }
+ }
+ }
+ });
- /*
- * This helps in displaying all folders under the document
- * root as well as the actual root itself.
- */
- ChangeLogRootContainer root = new ChangeLogRootContainer(this.initialSelection.getProject());
- // This has to be done after the viewer has been laid out
- treeViewer.setInput(root);
- }
+ /*
+ * This helps in displaying all folders under the document
+ * root as well as the actual root itself.
+ */
+ ChangeLogRootContainer root = new ChangeLogRootContainer(this.initialSelection.getProject());
+ // This has to be done after the viewer has been laid out
+ treeViewer.setInput(root);
+ }
- /**
- * Returns the currently entered container name. Null if the field is empty.
- * Note that the container may not exist yet if the user entered a new
- * container name in the field.
- *
- * @return IPath
- */
- public IPath getContainerFullPath() {
- if (allowNewContainerName) {
- String pathName = containerNameField.getText();
- if (pathName == null || pathName.isEmpty()) {
- return null;
- }
- // The user may not have made this absolute so do it for them
- return (new Path(TextProcessor.deprocess(pathName))).makeAbsolute();
+ /**
+ * Returns the currently entered container name. Null if the field is empty.
+ * Note that the container may not exist yet if the user entered a new
+ * container name in the field.
+ *
+ * @return IPath
+ */
+ public IPath getContainerFullPath() {
+ if (allowNewContainerName) {
+ String pathName = containerNameField.getText();
+ if (pathName == null || pathName.isEmpty()) {
+ return null;
+ }
+ // The user may not have made this absolute so do it for them
+ return (new Path(TextProcessor.deprocess(pathName))).makeAbsolute();
- }
- if (selectedContainer == null) {
- return null;
- }
- return selectedContainer.getFullPath();
+ }
+ if (selectedContainer == null) {
+ return null;
+ }
+ return selectedContainer.getFullPath();
- }
+ }
- /**
- * Sets the selected existing container.
- *
- * @param container container to set
- */
- public void setSelectedContainer(IContainer container) {
- selectedContainer = container;
+ /**
+ * Sets the selected existing container.
+ *
+ * @param container container to set
+ */
+ public void setSelectedContainer(IContainer container) {
+ selectedContainer = container;
- // expand to and select the specified container
- List<IContainer> itemsToExpand = new ArrayList<>();
- IContainer parent = container.getParent();
- while (parent != null) {
- itemsToExpand.add(0, parent);
- parent = parent.getParent();
- }
- treeViewer.setExpandedElements(itemsToExpand.toArray());
- treeViewer.setSelection(new StructuredSelection(container), true);
- }
+ // expand to and select the specified container
+ List<IContainer> itemsToExpand = new ArrayList<>();
+ IContainer parent = container.getParent();
+ while (parent != null) {
+ itemsToExpand.add(0, parent);
+ parent = parent.getParent();
+ }
+ treeViewer.setExpandedElements(itemsToExpand.toArray());
+ treeViewer.setSelection(new StructuredSelection(container), true);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogRootContainer.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogRootContainer.java
index 4c2a064468..a3a0facb85 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogRootContainer.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogRootContainer.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Red Hat - initial API and implementation
*******************************************************************************/
@@ -15,13 +15,13 @@ import org.eclipse.core.resources.IResource;
public class ChangeLogRootContainer {
- private IProject proj;
-
- public ChangeLogRootContainer(IProject project) {
- proj = project;
- }
+ private IProject proj;
- public IResource[] members() {
- return new IResource[]{proj};
- }
+ public ChangeLogRootContainer(IProject project) {
+ proj = project;
+ }
+
+ public IResource[] members() {
+ return new IResource[]{proj};
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java
index 89e90b71b5..60de2ddf38 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java
@@ -21,19 +21,19 @@ import org.eclipse.ui.handlers.HandlerUtil;
public class FormatChangeLogAction extends AbstractHandler {
- @Override
- public Object execute(ExecutionEvent event) {
- ChangeLogEditor editor = (ChangeLogEditor) HandlerUtil.getActiveEditor(event);
- if (editor == null)
- return null;
+ @Override
+ public Object execute(ExecutionEvent event) {
+ ChangeLogEditor editor = (ChangeLogEditor) HandlerUtil.getActiveEditor(event);
+ if (editor == null)
+ return null;
- SourceViewer srcViewer = (SourceViewer)editor.getMySourceViewer();
- if (srcViewer != null) {
- srcViewer.doOperation(ISourceViewer.FORMAT);
+ SourceViewer srcViewer = (SourceViewer)editor.getMySourceViewer();
+ if (srcViewer != null) {
+ srcViewer.doOperation(ISourceViewer.FORMAT);
- }
+ }
- return null;
- }
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java
index e01fd26fbc..0ade53ef82 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java
@@ -32,179 +32,179 @@ import org.eclipse.ui.handlers.HandlerUtil;
* @author pmuldoon (Phil Muldoon)
*/
public class InsertChangeLogKeyHandler extends ChangeLogAction implements
- IHandler, IWorkbenchWindowActionDelegate {
-
- private IEditorPart currentEditor;
-
- private String getEditorName() {
- if (currentEditor != null)
- return returnQualifedEditor(currentEditor.getClass());
- else
- return "";
-
- }
-
- private String getEntryFilePath() {
- if (currentEditor != null)
- return getDocumentLocation(currentEditor, false);
- else
- return "";
- }
-
- private String returnQualifedEditor(Class<?> ClassName) {
- return ClassName.toString().substring(
- ClassName.getPackage().toString().length() - 1,
- ClassName.toString().length());
- }
+ IHandler, IWorkbenchWindowActionDelegate {
+
+ private IEditorPart currentEditor;
+
+ private String getEditorName() {
+ if (currentEditor != null)
+ return returnQualifedEditor(currentEditor.getClass());
+ else
+ return "";
+
+ }
+
+ private String getEntryFilePath() {
+ if (currentEditor != null)
+ return getDocumentLocation(currentEditor, false);
+ else
+ return "";
+ }
+
+ private String returnQualifedEditor(Class<?> ClassName) {
+ return ClassName.toString().substring(
+ ClassName.getPackage().toString().length() - 1,
+ ClassName.toString().length());
+ }
- private IEditorPart getChangelog() {
-
- IConfigurationElement formatterConfigElement = extensionManager
- .getFormatterConfigElement();
- if (formatterConfigElement.getAttribute("inFile").equalsIgnoreCase(
- "true")) {
- return currentEditor;
- // this formatter wants to use an external changelog file
- } else {
- IEditorPart changelog = null;
+ private IEditorPart getChangelog() {
+
+ IConfigurationElement formatterConfigElement = extensionManager
+ .getFormatterConfigElement();
+ if (formatterConfigElement.getAttribute("inFile").equalsIgnoreCase(
+ "true")) {
+ return currentEditor;
+ // this formatter wants to use an external changelog file
+ } else {
+ IEditorPart changelog = null;
- IConfigurationElement nameElement = formatterConfigElement
- .getChildren()[0];
- if (nameElement.getAttribute("name") == null) {
- reportErr("Got non-name child with inFile set to False", null);
- return null;
- } else {
- pref_ChangeLogName = nameElement.getAttribute("name");
- changelog = getChangelog(getDocumentLocation(currentEditor,
- false));
-
- if (changelog == null) {
- changelog = askChangeLogLocation(getDocumentLocation(
- currentEditor, false));
- }
-
- return changelog;
- }
- }
-
- }
+ IConfigurationElement nameElement = formatterConfigElement
+ .getChildren()[0];
+ if (nameElement.getAttribute("name") == null) {
+ reportErr("Got non-name child with inFile set to False", null);
+ return null;
+ } else {
+ pref_ChangeLogName = nameElement.getAttribute("name");
+ changelog = getChangelog(getDocumentLocation(currentEditor,
+ false));
+
+ if (changelog == null) {
+ changelog = askChangeLogLocation(getDocumentLocation(
+ currentEditor, false));
+ }
+
+ return changelog;
+ }
+ }
+
+ }
- private String parseFunctionName(IParserChangeLogContrib parser) {
+ private String parseFunctionName(IParserChangeLogContrib parser) {
- try {
- return parser.parseCurrentFunction(currentEditor);
- } catch (CoreException e) {
- reportErr("Couldn't parse function name with "
- + parser.getClass().toString(), null);
- return "";
- }
+ try {
+ return parser.parseCurrentFunction(currentEditor);
+ } catch (CoreException e) {
+ reportErr("Couldn't parse function name with "
+ + parser.getClass().toString(), null);
+ return "";
+ }
- }
+ }
- @Override
- public Object execute(ExecutionEvent event) {
+ @Override
+ public Object execute(ExecutionEvent event) {
- currentEditor = HandlerUtil.getActiveEditor(event);
+ currentEditor = HandlerUtil.getActiveEditor(event);
- // make sure an editor is selected.
- if (currentEditor == null) {
- return null;
- }
+ // make sure an editor is selected.
+ if (currentEditor == null) {
+ return null;
+ }
- ChangeLogWriter clw = new ChangeLogWriter();
+ ChangeLogWriter clw = new ChangeLogWriter();
- // load settings from extensions + user pref.
- loadPreferences();
+ // load settings from extensions + user pref.
+ loadPreferences();
- // get file path from target file
- clw.setEntryFilePath(getEntryFilePath());
+ // get file path from target file
+ clw.setEntryFilePath(getEntryFilePath());
- // err check. do nothing if no file is being open/edited
- if (clw.getEntryFilePath() == "") {
- return null;
- }
+ // err check. do nothing if no file is being open/edited
+ if (clw.getEntryFilePath() == "") {
+ return null;
+ }
- String editorName = getEditorName();
+ String editorName = getEditorName();
- // get a parser for this file
- IParserChangeLogContrib parser = extensionManager
- .getParserContributor(editorName);
+ // get a parser for this file
+ IParserChangeLogContrib parser = extensionManager
+ .getParserContributor(editorName);
- // if no parser for this type of document, then don't guess function
- // name
- // and set it as "".
- if (parser == null) {
- clw.setGuessedFName("");
- } else {
- // guess function name
- clw.setGuessedFName(parseFunctionName(parser));
- }
+ // if no parser for this type of document, then don't guess function
+ // name
+ // and set it as "".
+ if (parser == null) {
+ clw.setGuessedFName("");
+ } else {
+ // guess function name
+ clw.setGuessedFName(parseFunctionName(parser));
+ }
- // get formatter
- clw.setFormatter(extensionManager.getFormatterContributor(clw
- .getEntryFilePath(), pref_Formatter));
+ // get formatter
+ clw.setFormatter(extensionManager.getFormatterContributor(clw
+ .getEntryFilePath(), pref_Formatter));
- // select changelog
- clw.setChangelog(getChangelog());
- if (clw.getChangelog() == null)
- return null;
+ // select changelog
+ clw.setChangelog(getChangelog());
+ if (clw.getChangelog() == null)
+ return null;
- // write to changelog
- clw.setDateLine(clw.getFormatter().formatDateLine(pref_AuthorName,
- pref_AuthorEmail));
+ // write to changelog
+ clw.setDateLine(clw.getFormatter().formatDateLine(pref_AuthorName,
+ pref_AuthorEmail));
- clw.setChangelogLocation(getDocumentLocation(clw.getChangelog(), true));
+ clw.setChangelogLocation(getDocumentLocation(clw.getChangelog(), true));
- clw.writeChangeLog();
+ clw.writeChangeLog();
- return null;
- }
+ return null;
+ }
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
+ @Override
+ public void addHandlerListener(IHandlerListener handlerListener) {
- }
+ }
- @Override
- public boolean isEnabled() {
- IEditorReference[] refs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
- for (int i = 0; i < refs.length; ++i) {
- IEditorReference ref = refs[i];
- String id = ref.getId();
- System.out.println(id);
- }
- return true;
- }
+ @Override
+ public boolean isEnabled() {
+ IEditorReference[] refs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
+ for (int i = 0; i < refs.length; ++i) {
+ IEditorReference ref = refs[i];
+ String id = ref.getId();
+ System.out.println(id);
+ }
+ return true;
+ }
- @Override
- public boolean isHandled() {
- return true;
- }
+ @Override
+ public boolean isHandled() {
+ return true;
+ }
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
+ @Override
+ public void removeHandlerListener(IHandlerListener handlerListener) {
- }
+ }
- @Override
- public void dispose() {
+ @Override
+ public void dispose() {
- }
+ }
- @Override
- public void init(IWorkbenchWindow window) {
+ @Override
+ public void init(IWorkbenchWindow window) {
- }
+ }
- @Override
- public void run(IAction action) {
+ @Override
+ public void run(IAction action) {
- execute(null);
- }
+ execute(null);
+ }
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
- }
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java
index 3743a2553b..eb6cb83514 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java
@@ -27,127 +27,127 @@ import org.eclipse.core.runtime.IPath;
*/
public class PatchFile {
- private static class EmptyStorage implements IStorage {
+ private static class EmptyStorage implements IStorage {
- public EmptyStorage() {
- }
+ public EmptyStorage() {
+ }
- @Override
- public InputStream getContents() {
- return new ByteArrayInputStream(new byte[0]);
- }
+ @Override
+ public InputStream getContents() {
+ return new ByteArrayInputStream(new byte[0]);
+ }
- @Override
- public IPath getFullPath() {
- return null;
- }
+ @Override
+ public IPath getFullPath() {
+ return null;
+ }
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- @Override
- public String getName() {
- return "__emptyStorage__";
- }
-
- @Override
- public boolean isReadOnly() {
- return true;
- }
- }
-
- private IStorage storage = new EmptyStorage();
- private ArrayList<PatchRangeElement> pranges = new ArrayList<>();
-
- private boolean newfile = false;
- private boolean removedfile = false;
- private IResource resource; // required only if dealing with change
-
-
- public boolean isNewfile() {
- return newfile;
- }
-
- public void setNewfile(boolean newfile) {
- this.newfile = newfile;
- }
-
- public boolean isRemovedFile() {
- return removedfile;
- }
-
- public void setRemovedFile(boolean removedfile) {
- this.removedfile = removedfile;
- }
-
- public PatchFile(IResource resource) {
- this.resource = resource;
- }
-
- public void addLineRange(int from, int to, boolean localChange) {
-
- pranges.add(new PatchRangeElement(from, to, localChange));
- }
-
- public PatchRangeElement[] getRanges() {
- Object[] tmpEle = pranges.toArray();
- PatchRangeElement[] ret = new PatchRangeElement[tmpEle.length];
-
- for (int i = 0; i < tmpEle.length; i++) {
- ret[i] = (PatchRangeElement) tmpEle[i];
- }
- return ret;
- }
-
-
- public IPath getPath() {
- return resource.getFullPath();
- }
-
- public IStorage getStorage() {
- return storage;
- }
-
- public void setStorage(IStorage storage) {
- this.storage = storage;
- }
-
- public IResource getResource() {
- return resource;
- }
-
- @Override
- public boolean equals(Object o) {
-
- if (!(o instanceof PatchFile))
- return false;
-
- PatchFile that = (PatchFile) o;
- // check fpath + count
- if (!this.resource.equals(that.resource) ||
- this.pranges.size() != that.pranges.size() ) {
- return false;
- }
-
- // check range elements
- PatchRangeElement[] thatsrange = that.getRanges();
-
- for(int i=0; i<this.pranges.size();i++) {
- if (!thatsrange[i].equals(pranges.get(i))) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- int hash = resource.hashCode();
- for(int i=0; i<this.pranges.size();i++) {
- hash += pranges.get(i).hashCode();
- }
- return hash;
- }
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return "__emptyStorage__";
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+ }
+
+ private IStorage storage = new EmptyStorage();
+ private ArrayList<PatchRangeElement> pranges = new ArrayList<>();
+
+ private boolean newfile = false;
+ private boolean removedfile = false;
+ private IResource resource; // required only if dealing with change
+
+
+ public boolean isNewfile() {
+ return newfile;
+ }
+
+ public void setNewfile(boolean newfile) {
+ this.newfile = newfile;
+ }
+
+ public boolean isRemovedFile() {
+ return removedfile;
+ }
+
+ public void setRemovedFile(boolean removedfile) {
+ this.removedfile = removedfile;
+ }
+
+ public PatchFile(IResource resource) {
+ this.resource = resource;
+ }
+
+ public void addLineRange(int from, int to, boolean localChange) {
+
+ pranges.add(new PatchRangeElement(from, to, localChange));
+ }
+
+ public PatchRangeElement[] getRanges() {
+ Object[] tmpEle = pranges.toArray();
+ PatchRangeElement[] ret = new PatchRangeElement[tmpEle.length];
+
+ for (int i = 0; i < tmpEle.length; i++) {
+ ret[i] = (PatchRangeElement) tmpEle[i];
+ }
+ return ret;
+ }
+
+
+ public IPath getPath() {
+ return resource.getFullPath();
+ }
+
+ public IStorage getStorage() {
+ return storage;
+ }
+
+ public void setStorage(IStorage storage) {
+ this.storage = storage;
+ }
+
+ public IResource getResource() {
+ return resource;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+
+ if (!(o instanceof PatchFile))
+ return false;
+
+ PatchFile that = (PatchFile) o;
+ // check fpath + count
+ if (!this.resource.equals(that.resource) ||
+ this.pranges.size() != that.pranges.size() ) {
+ return false;
+ }
+
+ // check range elements
+ PatchRangeElement[] thatsrange = that.getRanges();
+
+ for(int i=0; i<this.pranges.size();i++) {
+ if (!thatsrange[i].equals(pranges.get(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = resource.hashCode();
+ for(int i=0; i<this.pranges.size();i++) {
+ hash += pranges.get(i).hashCode();
+ }
+ return hash;
+ }
} \ No newline at end of file
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java
index 4d7cee7af2..e6100d48b2 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java
@@ -14,9 +14,9 @@ import java.util.Comparator;
public class PatchFileComparator implements Comparator<PatchFile> {
- @Override
- public int compare(PatchFile p1, PatchFile p2) {
- return p1.getResource().getLocation().toOSString().compareToIgnoreCase(p2.getResource().getLocation().toOSString());
- }
+ @Override
+ public int compare(PatchFile p1, PatchFile p2) {
+ return p1.getResource().getLocation().toOSString().compareToIgnoreCase(p2.getResource().getLocation().toOSString());
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchRangeElement.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchRangeElement.java
index 2c91eee410..73a2432ec5 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchRangeElement.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchRangeElement.java
@@ -18,32 +18,32 @@ package org.eclipse.linuxtools.internal.changelog.core.actions;
*/
public class PatchRangeElement {
- public int fromLine;
- public int toLine;
- private boolean localChange;
+ public int fromLine;
+ public int toLine;
+ private boolean localChange;
- public PatchRangeElement(int from, int to, boolean localChange) {
- this.fromLine =from;
- this.toLine= to;
- this.localChange = localChange;
- }
+ public PatchRangeElement(int from, int to, boolean localChange) {
+ this.fromLine =from;
+ this.toLine= to;
+ this.localChange = localChange;
+ }
- public boolean isLocalChange() {
- return localChange;
- }
+ public boolean isLocalChange() {
+ return localChange;
+ }
- @Override
- public boolean equals(Object o) {
- if (o instanceof PatchRangeElement) {
- PatchRangeElement b = (PatchRangeElement)o;
- return b.fromLine == fromLine && b.toLine == toLine && b.localChange == localChange;
- }
- else
- return this == o;
- }
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof PatchRangeElement) {
+ PatchRangeElement b = (PatchRangeElement)o;
+ return b.fromLine == fromLine && b.toLine == toLine && b.localChange == localChange;
+ }
+ else
+ return this == o;
+ }
- @Override
- public int hashCode() {
- return fromLine + toLine + (localChange ? 47 : 83);
- }
+ @Override
+ public int hashCode() {
+ return fromLine + toLine + (localChange ? 47 : 83);
+ }
} \ No newline at end of file
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java
index dbf91b80da..b3ee36ba1e 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java
@@ -76,522 +76,522 @@ import org.eclipse.ui.part.FileEditorInput;
*/
public class PrepareChangeLogAction extends ChangeLogAction {
- protected boolean changeLogModified = false;
- protected boolean newEntryWritten = false;
- protected boolean createChangeLog = true;
-
- private static class MyDocumentProvider extends FileDocumentProvider {
-
- @Override
- public IDocument createDocument(Object element) throws CoreException {
- return super.createDocument(element);
- }
- }
-
- private static class MyStorageDocumentProvider extends StorageDocumentProvider {
-
- @Override
- public IDocument createDocument(Object element) throws CoreException {
- return super.createDocument(element);
- }
- }
-
- private IStructuredSelection selected;
-
- public PrepareChangeLogAction() {
- super();
- }
-
- protected void setSelection(IStructuredSelection selection) {
- this.selected = selection;
- }
-
- private String parseCurrentFunctionAtOffset(String editorName,
- IEditorInput input, int offset) {
-
- IParserChangeLogContrib parser = extensionManager
- .getParserContributor(editorName);
-
- // return empty string if function parser for editorName is not present
- if (parser==null)
- return "";
-
- try {
- return parser.parseCurrentFunction(input, offset);
- } catch (CoreException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
- .getMessage(), e));
- }
- return "";
- }
-
- /**
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- protected void doRun() {
- IRunnableWithProgress code = new IRunnableWithProgress() {
-
- @Override
- public void run(IProgressMonitor monitor) {
- monitor.beginTask(Messages.getString("ChangeLog.PrepareChangeLog"), 1000); // $NON-NLS-1$
- prepareChangeLog(monitor);
- monitor.done();
- }
- };
-
- ProgressMonitorDialog pd = new ProgressMonitorDialog(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell());
-
- try {
- pd.run(false /* fork */, false /* cancelable */, code);
- } catch (InvocationTargetException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
- .getMessage(), e));
- return;
- } catch (InterruptedException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
- .getMessage(), e));
- }
- }
-
- private void extractSynchronizeModelInfo (ISynchronizeModelElement d, IPath path, Vector<PatchFile> newList, Vector<PatchFile> removeList, Vector<PatchFile> changeList) {
- // Recursively traverse the tree for children and sort leaf elements into their respective change kind sets.
- // Don't add entries for ChangeLog files though.
- if (d.hasChildren()) {
- IPath newPath = path.append(d.getName());
- for (IDiffElement element: d.getChildren()) {
- if (element instanceof ISynchronizeModelElement)
- extractSynchronizeModelInfo((ISynchronizeModelElement)element, newPath, newList, removeList, changeList);
- else {
- if (!(d.getName().equals("ChangeLog"))) { //$NON-NLS-1$
- PatchFile p = new PatchFile(d.getResource());
- int kind = d.getKind() & Differencer.CHANGE_TYPE_MASK;
- if (kind == Differencer.CHANGE) {
- changeList.add(p);
- } else if (kind == Differencer.ADDITION) {
- p.setNewfile(true);
- newList.add(p);
- } else if (kind == Differencer.DELETION) {
- p.setRemovedFile(true);
- removeList.add(p);
- }
- } else {
- this.changeLogModified = true;
- }
- }
- }
- } else {
- if (!(d.getName().equals("ChangeLog"))) { //$NON-NLS-1$
- PatchFile p = new PatchFile(d.getResource());
- int kind = d.getKind() & Differencer.CHANGE_TYPE_MASK;
- if (kind == Differencer.CHANGE) {
- changeList.add(p);
- } else if (kind == Differencer.ADDITION) {
- p.setNewfile(true);
- newList.add(p);
- } else if (kind == Differencer.DELETION) {
- p.setRemovedFile(true);
- removeList.add(p);
- }
- } else {
- this.changeLogModified = true;
- }
- }
- }
-
- private void getChangedLines(Subscriber s, PatchFile p, IProgressMonitor monitor) {
- try {
- // For an outgoing changed resource, find out which lines
- // differ from the local file and its previous local version
- // (i.e. we don't want to force a diff with the repository).
- IDiff d = s.getDiff(p.getResource());
- if (d instanceof IThreeWayDiff
- && ((IThreeWayDiff)d).getDirection() == IThreeWayDiff.OUTGOING) {
- IThreeWayDiff diff = (IThreeWayDiff)d;
- monitor.beginTask(null, 100);
- IResourceDiff localDiff = (IResourceDiff)diff.getLocalChange();
- IResource resource = localDiff.getResource();
- if (resource instanceof IFile) {
- IFile file = (IFile)resource;
- monitor.subTask(Messages.getString("ChangeLog.MergingDiffs")); // $NON-NLS-1$
- String osEncoding = file.getCharset();
- IFileRevision ancestorState = localDiff.getBeforeState();
- IStorage ancestorStorage;
- if (ancestorState != null) {
- ancestorStorage = ancestorState.getStorage(monitor);
- p.setStorage(ancestorStorage);
- }
- else {
- return;
- }
-
- try {
- // We compare using a standard differencer to get ranges
- // of changes. We modify them to be document-based (i.e.
- // first line is line 1) and store them for later parsing.
- LineComparator left = new LineComparator(ancestorStorage.getContents(), osEncoding);
- LineComparator right = new LineComparator(file.getContents(), osEncoding);
- for (RangeDifference tmp: RangeDifferencer.findDifferences(left, right)) {
- if (tmp.kind() == RangeDifference.CHANGE) {
- // Right side of diff are all changes found in local file.
- int rightLength = tmp.rightLength() > 0 ? tmp.rightLength() : tmp.rightLength() + 1;
- // We also want to store left side of the diff which are changes to the ancestor as it may contain
- // functions/methods that have been removed.
- int leftLength = tmp.leftLength() > 0 ? tmp.leftLength() : tmp.leftLength() + 1;
- // Only store left side changes if the storage exists and we add one to the start line number
- if (p.getStorage() != null)
- p.addLineRange(tmp.leftStart(), tmp.leftStart() + leftLength, false);
- p.addLineRange(tmp.rightStart(), tmp.rightStart() + rightLength, true);
- }
- }
- } catch (UnsupportedEncodingException e) {
- // do nothing for now
- }
- }
- monitor.done();
- }
- } catch (CoreException e) {
- // Do nothing if error occurs
- }
- }
-
- private void prepareChangeLog(IProgressMonitor monitor) {
-
- Object element = selected.getFirstElement();
-
- IResource resource = null;
- Vector<PatchFile> newList = new Vector<>();
- Vector<PatchFile> removeList = new Vector<>();
- Vector<PatchFile> changeList = new Vector<>();
- int totalChanges = 0;
-
- if (element instanceof IResource) {
- resource = (IResource)element;
- } else if (element instanceof ISynchronizeModelElement) {
- ISynchronizeModelElement sme = (ISynchronizeModelElement)element;
- resource = sme.getResource();
- } else if (element instanceof IAdaptable) {
- resource = (IResource)((IAdaptable)element).getAdapter(IResource.class);
- }
-
- if (resource == null)
- return;
-
- IProject project = resource.getProject();
- // Get the repository provider so we can support multiple types of
- // code repositories without knowing exactly which (e.g. CVS, SVN, etc..).
- RepositoryProvider r = RepositoryProvider.getProvider(project);
- if (r == null)
- return;
- SyncInfoSet set = new SyncInfoSet();
- Subscriber s = r.getSubscriber();
- if (s == null)
- return;
- if (element instanceof ISynchronizeModelElement) {
- // We can extract the ChangeLog list from the synchronize view which
- // allows us to skip items removed from the view
- ISynchronizeModelElement d = (ISynchronizeModelElement)element;
- while (d.getParent() != null)
- d = (ISynchronizeModelElement)d.getParent();
- extractSynchronizeModelInfo(d, new Path(""), newList, removeList, changeList);
- totalChanges = newList.size() + removeList.size() + changeList.size();
- }
- else {
- // We can then get a list of all out-of-sync resources.
- s.collectOutOfSync(new IResource[] {project}, IResource.DEPTH_INFINITE, set, monitor);
- SyncInfo[] infos = set.getSyncInfos();
- totalChanges = infos.length;
- // Iterate through the list of changed resources and categorize them into
- // New, Removed, and Changed lists.
- for (SyncInfo info : infos) {
- int kind = SyncInfo.getChange(info.getKind());
- PatchFile p = new PatchFile(info.getLocal());
-
- // Check the type of entry and sort into lists. Do not add an entry
- // for ChangeLog files.
- if (!(p.getPath().lastSegment().equals("ChangeLog"))) { // $NON-NLS-1$
- switch (kind) {
- case SyncInfo.ADDITION:
- p.setNewfile(true);
- newList.add(p);
- break;
- case SyncInfo.DELETION:
- p.setRemovedFile(true);
- removeList.add(p);
- break;
- case SyncInfo.CHANGE:
- if (info.getLocal().getType() == IResource.FILE) {
- changeList.add(p);
- }
- break;
- }
- } else {
- this.changeLogModified = true;
- }
- }
- }
-
- if (totalChanges == 0)
- return; // nothing to parse
-
- PatchFile[] patchFileInfoList = new PatchFile[totalChanges];
-
- // Group like changes together and sort them by path name.
- // We want removed files, then new files, then changed files.
- // To get this, we put them in the array in reverse order.
- int index = 0;
- if (changeList.size() > 0) {
- // Get the repository provider so we can support multiple types of
- // code repositories without knowing exactly which (e.g. CVS, SVN, etc..).
- Collections.sort(changeList, new PatchFileComparator());
- int size = changeList.size();
- for (int i = 0; i < size; ++i) {
- PatchFile p = changeList.get(i);
- getChangedLines(s, p, monitor);
- patchFileInfoList[index+(size-i-1)] = p;
- }
- index += size;
- }
-
- if (newList.size() > 0) {
- Collections.sort(newList, new PatchFileComparator());
- int size = newList.size();
- for (int i = 0; i < size; ++i)
- patchFileInfoList[index+(size-i-1)] = newList.get(i);
- index += size;
- }
-
- if (removeList.size() > 0) {
- Collections.sort(removeList, new PatchFileComparator());
- int size = removeList.size();
- for (int i = 0; i < size; ++i)
- patchFileInfoList[index+(size-i-1)] = removeList.get(i);
- }
-
- // now, find out modified functions/classes.
- // try to use the the extension point. so it can be extended easily
- // for all files in patch file info list, get function guesses of each
- // file.
- monitor.subTask(Messages.getString("ChangeLog.WritingMessage")); // $NON-NLS-1$
- int unitwork = 250 / patchFileInfoList.length;
- for (PatchFile pf: patchFileInfoList) {
- // for each file
- if (pf != null) { // any ChangeLog changes will have null entries for them
- String[] funcGuessList = guessFunctionNames(pf);
- outputMultipleEntryChangeLog(pf, funcGuessList);
- }
- monitor.worked(unitwork);
- }
- }
-
- private void outputMultipleEntryChangeLog(PatchFile pf, String[] functionGuess) {
-
- String defaultContent = null;
-
- if (pf.isNewfile())
- defaultContent = Messages.getString("ChangeLog.NewFile"); // $NON-NLS-1$
- else if (pf.isRemovedFile())
- defaultContent = Messages.getString("ChangeLog.RemovedFile"); // $NON-NLS-1$
-
- IPath entryPath = pf.getPath();
- String entryFileName = entryPath.toOSString();
-
- ChangeLogWriter clw = new ChangeLogWriter();
-
- // load settings from extensions + user pref.
- loadPreferences();
-
- // get file path from target file
- clw.setEntryFilePath(entryPath.toOSString());
-
- if (defaultContent != null)
- clw.setDefaultContent(defaultContent);
-
- // err check. do nothing if no file is being open/edited
- if (clw.getEntryFilePath() == "") {
- return;
- }
-
- // Check if formatter is internal or inline..if inline, use the
- // current active editor part, otherwise, we must find the external
- // ChangeLog file.
- IEditorPart changelog = null;
-
- // Before accessing the getFormatterConfigElement, the getFormatContibutor
- // method must be called to initialize.
- extensionManager.getFormatterContributor(clw.getEntryFilePath(),
- pref_Formatter);
- IConfigurationElement formatterConfigElement = extensionManager
+ protected boolean changeLogModified = false;
+ protected boolean newEntryWritten = false;
+ protected boolean createChangeLog = true;
+
+ private static class MyDocumentProvider extends FileDocumentProvider {
+
+ @Override
+ public IDocument createDocument(Object element) throws CoreException {
+ return super.createDocument(element);
+ }
+ }
+
+ private static class MyStorageDocumentProvider extends StorageDocumentProvider {
+
+ @Override
+ public IDocument createDocument(Object element) throws CoreException {
+ return super.createDocument(element);
+ }
+ }
+
+ private IStructuredSelection selected;
+
+ public PrepareChangeLogAction() {
+ super();
+ }
+
+ protected void setSelection(IStructuredSelection selection) {
+ this.selected = selection;
+ }
+
+ private String parseCurrentFunctionAtOffset(String editorName,
+ IEditorInput input, int offset) {
+
+ IParserChangeLogContrib parser = extensionManager
+ .getParserContributor(editorName);
+
+ // return empty string if function parser for editorName is not present
+ if (parser==null)
+ return "";
+
+ try {
+ return parser.parseCurrentFunction(input, offset);
+ } catch (CoreException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
+ .getMessage(), e));
+ }
+ return "";
+ }
+
+ /**
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ protected void doRun() {
+ IRunnableWithProgress code = new IRunnableWithProgress() {
+
+ @Override
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(Messages.getString("ChangeLog.PrepareChangeLog"), 1000); // $NON-NLS-1$
+ prepareChangeLog(monitor);
+ monitor.done();
+ }
+ };
+
+ ProgressMonitorDialog pd = new ProgressMonitorDialog(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell());
+
+ try {
+ pd.run(false /* fork */, false /* cancelable */, code);
+ } catch (InvocationTargetException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
+ .getMessage(), e));
+ return;
+ } catch (InterruptedException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
+ .getMessage(), e));
+ }
+ }
+
+ private void extractSynchronizeModelInfo (ISynchronizeModelElement d, IPath path, Vector<PatchFile> newList, Vector<PatchFile> removeList, Vector<PatchFile> changeList) {
+ // Recursively traverse the tree for children and sort leaf elements into their respective change kind sets.
+ // Don't add entries for ChangeLog files though.
+ if (d.hasChildren()) {
+ IPath newPath = path.append(d.getName());
+ for (IDiffElement element: d.getChildren()) {
+ if (element instanceof ISynchronizeModelElement)
+ extractSynchronizeModelInfo((ISynchronizeModelElement)element, newPath, newList, removeList, changeList);
+ else {
+ if (!(d.getName().equals("ChangeLog"))) { //$NON-NLS-1$
+ PatchFile p = new PatchFile(d.getResource());
+ int kind = d.getKind() & Differencer.CHANGE_TYPE_MASK;
+ if (kind == Differencer.CHANGE) {
+ changeList.add(p);
+ } else if (kind == Differencer.ADDITION) {
+ p.setNewfile(true);
+ newList.add(p);
+ } else if (kind == Differencer.DELETION) {
+ p.setRemovedFile(true);
+ removeList.add(p);
+ }
+ } else {
+ this.changeLogModified = true;
+ }
+ }
+ }
+ } else {
+ if (!(d.getName().equals("ChangeLog"))) { //$NON-NLS-1$
+ PatchFile p = new PatchFile(d.getResource());
+ int kind = d.getKind() & Differencer.CHANGE_TYPE_MASK;
+ if (kind == Differencer.CHANGE) {
+ changeList.add(p);
+ } else if (kind == Differencer.ADDITION) {
+ p.setNewfile(true);
+ newList.add(p);
+ } else if (kind == Differencer.DELETION) {
+ p.setRemovedFile(true);
+ removeList.add(p);
+ }
+ } else {
+ this.changeLogModified = true;
+ }
+ }
+ }
+
+ private void getChangedLines(Subscriber s, PatchFile p, IProgressMonitor monitor) {
+ try {
+ // For an outgoing changed resource, find out which lines
+ // differ from the local file and its previous local version
+ // (i.e. we don't want to force a diff with the repository).
+ IDiff d = s.getDiff(p.getResource());
+ if (d instanceof IThreeWayDiff
+ && ((IThreeWayDiff)d).getDirection() == IThreeWayDiff.OUTGOING) {
+ IThreeWayDiff diff = (IThreeWayDiff)d;
+ monitor.beginTask(null, 100);
+ IResourceDiff localDiff = (IResourceDiff)diff.getLocalChange();
+ IResource resource = localDiff.getResource();
+ if (resource instanceof IFile) {
+ IFile file = (IFile)resource;
+ monitor.subTask(Messages.getString("ChangeLog.MergingDiffs")); // $NON-NLS-1$
+ String osEncoding = file.getCharset();
+ IFileRevision ancestorState = localDiff.getBeforeState();
+ IStorage ancestorStorage;
+ if (ancestorState != null) {
+ ancestorStorage = ancestorState.getStorage(monitor);
+ p.setStorage(ancestorStorage);
+ }
+ else {
+ return;
+ }
+
+ try {
+ // We compare using a standard differencer to get ranges
+ // of changes. We modify them to be document-based (i.e.
+ // first line is line 1) and store them for later parsing.
+ LineComparator left = new LineComparator(ancestorStorage.getContents(), osEncoding);
+ LineComparator right = new LineComparator(file.getContents(), osEncoding);
+ for (RangeDifference tmp: RangeDifferencer.findDifferences(left, right)) {
+ if (tmp.kind() == RangeDifference.CHANGE) {
+ // Right side of diff are all changes found in local file.
+ int rightLength = tmp.rightLength() > 0 ? tmp.rightLength() : tmp.rightLength() + 1;
+ // We also want to store left side of the diff which are changes to the ancestor as it may contain
+ // functions/methods that have been removed.
+ int leftLength = tmp.leftLength() > 0 ? tmp.leftLength() : tmp.leftLength() + 1;
+ // Only store left side changes if the storage exists and we add one to the start line number
+ if (p.getStorage() != null)
+ p.addLineRange(tmp.leftStart(), tmp.leftStart() + leftLength, false);
+ p.addLineRange(tmp.rightStart(), tmp.rightStart() + rightLength, true);
+ }
+ }
+ } catch (UnsupportedEncodingException e) {
+ // do nothing for now
+ }
+ }
+ monitor.done();
+ }
+ } catch (CoreException e) {
+ // Do nothing if error occurs
+ }
+ }
+
+ private void prepareChangeLog(IProgressMonitor monitor) {
+
+ Object element = selected.getFirstElement();
+
+ IResource resource = null;
+ Vector<PatchFile> newList = new Vector<>();
+ Vector<PatchFile> removeList = new Vector<>();
+ Vector<PatchFile> changeList = new Vector<>();
+ int totalChanges = 0;
+
+ if (element instanceof IResource) {
+ resource = (IResource)element;
+ } else if (element instanceof ISynchronizeModelElement) {
+ ISynchronizeModelElement sme = (ISynchronizeModelElement)element;
+ resource = sme.getResource();
+ } else if (element instanceof IAdaptable) {
+ resource = (IResource)((IAdaptable)element).getAdapter(IResource.class);
+ }
+
+ if (resource == null)
+ return;
+
+ IProject project = resource.getProject();
+ // Get the repository provider so we can support multiple types of
+ // code repositories without knowing exactly which (e.g. CVS, SVN, etc..).
+ RepositoryProvider r = RepositoryProvider.getProvider(project);
+ if (r == null)
+ return;
+ SyncInfoSet set = new SyncInfoSet();
+ Subscriber s = r.getSubscriber();
+ if (s == null)
+ return;
+ if (element instanceof ISynchronizeModelElement) {
+ // We can extract the ChangeLog list from the synchronize view which
+ // allows us to skip items removed from the view
+ ISynchronizeModelElement d = (ISynchronizeModelElement)element;
+ while (d.getParent() != null)
+ d = (ISynchronizeModelElement)d.getParent();
+ extractSynchronizeModelInfo(d, new Path(""), newList, removeList, changeList);
+ totalChanges = newList.size() + removeList.size() + changeList.size();
+ }
+ else {
+ // We can then get a list of all out-of-sync resources.
+ s.collectOutOfSync(new IResource[] {project}, IResource.DEPTH_INFINITE, set, monitor);
+ SyncInfo[] infos = set.getSyncInfos();
+ totalChanges = infos.length;
+ // Iterate through the list of changed resources and categorize them into
+ // New, Removed, and Changed lists.
+ for (SyncInfo info : infos) {
+ int kind = SyncInfo.getChange(info.getKind());
+ PatchFile p = new PatchFile(info.getLocal());
+
+ // Check the type of entry and sort into lists. Do not add an entry
+ // for ChangeLog files.
+ if (!(p.getPath().lastSegment().equals("ChangeLog"))) { // $NON-NLS-1$
+ switch (kind) {
+ case SyncInfo.ADDITION:
+ p.setNewfile(true);
+ newList.add(p);
+ break;
+ case SyncInfo.DELETION:
+ p.setRemovedFile(true);
+ removeList.add(p);
+ break;
+ case SyncInfo.CHANGE:
+ if (info.getLocal().getType() == IResource.FILE) {
+ changeList.add(p);
+ }
+ break;
+ }
+ } else {
+ this.changeLogModified = true;
+ }
+ }
+ }
+
+ if (totalChanges == 0)
+ return; // nothing to parse
+
+ PatchFile[] patchFileInfoList = new PatchFile[totalChanges];
+
+ // Group like changes together and sort them by path name.
+ // We want removed files, then new files, then changed files.
+ // To get this, we put them in the array in reverse order.
+ int index = 0;
+ if (changeList.size() > 0) {
+ // Get the repository provider so we can support multiple types of
+ // code repositories without knowing exactly which (e.g. CVS, SVN, etc..).
+ Collections.sort(changeList, new PatchFileComparator());
+ int size = changeList.size();
+ for (int i = 0; i < size; ++i) {
+ PatchFile p = changeList.get(i);
+ getChangedLines(s, p, monitor);
+ patchFileInfoList[index+(size-i-1)] = p;
+ }
+ index += size;
+ }
+
+ if (newList.size() > 0) {
+ Collections.sort(newList, new PatchFileComparator());
+ int size = newList.size();
+ for (int i = 0; i < size; ++i)
+ patchFileInfoList[index+(size-i-1)] = newList.get(i);
+ index += size;
+ }
+
+ if (removeList.size() > 0) {
+ Collections.sort(removeList, new PatchFileComparator());
+ int size = removeList.size();
+ for (int i = 0; i < size; ++i)
+ patchFileInfoList[index+(size-i-1)] = removeList.get(i);
+ }
+
+ // now, find out modified functions/classes.
+ // try to use the the extension point. so it can be extended easily
+ // for all files in patch file info list, get function guesses of each
+ // file.
+ monitor.subTask(Messages.getString("ChangeLog.WritingMessage")); // $NON-NLS-1$
+ int unitwork = 250 / patchFileInfoList.length;
+ for (PatchFile pf: patchFileInfoList) {
+ // for each file
+ if (pf != null) { // any ChangeLog changes will have null entries for them
+ String[] funcGuessList = guessFunctionNames(pf);
+ outputMultipleEntryChangeLog(pf, funcGuessList);
+ }
+ monitor.worked(unitwork);
+ }
+ }
+
+ private void outputMultipleEntryChangeLog(PatchFile pf, String[] functionGuess) {
+
+ String defaultContent = null;
+
+ if (pf.isNewfile())
+ defaultContent = Messages.getString("ChangeLog.NewFile"); // $NON-NLS-1$
+ else if (pf.isRemovedFile())
+ defaultContent = Messages.getString("ChangeLog.RemovedFile"); // $NON-NLS-1$
+
+ IPath entryPath = pf.getPath();
+ String entryFileName = entryPath.toOSString();
+
+ ChangeLogWriter clw = new ChangeLogWriter();
+
+ // load settings from extensions + user pref.
+ loadPreferences();
+
+ // get file path from target file
+ clw.setEntryFilePath(entryPath.toOSString());
+
+ if (defaultContent != null)
+ clw.setDefaultContent(defaultContent);
+
+ // err check. do nothing if no file is being open/edited
+ if (clw.getEntryFilePath() == "") {
+ return;
+ }
+
+ // Check if formatter is internal or inline..if inline, use the
+ // current active editor part, otherwise, we must find the external
+ // ChangeLog file.
+ IEditorPart changelog = null;
+
+ // Before accessing the getFormatterConfigElement, the getFormatContibutor
+ // method must be called to initialize.
+ extensionManager.getFormatterContributor(clw.getEntryFilePath(),
+ pref_Formatter);
+ IConfigurationElement formatterConfigElement = extensionManager
.getFormatterConfigElement();
- if (formatterConfigElement.getAttribute("inFile").equalsIgnoreCase( //$NON-NLS-1$
- "true")) { //$NON-NLS-1$
- try {
- changelog = openEditor((IFile)pf.getResource());
- clw.setFormatter(extensionManager.getFormatterContributor(
- clw.getEntryFilePath(), pref_Formatter));
- } catch (Exception e) {
- // do nothing changelog will be null
- }
- } else {
- // external changelog
- // get formatter
- clw.setFormatter(extensionManager.getFormatterContributor(
- entryFileName, pref_Formatter));
-
- if (pf.isRemovedFile())
- changelog = getChangelogForRemovePath(entryPath);
- else
- changelog = getChangelog(entryFileName);
-
- // If there isn't a ChangeLog, we will ask for one here.
- // We originally avoided this to prevent a problem for rpm
- // projects whereby the changelog is inlined in a single file
- // and not presented externally. This has been changed in
- // response to bug #347703. If the user cancels the ask
- // dialog, then the prepare operation doesn't try to create
- // one.
- if (createChangeLog && changelog == null)
- changelog = askChangeLogLocation(entryPath.toOSString());
- if (changelog == null) {
- createChangeLog = false;
- return;
- }
- }
- if ((changelog instanceof ChangeLogEditor) && (!this.newEntryWritten)) {
- ChangeLogEditor editor = (ChangeLogEditor) changelog;
- // if the editor is dirty (changes added to the editor without
- // saving), treat it as a change log modification
- if (editor.isDirty())
- this.changeLogModified = true;
- editor.setForceNewLogEntry(!this.changeLogModified);
- this.newEntryWritten = true;
- }
- // select changelog
- clw.setChangelog(changelog);
-
- // write to changelog
- IFormatterChangeLogContrib formatter = clw.getFormatter();
- clw.setDateLine(formatter.formatDateLine(pref_AuthorName,
- pref_AuthorEmail));
-
- clw.setChangelogLocation(getDocumentLocation(clw.getChangelog(), true));
-
- // print multiple changelog entries with different
- // function guess names. We default to an empty guessed name
- // if we have zero function guess names.
- int numFuncs = 0;
- clw.setGuessedFName(""); // $NON-NLS-1$
- if (functionGuess.length > 0) {
- for (String guess : functionGuess) {
- if (!guess.trim().equals("")) { // $NON-NLS-1$
- ++numFuncs;
- clw.setGuessedFName(guess);
- clw.writeChangeLog();
- }
- }
- }
- // Default an empty entry if we did not have any none-empty
- // function guesses.
- if (numFuncs == 0) {
- clw.writeChangeLog();
- }
-
- }
-
-
- /**
- * Guesses the function effected/modified by the patch from local file(newer
- * file).
- *
- * @param patchFileInfo
- * patch file
- * @return array of unique function names
- */
- private String[] guessFunctionNames(PatchFile patchFileInfo) {
-
-
- // if this file is new file or removed file, do not guess function files
- // TODO: create an option to include function names on
- // new files or not
- if (patchFileInfo.isNewfile() || patchFileInfo.isRemovedFile()) {
- return new String[]{""};
- }
-
- String[] fnames = new String[0];
- String editorName = ""; // $NON-NLS-1$
-
- try {
- IEditorDescriptor ed = org.eclipse.ui.ide.IDE
- .getEditorDescriptor(patchFileInfo.getPath().toOSString());
- editorName = ed.getId().substring(ed.getId().lastIndexOf(".") + 1); // $NON-NLS-1$
- } catch (PartInitException e1) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
- e1.getMessage(), e1));
- return new String[0];
- }
-
- // check if the file type is supported
-
- // get editor input for target file
-
- IFileEditorInput fei = new FileEditorInput((IFile)patchFileInfo.getResource());
-
- SourceEditorInput sei = new SourceEditorInput(patchFileInfo.getStorage());
-
- MyDocumentProvider mdp = new MyDocumentProvider();
- MyStorageDocumentProvider msdp = new MyStorageDocumentProvider();
-
- try {
- // get document for target file (one for local file, one for repository storage)
- IDocument doc = mdp.createDocument(fei);
- IDocument olddoc = msdp.createDocument(sei);
-
- HashMap<String, String> functionNamesMap = new HashMap<>();
- ArrayList<String> nameList = new ArrayList<>();
-
- // for all the ranges
- for (PatchRangeElement tpre: patchFileInfo.getRanges()) {
-
- for (int j = tpre.fromLine; j <= tpre.toLine; j++) {
-
- String functionGuess = "";
- // add func that determines type of file.
- // right now it assumes it's java file.
- if (tpre.isLocalChange()) {
- if ((j < 0) || (j > doc.getNumberOfLines() - 1))
- continue; // ignore out of bound lines
- functionGuess = parseCurrentFunctionAtOffset(
- editorName, fei, doc.getLineOffset(j));
- } else {
- if ((j < 0) || (j > olddoc.getNumberOfLines() - 1))
- continue; // ignore out of bound lines
- functionGuess = parseCurrentFunctionAtOffset(
- editorName, sei, olddoc.getLineOffset(j));
- }
-
- // putting it in hashmap will eliminate duplicate
- // guesses. We use a list to keep track of ordering which
- // is helpful when trying to document a large set of changes.
- if (functionNamesMap.get(functionGuess) == null)
- nameList.add(functionGuess);
- functionNamesMap.put(functionGuess, functionGuess);
- }
- }
-
- // dump all unique func. guesses in the order found
- fnames = new String[nameList.size()];
- fnames = nameList.toArray(fnames);
-
- } catch (CoreException|BadLocationException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
- e.getMessage(), e));
- }
- return fnames;
- }
+ if (formatterConfigElement.getAttribute("inFile").equalsIgnoreCase( //$NON-NLS-1$
+ "true")) { //$NON-NLS-1$
+ try {
+ changelog = openEditor((IFile)pf.getResource());
+ clw.setFormatter(extensionManager.getFormatterContributor(
+ clw.getEntryFilePath(), pref_Formatter));
+ } catch (Exception e) {
+ // do nothing changelog will be null
+ }
+ } else {
+ // external changelog
+ // get formatter
+ clw.setFormatter(extensionManager.getFormatterContributor(
+ entryFileName, pref_Formatter));
+
+ if (pf.isRemovedFile())
+ changelog = getChangelogForRemovePath(entryPath);
+ else
+ changelog = getChangelog(entryFileName);
+
+ // If there isn't a ChangeLog, we will ask for one here.
+ // We originally avoided this to prevent a problem for rpm
+ // projects whereby the changelog is inlined in a single file
+ // and not presented externally. This has been changed in
+ // response to bug #347703. If the user cancels the ask
+ // dialog, then the prepare operation doesn't try to create
+ // one.
+ if (createChangeLog && changelog == null)
+ changelog = askChangeLogLocation(entryPath.toOSString());
+ if (changelog == null) {
+ createChangeLog = false;
+ return;
+ }
+ }
+ if ((changelog instanceof ChangeLogEditor) && (!this.newEntryWritten)) {
+ ChangeLogEditor editor = (ChangeLogEditor) changelog;
+ // if the editor is dirty (changes added to the editor without
+ // saving), treat it as a change log modification
+ if (editor.isDirty())
+ this.changeLogModified = true;
+ editor.setForceNewLogEntry(!this.changeLogModified);
+ this.newEntryWritten = true;
+ }
+ // select changelog
+ clw.setChangelog(changelog);
+
+ // write to changelog
+ IFormatterChangeLogContrib formatter = clw.getFormatter();
+ clw.setDateLine(formatter.formatDateLine(pref_AuthorName,
+ pref_AuthorEmail));
+
+ clw.setChangelogLocation(getDocumentLocation(clw.getChangelog(), true));
+
+ // print multiple changelog entries with different
+ // function guess names. We default to an empty guessed name
+ // if we have zero function guess names.
+ int numFuncs = 0;
+ clw.setGuessedFName(""); // $NON-NLS-1$
+ if (functionGuess.length > 0) {
+ for (String guess : functionGuess) {
+ if (!guess.trim().equals("")) { // $NON-NLS-1$
+ ++numFuncs;
+ clw.setGuessedFName(guess);
+ clw.writeChangeLog();
+ }
+ }
+ }
+ // Default an empty entry if we did not have any none-empty
+ // function guesses.
+ if (numFuncs == 0) {
+ clw.writeChangeLog();
+ }
+
+ }
+
+
+ /**
+ * Guesses the function effected/modified by the patch from local file(newer
+ * file).
+ *
+ * @param patchFileInfo
+ * patch file
+ * @return array of unique function names
+ */
+ private String[] guessFunctionNames(PatchFile patchFileInfo) {
+
+
+ // if this file is new file or removed file, do not guess function files
+ // TODO: create an option to include function names on
+ // new files or not
+ if (patchFileInfo.isNewfile() || patchFileInfo.isRemovedFile()) {
+ return new String[]{""};
+ }
+
+ String[] fnames = new String[0];
+ String editorName = ""; // $NON-NLS-1$
+
+ try {
+ IEditorDescriptor ed = org.eclipse.ui.ide.IDE
+ .getEditorDescriptor(patchFileInfo.getPath().toOSString());
+ editorName = ed.getId().substring(ed.getId().lastIndexOf(".") + 1); // $NON-NLS-1$
+ } catch (PartInitException e1) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
+ e1.getMessage(), e1));
+ return new String[0];
+ }
+
+ // check if the file type is supported
+
+ // get editor input for target file
+
+ IFileEditorInput fei = new FileEditorInput((IFile)patchFileInfo.getResource());
+
+ SourceEditorInput sei = new SourceEditorInput(patchFileInfo.getStorage());
+
+ MyDocumentProvider mdp = new MyDocumentProvider();
+ MyStorageDocumentProvider msdp = new MyStorageDocumentProvider();
+
+ try {
+ // get document for target file (one for local file, one for repository storage)
+ IDocument doc = mdp.createDocument(fei);
+ IDocument olddoc = msdp.createDocument(sei);
+
+ HashMap<String, String> functionNamesMap = new HashMap<>();
+ ArrayList<String> nameList = new ArrayList<>();
+
+ // for all the ranges
+ for (PatchRangeElement tpre: patchFileInfo.getRanges()) {
+
+ for (int j = tpre.fromLine; j <= tpre.toLine; j++) {
+
+ String functionGuess = "";
+ // add func that determines type of file.
+ // right now it assumes it's java file.
+ if (tpre.isLocalChange()) {
+ if ((j < 0) || (j > doc.getNumberOfLines() - 1))
+ continue; // ignore out of bound lines
+ functionGuess = parseCurrentFunctionAtOffset(
+ editorName, fei, doc.getLineOffset(j));
+ } else {
+ if ((j < 0) || (j > olddoc.getNumberOfLines() - 1))
+ continue; // ignore out of bound lines
+ functionGuess = parseCurrentFunctionAtOffset(
+ editorName, sei, olddoc.getLineOffset(j));
+ }
+
+ // putting it in hashmap will eliminate duplicate
+ // guesses. We use a list to keep track of ordering which
+ // is helpful when trying to document a large set of changes.
+ if (functionNamesMap.get(functionGuess) == null)
+ nameList.add(functionGuess);
+ functionNamesMap.put(functionGuess, functionGuess);
+ }
+ }
+
+ // dump all unique func. guesses in the order found
+ fnames = new String[nameList.size()];
+ fnames = nameList.toArray(fnames);
+
+ } catch (CoreException|BadLocationException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
+ e.getMessage(), e));
+ }
+ return fnames;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java
index dd8ea21f8f..5c3f139e20 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java
@@ -36,101 +36,101 @@ import org.eclipse.ui.handlers.HandlerUtil;
public class PrepareChangelogKeyHandler extends AbstractHandler {
- @Override
- public Object execute(ExecutionEvent event) {
+ @Override
+ public Object execute(ExecutionEvent event) {
- IStructuredSelection tempResult = null;
+ IStructuredSelection tempResult = null;
- // try getting currently selected project
- IWorkbenchPage ref = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- if (part instanceof IEditorPart) {
- // If we are in an editor, check if the file being edited is an IResource
- // that belongs to a project in the workspace
- IEditorPart editorPart = (IEditorPart)part;
- IEditorInput input = editorPart.getEditorInput();
- IResource r = (IResource)input.getAdapter(IResource.class);
- if (r != null) {
- // We have an IResource to work with, so create a selection we can use
- // in PrepareChangeLogAction
- tempResult = new StructuredSelection(r);
- }
- } else {
- // Otherwise, our view is not an editor, see if we have an IResource or something
- // that will lead us to an IResource
- ISelection selected = ref.getSelection();
- if (selected instanceof IStructuredSelection) {
- IResource r = null;
- IStructuredSelection iss = (IStructuredSelection)selected;
- Object o = ((IStructuredSelection)selected).getFirstElement();
- if (o instanceof ISynchronizeModelElement) {
- r = ((ISynchronizeModelElement)o).getResource();
- } else if (o instanceof IAdaptable) {
- r = (IResource)((IAdaptable)o).getAdapter(IResource.class);
- }
- if (r != null)
- tempResult = iss;
- }
- }
- if (tempResult == null) {
- // We don't have an obvious project match in the current active view.
- // Let's search all open views for the Synchronize View which is our first
- // choice to fall back on.
- for (IViewReference view: ref.getViewReferences()) {
- if (view.getId().equals("org.eclipse.team.sync.views.SynchronizeView")) { // $NON-NLS-1$
- IViewPart v = view.getView(false);
- ISelection s = null;
- ISelectionProvider sp = v.getViewSite().getSelectionProvider();
- if (sp != null) {
- s = sp.getSelection();
- }
- if (s instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection)s;
- Object element = ss.getFirstElement();
- IResource r = null;
- if (element instanceof ISynchronizeModelElement) {
- r = ((ISynchronizeModelElement)element).getResource();
- } else if (element instanceof IAdaptable) {
- r = (IResource)((IAdaptable)element).getAdapter(IResource.class);
- }
+ // try getting currently selected project
+ IWorkbenchPage ref = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ if (part instanceof IEditorPart) {
+ // If we are in an editor, check if the file being edited is an IResource
+ // that belongs to a project in the workspace
+ IEditorPart editorPart = (IEditorPart)part;
+ IEditorInput input = editorPart.getEditorInput();
+ IResource r = (IResource)input.getAdapter(IResource.class);
+ if (r != null) {
+ // We have an IResource to work with, so create a selection we can use
+ // in PrepareChangeLogAction
+ tempResult = new StructuredSelection(r);
+ }
+ } else {
+ // Otherwise, our view is not an editor, see if we have an IResource or something
+ // that will lead us to an IResource
+ ISelection selected = ref.getSelection();
+ if (selected instanceof IStructuredSelection) {
+ IResource r = null;
+ IStructuredSelection iss = (IStructuredSelection)selected;
+ Object o = ((IStructuredSelection)selected).getFirstElement();
+ if (o instanceof ISynchronizeModelElement) {
+ r = ((ISynchronizeModelElement)o).getResource();
+ } else if (o instanceof IAdaptable) {
+ r = (IResource)((IAdaptable)o).getAdapter(IResource.class);
+ }
+ if (r != null)
+ tempResult = iss;
+ }
+ }
+ if (tempResult == null) {
+ // We don't have an obvious project match in the current active view.
+ // Let's search all open views for the Synchronize View which is our first
+ // choice to fall back on.
+ for (IViewReference view: ref.getViewReferences()) {
+ if (view.getId().equals("org.eclipse.team.sync.views.SynchronizeView")) { // $NON-NLS-1$
+ IViewPart v = view.getView(false);
+ ISelection s = null;
+ ISelectionProvider sp = v.getViewSite().getSelectionProvider();
+ if (sp != null) {
+ s = sp.getSelection();
+ }
+ if (s instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)s;
+ Object element = ss.getFirstElement();
+ IResource r = null;
+ if (element instanceof ISynchronizeModelElement) {
+ r = ((ISynchronizeModelElement)element).getResource();
+ } else if (element instanceof IAdaptable) {
+ r = (IResource)((IAdaptable)element).getAdapter(IResource.class);
+ }
- if (r != null) {
- tempResult = ss;
- }
- }
- }
- }
- }
+ if (r != null) {
+ tempResult = ss;
+ }
+ }
+ }
+ }
+ }
- // If we can't find the project directly, let the user know.
- if (tempResult == null) {
- MessageDialog.openInformation(getActiveWorkbenchShell(), Messages.getString("ChangeLog.PrepareChangeLog"), // $NON-NLS-1$,
- Messages.getString("PrepareChangeLog.InfoNoProjectFound")); // $NON-NLS-1$
- return null;
- }
+ // If we can't find the project directly, let the user know.
+ if (tempResult == null) {
+ MessageDialog.openInformation(getActiveWorkbenchShell(), Messages.getString("ChangeLog.PrepareChangeLog"), // $NON-NLS-1$,
+ Messages.getString("PrepareChangeLog.InfoNoProjectFound")); // $NON-NLS-1$
+ return null;
+ }
- final IStructuredSelection result = tempResult;
- IAction exampleAction = new PrepareChangeLogAction() {
- @Override
- public void run() {
- setSelection(result);
- doRun();
- }
- };
+ final IStructuredSelection result = tempResult;
+ IAction exampleAction = new PrepareChangeLogAction() {
+ @Override
+ public void run() {
+ setSelection(result);
+ doRun();
+ }
+ };
- exampleAction.run();
+ exampleAction.run();
- return null;
- }
+ return null;
+ }
- /**
- * Returns active shell.
- */
- private Shell getActiveWorkbenchShell() {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- return window.getShell();
- }
- return null;
- }
+ /**
+ * Returns active shell.
+ */
+ private Shell getActiveWorkbenchShell() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ return window.getShell();
+ }
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java
index 87eeaded11..f751772734 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java
@@ -56,227 +56,227 @@ import org.eclipse.ui.ide.IContributorResourceAdapter2;
public class PrepareCommitHandler extends AbstractHandler {
- @Override
- public Object execute(ExecutionEvent event) {
+ @Override
+ public Object execute(ExecutionEvent event) {
- IRunnableWithProgress code = new IRunnableWithProgress() {
+ IRunnableWithProgress code = new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) {
- // monitor.beginTask("Loading Clipboard", 1000);
- loadClipboard(monitor);
- // monitor.done();
- }
- };
+ @Override
+ public void run(IProgressMonitor monitor) {
+ // monitor.beginTask("Loading Clipboard", 1000);
+ loadClipboard(monitor);
+ // monitor.done();
+ }
+ };
- ProgressMonitorDialog pd = new ProgressMonitorDialog(PlatformUI
- .getWorkbench().getActiveWorkbenchWindow().getShell());
+ ProgressMonitorDialog pd = new ProgressMonitorDialog(PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getShell());
- try {
- pd.run(false /* fork */, false /* cancelable */, code);
- } catch (InvocationTargetException e) {
- ChangelogPlugin
- .getDefault()
- .getLog()
- .log(new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
- IStatus.ERROR, e.getMessage(), e));
- } catch (InterruptedException e) {
- ChangelogPlugin
- .getDefault()
- .getLog()
- .log(new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
- IStatus.ERROR, e.getMessage(), e));
- }
+ try {
+ pd.run(false /* fork */, false /* cancelable */, code);
+ } catch (InvocationTargetException e) {
+ ChangelogPlugin
+ .getDefault()
+ .getLog()
+ .log(new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
+ IStatus.ERROR, e.getMessage(), e));
+ } catch (InterruptedException e) {
+ ChangelogPlugin
+ .getDefault()
+ .getLog()
+ .log(new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
+ IStatus.ERROR, e.getMessage(), e));
+ }
- return null;
- }
+ return null;
+ }
- private ResourceMapping getResourceMapping(Object o) {
- if (o instanceof ResourceMapping) {
- return (ResourceMapping) o;
- }
- if (o instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) o;
- Object adapted = adaptable.getAdapter(ResourceMapping.class);
- if (adapted instanceof ResourceMapping) {
- return (ResourceMapping) adapted;
- }
- adapted = adaptable.getAdapter(IContributorResourceAdapter.class);
- if (adapted instanceof IContributorResourceAdapter2) {
- IContributorResourceAdapter2 cra = (IContributorResourceAdapter2) adapted;
- return cra.getAdaptedResourceMapping(adaptable);
- }
- } else {
- Object adapted = Platform.getAdapterManager().getAdapter(o,
- ResourceMapping.class);
- if (adapted instanceof ResourceMapping) {
- return (ResourceMapping) adapted;
- }
- }
+ private ResourceMapping getResourceMapping(Object o) {
+ if (o instanceof ResourceMapping) {
+ return (ResourceMapping) o;
+ }
+ if (o instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) o;
+ Object adapted = adaptable.getAdapter(ResourceMapping.class);
+ if (adapted instanceof ResourceMapping) {
+ return (ResourceMapping) adapted;
+ }
+ adapted = adaptable.getAdapter(IContributorResourceAdapter.class);
+ if (adapted instanceof IContributorResourceAdapter2) {
+ IContributorResourceAdapter2 cra = (IContributorResourceAdapter2) adapted;
+ return cra.getAdaptedResourceMapping(adaptable);
+ }
+ } else {
+ Object adapted = Platform.getAdapterManager().getAdapter(o,
+ ResourceMapping.class);
+ if (adapted instanceof ResourceMapping) {
+ return (ResourceMapping) adapted;
+ }
+ }
- return null;
- }
+ return null;
+ }
- private void loadClipboard(IProgressMonitor monitor) {
+ private void loadClipboard(IProgressMonitor monitor) {
- IEditorPart currentEditor;
+ IEditorPart currentEditor;
- try {
- currentEditor = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage()
- .getActiveEditor();
- } catch (Exception e) {
- // no editor is active now so do nothing
+ try {
+ currentEditor = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .getActiveEditor();
+ } catch (Exception e) {
+ // no editor is active now so do nothing
- return;
- }
+ return;
+ }
- if (currentEditor == null)
- return;
+ if (currentEditor == null)
+ return;
- // System.out.println(currentEditor.getTitle());
- String diffResult = "";
- IEditorInput input = currentEditor.getEditorInput();
- ResourceMapping mapping = getResourceMapping(input);
- IProject project = null;
- IResource[] resources = new IResource[1];
+ // System.out.println(currentEditor.getTitle());
+ String diffResult = "";
+ IEditorInput input = currentEditor.getEditorInput();
+ ResourceMapping mapping = getResourceMapping(input);
+ IProject project = null;
+ IResource[] resources = new IResource[1];
- if (mapping != null) {
- project = mapping.getProjects()[0];
- resources[0] = (IResource) mapping.getModelObject();
- } else if (input instanceof IFileEditorInput) {
- IFileEditorInput f = (IFileEditorInput) input;
- project = f.getFile().getProject();
- resources[0] = f.getFile();
- } else {
- return; // can't get what we need
- }
+ if (mapping != null) {
+ project = mapping.getProjects()[0];
+ resources[0] = (IResource) mapping.getModelObject();
+ } else if (input instanceof IFileEditorInput) {
+ IFileEditorInput f = (IFileEditorInput) input;
+ project = f.getFile().getProject();
+ resources[0] = f.getFile();
+ } else {
+ return; // can't get what we need
+ }
- RepositoryProvider r = RepositoryProvider.getProvider(project);
- if (r == null) {
- return; // There is no repository provider for this project, i.e
- // it's not shared.
- }
- SyncInfoSet set = new SyncInfoSet();
- Subscriber s = r.getSubscriber();
- s.collectOutOfSync(resources, IResource.DEPTH_ZERO, set, monitor);
- SyncInfo[] infos = set.getSyncInfos();
+ RepositoryProvider r = RepositoryProvider.getProvider(project);
+ if (r == null) {
+ return; // There is no repository provider for this project, i.e
+ // it's not shared.
+ }
+ SyncInfoSet set = new SyncInfoSet();
+ Subscriber s = r.getSubscriber();
+ s.collectOutOfSync(resources, IResource.DEPTH_ZERO, set, monitor);
+ SyncInfo[] infos = set.getSyncInfos();
- if (infos.length == 1) {
- int kind = SyncInfo.getChange(infos[0].getKind());
- if (kind == SyncInfo.CHANGE) {
- try {
- IDiff d = s.getDiff(infos[0].getLocal());
- if (d instanceof IThreeWayDiff
- && ((IThreeWayDiff) d).getDirection() == IThreeWayDiff.OUTGOING) {
- IThreeWayDiff diff = (IThreeWayDiff) d;
- monitor.beginTask(null, 100);
- IResourceDiff localDiff = (IResourceDiff) diff
- .getLocalChange();
- IFile file = (IFile) localDiff.getResource();
- monitor.subTask(Messages
- .getString("ChangeLog.MergingDiffs")); // $NON-NLS-1$
- String osEncoding = file.getCharset();
- IFileRevision ancestorState = localDiff
- .getBeforeState();
- IStorage ancestorStorage;
- if (ancestorState != null)
- ancestorStorage = ancestorState.getStorage(monitor);
- else {
- ancestorStorage = null;
- return;
- }
+ if (infos.length == 1) {
+ int kind = SyncInfo.getChange(infos[0].getKind());
+ if (kind == SyncInfo.CHANGE) {
+ try {
+ IDiff d = s.getDiff(infos[0].getLocal());
+ if (d instanceof IThreeWayDiff
+ && ((IThreeWayDiff) d).getDirection() == IThreeWayDiff.OUTGOING) {
+ IThreeWayDiff diff = (IThreeWayDiff) d;
+ monitor.beginTask(null, 100);
+ IResourceDiff localDiff = (IResourceDiff) diff
+ .getLocalChange();
+ IFile file = (IFile) localDiff.getResource();
+ monitor.subTask(Messages
+ .getString("ChangeLog.MergingDiffs")); // $NON-NLS-1$
+ String osEncoding = file.getCharset();
+ IFileRevision ancestorState = localDiff
+ .getBeforeState();
+ IStorage ancestorStorage;
+ if (ancestorState != null)
+ ancestorStorage = ancestorState.getStorage(monitor);
+ else {
+ ancestorStorage = null;
+ return;
+ }
- try {
- LineComparator left = new LineComparator(
- ancestorStorage.getContents(), osEncoding);
- LineComparator right = new LineComparator(
- file.getContents(), osEncoding);
- for (RangeDifference tmp : RangeDifferencer
- .findDifferences(left, right)) {
- if (tmp.kind() == RangeDifference.CHANGE) {
- LineNumberReader l = new LineNumberReader(
- new InputStreamReader(
- file.getContents()));
- int rightLength = tmp.rightLength() > 0 ? tmp
- .rightLength()
- : tmp.rightLength() + 1;
- String line0 = null;
- String preDiffResult = "";
- for (int i = 0; i < tmp.rightStart(); ++i) {
- // We have equivalence at the start.
- // This could be due to a new entry with
- // the
- // same date stamp as the subsequent
- // entry. In this case, we want the diff
- // to
- // have the date stamp at the top so it
- // forms a complete entry. So, we cache
- // those equivalent lines for later
- // usage if needed.
- try {
- String line = l.readLine();
- if (line0 == null)
- line0 = line;
- preDiffResult += line + "\n";
- } catch (IOException e) {
- break;
- }
- }
- for (int i = 0; i < rightLength; ++i) {
- try {
- String line = l.readLine();
- // If the last line of the diff
- // matches the first line of the old
- // file and
- // there was equivalence at the
- // start of the ChangeLog, then we
- // want to put
- // the equivalent section at top so
- // as to give the best chance of
- // forming
- // a ChangeLog entry that can be
- // used as a commit comment.
- if (i == rightLength
- - tmp.rightStart()) {
- if (tmp.rightStart() != 0
- && line.equals(line0)) {
- diffResult = preDiffResult += diffResult;
- i = rightLength; // stop
- // loop
- } else
- diffResult += line + "\n";
- } else
- diffResult += line + "\n"; // $NON-NLS-1$
- } catch (IOException e) {
- // do nothing
- }
- }
- }
- }
- } catch (UnsupportedEncodingException e) {
- // do nothing for now
- }
- monitor.done();
- }
- } catch (CoreException e) {
- // do nothing
- }
- }
- }
+ try {
+ LineComparator left = new LineComparator(
+ ancestorStorage.getContents(), osEncoding);
+ LineComparator right = new LineComparator(
+ file.getContents(), osEncoding);
+ for (RangeDifference tmp : RangeDifferencer
+ .findDifferences(left, right)) {
+ if (tmp.kind() == RangeDifference.CHANGE) {
+ LineNumberReader l = new LineNumberReader(
+ new InputStreamReader(
+ file.getContents()));
+ int rightLength = tmp.rightLength() > 0 ? tmp
+ .rightLength()
+ : tmp.rightLength() + 1;
+ String line0 = null;
+ String preDiffResult = "";
+ for (int i = 0; i < tmp.rightStart(); ++i) {
+ // We have equivalence at the start.
+ // This could be due to a new entry with
+ // the
+ // same date stamp as the subsequent
+ // entry. In this case, we want the diff
+ // to
+ // have the date stamp at the top so it
+ // forms a complete entry. So, we cache
+ // those equivalent lines for later
+ // usage if needed.
+ try {
+ String line = l.readLine();
+ if (line0 == null)
+ line0 = line;
+ preDiffResult += line + "\n";
+ } catch (IOException e) {
+ break;
+ }
+ }
+ for (int i = 0; i < rightLength; ++i) {
+ try {
+ String line = l.readLine();
+ // If the last line of the diff
+ // matches the first line of the old
+ // file and
+ // there was equivalence at the
+ // start of the ChangeLog, then we
+ // want to put
+ // the equivalent section at top so
+ // as to give the best chance of
+ // forming
+ // a ChangeLog entry that can be
+ // used as a commit comment.
+ if (i == rightLength
+ - tmp.rightStart()) {
+ if (tmp.rightStart() != 0
+ && line.equals(line0)) {
+ diffResult = preDiffResult += diffResult;
+ i = rightLength; // stop
+ // loop
+ } else
+ diffResult += line + "\n";
+ } else
+ diffResult += line + "\n"; // $NON-NLS-1$
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
+ }
+ }
+ } catch (UnsupportedEncodingException e) {
+ // do nothing for now
+ }
+ monitor.done();
+ }
+ } catch (CoreException e) {
+ // do nothing
+ }
+ }
+ }
- if (!diffResult.equals(""))
- populateClipboardBuffer(diffResult);
- }
+ if (!diffResult.equals(""))
+ populateClipboardBuffer(diffResult);
+ }
- private void populateClipboardBuffer(String input) {
+ private void populateClipboardBuffer(String input) {
- TextTransfer plainTextTransfer = TextTransfer.getInstance();
- Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench()
- .getDisplay());
- clipboard.setContents(new String[] { input },
- new Transfer[] { plainTextTransfer });
- clipboard.dispose();
- }
+ TextTransfer plainTextTransfer = TextTransfer.getInstance();
+ Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench()
+ .getDisplay());
+ clipboard.setContents(new String[] { input },
+ new Transfer[] { plainTextTransfer });
+ clipboard.dispose();
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java
index 5f605a7cb3..314cd13c9a 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java
@@ -17,19 +17,19 @@ import org.eclipse.core.resources.IStorage;
*/
public class SourceEditorInput extends StorageEditorInput {
- /**
- * @param storage that represents a source file
- */
- public SourceEditorInput(IStorage storage) {
- super(storage);
- }
+ /**
+ * @param storage that represents a source file
+ */
+ public SourceEditorInput(IStorage storage) {
+ super(storage);
+ }
- /*
- * @see org.eclipse.ui.IEditorInput#exists()
- */
- @Override
- public boolean exists() {
- return false;
- }
+ /*
+ * @see org.eclipse.ui.IEditorInput#exists()
+ */
+ @Override
+ public boolean exists() {
+ return false;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java
index 95ff2926ee..aa33eb4547 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java
@@ -22,89 +22,89 @@ import org.eclipse.ui.IStorageEditorInput;
*/
public abstract class StorageEditorInput implements IStorageEditorInput {
- /**
- * Storage associated with this editor input
- */
- private IStorage fStorage;
+ /**
+ * Storage associated with this editor input
+ */
+ private IStorage fStorage;
- /**
- * Constructs an editor input on the given storage
- */
- public StorageEditorInput(IStorage storage) {
- fStorage = storage;
- }
+ /**
+ * Constructs an editor input on the given storage
+ */
+ public StorageEditorInput(IStorage storage) {
+ fStorage = storage;
+ }
- /**
- * @see IStorageEditorInput#getStorage()
- */
- @Override
- public IStorage getStorage() {
- return fStorage;
- }
+ /**
+ * @see IStorageEditorInput#getStorage()
+ */
+ @Override
+ public IStorage getStorage() {
+ return fStorage;
+ }
- /**
- * @see IStorageEditorInput#getImageDescriptor()
- */
- @Override
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
+ /**
+ * @see IStorageEditorInput#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
- /**
- * @see IStorageEditorInput#getName()
- */
- @Override
- public String getName() {
- return getStorage().getName();
- }
+ /**
+ * @see IStorageEditorInput#getName()
+ */
+ @Override
+ public String getName() {
+ return getStorage().getName();
+ }
- /**
- * @see IStorageEditorInput#getPersistable()
- */
- @Override
- public IPersistableElement getPersistable() {
- return null;
- }
+ /**
+ * @see IStorageEditorInput#getPersistable()
+ */
+ @Override
+ public IPersistableElement getPersistable() {
+ return null;
+ }
- /**
- * @see IStorageEditorInput#getToolTipText()
- */
- @Override
- public String getToolTipText() {
- return getStorage().getFullPath().toOSString();
- }
+ /**
+ * @see IStorageEditorInput#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return getStorage().getFullPath().toOSString();
+ }
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object object) {
- if (object == this) {
- return true;
- }
- try {
- return object instanceof IStorageEditorInput
- && getStorage().equals(((IStorageEditorInput)object).getStorage());
- } catch (CoreException e) {
- }
- return false;
- }
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object object) {
+ if (object == this) {
+ return true;
+ }
+ try {
+ return object instanceof IStorageEditorInput
+ && getStorage().equals(((IStorageEditorInput)object).getStorage());
+ } catch (CoreException e) {
+ }
+ return false;
+ }
- /**
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return getStorage().hashCode();
- }
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return getStorage().hashCode();
+ }
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @Override
- @SuppressWarnings({ "rawtypes" })
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @Override
+ @SuppressWarnings({ "rawtypes" })
public Object getAdapter(Class adapter) {
- return null;
- }
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentProvider.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentProvider.java
index 33c03407eb..e46b3731d7 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentProvider.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentProvider.java
@@ -18,8 +18,8 @@ import org.eclipse.ui.editors.text.TextFileDocumentProvider;
*/
public class ChangeLogDocumentProvider extends TextFileDocumentProvider {
- @Override
- public IDocument getDocument(Object element) {
- return super.getDocument(element);
- }
+ @Override
+ public IDocument getDocument(Object element) {
+ return super.getDocument(element);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java
index 750d3dbea1..818d158c0e 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java
@@ -26,62 +26,62 @@ import org.eclipse.linuxtools.changelog.core.IEditorChangeLogContrib2;
import org.eclipse.linuxtools.internal.changelog.core.ChangelogPlugin;
public class ChangeLogDocumentSetupParticipant implements
- IDocumentSetupParticipant, IDocumentListener {
+ IDocumentSetupParticipant, IDocumentListener {
- @Override
- public void setup(IDocument document) {
- IExtensionPoint editorExtensions = null;
- IEditorChangeLogContrib editorContrib = null;
+ @Override
+ public void setup(IDocument document) {
+ IExtensionPoint editorExtensions = null;
+ IEditorChangeLogContrib editorContrib = null;
- // get editor which is stored in preference.
- IPreferenceStore store = ChangelogPlugin.getDefault()
- .getPreferenceStore();
- String pref_Editor = store
- .getString("IChangeLogConstants.DEFAULT_EDITOR"); // $NON-NLS-1$
+ // get editor which is stored in preference.
+ IPreferenceStore store = ChangelogPlugin.getDefault()
+ .getPreferenceStore();
+ String pref_Editor = store
+ .getString("IChangeLogConstants.DEFAULT_EDITOR"); // $NON-NLS-1$
- editorExtensions = Platform.getExtensionRegistry().getExtensionPoint(
- "org.eclipse.linuxtools.changelog.core", "editorContribution"); //$NON-NLS-1$ //$NON-NLS-2$
+ editorExtensions = Platform.getExtensionRegistry().getExtensionPoint(
+ "org.eclipse.linuxtools.changelog.core", "editorContribution"); //$NON-NLS-1$ //$NON-NLS-2$
- if (editorExtensions != null) {
- IConfigurationElement[] elements = editorExtensions
- .getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getName().equals("editor") // $NON-NLS-1$
- && (elements[i].getAttribute("name").equals(pref_Editor))) { //$NON-NLS-1$
+ if (editorExtensions != null) {
+ IConfigurationElement[] elements = editorExtensions
+ .getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i].getName().equals("editor") // $NON-NLS-1$
+ && (elements[i].getAttribute("name").equals(pref_Editor))) { //$NON-NLS-1$
- try {
- // If editor has a special setup routine, use it.
- IConfigurationElement bob = elements[i];
- editorContrib = (IEditorChangeLogContrib) bob
- .createExecutableExtension("class"); // $NON-NLS-1$
+ try {
+ // If editor has a special setup routine, use it.
+ IConfigurationElement bob = elements[i];
+ editorContrib = (IEditorChangeLogContrib) bob
+ .createExecutableExtension("class"); // $NON-NLS-1$
- if (editorContrib instanceof IEditorChangeLogContrib2)
- ((IEditorChangeLogContrib2)editorContrib).setup(document);
- } catch (CoreException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
- IStatus.ERROR, e.getMessage(), e));
- }
- }
- }
- }
- }
+ if (editorContrib instanceof IEditorChangeLogContrib2)
+ ((IEditorChangeLogContrib2)editorContrib).setup(document);
+ } catch (CoreException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
+ IStatus.ERROR, e.getMessage(), e));
+ }
+ }
+ }
+ }
+ }
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
+ /*
+ * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
+ */
- @Override
- public void documentAboutToBeChanged(DocumentEvent e) {
- // do nothing
- }
+ @Override
+ public void documentAboutToBeChanged(DocumentEvent e) {
+ // do nothing
+ }
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- @Override
- public void documentChanged(DocumentEvent e) {
- // do nothing
- }
+ /*
+ * @see IDocumentListener#documentChanged(DocumentEvent)
+ */
+ @Override
+ public void documentChanged(DocumentEvent e) {
+ // do nothing
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java
index 63618322ad..1c23bea4d7 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java
@@ -35,83 +35,83 @@ import org.eclipse.ui.editors.text.TextEditor;
*/
public class ChangeLogEditor extends TextEditor {
- private boolean forceNewLogEntry;
-
- public ChangeLogEditor() {
- super();
-
- SourceViewerConfiguration config = getConfig();
-
- if (config != null) {
- setSourceViewerConfiguration(config);
- } else {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
- Messages.getString("ChangeLogEditor.ErrConfiguration"), // $NON-NLS-1$
- new Exception(Messages.getString("ChangeLogEditor.ErrConfiguration")))); // $NON-NLS-1$
- }
-
- setDocumentProvider(new ChangeLogDocumentProvider());
-
- }
-
- /**
- * Gets appropriate style editor from user pref.
- *
- * @return configuration for the Changelog editor
- */
-
- private SourceViewerConfiguration getConfig() {
-
- IExtensionPoint editorExtensions = null;
- IEditorChangeLogContrib editorContrib = null;
-
- // get editor which is stored in preference.
- IPreferenceStore store = ChangelogPlugin.getDefault()
- .getPreferenceStore();
- String pref_Editor = store
- .getString("IChangeLogConstants.DEFAULT_EDITOR"); // $NON-NLS-1$
-
- editorExtensions = Platform.getExtensionRegistry().getExtensionPoint(
- "org.eclipse.linuxtools.changelog.core", "editorContribution"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (editorExtensions != null) {
- IConfigurationElement[] elements = editorExtensions
- .getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getName().equals("editor") // $NON-NLS-1$
- && (elements[i].getAttribute("name").equals(pref_Editor))) { //$NON-NLS-1$
-
- try {
- IConfigurationElement bob = elements[i];
- editorContrib = (IEditorChangeLogContrib) bob
- .createExecutableExtension("class"); // $NON-NLS-1$
-
- editorContrib.setTextEditor(this);
- return (SourceViewerConfiguration) editorContrib;
- } catch (CoreException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
- IStatus.ERROR, e.getMessage(), e));
- }
-
- }
- }
- }
-
- return null;
- }
-
- public ISourceViewer getMySourceViewer() {
- return this.getSourceViewer();
- }
-
- public boolean isForceNewLogEntry() {
- return forceNewLogEntry;
- }
-
- public void setForceNewLogEntry(boolean forceNewLogEntry) {
- this.forceNewLogEntry = forceNewLogEntry;
- }
+ private boolean forceNewLogEntry;
+
+ public ChangeLogEditor() {
+ super();
+
+ SourceViewerConfiguration config = getConfig();
+
+ if (config != null) {
+ setSourceViewerConfiguration(config);
+ } else {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
+ Messages.getString("ChangeLogEditor.ErrConfiguration"), // $NON-NLS-1$
+ new Exception(Messages.getString("ChangeLogEditor.ErrConfiguration")))); // $NON-NLS-1$
+ }
+
+ setDocumentProvider(new ChangeLogDocumentProvider());
+
+ }
+
+ /**
+ * Gets appropriate style editor from user pref.
+ *
+ * @return configuration for the Changelog editor
+ */
+
+ private SourceViewerConfiguration getConfig() {
+
+ IExtensionPoint editorExtensions = null;
+ IEditorChangeLogContrib editorContrib = null;
+
+ // get editor which is stored in preference.
+ IPreferenceStore store = ChangelogPlugin.getDefault()
+ .getPreferenceStore();
+ String pref_Editor = store
+ .getString("IChangeLogConstants.DEFAULT_EDITOR"); // $NON-NLS-1$
+
+ editorExtensions = Platform.getExtensionRegistry().getExtensionPoint(
+ "org.eclipse.linuxtools.changelog.core", "editorContribution"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (editorExtensions != null) {
+ IConfigurationElement[] elements = editorExtensions
+ .getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i].getName().equals("editor") // $NON-NLS-1$
+ && (elements[i].getAttribute("name").equals(pref_Editor))) { //$NON-NLS-1$
+
+ try {
+ IConfigurationElement bob = elements[i];
+ editorContrib = (IEditorChangeLogContrib) bob
+ .createExecutableExtension("class"); // $NON-NLS-1$
+
+ editorContrib.setTextEditor(this);
+ return (SourceViewerConfiguration) editorContrib;
+ } catch (CoreException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID,
+ IStatus.ERROR, e.getMessage(), e));
+ }
+
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public ISourceViewer getMySourceViewer() {
+ return this.getSourceViewer();
+ }
+
+ public boolean isForceNewLogEntry() {
+ return forceNewLogEntry;
+ }
+
+ public void setForceNewLogEntry(boolean forceNewLogEntry) {
+ this.forceNewLogEntry = forceNewLogEntry;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java
index 2fbc1a6d05..41f2548b91 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java
@@ -20,224 +20,224 @@ import org.eclipse.jface.text.formatter.IFormattingStrategy;
public class ChangeLogFormattingStrategy implements IFormattingStrategy {
- private static final String NEW_LINE_CHAR = "\n";
+ private static final String NEW_LINE_CHAR = "\n";
- private static final String WHITE_SPACE_CHAR = " ";
-
- private static final String TAB_SPACE_CHAR = "\t";
-
- @Override
- public String format(String content, boolean isLineStart,
- String indentation, int[] positions) {
+ private static final String WHITE_SPACE_CHAR = " ";
+
+ private static final String TAB_SPACE_CHAR = "\t";
+
+ @Override
+ public String format(String content, boolean isLineStart,
+ String indentation, int[] positions) {
- ArrayList<String> formattedWords = new ArrayList<>();
- int currentLineLength = indentation.length();
- boolean newLineBegin = true;
+ ArrayList<String> formattedWords = new ArrayList<>();
+ int currentLineLength = indentation.length();
+ boolean newLineBegin = true;
- String firstLine = "";
-
- // if first line is not from the start, ignore it
- if (!isLineStart) {
- int eol;
- if ((eol = content.indexOf('\n')) == content.length() - 1) {
- return content;
- } else {
- firstLine = content.substring(0, eol + 1);
- content = content.substring(eol + 1);
- }
- }
+ String firstLine = "";
+
+ // if first line is not from the start, ignore it
+ if (!isLineStart) {
+ int eol;
+ if ((eol = content.indexOf('\n')) == content.length() - 1) {
+ return content;
+ } else {
+ firstLine = content.substring(0, eol + 1);
+ content = content.substring(eol + 1);
+ }
+ }
- StringTokenizer candidateWords = new StringTokenizer(content,
- NEW_LINE_CHAR + WHITE_SPACE_CHAR + TAB_SPACE_CHAR, true);
+ StringTokenizer candidateWords = new StringTokenizer(content,
+ NEW_LINE_CHAR + WHITE_SPACE_CHAR + TAB_SPACE_CHAR, true);
- boolean seenFirstWord = false;
+ boolean seenFirstWord = false;
- boolean addedFirstNL = false;
- while (candidateWords.hasMoreTokens()) {
+ boolean addedFirstNL = false;
+ while (candidateWords.hasMoreTokens()) {
- String cword = candidateWords.nextToken();
+ String cword = candidateWords.nextToken();
- if (!seenFirstWord) {
+ if (!seenFirstWord) {
- if ((cword.indexOf(NEW_LINE_CHAR) < 0
- && cword.indexOf(WHITE_SPACE_CHAR) < 0 && cword
- .indexOf(TAB_SPACE_CHAR) < 0)) {
- seenFirstWord = true;
- } else {
- if (!addedFirstNL && cword.indexOf(NEW_LINE_CHAR) >= 0) {
- firstLine += "\n";
- addedFirstNL = true;
- }
- continue;
- }
-
- } else {
-
- if (cword.indexOf(NEW_LINE_CHAR) >= 0
- || cword.indexOf(WHITE_SPACE_CHAR) >= 0
- || cword.indexOf(TAB_SPACE_CHAR) >= 0) {
- continue;
- }
- }
-
- // if the word is date, start new line and include
- // names, email, then an empty line.
- if (isDate(cword)) {
-
- // see if we are in middle of line and
- // if so, start new line, else continue.
- if (!newLineBegin)
- formattedWords.add(NEW_LINE_CHAR);
-
- if (formattedWords.size() > 0)
- formattedWords.add(NEW_LINE_CHAR);
-
- // insert date
- formattedWords.add(cword + WHITE_SPACE_CHAR);
-
- // insert name
- cword = candidateWords.nextToken();
- while (!isEmail(cword)) {
-
- if (!cword.equals(WHITE_SPACE_CHAR) && !cword.equals(TAB_SPACE_CHAR) && !cword.equals(NEW_LINE_CHAR)) {
- formattedWords.add(WHITE_SPACE_CHAR + cword);
- }
-
-
- cword = candidateWords.nextToken();
- }
-
- // insert email
- formattedWords.add(WHITE_SPACE_CHAR + WHITE_SPACE_CHAR + cword + NEW_LINE_CHAR);
-
- // inserted header, so insert a empty line
- formattedWords.add(NEW_LINE_CHAR);
- newLineBegin = true;
- currentLineLength = indentation.length();
- continue;
- }
-
- // means beginning of file name, so whole filename should be
- // in one line.
- if (isStar(cword)) {
- // see if we are in middle of line and
- // if so, start new line, else continue.
- if (!newLineBegin) {
- formattedWords.add(NEW_LINE_CHAR);
- currentLineLength = indentation.length();
- }
-
- formattedWords.add(TAB_SPACE_CHAR + cword);
- currentLineLength += cword.length() + 1;
-
- // this should be path name
- cword = candidateWords.nextToken();
- cword = candidateWords.nextToken();
-
- formattedWords.add(WHITE_SPACE_CHAR + cword);
- currentLineLength += cword.length() + 1;
- newLineBegin = false;
- continue;
- }
-
- if (cword.startsWith("(")) {
-
- if (formattedWords.size() > 0)
- formattedWords.add(NEW_LINE_CHAR + TAB_SPACE_CHAR);
- else
- formattedWords.add(TAB_SPACE_CHAR);
-
- currentLineLength = 1;
- // add until closing bracket
-
- boolean skipMultiWhiteSpace = false;
-
- while (!cword.endsWith("):")) {
-
- if (cword.equals(WHITE_SPACE_CHAR) && !skipMultiWhiteSpace) {
- formattedWords.add(cword);
- currentLineLength += cword.length();
- skipMultiWhiteSpace = true;
- }
-
- if (!cword.equals(WHITE_SPACE_CHAR)
- && !cword.equals(NEW_LINE_CHAR)
- && !cword.equals(TAB_SPACE_CHAR)) {
- formattedWords.add(cword);
- currentLineLength += cword.length();
- skipMultiWhiteSpace = false;
- }
-
- cword = candidateWords.nextToken();
- }
- formattedWords.add(cword);
- currentLineLength += cword.length();
- newLineBegin = false;
-
- continue;
- }
-
- if (currentLineLength + cword.length() > 80) {
- formattedWords.add(NEW_LINE_CHAR + TAB_SPACE_CHAR + cword);
- currentLineLength = indentation.length() + cword.length();
- newLineBegin = false;
- } else {
- if (newLineBegin) {
- formattedWords.add(TAB_SPACE_CHAR);
- newLineBegin = false;
- } else {
- formattedWords.add(WHITE_SPACE_CHAR);
- }
- formattedWords.add(cword);
- currentLineLength += cword.length() + 1;
-
- }
- }
-
- String finalContent = "";
-
- for (String formattedWord: formattedWords) {
- finalContent +=formattedWord;
- }
-
- return firstLine + finalContent;
- }
-
- private boolean isDate(String inputStr) {
-
- // Set up patterns for looking for the next date in the changelog
- SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd");
-
- // Try to find next Date bounded changelog entry by parsing date
- // patterns
- // First start with an ISO date
- try {
- Date ad = isoDate.parse(inputStr);
- if (ad != null)
- return true;
- } catch (ParseException e) {
- // We don't really care on exception; it just means it could not
- // parse a date on that line
- }
- return false;
- }
-
- private boolean isEmail(String inputStr) {
- return inputStr.startsWith("<") && inputStr.endsWith(">");
- }
-
- private boolean isStar(String inputStr) {
- return inputStr.equals("*");
- }
-
- @Override
- public void formatterStarts(String initialIndentation) {
-
- }
-
- @Override
- public void formatterStops() {
-
- }
+ if ((cword.indexOf(NEW_LINE_CHAR) < 0
+ && cword.indexOf(WHITE_SPACE_CHAR) < 0 && cword
+ .indexOf(TAB_SPACE_CHAR) < 0)) {
+ seenFirstWord = true;
+ } else {
+ if (!addedFirstNL && cword.indexOf(NEW_LINE_CHAR) >= 0) {
+ firstLine += "\n";
+ addedFirstNL = true;
+ }
+ continue;
+ }
+
+ } else {
+
+ if (cword.indexOf(NEW_LINE_CHAR) >= 0
+ || cword.indexOf(WHITE_SPACE_CHAR) >= 0
+ || cword.indexOf(TAB_SPACE_CHAR) >= 0) {
+ continue;
+ }
+ }
+
+ // if the word is date, start new line and include
+ // names, email, then an empty line.
+ if (isDate(cword)) {
+
+ // see if we are in middle of line and
+ // if so, start new line, else continue.
+ if (!newLineBegin)
+ formattedWords.add(NEW_LINE_CHAR);
+
+ if (formattedWords.size() > 0)
+ formattedWords.add(NEW_LINE_CHAR);
+
+ // insert date
+ formattedWords.add(cword + WHITE_SPACE_CHAR);
+
+ // insert name
+ cword = candidateWords.nextToken();
+ while (!isEmail(cword)) {
+
+ if (!cword.equals(WHITE_SPACE_CHAR) && !cword.equals(TAB_SPACE_CHAR) && !cword.equals(NEW_LINE_CHAR)) {
+ formattedWords.add(WHITE_SPACE_CHAR + cword);
+ }
+
+
+ cword = candidateWords.nextToken();
+ }
+
+ // insert email
+ formattedWords.add(WHITE_SPACE_CHAR + WHITE_SPACE_CHAR + cword + NEW_LINE_CHAR);
+
+ // inserted header, so insert a empty line
+ formattedWords.add(NEW_LINE_CHAR);
+ newLineBegin = true;
+ currentLineLength = indentation.length();
+ continue;
+ }
+
+ // means beginning of file name, so whole filename should be
+ // in one line.
+ if (isStar(cword)) {
+ // see if we are in middle of line and
+ // if so, start new line, else continue.
+ if (!newLineBegin) {
+ formattedWords.add(NEW_LINE_CHAR);
+ currentLineLength = indentation.length();
+ }
+
+ formattedWords.add(TAB_SPACE_CHAR + cword);
+ currentLineLength += cword.length() + 1;
+
+ // this should be path name
+ cword = candidateWords.nextToken();
+ cword = candidateWords.nextToken();
+
+ formattedWords.add(WHITE_SPACE_CHAR + cword);
+ currentLineLength += cword.length() + 1;
+ newLineBegin = false;
+ continue;
+ }
+
+ if (cword.startsWith("(")) {
+
+ if (formattedWords.size() > 0)
+ formattedWords.add(NEW_LINE_CHAR + TAB_SPACE_CHAR);
+ else
+ formattedWords.add(TAB_SPACE_CHAR);
+
+ currentLineLength = 1;
+ // add until closing bracket
+
+ boolean skipMultiWhiteSpace = false;
+
+ while (!cword.endsWith("):")) {
+
+ if (cword.equals(WHITE_SPACE_CHAR) && !skipMultiWhiteSpace) {
+ formattedWords.add(cword);
+ currentLineLength += cword.length();
+ skipMultiWhiteSpace = true;
+ }
+
+ if (!cword.equals(WHITE_SPACE_CHAR)
+ && !cword.equals(NEW_LINE_CHAR)
+ && !cword.equals(TAB_SPACE_CHAR)) {
+ formattedWords.add(cword);
+ currentLineLength += cword.length();
+ skipMultiWhiteSpace = false;
+ }
+
+ cword = candidateWords.nextToken();
+ }
+ formattedWords.add(cword);
+ currentLineLength += cword.length();
+ newLineBegin = false;
+
+ continue;
+ }
+
+ if (currentLineLength + cword.length() > 80) {
+ formattedWords.add(NEW_LINE_CHAR + TAB_SPACE_CHAR + cword);
+ currentLineLength = indentation.length() + cword.length();
+ newLineBegin = false;
+ } else {
+ if (newLineBegin) {
+ formattedWords.add(TAB_SPACE_CHAR);
+ newLineBegin = false;
+ } else {
+ formattedWords.add(WHITE_SPACE_CHAR);
+ }
+ formattedWords.add(cword);
+ currentLineLength += cword.length() + 1;
+
+ }
+ }
+
+ String finalContent = "";
+
+ for (String formattedWord: formattedWords) {
+ finalContent +=formattedWord;
+ }
+
+ return firstLine + finalContent;
+ }
+
+ private boolean isDate(String inputStr) {
+
+ // Set up patterns for looking for the next date in the changelog
+ SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd");
+
+ // Try to find next Date bounded changelog entry by parsing date
+ // patterns
+ // First start with an ISO date
+ try {
+ Date ad = isoDate.parse(inputStr);
+ if (ad != null)
+ return true;
+ } catch (ParseException e) {
+ // We don't really care on exception; it just means it could not
+ // parse a date on that line
+ }
+ return false;
+ }
+
+ private boolean isEmail(String inputStr) {
+ return inputStr.startsWith("<") && inputStr.endsWith(">");
+ }
+
+ private boolean isStar(String inputStr) {
+ return inputStr.equals("*");
+ }
+
+ @Override
+ public void formatterStarts(String initialIndentation) {
+
+ }
+
+ @Override
+ public void formatterStops() {
+
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ColorManager.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ColorManager.java
index 861069d335..c00e41cc56 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ColorManager.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ColorManager.java
@@ -26,20 +26,20 @@ import org.eclipse.swt.widgets.Display;
*/
public class ColorManager {
- protected Map<RGB, Color> fColorTable = new HashMap<>(10);
+ protected Map<RGB, Color> fColorTable = new HashMap<>(10);
- public void dispose() {
- for (Color color: fColorTable.values()){
- color.dispose();
- }
- }
+ public void dispose() {
+ for (Color color: fColorTable.values()){
+ color.dispose();
+ }
+ }
- public Color getColor(RGB rgb) {
- Color color = fColorTable.get(rgb);
- if (color == null) {
- color = new Color(Display.getCurrent(), rgb);
- fColorTable.put(rgb, color);
- }
- return color;
- }
+ public Color getColor(RGB rgb) {
+ Color color = fColorTable.get(rgb);
+ if (color == null) {
+ color = new Color(Display.getCurrent(), rgb);
+ fColorTable.put(rgb, color);
+ }
+ return color;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java
index 756e2314ad..f0e111e548 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java
@@ -25,43 +25,43 @@ import org.eclipse.ui.PlatformUI;
*/
public class FileHyperlink implements IHyperlink {
- private IFile fileLoc;
+ private IFile fileLoc;
- private IRegion region;
+ private IRegion region;
- public FileHyperlink(IRegion regionIn, IFile fileIn) {
- fileLoc = fileIn;
- region = regionIn;
- }
+ public FileHyperlink(IRegion regionIn, IFile fileIn) {
+ fileLoc = fileIn;
+ region = regionIn;
+ }
- @Override
- public IRegion getHyperlinkRegion() {
- return region;
- }
+ @Override
+ public IRegion getHyperlinkRegion() {
+ return region;
+ }
- @Override
- public String getTypeLabel() {
- return null;
- }
+ @Override
+ public String getTypeLabel() {
+ return null;
+ }
- @Override
- public String getHyperlinkText() {
- return null;
- }
+ @Override
+ public String getHyperlinkText() {
+ return null;
+ }
- /**
- * Opens the hyperlink in new editor window.
- */
- @Override
- public void open() {
- IWorkbench ws = PlatformUI.getWorkbench();
- try {
- org.eclipse.ui.ide.IDE.openEditor(ws.getActiveWorkbenchWindow()
- .getActivePage(), fileLoc, true);
- } catch (PartInitException e) {
- e.printStackTrace();
+ /**
+ * Opens the hyperlink in new editor window.
+ */
+ @Override
+ public void open() {
+ IWorkbench ws = PlatformUI.getWorkbench();
+ try {
+ org.eclipse.ui.ide.IDE.openEditor(ws.getActiveWorkbenchWindow()
+ .getActivePage(), fileLoc, true);
+ } catch (PartInitException e) {
+ e.printStackTrace();
- }
+ }
- }
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java
index c673a26259..df6b6c7f55 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java
@@ -36,144 +36,144 @@ import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
* @author klee (Kyu Lee)
*/
public class GNUEditorConfiguration extends TextSourceViewerConfiguration implements
- IEditorChangeLogContrib, IEditorChangeLogContrib2 {
-
- public static final String CHANGELOG_PARTITIONING= "gnu_changelog_partitioning"; //$NON-NLS-1$
-
- private GNUElementScanner scanner;
-
- private ColorManager colorManager;
-
- private TextEditor parentEditor;
-
- /**
- * Prepares configuration.
- */
- public GNUEditorConfiguration() {
- this.colorManager = new ColorManager();
-
- }
-
- /**
- * Sets TextEditor that this configuration is going to be applied.
- */
- @Override
- public void setTextEditor(TextEditor editor) {
- parentEditor = editor;
- }
-
- /**
- * Get configured content types.
- *
- * @return array of configured content types.
- */
- @Override
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
- GNUPartitionScanner.CHANGELOG_EMAIL,
- GNUPartitionScanner.CHANGELOG_SRC_ENTRY};
- }
-
- private GNUElementScanner getChangeLogFileScanner() {
- if (scanner == null) {
- scanner = new GNUElementScanner(colorManager);
- scanner.setDefaultReturnToken(new Token(new TextAttribute(
- colorManager.getColor(IChangeLogColorConstants.TEXT))));
- }
- return scanner;
- }
-
- /**
- * Detects hyperlinks in GNU formatted changelogs.
- *
- * @return link detector for GNU format.
- */
- @Override
- public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
- if (sourceViewer == null)
- return null;
-
- return getRegisteredHyperlinkDetectors(sourceViewer);
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
- */
- @Override
- public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
- return CHANGELOG_PARTITIONING;
- }
-
- /**
- * Set content formatter. For ChangeLog, it just wraps lines.
- */
- @Override
- public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
-
- ContentFormatter cf = new ContentFormatter();
-
- // no partitions
- cf.enablePartitionAwareFormatting(false);
-
- ChangeLogFormattingStrategy cfs = new ChangeLogFormattingStrategy();
-
- cf.setFormattingStrategy(cfs, IDocument.DEFAULT_CONTENT_TYPE);
-
-
- return cf;
- }
-
-
- /**
- * Highlights GNU format changelog syntaxes.
- *
- * @return reconciler for GNU format changelog.
- */
- @Override
- public IPresentationReconciler getPresentationReconciler(
- ISourceViewer sourceViewer) {
- PresentationReconciler reconciler = new PresentationReconciler();
-
- DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getChangeLogFileScanner());
- reconciler.setDamager(dr, GNUPartitionScanner.CHANGELOG_EMAIL);
- reconciler.setRepairer(dr, GNUPartitionScanner.CHANGELOG_EMAIL);
-
- dr= new GNUFileEntryDamagerRepairer(getChangeLogFileScanner());
- reconciler.setDamager(dr, GNUPartitionScanner.CHANGELOG_SRC_ENTRY);
- reconciler.setRepairer(dr, GNUPartitionScanner.CHANGELOG_SRC_ENTRY);
-
- dr= new MultilineRuleDamagerRepairer(getChangeLogFileScanner());
- reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
- reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
- return reconciler;
- }
-
- /**
- * Perform documentation setup to set up partitioning.
- *
- * @param document to set up partitioning on.
- */
- @Override
- public void setup(IDocument document) {
- FastPartitioner partitioner =
- new FastPartitioner(
- new GNUPartitionScanner(),
- GNUPartitionScanner.CHANGELOG_PARTITION_TYPES);
- partitioner.connect(document);
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- extension3.setDocumentPartitioner(CHANGELOG_PARTITIONING, partitioner);
- } else {
- document.setDocumentPartitioner(partitioner);
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
- Map targets = super.getHyperlinkDetectorTargets(sourceViewer);
- targets.put("org.eclipse.changelog.editor.target", parentEditor); //$NON-NLS-1$
- targets.put("org.eclipse.ui.DefaultTextEditor", parentEditor); //$NON-NLS-1$
- return targets;
- }}
+ IEditorChangeLogContrib, IEditorChangeLogContrib2 {
+
+ public static final String CHANGELOG_PARTITIONING= "gnu_changelog_partitioning"; //$NON-NLS-1$
+
+ private GNUElementScanner scanner;
+
+ private ColorManager colorManager;
+
+ private TextEditor parentEditor;
+
+ /**
+ * Prepares configuration.
+ */
+ public GNUEditorConfiguration() {
+ this.colorManager = new ColorManager();
+
+ }
+
+ /**
+ * Sets TextEditor that this configuration is going to be applied.
+ */
+ @Override
+ public void setTextEditor(TextEditor editor) {
+ parentEditor = editor;
+ }
+
+ /**
+ * Get configured content types.
+ *
+ * @return array of configured content types.
+ */
+ @Override
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+ return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
+ GNUPartitionScanner.CHANGELOG_EMAIL,
+ GNUPartitionScanner.CHANGELOG_SRC_ENTRY};
+ }
+
+ private GNUElementScanner getChangeLogFileScanner() {
+ if (scanner == null) {
+ scanner = new GNUElementScanner(colorManager);
+ scanner.setDefaultReturnToken(new Token(new TextAttribute(
+ colorManager.getColor(IChangeLogColorConstants.TEXT))));
+ }
+ return scanner;
+ }
+
+ /**
+ * Detects hyperlinks in GNU formatted changelogs.
+ *
+ * @return link detector for GNU format.
+ */
+ @Override
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ if (sourceViewer == null)
+ return null;
+
+ return getRegisteredHyperlinkDetectors(sourceViewer);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ @Override
+ public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
+ return CHANGELOG_PARTITIONING;
+ }
+
+ /**
+ * Set content formatter. For ChangeLog, it just wraps lines.
+ */
+ @Override
+ public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
+
+ ContentFormatter cf = new ContentFormatter();
+
+ // no partitions
+ cf.enablePartitionAwareFormatting(false);
+
+ ChangeLogFormattingStrategy cfs = new ChangeLogFormattingStrategy();
+
+ cf.setFormattingStrategy(cfs, IDocument.DEFAULT_CONTENT_TYPE);
+
+
+ return cf;
+ }
+
+
+ /**
+ * Highlights GNU format changelog syntaxes.
+ *
+ * @return reconciler for GNU format changelog.
+ */
+ @Override
+ public IPresentationReconciler getPresentationReconciler(
+ ISourceViewer sourceViewer) {
+ PresentationReconciler reconciler = new PresentationReconciler();
+
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getChangeLogFileScanner());
+ reconciler.setDamager(dr, GNUPartitionScanner.CHANGELOG_EMAIL);
+ reconciler.setRepairer(dr, GNUPartitionScanner.CHANGELOG_EMAIL);
+
+ dr= new GNUFileEntryDamagerRepairer(getChangeLogFileScanner());
+ reconciler.setDamager(dr, GNUPartitionScanner.CHANGELOG_SRC_ENTRY);
+ reconciler.setRepairer(dr, GNUPartitionScanner.CHANGELOG_SRC_ENTRY);
+
+ dr= new MultilineRuleDamagerRepairer(getChangeLogFileScanner());
+ reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+ return reconciler;
+ }
+
+ /**
+ * Perform documentation setup to set up partitioning.
+ *
+ * @param document to set up partitioning on.
+ */
+ @Override
+ public void setup(IDocument document) {
+ FastPartitioner partitioner =
+ new FastPartitioner(
+ new GNUPartitionScanner(),
+ GNUPartitionScanner.CHANGELOG_PARTITION_TYPES);
+ partitioner.connect(document);
+ if (document instanceof IDocumentExtension3) {
+ IDocumentExtension3 extension3= (IDocumentExtension3) document;
+ extension3.setDocumentPartitioner(CHANGELOG_PARTITIONING, partitioner);
+ } else {
+ document.setDocumentPartitioner(partitioner);
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
+ Map targets = super.getHyperlinkDetectorTargets(sourceViewer);
+ targets.put("org.eclipse.changelog.editor.target", parentEditor); //$NON-NLS-1$
+ targets.put("org.eclipse.ui.DefaultTextEditor", parentEditor); //$NON-NLS-1$
+ return targets;
+ }}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUElementScanner.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUElementScanner.java
index 2d921b92f8..1707f941d8 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUElementScanner.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUElementScanner.java
@@ -16,94 +16,94 @@ import org.eclipse.jface.text.rules.*;
/**
* Recognizes GNU format changelog. Can be configured to return different types
* of tokens.
- *
+ *
* @author klee (Kyu Lee)
*/
public class GNUElementScanner extends RuleBasedScanner {
- public static final String FILE_NAME = "_file_name"; // $NON-NLS-1$
+ public static final String FILE_NAME = "_file_name"; // $NON-NLS-1$
public static final String TEXT = "_text_content"; // $NON-NLS-1$
- public static final String EMAIL = "_author_email"; // $NON-NLS-1$
- public static final String DATE = "_entry_date"; // $NON-NLS-1$
- public static final String AUTHOR = "_author_name"; // $NON-NLS-1$
- public static final String FUNC_NAME = "_function_name"; // $NON-NLS-1$
- public static final String OTHER = "_other"; // $NON-NLS-1$
- /**
- * Build a scanner for syntax highlighting.
- *
- * @param manager Color scheme to use.
- */
- public GNUElementScanner(ColorManager manager) {
- IToken file = new Token(new TextAttribute(manager
- .getColor(IChangeLogColorConstants.FILE_NAME)));
-
- IToken func = new Token(new TextAttribute(manager
- .getColor(IChangeLogColorConstants.FUNC_NAME)));
-
- IToken email = new Token(new TextAttribute(manager
- .getColor(IChangeLogColorConstants.EMAIL)));
-
- IToken other = new Token(new TextAttribute(manager
- .getColor(IChangeLogColorConstants.TEXT)));
-
- IRule[] rules = new IRule[3];
-
- // Add rule for file path
- rules[0] = new GNUFileEntryRule(file);
-
- // function
- rules[1] = new SingleLineRule("(", ")", func); // $NON-NLS-1$ // $NON-NLS-2$
- // email
- rules[2] = new SingleLineRule("<", ">\n", email); // $NON-NLS-1$ // $NON-NLS-2$
-
- setDefaultReturnToken(other);
-
- setRules(rules);
- }
-
- /**
- * Build a scanner for hyperlink.
- *
- */
- public GNUElementScanner() {
- IToken file = new Token(FILE_NAME);
-
- IToken func = new Token(FUNC_NAME);
-
- IToken email = new Token(EMAIL);
-
- IToken other = new Token(OTHER);
-
- IRule[] rules = new IRule[3];
-
- // Add rule for file path
- rules[0] = new GNUFileEntryRule(file);
-
- // function
- rules[1] = new SingleLineRule("(", "):", func); // $NON-NLS-1$ // $NON-NLS-2$
- // email
- rules[2]= new SingleLineRule("<", ">", email); // $NON-NLS-1$ // $NON-NLS-2$
-
- setDefaultReturnToken(other);
-
- setRules(rules);
- }
-
- /**
- * Get the file offset.
- *
- * @return the file offset.
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * Get the default token.
- *
- * @return the default token.
- */
- public IToken getDefaultToken() {
- return fDefaultReturnToken;
- }
+ public static final String EMAIL = "_author_email"; // $NON-NLS-1$
+ public static final String DATE = "_entry_date"; // $NON-NLS-1$
+ public static final String AUTHOR = "_author_name"; // $NON-NLS-1$
+ public static final String FUNC_NAME = "_function_name"; // $NON-NLS-1$
+ public static final String OTHER = "_other"; // $NON-NLS-1$
+ /**
+ * Build a scanner for syntax highlighting.
+ *
+ * @param manager Color scheme to use.
+ */
+ public GNUElementScanner(ColorManager manager) {
+ IToken file = new Token(new TextAttribute(manager
+ .getColor(IChangeLogColorConstants.FILE_NAME)));
+
+ IToken func = new Token(new TextAttribute(manager
+ .getColor(IChangeLogColorConstants.FUNC_NAME)));
+
+ IToken email = new Token(new TextAttribute(manager
+ .getColor(IChangeLogColorConstants.EMAIL)));
+
+ IToken other = new Token(new TextAttribute(manager
+ .getColor(IChangeLogColorConstants.TEXT)));
+
+ IRule[] rules = new IRule[3];
+
+ // Add rule for file path
+ rules[0] = new GNUFileEntryRule(file);
+
+ // function
+ rules[1] = new SingleLineRule("(", ")", func); // $NON-NLS-1$ // $NON-NLS-2$
+ // email
+ rules[2] = new SingleLineRule("<", ">\n", email); // $NON-NLS-1$ // $NON-NLS-2$
+
+ setDefaultReturnToken(other);
+
+ setRules(rules);
+ }
+
+ /**
+ * Build a scanner for hyperlink.
+ *
+ */
+ public GNUElementScanner() {
+ IToken file = new Token(FILE_NAME);
+
+ IToken func = new Token(FUNC_NAME);
+
+ IToken email = new Token(EMAIL);
+
+ IToken other = new Token(OTHER);
+
+ IRule[] rules = new IRule[3];
+
+ // Add rule for file path
+ rules[0] = new GNUFileEntryRule(file);
+
+ // function
+ rules[1] = new SingleLineRule("(", "):", func); // $NON-NLS-1$ // $NON-NLS-2$
+ // email
+ rules[2]= new SingleLineRule("<", ">", email); // $NON-NLS-1$ // $NON-NLS-2$
+
+ setDefaultReturnToken(other);
+
+ setRules(rules);
+ }
+
+ /**
+ * Get the file offset.
+ *
+ * @return the file offset.
+ */
+ public int getOffset() {
+ return fOffset;
+ }
+
+ /**
+ * Get the default token.
+ *
+ * @return the default token.
+ */
+ public IToken getDefaultToken() {
+ return fDefaultReturnToken;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryDamagerRepairer.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryDamagerRepairer.java
index 035271c177..95deab2bcb 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryDamagerRepairer.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryDamagerRepairer.java
@@ -18,26 +18,26 @@ import org.eclipse.jface.text.rules.ITokenScanner;
public class GNUFileEntryDamagerRepairer extends DefaultDamagerRepairer {
- /**
- * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
- * and is assumed to return only token that carry text attributes.
- *
- * @param scanner the token scanner to be used, may not be <code>null</code>
- */
- public GNUFileEntryDamagerRepairer(ITokenScanner scanner) {
- super(scanner);
- }
+ /**
+ * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
+ * and is assumed to return only token that carry text attributes.
+ *
+ * @param scanner the token scanner to be used, may not be <code>null</code>
+ */
+ public GNUFileEntryDamagerRepairer(ITokenScanner scanner) {
+ super(scanner);
+ }
- /*
- * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
- */
- @Override
- public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) {
- // In the case of a partition with multiline rules, we will punt to
- // reparse the entire partition because we don't know if the line being
- // edited is in the middle of an area covered by a multiline rule. In
- // such a case, we need to back up and find the start sequence of the
- // rule. It is easiest to just reparse the whole partition.
- return partition;
- }
+ /*
+ * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
+ */
+ @Override
+ public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) {
+ // In the case of a partition with multiline rules, we will punt to
+ // reparse the entire partition because we don't know if the line being
+ // edited is in the middle of an area covered by a multiline rule. In
+ // such a case, we need to back up and find the start sequence of the
+ // rule. It is easiest to just reparse the whole partition.
+ return partition;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java
index 539e8dba8f..a2c9d04193 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java
@@ -18,128 +18,128 @@ import org.eclipse.jface.text.rules.IWordDetector;
import org.eclipse.jface.text.rules.Token;
public class GNUFileEntryRule implements IPredicateRule {
- /**
- * The default token to be returned on success and if nothing else has been
- * specified.
- */
- protected IToken fileToken;
-
- protected IWordDetector fDetector = new IWordDetector() {
-
- @Override
- public boolean isWordPart(char c) {
- return Character.isJavaIdentifierPart(c) || c == '/' || c == '.' || c == '-';
- }
-
- @Override
- public boolean isWordStart(char c) {
- return Character.isJavaIdentifierPart(c) || c == '/' || c == '.';
- }
-
- };
-
- private boolean started = false;
-
- private IWhitespaceDetector fWsDetector = new IWhitespaceDetector() {
- @Override
- public boolean isWhitespace(char character) {
- return Character.isWhitespace(character);
- }
- };
-
- /** The column constraint */
- protected int fColumn = UNDEFINED;
-
- /** Internal setting for the un-initialized column constraint */
- protected static final int UNDEFINED = -1;
-
- /** Buffer used for pattern detection */
- private StringBuffer fBuffer = new StringBuffer();
-
- private String fStartingSequence = "* ";
-
- public GNUFileEntryRule(IToken fileToken) {
- this.fileToken = fileToken;
- }
-
- @Override
- public IToken evaluate(ICharacterScanner scanner) {
- return evaluate(scanner, false);
- }
-
- @Override
- public IToken evaluate(ICharacterScanner scanner, boolean resume) {
- int c = scanner.read();
- fBuffer.setLength(0);
- if (started == false) {
- for (int i = 0; i < fStartingSequence.length(); i++) {
- fBuffer.append((char) c);
- if (fStartingSequence.charAt(i) != c) {
- unreadBuffer(scanner);
- return Token.UNDEFINED;
- }
- c = scanner.read();
- }
- } else if (c == ',') { // we are continuing after a comma (perhaps we have multiple entries
- fBuffer.append((char) c);
- c = scanner.read();
- while (c != ICharacterScanner.EOF && fWsDetector.isWhitespace((char)c)) {
- fBuffer.append((char) c);
- c = scanner.read();
- }
- scanner.unread();
- return ((GNUElementScanner)scanner).getDefaultToken();
- }
-
- boolean haveFilePart = false;
-
- while (c != ICharacterScanner.EOF) {
- if (fDetector.isWordPart((char) c)) {
- fBuffer.append((char) c);
- haveFilePart = true;
- }
- else if (c == '\\') {
- fBuffer.append((char) c);
- c = scanner.read();
- if (c == ICharacterScanner.EOF) {
- unreadBuffer(scanner);
- return Token.UNDEFINED;
- }
- fBuffer.append((char) c);
- } else {
- break;
- }
- c = scanner.read();
- }
-
- if (!haveFilePart) {
- unreadBuffer(scanner);
- return Token.UNDEFINED;
- }
-
- if (c == ',')
- started = true;
-
- scanner.unread();
- return fileToken;
- }
-
- /**
- * Returns the characters in the buffer to the scanner.
- *
- * @param scanner
- * the scanner to be used
- */
- private void unreadBuffer(ICharacterScanner scanner) {
- for (int i = fBuffer.length() - 1; i >= 0; i--) {
- scanner.unread();
- }
- started = false;
- }
-
- @Override
- public IToken getSuccessToken() {
- return fileToken;
- }
+ /**
+ * The default token to be returned on success and if nothing else has been
+ * specified.
+ */
+ protected IToken fileToken;
+
+ protected IWordDetector fDetector = new IWordDetector() {
+
+ @Override
+ public boolean isWordPart(char c) {
+ return Character.isJavaIdentifierPart(c) || c == '/' || c == '.' || c == '-';
+ }
+
+ @Override
+ public boolean isWordStart(char c) {
+ return Character.isJavaIdentifierPart(c) || c == '/' || c == '.';
+ }
+
+ };
+
+ private boolean started = false;
+
+ private IWhitespaceDetector fWsDetector = new IWhitespaceDetector() {
+ @Override
+ public boolean isWhitespace(char character) {
+ return Character.isWhitespace(character);
+ }
+ };
+
+ /** The column constraint */
+ protected int fColumn = UNDEFINED;
+
+ /** Internal setting for the un-initialized column constraint */
+ protected static final int UNDEFINED = -1;
+
+ /** Buffer used for pattern detection */
+ private StringBuffer fBuffer = new StringBuffer();
+
+ private String fStartingSequence = "* ";
+
+ public GNUFileEntryRule(IToken fileToken) {
+ this.fileToken = fileToken;
+ }
+
+ @Override
+ public IToken evaluate(ICharacterScanner scanner) {
+ return evaluate(scanner, false);
+ }
+
+ @Override
+ public IToken evaluate(ICharacterScanner scanner, boolean resume) {
+ int c = scanner.read();
+ fBuffer.setLength(0);
+ if (started == false) {
+ for (int i = 0; i < fStartingSequence.length(); i++) {
+ fBuffer.append((char) c);
+ if (fStartingSequence.charAt(i) != c) {
+ unreadBuffer(scanner);
+ return Token.UNDEFINED;
+ }
+ c = scanner.read();
+ }
+ } else if (c == ',') { // we are continuing after a comma (perhaps we have multiple entries
+ fBuffer.append((char) c);
+ c = scanner.read();
+ while (c != ICharacterScanner.EOF && fWsDetector.isWhitespace((char)c)) {
+ fBuffer.append((char) c);
+ c = scanner.read();
+ }
+ scanner.unread();
+ return ((GNUElementScanner)scanner).getDefaultToken();
+ }
+
+ boolean haveFilePart = false;
+
+ while (c != ICharacterScanner.EOF) {
+ if (fDetector.isWordPart((char) c)) {
+ fBuffer.append((char) c);
+ haveFilePart = true;
+ }
+ else if (c == '\\') {
+ fBuffer.append((char) c);
+ c = scanner.read();
+ if (c == ICharacterScanner.EOF) {
+ unreadBuffer(scanner);
+ return Token.UNDEFINED;
+ }
+ fBuffer.append((char) c);
+ } else {
+ break;
+ }
+ c = scanner.read();
+ }
+
+ if (!haveFilePart) {
+ unreadBuffer(scanner);
+ return Token.UNDEFINED;
+ }
+
+ if (c == ',')
+ started = true;
+
+ scanner.unread();
+ return fileToken;
+ }
+
+ /**
+ * Returns the characters in the buffer to the scanner.
+ *
+ * @param scanner
+ * the scanner to be used
+ */
+ private void unreadBuffer(ICharacterScanner scanner) {
+ for (int i = fBuffer.length() - 1; i >= 0; i--) {
+ scanner.unread();
+ }
+ started = false;
+ }
+
+ @Override
+ public IToken getSuccessToken() {
+ return fileToken;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java
index 8779d30211..889a657fa3 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java
@@ -39,172 +39,172 @@ import org.eclipse.ui.texteditor.ITextEditor;
*/
public class GNUHyperlinkDetector extends AbstractHyperlinkDetector {
- private IPath documentLocation;
-
- public GNUHyperlinkDetector() {
- }
-
- /**
- * Creates a new URL hyperlink detector for GNU Format changelogs.
- *
- * NOTE: It assumes that the path this ChangeLog is in, is root
- * directory of path names in this ChangeLog.
- *
- * ex) ChangeLog is in /some/project and in ChangeLog, path names are like
- * abc/file.java ghi/file2.java
- *
- * then absolute path of file.java and file2.java are
- * /some/project/abc/file.java and /some/project/ghi/file2.java
- *
- * @param textViewer The text viewer in which to detect the hyperlink.
- */
- public GNUHyperlinkDetector(ITextViewer textViewer, TextEditor editor) {
- Assert.isNotNull(textViewer);
-
- documentLocation = getDocumentLocation(editor);
-
- }
-
- /**
- * Detector using RuleBasedScanner.
- */
- @Override
- public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
- IRegion region, boolean canShowMultipleHyperlinks) {
- if (documentLocation == null) {
- ITextEditor ed = (ITextEditor) this.getAdapter(ITextEditor.class);
- documentLocation = getDocumentLocation(ed);
- }
-
- IDocument thisDoc = textViewer.getDocument();
-
- GNUElementScanner scanner = new GNUElementScanner();
-
- scanner.setDefaultReturnToken(new Token("default"));
-
- ITypedRegion partitionInfo = null;
-
- try {
- partitionInfo = thisDoc.getPartition(region.getOffset());
- } catch (org.eclipse.jface.text.BadLocationException e1) {
- e1.printStackTrace();
- return null;
- }
-
- scanner.setRange(thisDoc, partitionInfo.getOffset(), partitionInfo.getLength());
-
- Token tmpToken = (Token) scanner.nextToken();
-
- String tokenStr = (String) tmpToken.getData();
-
- if (tokenStr == null) {
- return null;
- }
-
- // try to find non-default token containing region..if none, return null.
- while (region.getOffset() < scanner.getTokenOffset() ||
- region.getOffset() > scanner.getOffset() ||
- tokenStr.equals("default")) {
- tmpToken = (Token) scanner.nextToken();
- tokenStr = (String) tmpToken.getData();
- if (tokenStr == null)
- return null;
- }
-
- Region tokenRegion = new Region(scanner.getTokenOffset(), scanner
- .getTokenLength());
-
- String line = "";
- try {
- line = thisDoc
- .get(tokenRegion.getOffset(), tokenRegion.getLength());
- } catch (org.eclipse.jface.text.BadLocationException e1) {
- e1.printStackTrace();
- return null;
- }
-
- // process file link
- if (tokenStr.equals(GNUElementScanner.FILE_NAME)) {
-
- Region pathRegion = null;
-
- int lineOffset = 0;
-
- // cut "* " if necessary
- if (line.startsWith("* ")) {
- lineOffset = 2;
- line = line.substring(2);
- }
-// int trailingWhiteSpace;
-// if (((trailingWhiteSpace = line.indexOf(":")) > 0)
-// || ((trailingWhiteSpace = line.indexOf(" ")) > 0)) {
+ private IPath documentLocation;
+
+ public GNUHyperlinkDetector() {
+ }
+
+ /**
+ * Creates a new URL hyperlink detector for GNU Format changelogs.
+ *
+ * NOTE: It assumes that the path this ChangeLog is in, is root
+ * directory of path names in this ChangeLog.
+ *
+ * ex) ChangeLog is in /some/project and in ChangeLog, path names are like
+ * abc/file.java ghi/file2.java
+ *
+ * then absolute path of file.java and file2.java are
+ * /some/project/abc/file.java and /some/project/ghi/file2.java
+ *
+ * @param textViewer The text viewer in which to detect the hyperlink.
+ */
+ public GNUHyperlinkDetector(ITextViewer textViewer, TextEditor editor) {
+ Assert.isNotNull(textViewer);
+
+ documentLocation = getDocumentLocation(editor);
+
+ }
+
+ /**
+ * Detector using RuleBasedScanner.
+ */
+ @Override
+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
+ IRegion region, boolean canShowMultipleHyperlinks) {
+ if (documentLocation == null) {
+ ITextEditor ed = (ITextEditor) this.getAdapter(ITextEditor.class);
+ documentLocation = getDocumentLocation(ed);
+ }
+
+ IDocument thisDoc = textViewer.getDocument();
+
+ GNUElementScanner scanner = new GNUElementScanner();
+
+ scanner.setDefaultReturnToken(new Token("default"));
+
+ ITypedRegion partitionInfo = null;
+
+ try {
+ partitionInfo = thisDoc.getPartition(region.getOffset());
+ } catch (org.eclipse.jface.text.BadLocationException e1) {
+ e1.printStackTrace();
+ return null;
+ }
+
+ scanner.setRange(thisDoc, partitionInfo.getOffset(), partitionInfo.getLength());
+
+ Token tmpToken = (Token) scanner.nextToken();
+
+ String tokenStr = (String) tmpToken.getData();
+
+ if (tokenStr == null) {
+ return null;
+ }
+
+ // try to find non-default token containing region..if none, return null.
+ while (region.getOffset() < scanner.getTokenOffset() ||
+ region.getOffset() > scanner.getOffset() ||
+ tokenStr.equals("default")) {
+ tmpToken = (Token) scanner.nextToken();
+ tokenStr = (String) tmpToken.getData();
+ if (tokenStr == null)
+ return null;
+ }
+
+ Region tokenRegion = new Region(scanner.getTokenOffset(), scanner
+ .getTokenLength());
+
+ String line = "";
+ try {
+ line = thisDoc
+ .get(tokenRegion.getOffset(), tokenRegion.getLength());
+ } catch (org.eclipse.jface.text.BadLocationException e1) {
+ e1.printStackTrace();
+ return null;
+ }
+
+ // process file link
+ if (tokenStr.equals(GNUElementScanner.FILE_NAME)) {
+
+ Region pathRegion = null;
+
+ int lineOffset = 0;
+
+ // cut "* " if necessary
+ if (line.startsWith("* ")) {
+ lineOffset = 2;
+ line = line.substring(2);
+ }
+// int trailingWhiteSpace;
+// if (((trailingWhiteSpace = line.indexOf(":")) > 0)
+// || ((trailingWhiteSpace = line.indexOf(" ")) > 0)) {
//
-// line = line.substring(0, trailingWhiteSpace);
-// pathRegion = new Region(tokenRegion.getOffset() + lineOffset,
-// trailingWhiteSpace);
-// } else {
- pathRegion = new Region(tokenRegion.getOffset() + lineOffset, line
- .length());
-// }
+// line = line.substring(0, trailingWhiteSpace);
+// pathRegion = new Region(tokenRegion.getOffset() + lineOffset,
+// trailingWhiteSpace);
+// } else {
+ pathRegion = new Region(tokenRegion.getOffset() + lineOffset, line
+ .length());
+// }
- if (documentLocation == null)
- return null;
+ if (documentLocation == null)
+ return null;
- // Replace any escape characters added to name
- line = line.replaceAll("\\\\(.)", "$1");
+ // Replace any escape characters added to name
+ line = line.replaceAll("\\\\(.)", "$1");
- IPath filePath = documentLocation.append(line);
+ IPath filePath = documentLocation.append(line);
- return new IHyperlink[] { new FileHyperlink(pathRegion,
- ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
- filePath)) };
+ return new IHyperlink[] { new FileHyperlink(pathRegion,
+ ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
+ filePath)) };
- }
+ }
- return null;
- }
+ return null;
+ }
- private IWorkspaceRoot getWorkspaceRoot() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
+ private IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
- /**
- * Get current directory that ChangeLog is in.
- *
- * @param currentEditor
- * @return path that this ChangeLog is in
- */
- private IPath getDocumentLocation(IEditorPart currentEditor) {
- IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
- String WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
- IEditorInput cc = currentEditor.getEditorInput();
+ /**
+ * Get current directory that ChangeLog is in.
+ *
+ * @param currentEditor
+ * @return path that this ChangeLog is in
+ */
+ private IPath getDocumentLocation(IEditorPart currentEditor) {
+ IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
+ String WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
+ IEditorInput cc = currentEditor.getEditorInput();
- if (cc instanceof IFileEditorInput) {
- IFileEditorInput test = (IFileEditorInput) cc;
- IFile loc = test.getFile();
+ if (cc instanceof IFileEditorInput) {
+ IFileEditorInput test = (IFileEditorInput) cc;
+ IFile loc = test.getFile();
- IPath docLoc = loc.getLocation();
- docLoc = docLoc.removeLastSegments(1);
- return docLoc;
+ IPath docLoc = loc.getLocation();
+ docLoc = docLoc.removeLastSegments(1);
+ return docLoc;
- }
+ }
- if ((cc instanceof SyncInfoCompareInput)
- || (cc instanceof CompareEditorInput)) {
+ if ((cc instanceof SyncInfoCompareInput)
+ || (cc instanceof CompareEditorInput)) {
- CompareEditorInput test = (CompareEditorInput) cc;
- if (test.getCompareResult() == null)
- return null;
+ CompareEditorInput test = (CompareEditorInput) cc;
+ if (test.getCompareResult() == null)
+ return null;
- IPath docLoc = new Path(WorkspaceRoot
- + test.getCompareResult().toString());
- docLoc = docLoc.removeLastSegments(1);
- return docLoc;
+ IPath docLoc = new Path(WorkspaceRoot
+ + test.getCompareResult().toString());
+ docLoc = docLoc.removeLastSegments(1);
+ return docLoc;
- }
+ }
- return null;
- }
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUPartitionScanner.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUPartitionScanner.java
index d29dd770c5..c479fd8978 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUPartitionScanner.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUPartitionScanner.java
@@ -20,31 +20,31 @@ import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
public class GNUPartitionScanner extends RuleBasedPartitionScanner {
- // We partition into sections we want to parse from the beginning every time
- // a change occurs within the area. In this case, we are only interested in
- // email entries which are surrounded by < and > and source entries which
- // have one or more file names which may extend across lines.
- public static final String CHANGELOG_EMAIL = "changelog_email"; //$NON-NLS-1$
- public static final String CHANGELOG_SRC_ENTRY = "changelog_src_entry"; //$NON-NLS-1$
- public static final String[] CHANGELOG_PARTITION_TYPES=
- new String[] { CHANGELOG_EMAIL, CHANGELOG_SRC_ENTRY };
-
- /**
- * Creates the partitioner and sets up the appropriate rules.
- */
- public GNUPartitionScanner() {
- super();
-
- List<IPredicateRule> rules= new ArrayList<>();
- Token email = new Token(CHANGELOG_EMAIL);
- Token srcEntry = new Token(CHANGELOG_SRC_ENTRY);
-
- rules.add(new SingleLineRule("<", ">", email, '\\'));
- rules.add(new MultiLineRule("* ", ":", srcEntry, '\\', true));
-
- IPredicateRule[] result= new IPredicateRule[rules.size()];
- rules.toArray(result);
- setPredicateRules(result);
- }
+ // We partition into sections we want to parse from the beginning every time
+ // a change occurs within the area. In this case, we are only interested in
+ // email entries which are surrounded by < and > and source entries which
+ // have one or more file names which may extend across lines.
+ public static final String CHANGELOG_EMAIL = "changelog_email"; //$NON-NLS-1$
+ public static final String CHANGELOG_SRC_ENTRY = "changelog_src_entry"; //$NON-NLS-1$
+ public static final String[] CHANGELOG_PARTITION_TYPES=
+ new String[] { CHANGELOG_EMAIL, CHANGELOG_SRC_ENTRY };
+
+ /**
+ * Creates the partitioner and sets up the appropriate rules.
+ */
+ public GNUPartitionScanner() {
+ super();
+
+ List<IPredicateRule> rules= new ArrayList<>();
+ Token email = new Token(CHANGELOG_EMAIL);
+ Token srcEntry = new Token(CHANGELOG_SRC_ENTRY);
+
+ rules.add(new SingleLineRule("<", ">", email, '\\'));
+ rules.add(new MultiLineRule("* ", ":", srcEntry, '\\', true));
+
+ IPredicateRule[] result= new IPredicateRule[rules.size()];
+ rules.toArray(result);
+ setPredicateRules(result);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/IChangeLogColorConstants.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/IChangeLogColorConstants.java
index 28d5cf5137..10eae4e6c4 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/IChangeLogColorConstants.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/IChangeLogColorConstants.java
@@ -14,20 +14,20 @@ import org.eclipse.swt.graphics.RGB;
/**
* Color scheme to use for syntax highlighting.
- *
+ *
* @author klee (Kyu Lee)
- *
+ *
*/
public interface IChangeLogColorConstants {
- RGB FILE_NAME = new RGB(128, 0, 0);
+ RGB FILE_NAME = new RGB(128, 0, 0);
- RGB FUNC_NAME = new RGB(0, 128, 0);
+ RGB FUNC_NAME = new RGB(0, 128, 0);
- RGB TEXT = new RGB(0, 0, 0);
+ RGB TEXT = new RGB(0, 0, 0);
- RGB EMAIL = new RGB(0, 0, 128);
+ RGB EMAIL = new RGB(0, 0, 128);
- RGB DATE = new RGB(64, 64, 0);
+ RGB DATE = new RGB(64, 64, 0);
- RGB AUTHOR = new RGB(0, 64, 64);
+ RGB AUTHOR = new RGB(0, 64, 64);
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/MultilineRuleDamagerRepairer.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/MultilineRuleDamagerRepairer.java
index d56d77d8de..b3d100b3cb 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/MultilineRuleDamagerRepairer.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/MultilineRuleDamagerRepairer.java
@@ -17,29 +17,29 @@ import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.ITokenScanner;
public class MultilineRuleDamagerRepairer extends DefaultDamagerRepairer {
-
-
- /**
- * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
- * and is assumed to return only token that carry text attributes.
- *
- * @param scanner the token scanner to be used, may not be <code>null</code>
- */
- public MultilineRuleDamagerRepairer(ITokenScanner scanner) {
- super(scanner);
- }
- /*
- * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
- */
- @Override
- public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) {
- // In the case of a partition with multiline rules, we will punt to
- // reparse the entire partition because we don't know if the line being
- // edited is in the middle of an area covered by a multiline rule. In
- // such a case, we need to back up and find the start sequence of the
- // rule. It is easiest to just reparse the whole partition.
- return partition;
- }
-
+
+ /**
+ * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
+ * and is assumed to return only token that carry text attributes.
+ *
+ * @param scanner the token scanner to be used, may not be <code>null</code>
+ */
+ public MultilineRuleDamagerRepairer(ITokenScanner scanner) {
+ super(scanner);
+ }
+
+ /*
+ * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
+ */
+ @Override
+ public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) {
+ // In the case of a partition with multiline rules, we will punt to
+ // reparse the entire partition because we don't know if the line being
+ // edited is in the middle of an area covered by a multiline rule. In
+ // such a case, we need to back up and find the start sequence of the
+ // rule. It is easiest to just reparse the whole partition.
+ return partition;
+ }
+
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java
index 0ef4f965d9..8ed9be02c8 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java
@@ -37,374 +37,374 @@ import org.eclipse.ui.texteditor.ITextEditor;
*/
public class GNUFormat implements IFormatterChangeLogContrib {
- final String line_sep = System.getProperty("line.separator"); //$NON-NLS-1$
-
- final static String TAB = "\t"; // $NON-NLS-1$
-
-
- @Override
- public String formatDateLine(String authorName, String authorEmail) {
- String detail = returnDate() + " " + //$NON-NLS-1$
- authorName + " " + "<" + authorEmail + ">" + line_sep + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- line_sep;
- return detail;
- }
-
-
- @Override
- public String mergeChangelog(String dateLine, String functionGuess,String defaultContent,
- IEditorPart changelog, String changeLogLocation, String fileLocation) {
-
- String fileDetail = formatFileDetail(changeLogLocation, fileLocation);
- IDocument changelog_doc = getDocument(changelog);
- String function = formatFunction(functionGuess);
- boolean multipleEntrySuccess = false;
- boolean forceNewEntry = false;
- String functionSpacer = " "; // $NON-NLS-1$
- if (function.equals(": ")) // $NON-NLS-1$
- functionSpacer = ""; // $NON-NLS-1$
-
- /* Fix Bz #366854. Make sure that forceNewEntry is used only
- * once and then cleared even when the ChangeLog is empty to start with.
- */
- if(changelog instanceof ChangeLogEditor) {
- ChangeLogEditor editor = (ChangeLogEditor)changelog;
- forceNewEntry = editor.isForceNewLogEntry();
- editor.setForceNewLogEntry(false);
- }
-
- if (changelog_doc.getLength() > 0) {
-
- int offset_start = findChangeLogEntry(changelog_doc, dateLine);
- int offset_end = dateLine.length();
- boolean foundFunction = false;
- //if the prepare change action determines it requires a new entry, we force
- //a new entry by changing the offset_start and change the corresponding field
- //of the editor back to false to prevent subsequent function change log being
- //written to a new entry again.
- if (forceNewEntry)
- offset_start = -1;
-
- if (offset_start != -1) {
- int nextChangeEntry = findChangeLogPattern(changelog_doc,
- offset_start + dateLine.length());
- int functLogEntry = offset_start + dateLine.length();
-
- while (functLogEntry < nextChangeEntry) {
- int line_length = 0;
- String entry = ""; // $NON-NLS-1$
- try {
- line_length = changelog_doc
- .getLineOfOffset(functLogEntry);
- entry = changelog_doc.get(functLogEntry, changelog_doc
- .getLineLength(line_length));
- } catch (BadLocationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // Look to see if entry already exists for file (will be preceded by "*")
- if (entry.lastIndexOf("* " + fileDetail) > 0) {
- foundFunction = true;
- // Check for the case where the default content (e.g. new or removed file)
- // is being caught again because user has prepared the ChangeLog more than once.
- // In such a case, just return. We don't need to repeat ourselves.
- if (defaultContent.length() > 0 && entry.lastIndexOf(defaultContent) > 0) {
- return ""; // $NON-NLS-1$
- }
- int nextFunctLoc = functLogEntry + fileDetail.length() + 2;
- String nextFunc = ""; // $NON-NLS-1$
- try {
- nextFunc = changelog_doc.get(nextFunctLoc,
- nextChangeEntry - nextFunctLoc);
- } catch (BadLocationException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- int foundFunc = nextFunc.indexOf("* "); // $NON-NLS-1$
- if (foundFunc > 0) {
- foundFunc--;
- try {
- while (changelog_doc.get(
- nextFunctLoc + foundFunc, 1).equals(
- "\t") // $NON-NLS-1$
- || changelog_doc.get(
- nextFunctLoc + foundFunc, 1)
- .equals("\n")) { // $NON-NLS-1$
- foundFunc--;
- }
- } catch (BadLocationException e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
- }
- functLogEntry = nextFunctLoc + foundFunc + 1;
- break;
- }
-
- }
- try {
- functLogEntry += changelog_doc
- .getLineLength(line_length);
- } catch (BadLocationException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- if (functLogEntry >= nextChangeEntry) {
- functLogEntry = nextChangeEntry - 1;
- try {
- // Get rid of some potential lines containing whitespace only.
- functLogEntry = removeWhitespaceOnlyLines(changelog_doc, functLogEntry);
- while (changelog_doc.get(functLogEntry, 1).equals("\n")) // $NON-NLS-1$
- functLogEntry--;
- } catch (BadLocationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- functLogEntry++;
- }
-
- if (offset_start != -1) {
- if (foundFunction) {
- try {
- if (!function.equals(": ")) // $NON-NLS-1$
- changelog_doc.replace(functLogEntry, 0, "\n" + TAB // $NON-NLS-1$
- + function + " "); // $NON-NLS-1$
- else
- changelog_doc.replace(functLogEntry, 0, "\n" + TAB // $NON-NLS-1$
- );
- } catch (BadLocationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- ITextEditor edit = (ITextEditor) changelog;
- if (!function.equals(": ")) // $NON-NLS-1$
- edit.selectAndReveal(functLogEntry + function.length()
- + 3, 0);
- else
- edit.selectAndReveal(functLogEntry + function.length()
- , 0);
- multipleEntrySuccess = true;
- } else {
- try {
- changelog_doc.replace(offset_end, 0, TAB
- + "* " + fileDetail + functionSpacer // $NON-NLS-1$
- + function + functionSpacer + defaultContent + "\n"); //$NON-NLS-1$
- } catch (BadLocationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- ITextEditor edit = (ITextEditor) changelog;
- edit.selectAndReveal(offset_end + fileDetail.length()
- + function.length() +functionSpacer.length()*2 + 3 + defaultContent.length(), 0);
- multipleEntrySuccess = true;
- }
-
- }
- }
- }
-
- if (!multipleEntrySuccess) {
- try {
- if (changelog_doc.getLength() > 0)
- changelog_doc.replace(0, 0, "\n\n"); //$NON-NLS-1$
- changelog_doc.replace(0, 0, dateLine + TAB + "* " + fileDetail // $NON-NLS-1$
- + functionSpacer+function+functionSpacer+defaultContent);
-
- ITextEditor edit = (ITextEditor) changelog;
- edit.selectAndReveal(dateLine.length() + fileDetail.length()
- + function.length() + functionSpacer.length()*2 + 3 + defaultContent.length(), 0);
- } catch (BadLocationException e) {
- e.printStackTrace();
-
- }
-
- }
-
- return ""; // $NON-NLS-1$
-
- }
-
- /**
- * Remove any empty lines (i.e. lines only containing whitespace) between
- * <code>offset</code> and index backed-up until a '\n' preceded by some non-whitespace
- * character is reached. Whitespace will be merged to '\n\n'. For example
- * consider the following string "(main): Removed.\n\t\ \n\n\t\n" and
- * <code>offset</code> pointing to the last '\n'. This string would be
- * changed to: "(main): Removed.\n\n".
- *
- * @param changelog_doc
- * @param offset
- * @return The new offset.
- */
- private int removeWhitespaceOnlyLines(IDocument changelog_doc, int offset) {
- int initialOffset = offset;
- int backedUpOffset = offset;
- char charAtOffset;
- try {
- charAtOffset = changelog_doc.get(offset, 1).charAt(0);
- } catch (BadLocationException e) {
- e.printStackTrace();
- return offset;
- }
- while( backedUpOffset > 0 && (charAtOffset == '\n' || charAtOffset == '\t' || charAtOffset == ' ') ) {
- backedUpOffset--;
- try {
- charAtOffset = changelog_doc.get(backedUpOffset, 1).charAt(0);
- } catch (BadLocationException e) {
- e.printStackTrace();
- break;
- }
- }
- if ( (initialOffset - backedUpOffset) > 2 ) {
- try {
- int replaceLength = (initialOffset - backedUpOffset - 2);
- changelog_doc.replace(backedUpOffset + 2, replaceLength, "");
- // change offset accordingly
- offset -= replaceLength;
- } catch (BadLocationException e) {
- // exception should have been thrown earlier if that's
- // really a bad location...
- }
- }
- return offset;
- }
-
- private IWorkspaceRoot getWorkspaceRoot() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
- private String formatFileDetail(String changeLogLocation,
- String editorFileLocation) {
- // Format Path. Is a full path specified, or just file name?
- IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
- String WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
- String changeLogLocNoRoot = ""; // $NON-NLS-1$
- String editorFileLocNoRoot = ""; // $NON-NLS-1$
- if (changeLogLocation.lastIndexOf(WorkspaceRoot) >= 0) {
- changeLogLocNoRoot = changeLogLocation.substring(changeLogLocation
- .lastIndexOf(WorkspaceRoot)
- + WorkspaceRoot.length(), changeLogLocation.length());
- } else
- changeLogLocNoRoot = changeLogLocation;
-
- if (editorFileLocation.lastIndexOf(WorkspaceRoot) >= 0) {
- editorFileLocNoRoot = editorFileLocation.substring(
- editorFileLocation.lastIndexOf(WorkspaceRoot),
- editorFileLocation.lastIndexOf(WorkspaceRoot)
- + WorkspaceRoot.length());
- } else
- editorFileLocNoRoot = editorFileLocation;
-
- File changelogLocation = new File(changeLogLocNoRoot);
- File fileLocation = new File(editorFileLocNoRoot);
- File reversePath = fileLocation.getParentFile();
- String reversePathb = ""; // $NON-NLS-1$
-
- while (reversePath.getParentFile() != null) {
- if (reversePath.compareTo(changelogLocation.getParentFile()) == 0)
- break;
- reversePath = reversePath.getParentFile();
- }
- if (reversePath != null)
- reversePathb = fileLocation.toString().substring(
- reversePath.toString().length() + 1,
- fileLocation.toString().length());
- return reversePathb;
- }
-
- private int findChangeLogPattern(IDocument changelog_doc, int startOffset) {
- // find the "pattern" of a changelog entry. Not a specific one,
- // but one that "looks" like an entry
- int nextEntry = startOffset;
- int line_length = 0;
- String entry = ""; // $NON-NLS-1$
- while (nextEntry < changelog_doc.getLength()) {
- try {
- // Get the line of interest in the changelog document
- line_length = changelog_doc.getLineOfOffset(nextEntry);
- entry = changelog_doc.get(nextEntry, changelog_doc
- .getLineLength(line_length));
- // Attempt to find date pattern on line
- if (matchDatePattern(entry)) {
- //nextDate -= entry.length()+1;
- break;
- }
- // If no date matches, move to the next line
- nextEntry += changelog_doc.getLineLength(line_length);
- } catch (BadLocationException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
- .getMessage(), e
-
- ));
- }
-
- }
- return nextEntry;
- }
-
- private boolean matchDatePattern(String text) {
-
- // Set up patterns for looking for the next date in the changelog
- SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd"); // $NON-NLS-1$
-
- // Try to find next Date bounded changelog entry by parsing date patterns
- // First start with an ISO date
- try {
- Date ad = isoDate.parse(text);
- if (ad != null)
- return true;
- } catch (ParseException e) {
- // We don't really care on exception; it just means it could not parse a date on that line
- }
-
- return false;
- }
-
- private int findChangeLogEntry(IDocument changelog_doc, String entry) {
- FindReplaceDocumentAdapter findDocumentAptd = new FindReplaceDocumentAdapter(
- changelog_doc);
- IRegion region = null;
- try {
- region = findDocumentAptd.find(0, entry, true, false,/*whole world */ false, true);
- } catch (BadLocationException e) {
- ChangelogPlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
- .getMessage(), e
-
- ));
- return -1;
- }
- if (region != null) {
- // If the user's entry is not at the beginning of the file,
- // make a new entry.
- return region.getOffset() > 0 ? -1 : 0;
- }
- else
- return -1;
- }
-
- private String formatFunction(String function) {
-
- // If Function Guess is true, and Function Guess has found something
- if (function.length() > 0)
- return "(" + function + "):"; // $NON-NLS-1$ // $NON-NLS-2$
- else
- return ": "; //$NON-NLS-1$
-
- }
-
- public IDocument getDocument(IEditorPart currentEditor) {
- AbstractTextEditor castEditor = (AbstractTextEditor) currentEditor;
- IDocumentProvider provider = castEditor.getDocumentProvider();
-
- return provider.getDocument(castEditor.getEditorInput());
- }
-
- private String returnDate() {
- SimpleDateFormat date_Format = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
- return date_Format.format(new Date());
- }
+ final String line_sep = System.getProperty("line.separator"); //$NON-NLS-1$
+
+ final static String TAB = "\t"; // $NON-NLS-1$
+
+
+ @Override
+ public String formatDateLine(String authorName, String authorEmail) {
+ String detail = returnDate() + " " + //$NON-NLS-1$
+ authorName + " " + "<" + authorEmail + ">" + line_sep + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ line_sep;
+ return detail;
+ }
+
+
+ @Override
+ public String mergeChangelog(String dateLine, String functionGuess,String defaultContent,
+ IEditorPart changelog, String changeLogLocation, String fileLocation) {
+
+ String fileDetail = formatFileDetail(changeLogLocation, fileLocation);
+ IDocument changelog_doc = getDocument(changelog);
+ String function = formatFunction(functionGuess);
+ boolean multipleEntrySuccess = false;
+ boolean forceNewEntry = false;
+ String functionSpacer = " "; // $NON-NLS-1$
+ if (function.equals(": ")) // $NON-NLS-1$
+ functionSpacer = ""; // $NON-NLS-1$
+
+ /* Fix Bz #366854. Make sure that forceNewEntry is used only
+ * once and then cleared even when the ChangeLog is empty to start with.
+ */
+ if(changelog instanceof ChangeLogEditor) {
+ ChangeLogEditor editor = (ChangeLogEditor)changelog;
+ forceNewEntry = editor.isForceNewLogEntry();
+ editor.setForceNewLogEntry(false);
+ }
+
+ if (changelog_doc.getLength() > 0) {
+
+ int offset_start = findChangeLogEntry(changelog_doc, dateLine);
+ int offset_end = dateLine.length();
+ boolean foundFunction = false;
+ //if the prepare change action determines it requires a new entry, we force
+ //a new entry by changing the offset_start and change the corresponding field
+ //of the editor back to false to prevent subsequent function change log being
+ //written to a new entry again.
+ if (forceNewEntry)
+ offset_start = -1;
+
+ if (offset_start != -1) {
+ int nextChangeEntry = findChangeLogPattern(changelog_doc,
+ offset_start + dateLine.length());
+ int functLogEntry = offset_start + dateLine.length();
+
+ while (functLogEntry < nextChangeEntry) {
+ int line_length = 0;
+ String entry = ""; // $NON-NLS-1$
+ try {
+ line_length = changelog_doc
+ .getLineOfOffset(functLogEntry);
+ entry = changelog_doc.get(functLogEntry, changelog_doc
+ .getLineLength(line_length));
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // Look to see if entry already exists for file (will be preceded by "*")
+ if (entry.lastIndexOf("* " + fileDetail) > 0) {
+ foundFunction = true;
+ // Check for the case where the default content (e.g. new or removed file)
+ // is being caught again because user has prepared the ChangeLog more than once.
+ // In such a case, just return. We don't need to repeat ourselves.
+ if (defaultContent.length() > 0 && entry.lastIndexOf(defaultContent) > 0) {
+ return ""; // $NON-NLS-1$
+ }
+ int nextFunctLoc = functLogEntry + fileDetail.length() + 2;
+ String nextFunc = ""; // $NON-NLS-1$
+ try {
+ nextFunc = changelog_doc.get(nextFunctLoc,
+ nextChangeEntry - nextFunctLoc);
+ } catch (BadLocationException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ int foundFunc = nextFunc.indexOf("* "); // $NON-NLS-1$
+ if (foundFunc > 0) {
+ foundFunc--;
+ try {
+ while (changelog_doc.get(
+ nextFunctLoc + foundFunc, 1).equals(
+ "\t") // $NON-NLS-1$
+ || changelog_doc.get(
+ nextFunctLoc + foundFunc, 1)
+ .equals("\n")) { // $NON-NLS-1$
+ foundFunc--;
+ }
+ } catch (BadLocationException e2) {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ }
+ functLogEntry = nextFunctLoc + foundFunc + 1;
+ break;
+ }
+
+ }
+ try {
+ functLogEntry += changelog_doc
+ .getLineLength(line_length);
+ } catch (BadLocationException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ if (functLogEntry >= nextChangeEntry) {
+ functLogEntry = nextChangeEntry - 1;
+ try {
+ // Get rid of some potential lines containing whitespace only.
+ functLogEntry = removeWhitespaceOnlyLines(changelog_doc, functLogEntry);
+ while (changelog_doc.get(functLogEntry, 1).equals("\n")) // $NON-NLS-1$
+ functLogEntry--;
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ functLogEntry++;
+ }
+
+ if (offset_start != -1) {
+ if (foundFunction) {
+ try {
+ if (!function.equals(": ")) // $NON-NLS-1$
+ changelog_doc.replace(functLogEntry, 0, "\n" + TAB // $NON-NLS-1$
+ + function + " "); // $NON-NLS-1$
+ else
+ changelog_doc.replace(functLogEntry, 0, "\n" + TAB // $NON-NLS-1$
+ );
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ITextEditor edit = (ITextEditor) changelog;
+ if (!function.equals(": ")) // $NON-NLS-1$
+ edit.selectAndReveal(functLogEntry + function.length()
+ + 3, 0);
+ else
+ edit.selectAndReveal(functLogEntry + function.length()
+ , 0);
+ multipleEntrySuccess = true;
+ } else {
+ try {
+ changelog_doc.replace(offset_end, 0, TAB
+ + "* " + fileDetail + functionSpacer // $NON-NLS-1$
+ + function + functionSpacer + defaultContent + "\n"); //$NON-NLS-1$
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ ITextEditor edit = (ITextEditor) changelog;
+ edit.selectAndReveal(offset_end + fileDetail.length()
+ + function.length() +functionSpacer.length()*2 + 3 + defaultContent.length(), 0);
+ multipleEntrySuccess = true;
+ }
+
+ }
+ }
+ }
+
+ if (!multipleEntrySuccess) {
+ try {
+ if (changelog_doc.getLength() > 0)
+ changelog_doc.replace(0, 0, "\n\n"); //$NON-NLS-1$
+ changelog_doc.replace(0, 0, dateLine + TAB + "* " + fileDetail // $NON-NLS-1$
+ + functionSpacer+function+functionSpacer+defaultContent);
+
+ ITextEditor edit = (ITextEditor) changelog;
+ edit.selectAndReveal(dateLine.length() + fileDetail.length()
+ + function.length() + functionSpacer.length()*2 + 3 + defaultContent.length(), 0);
+ } catch (BadLocationException e) {
+ e.printStackTrace();
+
+ }
+
+ }
+
+ return ""; // $NON-NLS-1$
+
+ }
+
+ /**
+ * Remove any empty lines (i.e. lines only containing whitespace) between
+ * <code>offset</code> and index backed-up until a '\n' preceded by some non-whitespace
+ * character is reached. Whitespace will be merged to '\n\n'. For example
+ * consider the following string "(main): Removed.\n\t\ \n\n\t\n" and
+ * <code>offset</code> pointing to the last '\n'. This string would be
+ * changed to: "(main): Removed.\n\n".
+ *
+ * @param changelog_doc
+ * @param offset
+ * @return The new offset.
+ */
+ private int removeWhitespaceOnlyLines(IDocument changelog_doc, int offset) {
+ int initialOffset = offset;
+ int backedUpOffset = offset;
+ char charAtOffset;
+ try {
+ charAtOffset = changelog_doc.get(offset, 1).charAt(0);
+ } catch (BadLocationException e) {
+ e.printStackTrace();
+ return offset;
+ }
+ while( backedUpOffset > 0 && (charAtOffset == '\n' || charAtOffset == '\t' || charAtOffset == ' ') ) {
+ backedUpOffset--;
+ try {
+ charAtOffset = changelog_doc.get(backedUpOffset, 1).charAt(0);
+ } catch (BadLocationException e) {
+ e.printStackTrace();
+ break;
+ }
+ }
+ if ( (initialOffset - backedUpOffset) > 2 ) {
+ try {
+ int replaceLength = (initialOffset - backedUpOffset - 2);
+ changelog_doc.replace(backedUpOffset + 2, replaceLength, "");
+ // change offset accordingly
+ offset -= replaceLength;
+ } catch (BadLocationException e) {
+ // exception should have been thrown earlier if that's
+ // really a bad location...
+ }
+ }
+ return offset;
+ }
+
+ private IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ private String formatFileDetail(String changeLogLocation,
+ String editorFileLocation) {
+ // Format Path. Is a full path specified, or just file name?
+ IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
+ String WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
+ String changeLogLocNoRoot = ""; // $NON-NLS-1$
+ String editorFileLocNoRoot = ""; // $NON-NLS-1$
+ if (changeLogLocation.lastIndexOf(WorkspaceRoot) >= 0) {
+ changeLogLocNoRoot = changeLogLocation.substring(changeLogLocation
+ .lastIndexOf(WorkspaceRoot)
+ + WorkspaceRoot.length(), changeLogLocation.length());
+ } else
+ changeLogLocNoRoot = changeLogLocation;
+
+ if (editorFileLocation.lastIndexOf(WorkspaceRoot) >= 0) {
+ editorFileLocNoRoot = editorFileLocation.substring(
+ editorFileLocation.lastIndexOf(WorkspaceRoot),
+ editorFileLocation.lastIndexOf(WorkspaceRoot)
+ + WorkspaceRoot.length());
+ } else
+ editorFileLocNoRoot = editorFileLocation;
+
+ File changelogLocation = new File(changeLogLocNoRoot);
+ File fileLocation = new File(editorFileLocNoRoot);
+ File reversePath = fileLocation.getParentFile();
+ String reversePathb = ""; // $NON-NLS-1$
+
+ while (reversePath.getParentFile() != null) {
+ if (reversePath.compareTo(changelogLocation.getParentFile()) == 0)
+ break;
+ reversePath = reversePath.getParentFile();
+ }
+ if (reversePath != null)
+ reversePathb = fileLocation.toString().substring(
+ reversePath.toString().length() + 1,
+ fileLocation.toString().length());
+ return reversePathb;
+ }
+
+ private int findChangeLogPattern(IDocument changelog_doc, int startOffset) {
+ // find the "pattern" of a changelog entry. Not a specific one,
+ // but one that "looks" like an entry
+ int nextEntry = startOffset;
+ int line_length = 0;
+ String entry = ""; // $NON-NLS-1$
+ while (nextEntry < changelog_doc.getLength()) {
+ try {
+ // Get the line of interest in the changelog document
+ line_length = changelog_doc.getLineOfOffset(nextEntry);
+ entry = changelog_doc.get(nextEntry, changelog_doc
+ .getLineLength(line_length));
+ // Attempt to find date pattern on line
+ if (matchDatePattern(entry)) {
+ //nextDate -= entry.length()+1;
+ break;
+ }
+ // If no date matches, move to the next line
+ nextEntry += changelog_doc.getLineLength(line_length);
+ } catch (BadLocationException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
+ .getMessage(), e
+
+ ));
+ }
+
+ }
+ return nextEntry;
+ }
+
+ private boolean matchDatePattern(String text) {
+
+ // Set up patterns for looking for the next date in the changelog
+ SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd"); // $NON-NLS-1$
+
+ // Try to find next Date bounded changelog entry by parsing date patterns
+ // First start with an ISO date
+ try {
+ Date ad = isoDate.parse(text);
+ if (ad != null)
+ return true;
+ } catch (ParseException e) {
+ // We don't really care on exception; it just means it could not parse a date on that line
+ }
+
+ return false;
+ }
+
+ private int findChangeLogEntry(IDocument changelog_doc, String entry) {
+ FindReplaceDocumentAdapter findDocumentAptd = new FindReplaceDocumentAdapter(
+ changelog_doc);
+ IRegion region = null;
+ try {
+ region = findDocumentAptd.find(0, entry, true, false,/*whole world */ false, true);
+ } catch (BadLocationException e) {
+ ChangelogPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e
+ .getMessage(), e
+
+ ));
+ return -1;
+ }
+ if (region != null) {
+ // If the user's entry is not at the beginning of the file,
+ // make a new entry.
+ return region.getOffset() > 0 ? -1 : 0;
+ }
+ else
+ return -1;
+ }
+
+ private String formatFunction(String function) {
+
+ // If Function Guess is true, and Function Guess has found something
+ if (function.length() > 0)
+ return "(" + function + "):"; // $NON-NLS-1$ // $NON-NLS-2$
+ else
+ return ": "; //$NON-NLS-1$
+
+ }
+
+ public IDocument getDocument(IEditorPart currentEditor) {
+ AbstractTextEditor castEditor = (AbstractTextEditor) currentEditor;
+ IDocumentProvider provider = castEditor.getDocumentProvider();
+
+ return provider.getDocument(castEditor.getEditorInput());
+ }
+
+ private String returnDate() {
+ SimpleDateFormat date_Format = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
+ return date_Format.format(new Date());
+ }
} \ No newline at end of file
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ui/ChangeLogActionProvider.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ui/ChangeLogActionProvider.java
index db2990f2a0..79d40db6c1 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ui/ChangeLogActionProvider.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ui/ChangeLogActionProvider.java
@@ -20,32 +20,32 @@ import org.eclipse.ui.navigator.ICommonActionConstants;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
public class ChangeLogActionProvider extends CommonActionProvider {
- private Action exampleAction;
-
- @Override
- public void init(ICommonActionExtensionSite aSite) {
- super.init(aSite);
- exampleAction = new PrepareChangeLogAction() {
- @Override
- public void run() {
- setSelection((IStructuredSelection) getContext().getSelection());
- doRun();
- }
-
- };
-
- }
-
- @Override
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- menu.add(exampleAction);
- }
-
- @Override
- public void fillActionBars(IActionBars actionBars) {
-
- actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN,
- exampleAction);
- }
+ private Action exampleAction;
+
+ @Override
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ exampleAction = new PrepareChangeLogAction() {
+ @Override
+ public void run() {
+ setSelection((IStructuredSelection) getContext().getSelection());
+ doRun();
+ }
+
+ };
+
+ }
+
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+ menu.add(exampleAction);
+ }
+
+ @Override
+ public void fillActionBars(IActionBars actionBars) {
+
+ actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN,
+ exampleAction);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.cparser/src/org/eclipse/linuxtools/internal/changelog/parsers/CParser.java b/changelog/org.eclipse.linuxtools.changelog.cparser/src/org/eclipse/linuxtools/internal/changelog/parsers/CParser.java
index 496abe7117..72050762ac 100644
--- a/changelog/org.eclipse.linuxtools.changelog.cparser/src/org/eclipse/linuxtools/internal/changelog/parsers/CParser.java
+++ b/changelog/org.eclipse.linuxtools.changelog.cparser/src/org/eclipse/linuxtools/internal/changelog/parsers/CParser.java
@@ -44,171 +44,171 @@ import org.eclipse.ui.texteditor.AbstractTextEditor;
*/
public class CParser implements IParserChangeLogContrib {
- public CParser() {
- super();
- }
-
- /**
- * @see IParserChangeLogContrib#parseCurrentFunction(IEditorInput, int)
- */
- @Override
- public String parseCurrentFunction(IEditorInput input, int offset)
- throws CoreException {
-
- String currentElementName;
-
- if (input instanceof IFileEditorInput) {
- // Get the working copy and connect to input.
- IWorkingCopyManager manager = CUIPlugin.getDefault()
- .getWorkingCopyManager();
- manager.connect(input);
-
- // Retrieve the C/C++ Element in question.
- IWorkingCopy workingCopy = manager.getWorkingCopy(input);
- ICElement method = workingCopy.getElementAtOffset(offset);
-
- manager.disconnect(input);
-
- // no element selected
- if (method == null)
- return "";
-
- // Get the current element name, to test it.
- currentElementName = method.getElementName();
-
- // Element doesn't have a name. Can go no further.
- if (currentElementName == null) {
- // element doesn't have a name
- return "";
- }
-
- // Get the Element Type to test.
- int elementType = method.getElementType();
-
- switch (elementType) {
- case ICElement.C_FIELD:
- case ICElement.C_METHOD:
- case ICElement.C_FUNCTION:
- break;
- case ICElement.C_MODEL:
- return "";
-
- // So it's not a method, field, function, or model. Where are we?
- default:
- ICElement tmpMethodType;
- if (((tmpMethodType = method.getAncestor(ICElement.C_FUNCTION)) == null)
- && ((tmpMethodType = method.getAncestor(ICElement.C_METHOD)) == null)
- && ((tmpMethodType = method.getAncestor(ICElement.C_CLASS)) == null)) {
- return "";
- } else {
- // In a class, but not in a method. Return class name instead.
- method = tmpMethodType;
- currentElementName = method.getElementName();
- }
-
- }
-
- // Build all ancestor classes.
- // Append all ancestor class names to string
- ICElement tmpParent = method.getParent();
-
- while (tmpParent != null) {
- ICElement tmpParentClass = tmpParent.getAncestor(ICElement.C_CLASS);
- if (tmpParentClass != null) {
- String tmpParentClassName = tmpParentClass.getElementName();
- if (tmpParentClassName == null)
- return currentElementName;
- currentElementName = tmpParentClassName + "."
- + currentElementName;
- } else
- return currentElementName;
- tmpParent = tmpParentClass.getParent();
-
- }
- return currentElementName;
- }
- else if (input instanceof IStorageEditorInput) {
- // Get the working copy and connect to input.
- // don't follow inclusions
- currentElementName = "";
- IStorageEditorInput sei = (IStorageEditorInput)input;
- // don't follow inclusions
- IncludeFileContentProvider contentProvider = IncludeFileContentProvider.getEmptyFilesProvider();
-
- // empty scanner info
- IScannerInfo scanInfo= new ScannerInfo();
- IStorage ancestorStorage = sei.getStorage();
- if (ancestorStorage == null)
- return "";
- InputStream stream = ancestorStorage.getContents();
- byte buffer[] = new byte[100];
- String data = "";
- int read = 0;
- try {
- do {
- read = stream.read(buffer);
- if (read > 0) {
- String tmp = new String(buffer, 0, read);
- data = data.concat(tmp);
- }
- } while (read == 100);
- stream.close();
- } catch (IOException e) {
- // do nothing
- }
-
- FileContent content = FileContent.create("<text>", data.toCharArray()); //$NON-NLS-1$
-
- // determine the language
- boolean isSource[]= {false};
- ILanguage language= GPPLanguage.getDefault();
-
- try {
- IASTTranslationUnit ast;
- int options= isSource[0] ? ILanguage.OPTION_IS_SOURCE_UNIT : 0;
- ast= language.getASTTranslationUnit(content, scanInfo, contentProvider, null, options, ParserUtil.getParserLogService());
- IASTNodeSelector n = ast.getNodeSelector(null);
- IASTNode node = n.findFirstContainedNode(offset, 100);
- while (node != null && !(node instanceof IASTTranslationUnit)) {
- if (node instanceof IASTFunctionDefinition) {
- IASTFunctionDefinition fd = (IASTFunctionDefinition)node;
- IASTFunctionDeclarator d = fd.getDeclarator();
- currentElementName = new String(d.getName().getSimpleID());
- break;
- }
- node = node.getParent();
- }
-// System.out.println(currentElementName);
- } catch (CoreException exc) {
- currentElementName = "";
- CUIPlugin.log(exc);
- }
-
- return currentElementName;
- }
-
- return "";
- }
-
- /**
- * @see IParserChangeLogContrib#parseCurrentFunction(IEditorPart)
- */
- @Override
- public String parseCurrentFunction(IEditorPart editor) throws CoreException {
-
- // Check for correct editor type
- if (!(editor instanceof AbstractTextEditor))
- return "";
-
- // Get the editor, test selection and input.
- AbstractTextEditor a_editor = (AbstractTextEditor) editor;
- ITextSelection selection = (ITextSelection) (a_editor)
- .getSelectionProvider().getSelection();
- IEditorInput input = a_editor.getEditorInput();
-
- // Parse it and return the function.
- return parseCurrentFunction(input, selection.getOffset());
- }
+ public CParser() {
+ super();
+ }
+
+ /**
+ * @see IParserChangeLogContrib#parseCurrentFunction(IEditorInput, int)
+ */
+ @Override
+ public String parseCurrentFunction(IEditorInput input, int offset)
+ throws CoreException {
+
+ String currentElementName;
+
+ if (input instanceof IFileEditorInput) {
+ // Get the working copy and connect to input.
+ IWorkingCopyManager manager = CUIPlugin.getDefault()
+ .getWorkingCopyManager();
+ manager.connect(input);
+
+ // Retrieve the C/C++ Element in question.
+ IWorkingCopy workingCopy = manager.getWorkingCopy(input);
+ ICElement method = workingCopy.getElementAtOffset(offset);
+
+ manager.disconnect(input);
+
+ // no element selected
+ if (method == null)
+ return "";
+
+ // Get the current element name, to test it.
+ currentElementName = method.getElementName();
+
+ // Element doesn't have a name. Can go no further.
+ if (currentElementName == null) {
+ // element doesn't have a name
+ return "";
+ }
+
+ // Get the Element Type to test.
+ int elementType = method.getElementType();
+
+ switch (elementType) {
+ case ICElement.C_FIELD:
+ case ICElement.C_METHOD:
+ case ICElement.C_FUNCTION:
+ break;
+ case ICElement.C_MODEL:
+ return "";
+
+ // So it's not a method, field, function, or model. Where are we?
+ default:
+ ICElement tmpMethodType;
+ if (((tmpMethodType = method.getAncestor(ICElement.C_FUNCTION)) == null)
+ && ((tmpMethodType = method.getAncestor(ICElement.C_METHOD)) == null)
+ && ((tmpMethodType = method.getAncestor(ICElement.C_CLASS)) == null)) {
+ return "";
+ } else {
+ // In a class, but not in a method. Return class name instead.
+ method = tmpMethodType;
+ currentElementName = method.getElementName();
+ }
+
+ }
+
+ // Build all ancestor classes.
+ // Append all ancestor class names to string
+ ICElement tmpParent = method.getParent();
+
+ while (tmpParent != null) {
+ ICElement tmpParentClass = tmpParent.getAncestor(ICElement.C_CLASS);
+ if (tmpParentClass != null) {
+ String tmpParentClassName = tmpParentClass.getElementName();
+ if (tmpParentClassName == null)
+ return currentElementName;
+ currentElementName = tmpParentClassName + "."
+ + currentElementName;
+ } else
+ return currentElementName;
+ tmpParent = tmpParentClass.getParent();
+
+ }
+ return currentElementName;
+ }
+ else if (input instanceof IStorageEditorInput) {
+ // Get the working copy and connect to input.
+ // don't follow inclusions
+ currentElementName = "";
+ IStorageEditorInput sei = (IStorageEditorInput)input;
+ // don't follow inclusions
+ IncludeFileContentProvider contentProvider = IncludeFileContentProvider.getEmptyFilesProvider();
+
+ // empty scanner info
+ IScannerInfo scanInfo= new ScannerInfo();
+ IStorage ancestorStorage = sei.getStorage();
+ if (ancestorStorage == null)
+ return "";
+ InputStream stream = ancestorStorage.getContents();
+ byte buffer[] = new byte[100];
+ String data = "";
+ int read = 0;
+ try {
+ do {
+ read = stream.read(buffer);
+ if (read > 0) {
+ String tmp = new String(buffer, 0, read);
+ data = data.concat(tmp);
+ }
+ } while (read == 100);
+ stream.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+
+ FileContent content = FileContent.create("<text>", data.toCharArray()); //$NON-NLS-1$
+
+ // determine the language
+ boolean isSource[]= {false};
+ ILanguage language= GPPLanguage.getDefault();
+
+ try {
+ IASTTranslationUnit ast;
+ int options= isSource[0] ? ILanguage.OPTION_IS_SOURCE_UNIT : 0;
+ ast= language.getASTTranslationUnit(content, scanInfo, contentProvider, null, options, ParserUtil.getParserLogService());
+ IASTNodeSelector n = ast.getNodeSelector(null);
+ IASTNode node = n.findFirstContainedNode(offset, 100);
+ while (node != null && !(node instanceof IASTTranslationUnit)) {
+ if (node instanceof IASTFunctionDefinition) {
+ IASTFunctionDefinition fd = (IASTFunctionDefinition)node;
+ IASTFunctionDeclarator d = fd.getDeclarator();
+ currentElementName = new String(d.getName().getSimpleID());
+ break;
+ }
+ node = node.getParent();
+ }
+// System.out.println(currentElementName);
+ } catch (CoreException exc) {
+ currentElementName = "";
+ CUIPlugin.log(exc);
+ }
+
+ return currentElementName;
+ }
+
+ return "";
+ }
+
+ /**
+ * @see IParserChangeLogContrib#parseCurrentFunction(IEditorPart)
+ */
+ @Override
+ public String parseCurrentFunction(IEditorPart editor) throws CoreException {
+
+ // Check for correct editor type
+ if (!(editor instanceof AbstractTextEditor))
+ return "";
+
+ // Get the editor, test selection and input.
+ AbstractTextEditor a_editor = (AbstractTextEditor) editor;
+ ITextSelection selection = (ITextSelection) (a_editor)
+ .getSelectionProvider().getSelection();
+ IEditorInput input = a_editor.getEditorInput();
+
+ // Parse it and return the function.
+ return parseCurrentFunction(input, selection.getOffset());
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.doc/build-helper.xml b/changelog/org.eclipse.linuxtools.changelog.doc/build-helper.xml
index 83891d8fd1..0062c117ce 100644
--- a/changelog/org.eclipse.linuxtools.changelog.doc/build-helper.xml
+++ b/changelog/org.eclipse.linuxtools.changelog.doc/build-helper.xml
@@ -1,61 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="org.eclipse.linuxtools.changelog.doc" default="all">
- <description>
+ <description>
Generate Eclipse help content for the Linux Tools changelog user guide
</description>
- <property name="help.doc.url.base" value="http://wiki.eclipse.org" />
+ <property name="help.doc.url.base" value="http://wiki.eclipse.org" />
- <path id="tasks.classpath" path="bin" />
- <path id="wikitext.tasks.classpath">
- <!-- Replace dir with the dir you have wikitext installed into.-->
- <fileset dir="/usr/share/eclipse/dropins/mylyn/eclipse/plugins">
- <include name="org.eclipse.mylyn.wikitext.*core*.jar" />
- </fileset>
- </path>
+ <path id="tasks.classpath" path="bin" />
+ <path id="wikitext.tasks.classpath">
+ <!-- Replace dir with the dir you have wikitext installed into.-->
+ <fileset dir="/usr/share/eclipse/dropins/mylyn/eclipse/plugins">
+ <include name="org.eclipse.mylyn.wikitext.*core*.jar" />
+ </fileset>
+ </path>
- <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/internal/wikitext/mediawiki/core/tasks/tasks.properties" />
- <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties" />
+ <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/internal/wikitext/mediawiki/core/tasks/tasks.properties" />
+ <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties" />
- <target name="all" description="Generate Eclipse help content for the Linux Tools changelog user guide">
- <mediawiki-to-eclipse-help wikiBaseUrl="${help.doc.url.base}" title="ChangeLog Editor User Guide" formatoutput="true" dest="." templateExcludes="*eclipseproject*,Linux_Tools">
+ <target name="all" description="Generate Eclipse help content for the Linux Tools changelog user guide">
+ <mediawiki-to-eclipse-help wikiBaseUrl="${help.doc.url.base}" title="ChangeLog Editor User Guide" formatoutput="true" dest="." templateExcludes="*eclipseproject*,Linux_Tools">
- <path name="Linux_Tools_Project/ChangeLog/User_Guide" title="ChangeLog Editor User Guide" generateToc="false" />
- <stylesheet url="book.css" />
- <pageAppendum>
- = Updating This Document =
+ <path name="Linux_Tools_Project/ChangeLog/User_Guide" title="ChangeLog Editor User Guide" generateToc="false" />
+ <stylesheet url="book.css" />
+ <pageAppendum>
+ = Updating This Document =
- This document is maintained in a collaborative wiki. If you wish to update or modify this document please visit
- http://wiki.eclipse.org/Linux_Tools_Project/ChangeLog/User_Guide .
- </pageAppendum>
- </mediawiki-to-eclipse-help>
- <antcall target="test" />
- </target>
+ This document is maintained in a collaborative wiki. If you wish to update or modify this document please visit
+ http://wiki.eclipse.org/Linux_Tools_Project/ChangeLog/User_Guide .
+ </pageAppendum>
+ </mediawiki-to-eclipse-help>
+ <antcall target="test" />
+ </target>
- <target name="test" description="verify that all of the HTML files are well-formed XML">
- <echo level="info">
+ <target name="test" description="verify that all of the HTML files are well-formed XML">
+ <echo level="info">
Validating help content XML and HTML files: The Eclipse help system expects well-formed XML
-
+
If validation fails it is because either:
-
+
* the userguide source code is poorly formed, or
* the WikiText MediaWiki parser has a bug
-
+
Problems with userguide source are usually caused by improper use of HTML markup in the MediaWiki source,
or inadvertently starting a line with a space character (in MediaWiki this starts a preformatted block)
- </echo>
-
- <!--
- Don't bother with DTD validation: we only care if the files are well-formed.
- We therefore provide an empty DTD
- -->
- <echo file="tmp/__empty.dtd" message="" />
- <xmlvalidate lenient="true">
- <fileset dir="Linux_Tools_Project">
- <include name="**/*.html" />
- </fileset>
- <dtd publicid="-//W3C//DTD XHTML 1.0 Transitional//EN" location="${basedir}/tmp/__empty.dtd" />
- </xmlvalidate>
- <delete dir="tmp" />
- </target>
+ </echo>
+
+ <!--
+ Don't bother with DTD validation: we only care if the files are well-formed.
+ We therefore provide an empty DTD
+ -->
+ <echo file="tmp/__empty.dtd" message="" />
+ <xmlvalidate lenient="true">
+ <fileset dir="Linux_Tools_Project">
+ <include name="**/*.html" />
+ </fileset>
+ <dtd publicid="-//W3C//DTD XHTML 1.0 Transitional//EN" location="${basedir}/tmp/__empty.dtd" />
+ </xmlvalidate>
+ <delete dir="tmp" />
+ </target>
</project>
diff --git a/changelog/org.eclipse.linuxtools.changelog.doc/toc-doc.xml b/changelog/org.eclipse.linuxtools.changelog.doc/toc-doc.xml
index 53a2102920..e63c786aee 100644
--- a/changelog/org.eclipse.linuxtools.changelog.doc/toc-doc.xml
+++ b/changelog/org.eclipse.linuxtools.changelog.doc/toc-doc.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8' ?>
<toc topic="Linux_Tools_Project/ChangeLog/User_Guide/User-Guide.html" label="ChangeLog Editor User Guide">
-<link toc="toc.xml" />
+<link toc="toc.xml" />
<topic href="doc/notices.html" label="Legal"> </topic>
</toc>
diff --git a/changelog/org.eclipse.linuxtools.changelog.doc/toc.xml b/changelog/org.eclipse.linuxtools.changelog.doc/toc.xml
index ae39864308..14c002890a 100644
--- a/changelog/org.eclipse.linuxtools.changelog.doc/toc.xml
+++ b/changelog/org.eclipse.linuxtools.changelog.doc/toc.xml
@@ -1,14 +1,14 @@
<?xml version='1.0' encoding='utf-8' ?>
<toc topic="Linux_Tools_Project/ChangeLog/User_Guide/User-Guide.html" label="ChangeLog Editor User Guide">
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/User-Guide.html" label="ChangeLog Editor User Guide">
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/User-Guide.html" label="Overview"></topic>
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Preferences.html" label="ChangeLog Preferences"></topic>
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Editor.html" label="ChangeLog Editor"></topic>
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Plug-in-Functions.html" label="ChangeLog Plug-in Functions">
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Plug-in-Functions.html#Insert_ChangeLog" label="Insert ChangeLog"></topic>
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Plug-in-Functions.html#Prepare_ChangeLog" label="Prepare ChangeLog"></topic>
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Plug-in-Functions.html#Format_ChangeLog" label="Format ChangeLog"></topic>
- </topic>
- <topic href="Linux_Tools_Project/ChangeLog/User_Guide/Updating-This-Document.html" label="Updating This Document"></topic>
- </topic>
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/User-Guide.html" label="ChangeLog Editor User Guide">
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/User-Guide.html" label="Overview"></topic>
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Preferences.html" label="ChangeLog Preferences"></topic>
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Editor.html" label="ChangeLog Editor"></topic>
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Plug-in-Functions.html" label="ChangeLog Plug-in Functions">
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Plug-in-Functions.html#Insert_ChangeLog" label="Insert ChangeLog"></topic>
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Plug-in-Functions.html#Prepare_ChangeLog" label="Prepare ChangeLog"></topic>
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/ChangeLog-Plug-in-Functions.html#Format_ChangeLog" label="Format ChangeLog"></topic>
+ </topic>
+ <topic href="Linux_Tools_Project/ChangeLog/User_Guide/Updating-This-Document.html" label="Updating This Document"></topic>
+ </topic>
</toc> \ No newline at end of file
diff --git a/changelog/org.eclipse.linuxtools.changelog.javaparser/src/org/eclipse/linuxtools/internal/changelog/parsers/java/JavaParser.java b/changelog/org.eclipse.linuxtools.changelog.javaparser/src/org/eclipse/linuxtools/internal/changelog/parsers/java/JavaParser.java
index d10bbacef0..2d5be01fbe 100644
--- a/changelog/org.eclipse.linuxtools.changelog.javaparser/src/org/eclipse/linuxtools/internal/changelog/parsers/java/JavaParser.java
+++ b/changelog/org.eclipse.linuxtools.changelog.javaparser/src/org/eclipse/linuxtools/internal/changelog/parsers/java/JavaParser.java
@@ -30,137 +30,137 @@ import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
@SuppressWarnings("restriction")
public class JavaParser implements IParserChangeLogContrib {
- public static final String STATIC_INITIALIZER_NAME = "static initializer";
-
- /**
- * @see IParserChangeLogContrib#parseCurrentFunction(IEditorPart)
- */
- @Override
- public String parseCurrentFunction(IEditorInput input, int offset)
- throws CoreException {
-
- String currentElementName;
- int elementType;
-
- // Get the working copy and connect to input.
- IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
- manager.connect(input);
-
- // Retrieve the Java Element in question.
- // The following internal access is done because the getWorkingCopy()
- // method
- // for the WorkingCopyManager returns null for StorageEditorInput,
- // however,
- // there is a working copy available through the
- // ICompilationUnitDocumentProvider.
- ICompilationUnitDocumentProvider x = (ICompilationUnitDocumentProvider) JavaUI
- .getDocumentProvider();
- // Retrieve the Java Element in question.
- ICompilationUnit workingCopy = x.getWorkingCopy(input);
-
- if (workingCopy == null) {
- return "";
- }
-
- IJavaElement method = workingCopy.getElementAt(offset);
-
- manager.disconnect(input);
-
- // no element selected
- if (method == null) {
- return "";
- }
-
- // Get the current element name, to test it.
- currentElementName = method.getElementName();
-
- // Element doesn't have a name. Can go no further.
- if (currentElementName == null) {
- return "";
- }
-
- // Get the Element Type to test.
- elementType = method.getElementType();
-
- switch (elementType) {
- case IJavaElement.METHOD:
- case IJavaElement.FIELD:
- break;
- case IJavaElement.COMPILATION_UNIT:
- return "";
- case IJavaElement.INITIALIZER:
- return STATIC_INITIALIZER_NAME;
-
- // So it's not a method, field, type, or static initializer. Where
- // are we?
- default:
- IJavaElement tmpMethodType;
- if (((tmpMethodType = method.getAncestor(IJavaElement.METHOD)) == null)
- && ((tmpMethodType = method.getAncestor(IJavaElement.TYPE)) == null)) {
- return "";
- } else {
- // In a class, but not in a method. Return class name instead.
- method = tmpMethodType;
- currentElementName = method.getElementName();
- }
- }
-
- // Build all ancestor classes.
- // Append all ancestor class names to string
-
- IJavaElement tmpParent = method.getParent();
- boolean firstLoop = true;
-
- while (tmpParent != null) {
- IJavaElement tmpParentClass = tmpParent
- .getAncestor(IJavaElement.TYPE);
- if (tmpParentClass != null) {
- String tmpParentClassName = tmpParentClass.getElementName();
- if (tmpParentClassName == null) {
- return "";
- }
- currentElementName = tmpParentClassName + "."
- + currentElementName;
- } else {
- // cut root class name
- int rootClassPos = currentElementName.indexOf('.');
- if (rootClassPos >= 0) {
- currentElementName = currentElementName
- .substring(rootClassPos + 1);
- }
- if (firstLoop) {
- return "";
- } else {
- return currentElementName;
- }
- }
- tmpParent = tmpParentClass.getParent();
- firstLoop = false;
-
- }
-
- return "";
- }
-
- /**
- * @see IParserChangeLogContrib#parseCurrentFunction(IEditorInput, int)
- */
- @Override
- public String parseCurrentFunction(IEditorPart editor) throws CoreException {
-
- // Check for correct editor type
- if (!(editor instanceof AbstractDecoratedTextEditor)) {
- return "";
- }
-
- // Get the editor, test selection and input.
- AbstractDecoratedTextEditor java_editor = (AbstractDecoratedTextEditor) editor;
- ITextSelection selection = (ITextSelection) (java_editor
- .getSelectionProvider().getSelection());
- IEditorInput input = java_editor.getEditorInput();
-
- // Parse it and return the function.
- return parseCurrentFunction(input, selection.getOffset());
- }
+ public static final String STATIC_INITIALIZER_NAME = "static initializer";
+
+ /**
+ * @see IParserChangeLogContrib#parseCurrentFunction(IEditorPart)
+ */
+ @Override
+ public String parseCurrentFunction(IEditorInput input, int offset)
+ throws CoreException {
+
+ String currentElementName;
+ int elementType;
+
+ // Get the working copy and connect to input.
+ IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
+ manager.connect(input);
+
+ // Retrieve the Java Element in question.
+ // The following internal access is done because the getWorkingCopy()
+ // method
+ // for the WorkingCopyManager returns null for StorageEditorInput,
+ // however,
+ // there is a working copy available through the
+ // ICompilationUnitDocumentProvider.
+ ICompilationUnitDocumentProvider x = (ICompilationUnitDocumentProvider) JavaUI
+ .getDocumentProvider();
+ // Retrieve the Java Element in question.
+ ICompilationUnit workingCopy = x.getWorkingCopy(input);
+
+ if (workingCopy == null) {
+ return "";
+ }
+
+ IJavaElement method = workingCopy.getElementAt(offset);
+
+ manager.disconnect(input);
+
+ // no element selected
+ if (method == null) {
+ return "";
+ }
+
+ // Get the current element name, to test it.
+ currentElementName = method.getElementName();
+
+ // Element doesn't have a name. Can go no further.
+ if (currentElementName == null) {
+ return "";
+ }
+
+ // Get the Element Type to test.
+ elementType = method.getElementType();
+
+ switch (elementType) {
+ case IJavaElement.METHOD:
+ case IJavaElement.FIELD:
+ break;
+ case IJavaElement.COMPILATION_UNIT:
+ return "";
+ case IJavaElement.INITIALIZER:
+ return STATIC_INITIALIZER_NAME;
+
+ // So it's not a method, field, type, or static initializer. Where
+ // are we?
+ default:
+ IJavaElement tmpMethodType;
+ if (((tmpMethodType = method.getAncestor(IJavaElement.METHOD)) == null)
+ && ((tmpMethodType = method.getAncestor(IJavaElement.TYPE)) == null)) {
+ return "";
+ } else {
+ // In a class, but not in a method. Return class name instead.
+ method = tmpMethodType;
+ currentElementName = method.getElementName();
+ }
+ }
+
+ // Build all ancestor classes.
+ // Append all ancestor class names to string
+
+ IJavaElement tmpParent = method.getParent();
+ boolean firstLoop = true;
+
+ while (tmpParent != null) {
+ IJavaElement tmpParentClass = tmpParent
+ .getAncestor(IJavaElement.TYPE);
+ if (tmpParentClass != null) {
+ String tmpParentClassName = tmpParentClass.getElementName();
+ if (tmpParentClassName == null) {
+ return "";
+ }
+ currentElementName = tmpParentClassName + "."
+ + currentElementName;
+ } else {
+ // cut root class name
+ int rootClassPos = currentElementName.indexOf('.');
+ if (rootClassPos >= 0) {
+ currentElementName = currentElementName
+ .substring(rootClassPos + 1);
+ }
+ if (firstLoop) {
+ return "";
+ } else {
+ return currentElementName;
+ }
+ }
+ tmpParent = tmpParentClass.getParent();
+ firstLoop = false;
+
+ }
+
+ return "";
+ }
+
+ /**
+ * @see IParserChangeLogContrib#parseCurrentFunction(IEditorInput, int)
+ */
+ @Override
+ public String parseCurrentFunction(IEditorPart editor) throws CoreException {
+
+ // Check for correct editor type
+ if (!(editor instanceof AbstractDecoratedTextEditor)) {
+ return "";
+ }
+
+ // Get the editor, test selection and input.
+ AbstractDecoratedTextEditor java_editor = (AbstractDecoratedTextEditor) editor;
+ ITextSelection selection = (ITextSelection) (java_editor
+ .getSelectionProvider().getSelection());
+ IEditorInput input = java_editor.getEditorInput();
+
+ // Parse it and return the function.
+ return parseCurrentFunction(input, selection.getOffset());
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/pom.xml b/changelog/org.eclipse.linuxtools.changelog.tests/pom.xml
index f684b0d25c..30c86db3d6 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/pom.xml
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/pom.xml
@@ -36,7 +36,7 @@
</excludes>
<testSuite>org.eclipse.linuxtools.changelog.tests</testSuite>
<testClass>org.eclipse.linuxtools.changelog.core.tests.AllTests</testClass>
- <useUIHarness>true</useUIHarness>
+ <useUIHarness>true</useUIHarness>
<useUIThread>true</useUIThread>
<product>org.eclipse.platform.ide</product>
<dependencies>
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/formatters/tests/GNUFormatTest.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/formatters/tests/GNUFormatTest.java
index d44efd68c3..d8069b14c2 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/formatters/tests/GNUFormatTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/formatters/tests/GNUFormatTest.java
@@ -33,479 +33,479 @@ import org.eclipse.jface.text.IDocument;
public class GNUFormatTest {
- // The instance under test
- private GNUFormat gnuFormatter;
- // A faked project
- private ChangeLogTestProject project;
- // The IEditorPart corresponding to the ChangeLog file
- private IEditorPart changelogEditorPart = null;
-
- // Tokens for the GNU format
- private static final String TWO_SPACES = " ";
- private static final String SPACE = " ";
- private static final String TAB = "\t";
- private static final String LEFT_EMAIL_BRACKET = "<";
- private static final String RIGHT_EMAIL_BRACKET = ">";
- private static final String FILE_ENTRY_START_MARKER = "* ";
- private static final String FILE_ENTRY_END_MARKER = ": ";
- private static final String FUNCTION_START_MARKER = "(";
- private static final String FUNCTION_END_MARKER = ")";
- private static final String NEW_LINE = "\n";
-
- @Before
- public void setUp() throws Exception {
- gnuFormatter = new GNUFormat();
- project = new ChangeLogTestProject("GNUFormatterTest");
- }
-
- @After
- public void tearDown() throws Exception {
- // Most tests in this class use changelogEditorPart. In order to avoid
- // spill-over from previous runs, truncate content (i.e. manually set
- // content to the empty string).
- if (changelogEditorPart != null) { // testFormatDateLine does not use it
- AbstractTextEditor castEditor = (AbstractTextEditor) changelogEditorPart;
- IDocumentProvider iDocProvider = castEditor.getDocumentProvider();
- IDocument changelogContentDoc = iDocProvider.getDocument(castEditor.getEditorInput());
- changelogContentDoc.set(""); // empty content
- changelogEditorPart.doSave(null);
- // Also close open editor in order for default content to work.
- // I.e. avoid spill over from previous test runs
- closeEditor(changelogEditorPart);
- }
- project.getTestProject().delete(true, true, null); // dispose
- }
-
- /**
- * GNU ChangeLog style date lines are of the following format
- *
- * YYYY-MM-DD Author Name <author.email@domain.com>
- */
- @Test
- public void testFormatDateLine() {
- // Today's date in ISO format
- Calendar c = new GregorianCalendar();
- String isoDate = String.format("%1$tY-%1$tm-%1$td", c);
- String authorName = "William Shakespeare";
- String authorEmail = "william.shakespeare@medieval.com";
- final String expectedDateFormatting = isoDate +
- TWO_SPACES +
- authorName +
- TWO_SPACES +
- LEFT_EMAIL_BRACKET +
- authorEmail +
- RIGHT_EMAIL_BRACKET +
- "\n\n";
- assertEquals(expectedDateFormatting,
- gnuFormatter.formatDateLine(authorName, authorEmail));
- }
-
- /**
- * Assume the following initial content of ChangeLog:
- *
- * <code>
- * 2010-11-26 Severin Gehwolf <sgehwolf@redhat.com>
- *
- * * src/org/eclipse/linuxtools/changelog/parsers/java/HelloWorld.java (test): New Method\n\t\n
- * </code>
- *
- * Note the trailing new-line, tab, new-line combination. If another change in the same file but
- * in a different method (or function) is merged, the empty line containing a tab only should be
- * removed.
- *
- */
- @Test
- public void twoChangesInSameFileAreProperlyMergedWhenThereIsATrailingTabNewLine() throws Exception {
- // set date/author line
- String authorName = "Test Foo";
- String email = "test@example.com";
- final String dateLine = gnuFormatter.formatDateLine(authorName, email);
-
- // full absolute path to ChangeLog file (relative to project root)
- String changelogPath = "/" + project.getTestProject().getName() + "/path/to";
- final String changelogFilePath = changelogPath + "/ChangeLog";
-
- // entry file path (need overlap with changelogPath)
- String fileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
- final String entryFilePath = changelogPath + "/" + fileEntryRelPath;
-
- final String firstMethodName = "main";
- final String firstChangeComment = "Fix args parsing.";
- // Setup proper pre-existing content
- String content = dateLine + NEW_LINE + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
- fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
- firstMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
- firstChangeComment + NEW_LINE +
- TAB + NEW_LINE; // produces an empty line which should be removed
-
- assertNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
-
- // add a ChangeLog file to our test project
- InputStream newFileInputStream = new ByteArrayInputStream(
- content.getBytes());
- IFile changelogFile = project.addFileToProject( "/path/to", "ChangeLog",
- newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
-
- // Open a document and get the IEditorPart
- changelogEditorPart = EditorHelper.openEditor(changelogFile);
-
- // make sure changelog editor content is right before merging
- assertEquals(content, getContent(changelogEditorPart));
-
- final String secondMethodName = "toString";
-
- // Do the merge with the existing content
- gnuFormatter.mergeChangelog(dateLine, secondMethodName,
- "" /* no default content */, changelogEditorPart,
- changelogFilePath, entryFilePath);
-
- final String actualMergeResult = getContent(changelogEditorPart);
-
- // Expect trailing tab+newline combination to not show up in merge
- final String expectedResult = dateLine + NEW_LINE + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
- fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
- firstMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
- firstChangeComment + NEW_LINE + TAB + FUNCTION_START_MARKER +
- secondMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
- NEW_LINE + NEW_LINE;
- assertEquals(expectedResult, actualMergeResult);
- }
-
- /**
- * Test merge of two separate changes to an existing file within the same changelog entry.
- * I.e. test for
- *
- * * path/to/file (method1): First change.
- * (method2): Another change in same file but different function/method.
- */
- @Test
- public void twoChangesInSameFileAreProperlyMerged() throws Exception {
- // set date/author line
- String authorName = "Test Author";
- String email = "test@example.com";
- final String dateLine = gnuFormatter.formatDateLine(authorName, email);
-
- // full absolute path to ChangeLog file (relative to project root)
- String changelogPath = "/" + project.getTestProject().getName() + "/path/to";
- final String changelogFilePath = changelogPath + "/ChangeLog";
-
- // entry file path (need overlap with changelogPath)
- String fileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
- final String entryFilePath = changelogPath + "/" + fileEntryRelPath;
-
- final String firstMethodName = "main";
- final String firstChangeComment = "Fix args parsing.";
- // Setup proper pre-existing content
- String content = dateLine + NEW_LINE + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
- fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
- firstMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
- firstChangeComment + NEW_LINE;
-
- assertNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
-
- // add a ChangeLog file to our test project
- InputStream newFileInputStream = new ByteArrayInputStream(
- content.getBytes());
- IFile changelogFile = project.addFileToProject( "/path/to", "ChangeLog",
- newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
-
- // Open a document and get the IEditorPart
- changelogEditorPart = openEditor(changelogFile);
- // make sure changelog editor content is right before merging
- assertEquals(content, getContent(changelogEditorPart));
-
- final String secondMethodName = "toString";
-
- // Do the merge with the existing content
- gnuFormatter.mergeChangelog(dateLine, secondMethodName,
- "" /* no default content */, changelogEditorPart,
- changelogFilePath, entryFilePath);
-
- final String actualMergeResult = getContent(changelogEditorPart);
-
- final String expectedResult = dateLine + NEW_LINE + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
- fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
- firstMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
- firstChangeComment + NEW_LINE + TAB + FUNCTION_START_MARKER +
- secondMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
- NEW_LINE;
-
- assertEquals(expectedResult, actualMergeResult);
- }
-
- /**
- * If two different authors make modifications on the same day, both modifications must
- * show up as separate changelog entries for that day.
- */
- @Test
- public void newChangeLogEntryForNewAuthorOnSameDay() throws Exception {
- // first author
- String authorName = "Test Author";
- String email = "test@example.com";
- final String firstDateLine = gnuFormatter.formatDateLine(authorName, email);
- // second author
- authorName = "William Shakespeare";
- email = "will@pear.com";
- final String secondDateLine = gnuFormatter.formatDateLine(authorName, email);
-
- // full absolute path to ChangeLog file
- String changelogPath = "/" + project.getTestProject().getName() + "/path/to";
- final String changelogFilePath = changelogPath + "/ChangeLog";
-
- // No existing content in ChangeLog file
- String content = "";
-
- assertNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
-
- // add a ChangeLog file to our test project
- InputStream newFileInputStream = new ByteArrayInputStream(
- content.getBytes());
- IFile changelogFile = project.addFileToProject( changelogPath, "ChangeLog",
- newFileInputStream);
- // Open a document and get the IEditorPart
- changelogEditorPart = openEditor(changelogFile);
-
- // entry file path (needs overlap with changelogPath)
- String fileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
- final String entryFilePath = changelogPath + "/" + fileEntryRelPath;
-
- final String guessedFunctionName = "bazinga";
-
- // merge first changelog entry with empty content
- gnuFormatter.mergeChangelog(firstDateLine, guessedFunctionName,
- "" /* empty default content */, changelogEditorPart,
- changelogFilePath, entryFilePath);
-
- String actualMergeResult = getContent(changelogEditorPart);
-
- String expectedResult = firstDateLine + TAB + FILE_ENTRY_START_MARKER +
- fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
- guessedFunctionName + FUNCTION_END_MARKER +
- FILE_ENTRY_END_MARKER;
-
- assertEquals(expectedResult, actualMergeResult);
-
- // add second changelog entry on same date but by different author
- gnuFormatter.mergeChangelog(secondDateLine, guessedFunctionName,
- "" /* empty default content */, changelogEditorPart,
- changelogFilePath, entryFilePath);
-
- actualMergeResult = getContent(changelogEditorPart);
-
- expectedResult = secondDateLine + TAB + FILE_ENTRY_START_MARKER +
- fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
- guessedFunctionName + FUNCTION_END_MARKER +
- FILE_ENTRY_END_MARKER + NEW_LINE + NEW_LINE +
- expectedResult;
-
- assertEquals(expectedResult, actualMergeResult);
- }
-
- /**
- * Basic format check.
- */
- @Test
- public void mergeChangeLogHasProperFormat() throws Exception {
- // set date/author line
- String authorName = "Test Author";
- String email = "test@example.com";
- final String dateLine = gnuFormatter.formatDateLine(authorName, email);
-
- // full absolute path to ChangeLog file (relative to project root)
- String changelogPath = "/" + project.getTestProject().getName() + "/path/to";
- final String changelogFilePath = changelogPath + "/ChangeLog";
-
- // Content to merge into
- String content = "";
-
- assertNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
-
- // add a ChangeLog file to our test project
- InputStream newFileInputStream = new ByteArrayInputStream(
- content.getBytes());
- IFile changelogFile = project.addFileToProject( "/path/to", "ChangeLog",
- newFileInputStream);
- // Open a document and get the IEditorPart
- changelogEditorPart = openEditor(changelogFile);
-
- // make sure changelog editor content is empty
- assertEquals(content, getContent(changelogEditorPart));
-
- // entry file path (need overlap with changelogPath)
- String fileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
- final String entryFilePath = changelogPath + "/" + fileEntryRelPath;
-
- // Will show up surrounded by "(" and ")" in ChangeLog
- final String guessedFunctionName = "bazinga";
-
- // This always returns an empty String (should probably be changed...)
- // merge result will be written to editorContent
- gnuFormatter.mergeChangelog(dateLine, guessedFunctionName,
- "" /* empty default content */, changelogEditorPart,
- changelogFilePath, entryFilePath);
-
- final String actualMergeResult = getContent(changelogEditorPart);
-
- final String expectedResult = dateLine + TAB + FILE_ENTRY_START_MARKER +
- fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
- guessedFunctionName + FUNCTION_END_MARKER +
- FILE_ENTRY_END_MARKER;
-
- assertEquals(expectedResult, actualMergeResult);
- }
-
- /**
- * Here's the scenario for this test. It may be that there are only files removed and
- * new files added for a commit. This should yield to changelog entries for the following
- * form:
- *
- *<code>
- * 2010-11-26 Some Author <some.author@example.com>
- *
- * * path/to/deleted/file.c: Removed.
- * * path/to/new/file.c: New file.
- *</code>
- *
- * Prior to the fix for Eclipse Bz #331244 the result was:
- *
- *<code>
- * 2010-11-26 Some Author <some.author@example.com>
- *
- * * path/to/deleted/file.c: Removed.
- * * path/to/new/file.c:
- *</code>
- *
- * This regression test should catch this.
- */
- @Test
- public void canHaveEntriesWithDefaultTextOnly() throws Exception {
- // set date/author line
- String authorName = "Test Author";
- String email = "test@example.com";
- final String dateLine = gnuFormatter.formatDateLine(authorName, email);
-
- // full absolute path to ChangeLog file (relative to project root)
- String changelogPath = "/" + project.getTestProject().getName() + "/path/example";
- final String changelogFilePath = changelogPath + "/ChangeLog";
-
- // Content to merge into
- String content = "";
-
- // add a ChangeLog file to our test project
- InputStream newFileInputStream = new ByteArrayInputStream(
- content.getBytes());
- IFile changelogFile = project.addFileToProject( "/path/example", "ChangeLog",
- newFileInputStream);
- // Open a document and get the IEditorPart
- changelogEditorPart = openEditor(changelogFile);
-
- // make sure changelog editor content is empty
- assertEquals(content, getContent(changelogEditorPart));
-
- // entry file path (need overlap with changelogPath)
- final String firstFileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
- String entryFilePath = changelogPath + "/" + firstFileEntryRelPath;
-
- final String firstDefaultContent = "New file.";
-
- // Note: This always returns an empty String (should probably be changed...)
- // merge result will be written to editorContent.
- //
- // Create a line with default text "New file"
- gnuFormatter.mergeChangelog(dateLine, "" /* no guessed function name */,
- firstDefaultContent, changelogEditorPart,
- changelogFilePath, entryFilePath);
- final String secondFileEntryRelPath = "eclipse/example/test/OldCoffeeMaker.java";
- entryFilePath = changelogPath + "/" + secondFileEntryRelPath;
- final String secondDefaultContent = "Removed.";
- // Add entry for removed file
- gnuFormatter.mergeChangelog(dateLine, "" /* no guessed function name */,
- secondDefaultContent, changelogEditorPart,
- changelogFilePath, entryFilePath);
-
- final String actualMergeResult = getContent(changelogEditorPart);
-
- // Note: Removed files occur in the list first, new file items come after that.
- final String expectedResult = dateLine + TAB + FILE_ENTRY_START_MARKER +
- secondFileEntryRelPath+ FILE_ENTRY_END_MARKER +
- secondDefaultContent + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
- firstFileEntryRelPath + FILE_ENTRY_END_MARKER +
- firstDefaultContent;
-
- assertEquals(expectedResult, actualMergeResult);
- }
-
- /**
- * Test for a changelog entry with items for removed files, new files and modified
- * existing files. This test differs from the previous in that the ChangeLog is
- * empty to start with. This verifies Bz #366854 fix.
- *
- * @throws Exception
- */
- @Test
- public void canHaveEntriesWithDefaultTextAndSomeModificationToAnExistingFile2() throws Exception {
- // set date/author line
- String authorName = "Test Author";
- String email = "test@example.com";
- final String dateLine = gnuFormatter.formatDateLine(authorName, email);
-
- // full absolute path to ChangeLog file (relative to project root)
- String changelogPath = "/" + project.getTestProject().getName() + "/test/example";
- final String changelogFilePath = changelogPath + "/ChangeLog";
-
- // add a new empty ChangeLog file to our test project
- InputStream newFileInputStream = new ByteArrayInputStream(new byte[0]);
- IFile changelogFile = project.addFileToProject( "/test/example", "ChangeLog",
- newFileInputStream);
- // Open a document and get the IEditorPart
- changelogEditorPart = openEditor(changelogFile);
-
- // entry file path (need overlap with changelogPath)
- final String firstFileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
- String entryFilePath = changelogPath + "/" + firstFileEntryRelPath;
-
- final String firstDefaultContent = "New file.";
-
- // Note: This always returns an empty String (should probably be changed...)
- // merge result will be written to editorContent.
- //
- // Create an item with default text "New file"
- gnuFormatter.mergeChangelog(dateLine, "" /* no guessed function name */,
- firstDefaultContent, changelogEditorPart,
- changelogFilePath, entryFilePath);
- final String secondFileEntryRelPath = "eclipse/example/test/OldCoffeeMaker.java";
- entryFilePath = changelogPath + "/" + secondFileEntryRelPath;
- final String secondDefaultContent = "Removed.";
- // Add entry for removed file
- gnuFormatter.mergeChangelog(dateLine, "" /* no guessed function name */,
- secondDefaultContent, changelogEditorPart,
- changelogFilePath, entryFilePath);
- final String thirdFileEntryRelPath = "eclipse/example/test/ModifiedFile.java";
- entryFilePath = changelogPath + "/" + thirdFileEntryRelPath;
- final String guessedFunctionName = "main";
- // Create a bullet point describing a change in some existing file
- gnuFormatter.mergeChangelog(dateLine, guessedFunctionName,
- "" /* no default content */, changelogEditorPart,
- changelogFilePath, entryFilePath);
-
- final String actualMergeResult = getContent(changelogEditorPart);
-
- // Note that changes to existing files appear first in the changelog entries.
- // Second are removed files and new files are last.
- final String expectedResult = dateLine + TAB + FILE_ENTRY_START_MARKER +
- thirdFileEntryRelPath + SPACE + FUNCTION_START_MARKER +
- guessedFunctionName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
- NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
- secondFileEntryRelPath+ FILE_ENTRY_END_MARKER +
- secondDefaultContent + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
- firstFileEntryRelPath + FILE_ENTRY_END_MARKER +
- firstDefaultContent;
-
- assertEquals(expectedResult, actualMergeResult);
- }
+ // The instance under test
+ private GNUFormat gnuFormatter;
+ // A faked project
+ private ChangeLogTestProject project;
+ // The IEditorPart corresponding to the ChangeLog file
+ private IEditorPart changelogEditorPart = null;
+
+ // Tokens for the GNU format
+ private static final String TWO_SPACES = " ";
+ private static final String SPACE = " ";
+ private static final String TAB = "\t";
+ private static final String LEFT_EMAIL_BRACKET = "<";
+ private static final String RIGHT_EMAIL_BRACKET = ">";
+ private static final String FILE_ENTRY_START_MARKER = "* ";
+ private static final String FILE_ENTRY_END_MARKER = ": ";
+ private static final String FUNCTION_START_MARKER = "(";
+ private static final String FUNCTION_END_MARKER = ")";
+ private static final String NEW_LINE = "\n";
+
+ @Before
+ public void setUp() throws Exception {
+ gnuFormatter = new GNUFormat();
+ project = new ChangeLogTestProject("GNUFormatterTest");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Most tests in this class use changelogEditorPart. In order to avoid
+ // spill-over from previous runs, truncate content (i.e. manually set
+ // content to the empty string).
+ if (changelogEditorPart != null) { // testFormatDateLine does not use it
+ AbstractTextEditor castEditor = (AbstractTextEditor) changelogEditorPart;
+ IDocumentProvider iDocProvider = castEditor.getDocumentProvider();
+ IDocument changelogContentDoc = iDocProvider.getDocument(castEditor.getEditorInput());
+ changelogContentDoc.set(""); // empty content
+ changelogEditorPart.doSave(null);
+ // Also close open editor in order for default content to work.
+ // I.e. avoid spill over from previous test runs
+ closeEditor(changelogEditorPart);
+ }
+ project.getTestProject().delete(true, true, null); // dispose
+ }
+
+ /**
+ * GNU ChangeLog style date lines are of the following format
+ *
+ * YYYY-MM-DD Author Name <author.email@domain.com>
+ */
+ @Test
+ public void testFormatDateLine() {
+ // Today's date in ISO format
+ Calendar c = new GregorianCalendar();
+ String isoDate = String.format("%1$tY-%1$tm-%1$td", c);
+ String authorName = "William Shakespeare";
+ String authorEmail = "william.shakespeare@medieval.com";
+ final String expectedDateFormatting = isoDate +
+ TWO_SPACES +
+ authorName +
+ TWO_SPACES +
+ LEFT_EMAIL_BRACKET +
+ authorEmail +
+ RIGHT_EMAIL_BRACKET +
+ "\n\n";
+ assertEquals(expectedDateFormatting,
+ gnuFormatter.formatDateLine(authorName, authorEmail));
+ }
+
+ /**
+ * Assume the following initial content of ChangeLog:
+ *
+ * <code>
+ * 2010-11-26 Severin Gehwolf <sgehwolf@redhat.com>
+ *
+ * * src/org/eclipse/linuxtools/changelog/parsers/java/HelloWorld.java (test): New Method\n\t\n
+ * </code>
+ *
+ * Note the trailing new-line, tab, new-line combination. If another change in the same file but
+ * in a different method (or function) is merged, the empty line containing a tab only should be
+ * removed.
+ *
+ */
+ @Test
+ public void twoChangesInSameFileAreProperlyMergedWhenThereIsATrailingTabNewLine() throws Exception {
+ // set date/author line
+ String authorName = "Test Foo";
+ String email = "test@example.com";
+ final String dateLine = gnuFormatter.formatDateLine(authorName, email);
+
+ // full absolute path to ChangeLog file (relative to project root)
+ String changelogPath = "/" + project.getTestProject().getName() + "/path/to";
+ final String changelogFilePath = changelogPath + "/ChangeLog";
+
+ // entry file path (need overlap with changelogPath)
+ String fileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
+ final String entryFilePath = changelogPath + "/" + fileEntryRelPath;
+
+ final String firstMethodName = "main";
+ final String firstChangeComment = "Fix args parsing.";
+ // Setup proper pre-existing content
+ String content = dateLine + NEW_LINE + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
+ fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
+ firstMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
+ firstChangeComment + NEW_LINE +
+ TAB + NEW_LINE; // produces an empty line which should be removed
+
+ assertNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
+
+ // add a ChangeLog file to our test project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ content.getBytes());
+ IFile changelogFile = project.addFileToProject( "/path/to", "ChangeLog",
+ newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
+
+ // Open a document and get the IEditorPart
+ changelogEditorPart = EditorHelper.openEditor(changelogFile);
+
+ // make sure changelog editor content is right before merging
+ assertEquals(content, getContent(changelogEditorPart));
+
+ final String secondMethodName = "toString";
+
+ // Do the merge with the existing content
+ gnuFormatter.mergeChangelog(dateLine, secondMethodName,
+ "" /* no default content */, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+
+ final String actualMergeResult = getContent(changelogEditorPart);
+
+ // Expect trailing tab+newline combination to not show up in merge
+ final String expectedResult = dateLine + NEW_LINE + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
+ fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
+ firstMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
+ firstChangeComment + NEW_LINE + TAB + FUNCTION_START_MARKER +
+ secondMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
+ NEW_LINE + NEW_LINE;
+ assertEquals(expectedResult, actualMergeResult);
+ }
+
+ /**
+ * Test merge of two separate changes to an existing file within the same changelog entry.
+ * I.e. test for
+ *
+ * * path/to/file (method1): First change.
+ * (method2): Another change in same file but different function/method.
+ */
+ @Test
+ public void twoChangesInSameFileAreProperlyMerged() throws Exception {
+ // set date/author line
+ String authorName = "Test Author";
+ String email = "test@example.com";
+ final String dateLine = gnuFormatter.formatDateLine(authorName, email);
+
+ // full absolute path to ChangeLog file (relative to project root)
+ String changelogPath = "/" + project.getTestProject().getName() + "/path/to";
+ final String changelogFilePath = changelogPath + "/ChangeLog";
+
+ // entry file path (need overlap with changelogPath)
+ String fileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
+ final String entryFilePath = changelogPath + "/" + fileEntryRelPath;
+
+ final String firstMethodName = "main";
+ final String firstChangeComment = "Fix args parsing.";
+ // Setup proper pre-existing content
+ String content = dateLine + NEW_LINE + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
+ fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
+ firstMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
+ firstChangeComment + NEW_LINE;
+
+ assertNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
+
+ // add a ChangeLog file to our test project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ content.getBytes());
+ IFile changelogFile = project.addFileToProject( "/path/to", "ChangeLog",
+ newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
+
+ // Open a document and get the IEditorPart
+ changelogEditorPart = openEditor(changelogFile);
+ // make sure changelog editor content is right before merging
+ assertEquals(content, getContent(changelogEditorPart));
+
+ final String secondMethodName = "toString";
+
+ // Do the merge with the existing content
+ gnuFormatter.mergeChangelog(dateLine, secondMethodName,
+ "" /* no default content */, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+
+ final String actualMergeResult = getContent(changelogEditorPart);
+
+ final String expectedResult = dateLine + NEW_LINE + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
+ fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
+ firstMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
+ firstChangeComment + NEW_LINE + TAB + FUNCTION_START_MARKER +
+ secondMethodName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
+ NEW_LINE;
+
+ assertEquals(expectedResult, actualMergeResult);
+ }
+
+ /**
+ * If two different authors make modifications on the same day, both modifications must
+ * show up as separate changelog entries for that day.
+ */
+ @Test
+ public void newChangeLogEntryForNewAuthorOnSameDay() throws Exception {
+ // first author
+ String authorName = "Test Author";
+ String email = "test@example.com";
+ final String firstDateLine = gnuFormatter.formatDateLine(authorName, email);
+ // second author
+ authorName = "William Shakespeare";
+ email = "will@pear.com";
+ final String secondDateLine = gnuFormatter.formatDateLine(authorName, email);
+
+ // full absolute path to ChangeLog file
+ String changelogPath = "/" + project.getTestProject().getName() + "/path/to";
+ final String changelogFilePath = changelogPath + "/ChangeLog";
+
+ // No existing content in ChangeLog file
+ String content = "";
+
+ assertNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
+
+ // add a ChangeLog file to our test project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ content.getBytes());
+ IFile changelogFile = project.addFileToProject( changelogPath, "ChangeLog",
+ newFileInputStream);
+ // Open a document and get the IEditorPart
+ changelogEditorPart = openEditor(changelogFile);
+
+ // entry file path (needs overlap with changelogPath)
+ String fileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
+ final String entryFilePath = changelogPath + "/" + fileEntryRelPath;
+
+ final String guessedFunctionName = "bazinga";
+
+ // merge first changelog entry with empty content
+ gnuFormatter.mergeChangelog(firstDateLine, guessedFunctionName,
+ "" /* empty default content */, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+
+ String actualMergeResult = getContent(changelogEditorPart);
+
+ String expectedResult = firstDateLine + TAB + FILE_ENTRY_START_MARKER +
+ fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
+ guessedFunctionName + FUNCTION_END_MARKER +
+ FILE_ENTRY_END_MARKER;
+
+ assertEquals(expectedResult, actualMergeResult);
+
+ // add second changelog entry on same date but by different author
+ gnuFormatter.mergeChangelog(secondDateLine, guessedFunctionName,
+ "" /* empty default content */, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+
+ actualMergeResult = getContent(changelogEditorPart);
+
+ expectedResult = secondDateLine + TAB + FILE_ENTRY_START_MARKER +
+ fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
+ guessedFunctionName + FUNCTION_END_MARKER +
+ FILE_ENTRY_END_MARKER + NEW_LINE + NEW_LINE +
+ expectedResult;
+
+ assertEquals(expectedResult, actualMergeResult);
+ }
+
+ /**
+ * Basic format check.
+ */
+ @Test
+ public void mergeChangeLogHasProperFormat() throws Exception {
+ // set date/author line
+ String authorName = "Test Author";
+ String email = "test@example.com";
+ final String dateLine = gnuFormatter.formatDateLine(authorName, email);
+
+ // full absolute path to ChangeLog file (relative to project root)
+ String changelogPath = "/" + project.getTestProject().getName() + "/path/to";
+ final String changelogFilePath = changelogPath + "/ChangeLog";
+
+ // Content to merge into
+ String content = "";
+
+ assertNull(project.getTestProject().findMember(new Path("/path/to/ChangeLog")));
+
+ // add a ChangeLog file to our test project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ content.getBytes());
+ IFile changelogFile = project.addFileToProject( "/path/to", "ChangeLog",
+ newFileInputStream);
+ // Open a document and get the IEditorPart
+ changelogEditorPart = openEditor(changelogFile);
+
+ // make sure changelog editor content is empty
+ assertEquals(content, getContent(changelogEditorPart));
+
+ // entry file path (need overlap with changelogPath)
+ String fileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
+ final String entryFilePath = changelogPath + "/" + fileEntryRelPath;
+
+ // Will show up surrounded by "(" and ")" in ChangeLog
+ final String guessedFunctionName = "bazinga";
+
+ // This always returns an empty String (should probably be changed...)
+ // merge result will be written to editorContent
+ gnuFormatter.mergeChangelog(dateLine, guessedFunctionName,
+ "" /* empty default content */, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+
+ final String actualMergeResult = getContent(changelogEditorPart);
+
+ final String expectedResult = dateLine + TAB + FILE_ENTRY_START_MARKER +
+ fileEntryRelPath + SPACE + FUNCTION_START_MARKER +
+ guessedFunctionName + FUNCTION_END_MARKER +
+ FILE_ENTRY_END_MARKER;
+
+ assertEquals(expectedResult, actualMergeResult);
+ }
+
+ /**
+ * Here's the scenario for this test. It may be that there are only files removed and
+ * new files added for a commit. This should yield to changelog entries for the following
+ * form:
+ *
+ *<code>
+ * 2010-11-26 Some Author <some.author@example.com>
+ *
+ * * path/to/deleted/file.c: Removed.
+ * * path/to/new/file.c: New file.
+ *</code>
+ *
+ * Prior to the fix for Eclipse Bz #331244 the result was:
+ *
+ *<code>
+ * 2010-11-26 Some Author <some.author@example.com>
+ *
+ * * path/to/deleted/file.c: Removed.
+ * * path/to/new/file.c:
+ *</code>
+ *
+ * This regression test should catch this.
+ */
+ @Test
+ public void canHaveEntriesWithDefaultTextOnly() throws Exception {
+ // set date/author line
+ String authorName = "Test Author";
+ String email = "test@example.com";
+ final String dateLine = gnuFormatter.formatDateLine(authorName, email);
+
+ // full absolute path to ChangeLog file (relative to project root)
+ String changelogPath = "/" + project.getTestProject().getName() + "/path/example";
+ final String changelogFilePath = changelogPath + "/ChangeLog";
+
+ // Content to merge into
+ String content = "";
+
+ // add a ChangeLog file to our test project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ content.getBytes());
+ IFile changelogFile = project.addFileToProject( "/path/example", "ChangeLog",
+ newFileInputStream);
+ // Open a document and get the IEditorPart
+ changelogEditorPart = openEditor(changelogFile);
+
+ // make sure changelog editor content is empty
+ assertEquals(content, getContent(changelogEditorPart));
+
+ // entry file path (need overlap with changelogPath)
+ final String firstFileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
+ String entryFilePath = changelogPath + "/" + firstFileEntryRelPath;
+
+ final String firstDefaultContent = "New file.";
+
+ // Note: This always returns an empty String (should probably be changed...)
+ // merge result will be written to editorContent.
+ //
+ // Create a line with default text "New file"
+ gnuFormatter.mergeChangelog(dateLine, "" /* no guessed function name */,
+ firstDefaultContent, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+ final String secondFileEntryRelPath = "eclipse/example/test/OldCoffeeMaker.java";
+ entryFilePath = changelogPath + "/" + secondFileEntryRelPath;
+ final String secondDefaultContent = "Removed.";
+ // Add entry for removed file
+ gnuFormatter.mergeChangelog(dateLine, "" /* no guessed function name */,
+ secondDefaultContent, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+
+ final String actualMergeResult = getContent(changelogEditorPart);
+
+ // Note: Removed files occur in the list first, new file items come after that.
+ final String expectedResult = dateLine + TAB + FILE_ENTRY_START_MARKER +
+ secondFileEntryRelPath+ FILE_ENTRY_END_MARKER +
+ secondDefaultContent + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
+ firstFileEntryRelPath + FILE_ENTRY_END_MARKER +
+ firstDefaultContent;
+
+ assertEquals(expectedResult, actualMergeResult);
+ }
+
+ /**
+ * Test for a changelog entry with items for removed files, new files and modified
+ * existing files. This test differs from the previous in that the ChangeLog is
+ * empty to start with. This verifies Bz #366854 fix.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canHaveEntriesWithDefaultTextAndSomeModificationToAnExistingFile2() throws Exception {
+ // set date/author line
+ String authorName = "Test Author";
+ String email = "test@example.com";
+ final String dateLine = gnuFormatter.formatDateLine(authorName, email);
+
+ // full absolute path to ChangeLog file (relative to project root)
+ String changelogPath = "/" + project.getTestProject().getName() + "/test/example";
+ final String changelogFilePath = changelogPath + "/ChangeLog";
+
+ // add a new empty ChangeLog file to our test project
+ InputStream newFileInputStream = new ByteArrayInputStream(new byte[0]);
+ IFile changelogFile = project.addFileToProject( "/test/example", "ChangeLog",
+ newFileInputStream);
+ // Open a document and get the IEditorPart
+ changelogEditorPart = openEditor(changelogFile);
+
+ // entry file path (need overlap with changelogPath)
+ final String firstFileEntryRelPath = "eclipse/example/test/NewCoffeeMaker.java";
+ String entryFilePath = changelogPath + "/" + firstFileEntryRelPath;
+
+ final String firstDefaultContent = "New file.";
+
+ // Note: This always returns an empty String (should probably be changed...)
+ // merge result will be written to editorContent.
+ //
+ // Create an item with default text "New file"
+ gnuFormatter.mergeChangelog(dateLine, "" /* no guessed function name */,
+ firstDefaultContent, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+ final String secondFileEntryRelPath = "eclipse/example/test/OldCoffeeMaker.java";
+ entryFilePath = changelogPath + "/" + secondFileEntryRelPath;
+ final String secondDefaultContent = "Removed.";
+ // Add entry for removed file
+ gnuFormatter.mergeChangelog(dateLine, "" /* no guessed function name */,
+ secondDefaultContent, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+ final String thirdFileEntryRelPath = "eclipse/example/test/ModifiedFile.java";
+ entryFilePath = changelogPath + "/" + thirdFileEntryRelPath;
+ final String guessedFunctionName = "main";
+ // Create a bullet point describing a change in some existing file
+ gnuFormatter.mergeChangelog(dateLine, guessedFunctionName,
+ "" /* no default content */, changelogEditorPart,
+ changelogFilePath, entryFilePath);
+
+ final String actualMergeResult = getContent(changelogEditorPart);
+
+ // Note that changes to existing files appear first in the changelog entries.
+ // Second are removed files and new files are last.
+ final String expectedResult = dateLine + TAB + FILE_ENTRY_START_MARKER +
+ thirdFileEntryRelPath + SPACE + FUNCTION_START_MARKER +
+ guessedFunctionName + FUNCTION_END_MARKER + FILE_ENTRY_END_MARKER +
+ NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
+ secondFileEntryRelPath+ FILE_ENTRY_END_MARKER +
+ secondDefaultContent + NEW_LINE + TAB + FILE_ENTRY_START_MARKER +
+ firstFileEntryRelPath + FILE_ENTRY_END_MARKER +
+ firstDefaultContent;
+
+ assertEquals(expectedResult, actualMergeResult);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/AllTests.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/AllTests.java
index 329c4cc799..fba24ddc5e 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/AllTests.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/AllTests.java
@@ -20,15 +20,15 @@ import org.junit.runners.Suite.SuiteClasses;
*/
@RunWith(Suite.class)
@SuiteClasses({
- ChangeLogWriterTest.class,
- GNUFormatTest.class,
- JavaParserTest.class,
- CParserTest.class,
- // A small test for the fixture
- TestChangeLogTestProject.class
- }
+ ChangeLogWriterTest.class,
+ GNUFormatTest.class,
+ JavaParserTest.class,
+ CParserTest.class,
+ // A small test for the fixture
+ TestChangeLogTestProject.class
+ }
)
public class AllTests {
- // empty
+ // empty
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/ChangeLogWriterTest.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/ChangeLogWriterTest.java
index d366b3c2f5..74206bef4f 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/ChangeLogWriterTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/core/tests/ChangeLogWriterTest.java
@@ -31,266 +31,266 @@ import org.eclipse.linuxtools.internal.changelog.core.formatters.GNUFormat;
/**
* @author Severin Gehwolf <sgehwolf@redhat.com>
- *
+ *
*/
public class ChangeLogWriterTest {
- // The instance of the class under test
- private ChangeLogWriter clogWriter;
- // A fake project
- private ChangeLogTestProject project;
- // the path elements to the ChangeLog file, absolute to the project root
- private final String CHANGELOG_FILE_PATH = "/project-name/src/org/";
- private final String CHANGELOG_FILE_NAME = "ChangeLog";
- private String changelogFilePath;
- // IFile handle to '/path/changelog/ChangeLog'
- private IFile changelogFile;
- // Current content of the ChangeLog file
- private final String changeLogContent = "2009-10-14 Some Author <some.author@example.com>\n\n" +
- "\t* this/file/does/not/really/exist/SpringRoll.java: new file\n\n";
-
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- clogWriter = new ChangeLogWriter();
- // create a testproject and add a file to it
- project = new ChangeLogTestProject("changelogWriterProject");
- // Generate full path to ChangeLog file
- changelogFilePath = CHANGELOG_FILE_PATH + CHANGELOG_FILE_NAME;
- // add a ChangeLog file to the project at the path specified by
- // CHANGELOG_FILE_PATH_SEGMENTS
- InputStream newFileInputStream = new ByteArrayInputStream(
- changeLogContent.getBytes());
- changelogFile = project.addFileToProject(CHANGELOG_FILE_PATH + CHANGELOG_FILE_NAME, CHANGELOG_FILE_NAME,
- newFileInputStream);
- }
-
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws CoreException {
- // dispose testproject
- project.getTestProject().delete(true, null);
- }
-
- /**
- * Test for setting and getting the content of the ChangeLog
- * file.
- */
- @Test
- public void testGetSetChangelog() {
- // Open the ChangeLog file and get the IEdiorPart
- final IEditorPart currentContent = EditorHelper.openEditor(changelogFile);
- clogWriter.setChangelog(currentContent);
- assertEquals(currentContent, clogWriter.getChangelog());
- EditorHelper.closeEditor(currentContent);
- }
-
- @Test
- public void testGetSetChangelogLocation() {
- final String path = "/path/to/changelog/file/ChangeLog";
- clogWriter.setChangelogLocation(path);
- assertEquals(path, clogWriter.getChangelogLocation());
- }
-
- @Test
- public void testGetSetDateLine() {
- String authorName = "Test Author";
- String email = "spongebob@commedycentral.com";
- clogWriter.setDateLine(new GNUFormat().formatDateLine(
- authorName, email));
-
- // Today's date in ISO format
- Calendar c = new GregorianCalendar();
- String isoDate = String.format("%1$tY-%1$tm-%1$td", c);
-
- // expected date/author line
- String expectedDateLine = isoDate + " " + authorName + " <" + email + ">\n\n";
- assertEquals(expectedDateLine, clogWriter.getDateLine());
- }
-
- @Test
- public void testGetSetEntryFilePath() {
- final String entryFilePath = "/some/path/to/some/File.java";
- clogWriter.setEntryFilePath(entryFilePath);
- assertEquals(entryFilePath, clogWriter.getEntryFilePath());
- }
-
- @Test
- public void testGetSetFormatter() {
- IFormatterChangeLogContrib formatter = new GNUFormat();
- clogWriter.setFormatter(formatter);
- assertEquals(formatter, clogWriter.getFormatter());
- }
-
- @Test
- public void testGetSetGuessedFName() {
- final String guessedFunctionName = "getInstance";
- clogWriter.setGuessedFName(guessedFunctionName);
- assertEquals(guessedFunctionName, clogWriter.getGuessedFName());
- }
-
- /**
- * Note that there can be several Changelogs inside a directory tree.
- * The {@link ChangeLogWriter#writeChangeLog()} code assumes that the full path to
- * the ChangeLog file and the full path to the file for which to generate a ChangeLog
- * entry have the same ancestor (with some potential overlap).
- *
- * Consider the following example:
- *
- * 1. The ChangeLog file is <project-root>/src/ChangeLog
- * 2. The currently open editor contains code of <project-root>/src/org/eclipse/example/Test.java
- *
- * In the above case entries in <project-root>/src/ChangeLog *should* be of the form:
- *
- * <code>
- *
- * YYYY-MM-DD Author Name <email@example.com>
- *
- * * org/eclipse/example/Test.java: new File
- *
- * </code>
- *
- * Similarly, if the ChangeLog file is in <project-root>/ChangeLog and the currently open
- * file is <project-root>/src/org/eclipse/example/Sun.java, generated entries in
- * <project-root>/ChangeLog would look like (note the "src" path is added in this case):
- *
- * <code>
- *
- * YYYY-MM-DD Author Name <email@example.com>
- *
- * * src/org/eclipse/example/Sun.java: new File
- *
- * </code>
- *
- * Test for method {@link org.eclipse.linuxtools.internal.changelog.core.ChangeLogWriter#writeChangeLog()}
- */
- @Test
- public void testWriteChangeLog() throws Exception {
- // We want paths up to the ChangeLog file to overlap
-
- final String pathRelativeToChangeLog = "eclipse/example/test/NewCoffeeMaker.java";
- clogWriter.setEntryFilePath( CHANGELOG_FILE_PATH + pathRelativeToChangeLog );
-
- // Will show up surrounded by "(" and ")" in ChangeLog
- String guessedFunctionName = "bazinga";
- clogWriter.setGuessedFName(guessedFunctionName);
-
- // set GNU formatter
- clogWriter.setFormatter(new GNUFormat());
-
- // Open a document and get the IEditorPart
- IEditorPart editorContent = EditorHelper.openEditor(changelogFile);
- clogWriter.setChangelog(editorContent);
-
- // set date/author line
- String authorName = "Test Author";
- String email = "test@example.com";
- clogWriter.setDateLine(clogWriter.getFormatter().formatDateLine(
- authorName, email));
-
- // full absolute path to ChangeLog file (relative to project root)
- clogWriter.setChangelogLocation(changelogFilePath);
-
- // Write changelog to buffer - need to save for persistence
- clogWriter.writeChangeLog();
-
- // above written content is not persistent yet; save it to make it persistent
- clogWriter.getChangelog().doSave(null);
-
- // Today's date in ISO format
- Calendar c = new GregorianCalendar();
- String isoDate = String.format("%1$tY-%1$tm-%1$td", c);
-
- // Construct the changelog entry by hand and match it with what has been written
- String expectedChangeLogEntry = isoDate + " " + authorName + " <" + email + ">\n\n";
- expectedChangeLogEntry += "\t* " + pathRelativeToChangeLog + " (" + guessedFunctionName + "): \n\n";
-
- String expectedContent = expectedChangeLogEntry + changeLogContent;
-
- // Read in content written to file
- StringBuffer actualContent = new StringBuffer();
- try (BufferedReader br = new BufferedReader(new InputStreamReader(
- new FileInputStream(changelogFile.getLocation().toFile())))) {
- String line;
- while ((line = br.readLine()) != null) {
- actualContent.append(line + "\n");
- }
- }
- // Assert proper content has been added
- assertEquals(expectedContent, actualContent.toString());
- EditorHelper.closeEditor(editorContent);
- }
-
- @Test
- public void testGetSetDefaultContent() {
- final String defaultContent = "DISCLAIMER: default ChangeLog content for new files?";
- clogWriter.setDefaultContent(defaultContent);
- assertEquals(defaultContent, clogWriter.getDefaultContent());
- }
-
-
- /**
- * Test the use of default text.
- *
- * @throws Exception
- */
- @Test
- public void canWriteChangeLogToEmptyChangeLogButWithSomeDefaultContent() throws Exception {
- // set GNU formatter
- clogWriter.setFormatter(new GNUFormat());
-
- // Open up a new ChangeLog file at newPathToChangeLog with empty content
- // and get the IEditorPart
- InputStream newFileInputStream = new ByteArrayInputStream(
- "".getBytes()); // no content
- String destinationPath = "/this/is/some/random/path";
- IFile emptyChangeLogFile = project.addFileToProject(destinationPath, CHANGELOG_FILE_NAME,
- newFileInputStream);
- IEditorPart editorContent = EditorHelper.openEditor(emptyChangeLogFile);
- clogWriter.setChangelog(editorContent);
-
- String authorName = "Test Author";
- String email = "test@example.com";
- clogWriter.setDateLine(clogWriter.getFormatter().formatDateLine(
- authorName, email));
- clogWriter.setChangelogLocation(destinationPath + "/" + CHANGELOG_FILE_NAME);
-
- // Set some default content
- String defaultContent = "Removed.";
- clogWriter.setDefaultContent(defaultContent);
-
- String relativePathOfChangedFile = "path/to/file/for/new/entry/test.c";
- clogWriter.setEntryFilePath( destinationPath + "/" + relativePathOfChangedFile );
-
- clogWriter.setGuessedFName("");
-
- // Write changelog to buffer - need to save for persistence
- clogWriter.writeChangeLog();
-
- // above written content is not persistent yet; save it to make it persistent
- clogWriter.getChangelog().doSave(null);
-
- // Construct the changelog entry by hand and match it with what has been written
- String expectedChangeLogEntry = new GNUFormat().formatDateLine(authorName, email);
- expectedChangeLogEntry += "\t* " + relativePathOfChangedFile + ": "
- + defaultContent + "\n";
-
- // Read in content written to file
- StringBuffer actualContent = new StringBuffer();
- try (BufferedReader br = new BufferedReader(new InputStreamReader(
- new FileInputStream(emptyChangeLogFile.getLocation().toFile())))) {
- String line;
- while ((line = br.readLine()) != null) {
- actualContent.append(line + "\n");
- }
- }
- // Assert proper content has been added
- assertEquals(expectedChangeLogEntry, actualContent.toString());
- EditorHelper.closeEditor(editorContent);
- }
+ // The instance of the class under test
+ private ChangeLogWriter clogWriter;
+ // A fake project
+ private ChangeLogTestProject project;
+ // the path elements to the ChangeLog file, absolute to the project root
+ private final String CHANGELOG_FILE_PATH = "/project-name/src/org/";
+ private final String CHANGELOG_FILE_NAME = "ChangeLog";
+ private String changelogFilePath;
+ // IFile handle to '/path/changelog/ChangeLog'
+ private IFile changelogFile;
+ // Current content of the ChangeLog file
+ private final String changeLogContent = "2009-10-14 Some Author <some.author@example.com>\n\n" +
+ "\t* this/file/does/not/really/exist/SpringRoll.java: new file\n\n";
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ clogWriter = new ChangeLogWriter();
+ // create a testproject and add a file to it
+ project = new ChangeLogTestProject("changelogWriterProject");
+ // Generate full path to ChangeLog file
+ changelogFilePath = CHANGELOG_FILE_PATH + CHANGELOG_FILE_NAME;
+ // add a ChangeLog file to the project at the path specified by
+ // CHANGELOG_FILE_PATH_SEGMENTS
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ changeLogContent.getBytes());
+ changelogFile = project.addFileToProject(CHANGELOG_FILE_PATH + CHANGELOG_FILE_NAME, CHANGELOG_FILE_NAME,
+ newFileInputStream);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws CoreException {
+ // dispose testproject
+ project.getTestProject().delete(true, null);
+ }
+
+ /**
+ * Test for setting and getting the content of the ChangeLog
+ * file.
+ */
+ @Test
+ public void testGetSetChangelog() {
+ // Open the ChangeLog file and get the IEdiorPart
+ final IEditorPart currentContent = EditorHelper.openEditor(changelogFile);
+ clogWriter.setChangelog(currentContent);
+ assertEquals(currentContent, clogWriter.getChangelog());
+ EditorHelper.closeEditor(currentContent);
+ }
+
+ @Test
+ public void testGetSetChangelogLocation() {
+ final String path = "/path/to/changelog/file/ChangeLog";
+ clogWriter.setChangelogLocation(path);
+ assertEquals(path, clogWriter.getChangelogLocation());
+ }
+
+ @Test
+ public void testGetSetDateLine() {
+ String authorName = "Test Author";
+ String email = "spongebob@commedycentral.com";
+ clogWriter.setDateLine(new GNUFormat().formatDateLine(
+ authorName, email));
+
+ // Today's date in ISO format
+ Calendar c = new GregorianCalendar();
+ String isoDate = String.format("%1$tY-%1$tm-%1$td", c);
+
+ // expected date/author line
+ String expectedDateLine = isoDate + " " + authorName + " <" + email + ">\n\n";
+ assertEquals(expectedDateLine, clogWriter.getDateLine());
+ }
+
+ @Test
+ public void testGetSetEntryFilePath() {
+ final String entryFilePath = "/some/path/to/some/File.java";
+ clogWriter.setEntryFilePath(entryFilePath);
+ assertEquals(entryFilePath, clogWriter.getEntryFilePath());
+ }
+
+ @Test
+ public void testGetSetFormatter() {
+ IFormatterChangeLogContrib formatter = new GNUFormat();
+ clogWriter.setFormatter(formatter);
+ assertEquals(formatter, clogWriter.getFormatter());
+ }
+
+ @Test
+ public void testGetSetGuessedFName() {
+ final String guessedFunctionName = "getInstance";
+ clogWriter.setGuessedFName(guessedFunctionName);
+ assertEquals(guessedFunctionName, clogWriter.getGuessedFName());
+ }
+
+ /**
+ * Note that there can be several Changelogs inside a directory tree.
+ * The {@link ChangeLogWriter#writeChangeLog()} code assumes that the full path to
+ * the ChangeLog file and the full path to the file for which to generate a ChangeLog
+ * entry have the same ancestor (with some potential overlap).
+ *
+ * Consider the following example:
+ *
+ * 1. The ChangeLog file is <project-root>/src/ChangeLog
+ * 2. The currently open editor contains code of <project-root>/src/org/eclipse/example/Test.java
+ *
+ * In the above case entries in <project-root>/src/ChangeLog *should* be of the form:
+ *
+ * <code>
+ *
+ * YYYY-MM-DD Author Name <email@example.com>
+ *
+ * * org/eclipse/example/Test.java: new File
+ *
+ * </code>
+ *
+ * Similarly, if the ChangeLog file is in <project-root>/ChangeLog and the currently open
+ * file is <project-root>/src/org/eclipse/example/Sun.java, generated entries in
+ * <project-root>/ChangeLog would look like (note the "src" path is added in this case):
+ *
+ * <code>
+ *
+ * YYYY-MM-DD Author Name <email@example.com>
+ *
+ * * src/org/eclipse/example/Sun.java: new File
+ *
+ * </code>
+ *
+ * Test for method {@link org.eclipse.linuxtools.internal.changelog.core.ChangeLogWriter#writeChangeLog()}
+ */
+ @Test
+ public void testWriteChangeLog() throws Exception {
+ // We want paths up to the ChangeLog file to overlap
+
+ final String pathRelativeToChangeLog = "eclipse/example/test/NewCoffeeMaker.java";
+ clogWriter.setEntryFilePath( CHANGELOG_FILE_PATH + pathRelativeToChangeLog );
+
+ // Will show up surrounded by "(" and ")" in ChangeLog
+ String guessedFunctionName = "bazinga";
+ clogWriter.setGuessedFName(guessedFunctionName);
+
+ // set GNU formatter
+ clogWriter.setFormatter(new GNUFormat());
+
+ // Open a document and get the IEditorPart
+ IEditorPart editorContent = EditorHelper.openEditor(changelogFile);
+ clogWriter.setChangelog(editorContent);
+
+ // set date/author line
+ String authorName = "Test Author";
+ String email = "test@example.com";
+ clogWriter.setDateLine(clogWriter.getFormatter().formatDateLine(
+ authorName, email));
+
+ // full absolute path to ChangeLog file (relative to project root)
+ clogWriter.setChangelogLocation(changelogFilePath);
+
+ // Write changelog to buffer - need to save for persistence
+ clogWriter.writeChangeLog();
+
+ // above written content is not persistent yet; save it to make it persistent
+ clogWriter.getChangelog().doSave(null);
+
+ // Today's date in ISO format
+ Calendar c = new GregorianCalendar();
+ String isoDate = String.format("%1$tY-%1$tm-%1$td", c);
+
+ // Construct the changelog entry by hand and match it with what has been written
+ String expectedChangeLogEntry = isoDate + " " + authorName + " <" + email + ">\n\n";
+ expectedChangeLogEntry += "\t* " + pathRelativeToChangeLog + " (" + guessedFunctionName + "): \n\n";
+
+ String expectedContent = expectedChangeLogEntry + changeLogContent;
+
+ // Read in content written to file
+ StringBuffer actualContent = new StringBuffer();
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(changelogFile.getLocation().toFile())))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ actualContent.append(line + "\n");
+ }
+ }
+ // Assert proper content has been added
+ assertEquals(expectedContent, actualContent.toString());
+ EditorHelper.closeEditor(editorContent);
+ }
+
+ @Test
+ public void testGetSetDefaultContent() {
+ final String defaultContent = "DISCLAIMER: default ChangeLog content for new files?";
+ clogWriter.setDefaultContent(defaultContent);
+ assertEquals(defaultContent, clogWriter.getDefaultContent());
+ }
+
+
+ /**
+ * Test the use of default text.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canWriteChangeLogToEmptyChangeLogButWithSomeDefaultContent() throws Exception {
+ // set GNU formatter
+ clogWriter.setFormatter(new GNUFormat());
+
+ // Open up a new ChangeLog file at newPathToChangeLog with empty content
+ // and get the IEditorPart
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ "".getBytes()); // no content
+ String destinationPath = "/this/is/some/random/path";
+ IFile emptyChangeLogFile = project.addFileToProject(destinationPath, CHANGELOG_FILE_NAME,
+ newFileInputStream);
+ IEditorPart editorContent = EditorHelper.openEditor(emptyChangeLogFile);
+ clogWriter.setChangelog(editorContent);
+
+ String authorName = "Test Author";
+ String email = "test@example.com";
+ clogWriter.setDateLine(clogWriter.getFormatter().formatDateLine(
+ authorName, email));
+ clogWriter.setChangelogLocation(destinationPath + "/" + CHANGELOG_FILE_NAME);
+
+ // Set some default content
+ String defaultContent = "Removed.";
+ clogWriter.setDefaultContent(defaultContent);
+
+ String relativePathOfChangedFile = "path/to/file/for/new/entry/test.c";
+ clogWriter.setEntryFilePath( destinationPath + "/" + relativePathOfChangedFile );
+
+ clogWriter.setGuessedFName("");
+
+ // Write changelog to buffer - need to save for persistence
+ clogWriter.writeChangeLog();
+
+ // above written content is not persistent yet; save it to make it persistent
+ clogWriter.getChangelog().doSave(null);
+
+ // Construct the changelog entry by hand and match it with what has been written
+ String expectedChangeLogEntry = new GNUFormat().formatDateLine(authorName, email);
+ expectedChangeLogEntry += "\t* " + relativePathOfChangedFile + ": "
+ + defaultContent + "\n";
+
+ // Read in content written to file
+ StringBuffer actualContent = new StringBuffer();
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(emptyChangeLogFile.getLocation().toFile())))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ actualContent.append(line + "\n");
+ }
+ }
+ // Assert proper content has been added
+ assertEquals(expectedChangeLogEntry, actualContent.toString());
+ EditorHelper.closeEditor(editorContent);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/CParserTest.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/CParserTest.java
index a94897c82f..afe5b3cd3d 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/CParserTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/CParserTest.java
@@ -38,395 +38,395 @@ import org.junit.Test;
/**
* CParser test suite.
- *
+ *
*/
public class CParserTest {
- // A unique string to mark the place of current selection in source code
- private static final String OFFSET_MARKER = "<# selection #>";
- // The parser under test
- private IParserChangeLogContrib cParser;
- // A faked project
- private ChangeLogTestProject project;
- // The IEditorPart corresponding to the ChangeLog file
- private IEditorPart cppSourceEditorPart = null;
-
- @Before
- public void setUp() throws Exception {
- cParser = ChangeLogExtensionManager.getExtensionManager().getParserContributor("CEditor");
- project = new ChangeLogTestProject("c-parser-test-project");
- }
-
- @After
- public void tearDown() throws Exception {
- // Tests in this class use javaSourceEditorPart. In order to avoid
- // spill-over from previous runs, truncate content (i.e. manually set
- // content to the empty string).
- if (cppSourceEditorPart != null) {
- AbstractTextEditor castEditor = (AbstractTextEditor) cppSourceEditorPart;
- IDocumentProvider iDocProvider = castEditor.getDocumentProvider();
- IDocument changelogContentDoc = iDocProvider.getDocument(castEditor.getEditorInput());
- changelogContentDoc.set("");
- cppSourceEditorPart.doSave(null);
- // Also close open editor in order for default content to work.
- // I.e. avoid spill over from previous test runs
- closeEditor(cppSourceEditorPart);
- }
- project.getTestProject().delete(true, true, null); // dispose
- }
-
- /**
- * Given an IEditorPart we should be able to retrieve the currently
- * function active C function inside a C source file.
- *
- * @throws Exception
- */
- @Test
- public void canParseCurrentFunctionFromCFile() throws Exception {
- // make testproject a C project
- project.addCNature();
-
- final String expectedFunctionName = "doSomething";
- final String cSourceCode = "static int " + expectedFunctionName + "(char *test)\n"
- + "{\n"
- + "int index = 0;\n"
- + "// " + OFFSET_MARKER + "\n"
- + "return 0;\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/some_c_file.c")));
-
- // Add some_c_file.c to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- cSourceCode.getBytes());
- IFile cSourceFile = project.addFileToProject(
- "/src",
- "some_c_file.c", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/some_c_file.c")));
-
- // Open a source file and get the IEditorPart
- cppSourceEditorPart = openEditor(cSourceFile);
- assertEquals(cSourceCode, getContent(cppSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
-
- // Select the snippet we want
- int selectionStart = cSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractTextEditor cEditor = (AbstractTextEditor) cppSourceEditorPart;
- cEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualFunctionName = cParser.parseCurrentFunction(cppSourceEditorPart);
-
- assertEquals(expectedFunctionName, actualFunctionName);
- }
-
- /**
- * Given an IEditorPart and not being inside any function within a C
- * source file, no function should be determined.
- *
- * @throws Exception
- */
- @Test
- public void canDetermineThatInNoFunctionInCFile() throws Exception {
- // make test project a C project
- project.addCNature();
-
- final String cSourceCode = "// Prototype " + OFFSET_MARKER + "\n"
- + "static int doSomething(char *test);\n\n"
- + "static int doSomething(char *test)\n"
- + "{\n"
- + "int index = 0;\n"
- + "return 0;\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/some_c_file.c")));
-
- // Add some_c_file.c to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- cSourceCode.getBytes());
- IFile cSourceFile = project.addFileToProject(
- "/src",
- "some_c_file.c", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/some_c_file.c")));
-
- // Open a source file and get the IEditorPart
- cppSourceEditorPart = openEditor(cSourceFile);
- assertEquals(cSourceCode, getContent(cppSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
-
- // Select the snippet we want
- int selectionStart = cSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractTextEditor cEditor = (AbstractTextEditor) cppSourceEditorPart;
- cEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualFunctionName = cParser.parseCurrentFunction(cppSourceEditorPart);
-
- assertEquals("" /* expect empty function name */, actualFunctionName);
- }
-
- /**
- * Given an IEditorPart we should be able to retrieve the currently selected
- * variable identifier inside a C++ file.
- *
- * @throws Exception
- */
- @Test
- public void canParseCurrentlySelectedVariableIdentifierInCppFile() throws Exception {
- // make test project a C++ project
- project.addCCNature();
-
- final String expectedIdentifier = "myIdentifier";
- final String className = "shape";
- final String cppSourceCode = "class " + className + " {\n"
- + "int x;\n"
- + "int y;\n"
- + "private:\n"
- + "int color;\n"
- + "float " + expectedIdentifier + ";\n"
- + "void set_color(int color);\n"
- +"}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/shape.h")));
-
- // Add shape.h to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- cppSourceCode.getBytes());
- IFile cppSourceFile = project.addFileToProject(
- "/src",
- "shape.h", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/shape.h")));
-
- // Open a source file and get the IEditorPart
- cppSourceEditorPart = openEditor(cppSourceFile);
- // make sure editor content is correct
- assertEquals(cppSourceCode, getContent(cppSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
-
- // Select the snippet we want
- int selectionStart = cppSourceCode.indexOf(expectedIdentifier);
- assertTrue(selectionStart >= 0);
- // shouldn't need to mark whole length of identifier.
- int selectionLength = expectedIdentifier.length() - 3;
- AbstractTextEditor cppEditor = (AbstractTextEditor) cppSourceEditorPart;
- cppEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualIdentifier = cParser.parseCurrentFunction(cppSourceEditorPart);
-
- assertEquals(className + "." + expectedIdentifier, actualIdentifier);
- }
-
- /**
- * Given an IEditorPart and not selected any variable identifier in a class, we should
- * get the class name as selected function name only.
- *
- * @throws Exception
- */
- @Test
- public void canParseClassNameIfNoVariableIdentifierSelectedInCppFile() throws Exception {
- // make test project a C++ project
- project.addCCNature();
-
- final String className = "shape";
- final String cppSourceCode = "class " + className + " {\n"
- + "int x;\n"
- + "int y;\n"
- + "// " + OFFSET_MARKER + "\n"
- + "private:\n"
- + "int color;\n"
- + "void set_color(int color);\n"
- +"}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/shape.h")));
-
- // Add shape.h to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- cppSourceCode.getBytes());
- IFile cppSourceFile = project.addFileToProject(
- "/src",
- "shape.h", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/shape.h")));
-
- // Open a source file and get the IEditorPart
- cppSourceEditorPart = openEditor(cppSourceFile);
- // make sure editor content is correct
- assertEquals(cppSourceCode, getContent(cppSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
-
- // Select the snippet we want
- int selectionStart = cppSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractTextEditor cppEditor = (AbstractTextEditor) cppSourceEditorPart;
- cppEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualFunction = cParser.parseCurrentFunction(cppSourceEditorPart);
-
- assertEquals(className, actualFunction);
- }
-
- /**
- * Given an IEditorPart and current selection is inside a method,
- * CParser should be able to figure that out.
- *
- * @throws Exception
- */
- @Test
- public void canParseCurrentMethodNameInCppFile() throws Exception {
- // make test project a C++ project
- project.addCCNature();
-
- final String expectedMethodName = "circle::area";
- final String cppSourceCode = "#include \"circle.h\"\n"
- + "#include <math.h>\n"
- + "float " + expectedMethodName + "() {\n"
- + "// " + OFFSET_MARKER + "\n"
- + "return this->radius * this-> radius * M_PI\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/circle.cpp")));
-
- // Add shape.h to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- cppSourceCode.getBytes());
- IFile cppSourceFile = project.addFileToProject(
- "/src",
- "circle.cpp", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/circle.cpp")));
-
- // Open a source file and get the IEditorPart
- cppSourceEditorPart = openEditor(cppSourceFile);
- // make sure editor content is correct
- assertEquals(cppSourceCode, getContent(cppSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
-
- // Select the snippet we want
- int selectionStart = cppSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractTextEditor cppEditor = (AbstractTextEditor) cppSourceEditorPart;
- cppEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualMethodName = cParser.parseCurrentFunction(cppSourceEditorPart);
-
- assertEquals(expectedMethodName, actualMethodName);
- }
-
- /**
- * Given an IEditorPart and current selection is inside a method,
- * CParser should be able to figure that out.
- *
- * @throws Exception
- */
- @Test
- public void canParseCurrentFunctionInCppFile() throws Exception {
- // make test project a C++ project
- project.addCCNature();
-
- final String expectedFunction = "main";
- final String cppSourceCode = "#include \"circle.h\"\n"
- + "#include <math.h>\n"
- + "float circle::area() {\n"
- + "return this->radius * this-> radius * M_PI\n"
- + "}\n"
- + "int " + expectedFunction + "() {\n"
- + "int some_var = 0;\n"
- + "// " + OFFSET_MARKER + "\n"
- + "return 0;\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/circle.cpp")));
-
- // Add shape.h to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- cppSourceCode.getBytes());
- IFile cppSourceFile = project.addFileToProject(
- "/src",
- "circle.cpp", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/circle.cpp")));
-
- // Open a source file and get the IEditorPart
- cppSourceEditorPart = openEditor(cppSourceFile);
- // make sure editor content is correct
- assertEquals(cppSourceCode, getContent(cppSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
-
- // Select the snippet we want
- int selectionStart = cppSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractTextEditor cppEditor = (AbstractTextEditor) cppSourceEditorPart;
- cppEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualFunction = cParser.parseCurrentFunction(cppSourceEditorPart);
-
- assertEquals(expectedFunction, actualFunction);
- }
-
- /**
- * Given an IStorageEditorInput we should be able to retrieve the currently
- * active C function.
- *
- * @throws Exception
- */
- @Test
- public void canParseCurrentFunctionFromCStringInIStorageEditorInput() throws Exception {
- final String expectedFunctionName = "doSomething";
- final String cSourceCode = "static int " + expectedFunctionName + "(char *test)\n"
- + "{\n"
- + "int index = 0;\n"
- + "// " + OFFSET_MARKER + "\n"
- + "return 0;\n"
- + "}\n";
-
- // prepare IStorageEditorInput
- IStorage cStringStorage = new CStringStorage(cSourceCode);
- IStorageEditorInput cStringStorageEditorInput = new CStringStorageInput(cStringStorage);
-
- // Figure out the desired offset
- int selectOffset = cSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectOffset >= 0);
-
- final String actualFunctionName = cParser.parseCurrentFunction(cStringStorageEditorInput, selectOffset);
-
- assertEquals(expectedFunctionName, actualFunctionName);
- }
+ // A unique string to mark the place of current selection in source code
+ private static final String OFFSET_MARKER = "<# selection #>";
+ // The parser under test
+ private IParserChangeLogContrib cParser;
+ // A faked project
+ private ChangeLogTestProject project;
+ // The IEditorPart corresponding to the ChangeLog file
+ private IEditorPart cppSourceEditorPart = null;
+
+ @Before
+ public void setUp() throws Exception {
+ cParser = ChangeLogExtensionManager.getExtensionManager().getParserContributor("CEditor");
+ project = new ChangeLogTestProject("c-parser-test-project");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Tests in this class use javaSourceEditorPart. In order to avoid
+ // spill-over from previous runs, truncate content (i.e. manually set
+ // content to the empty string).
+ if (cppSourceEditorPart != null) {
+ AbstractTextEditor castEditor = (AbstractTextEditor) cppSourceEditorPart;
+ IDocumentProvider iDocProvider = castEditor.getDocumentProvider();
+ IDocument changelogContentDoc = iDocProvider.getDocument(castEditor.getEditorInput());
+ changelogContentDoc.set("");
+ cppSourceEditorPart.doSave(null);
+ // Also close open editor in order for default content to work.
+ // I.e. avoid spill over from previous test runs
+ closeEditor(cppSourceEditorPart);
+ }
+ project.getTestProject().delete(true, true, null); // dispose
+ }
+
+ /**
+ * Given an IEditorPart we should be able to retrieve the currently
+ * function active C function inside a C source file.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canParseCurrentFunctionFromCFile() throws Exception {
+ // make testproject a C project
+ project.addCNature();
+
+ final String expectedFunctionName = "doSomething";
+ final String cSourceCode = "static int " + expectedFunctionName + "(char *test)\n"
+ + "{\n"
+ + "int index = 0;\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "return 0;\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/some_c_file.c")));
+
+ // Add some_c_file.c to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ cSourceCode.getBytes());
+ IFile cSourceFile = project.addFileToProject(
+ "/src",
+ "some_c_file.c", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/some_c_file.c")));
+
+ // Open a source file and get the IEditorPart
+ cppSourceEditorPart = openEditor(cSourceFile);
+ assertEquals(cSourceCode, getContent(cppSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = cSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractTextEditor cEditor = (AbstractTextEditor) cppSourceEditorPart;
+ cEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualFunctionName = cParser.parseCurrentFunction(cppSourceEditorPart);
+
+ assertEquals(expectedFunctionName, actualFunctionName);
+ }
+
+ /**
+ * Given an IEditorPart and not being inside any function within a C
+ * source file, no function should be determined.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canDetermineThatInNoFunctionInCFile() throws Exception {
+ // make test project a C project
+ project.addCNature();
+
+ final String cSourceCode = "// Prototype " + OFFSET_MARKER + "\n"
+ + "static int doSomething(char *test);\n\n"
+ + "static int doSomething(char *test)\n"
+ + "{\n"
+ + "int index = 0;\n"
+ + "return 0;\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/some_c_file.c")));
+
+ // Add some_c_file.c to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ cSourceCode.getBytes());
+ IFile cSourceFile = project.addFileToProject(
+ "/src",
+ "some_c_file.c", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/some_c_file.c")));
+
+ // Open a source file and get the IEditorPart
+ cppSourceEditorPart = openEditor(cSourceFile);
+ assertEquals(cSourceCode, getContent(cppSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = cSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractTextEditor cEditor = (AbstractTextEditor) cppSourceEditorPart;
+ cEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualFunctionName = cParser.parseCurrentFunction(cppSourceEditorPart);
+
+ assertEquals("" /* expect empty function name */, actualFunctionName);
+ }
+
+ /**
+ * Given an IEditorPart we should be able to retrieve the currently selected
+ * variable identifier inside a C++ file.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canParseCurrentlySelectedVariableIdentifierInCppFile() throws Exception {
+ // make test project a C++ project
+ project.addCCNature();
+
+ final String expectedIdentifier = "myIdentifier";
+ final String className = "shape";
+ final String cppSourceCode = "class " + className + " {\n"
+ + "int x;\n"
+ + "int y;\n"
+ + "private:\n"
+ + "int color;\n"
+ + "float " + expectedIdentifier + ";\n"
+ + "void set_color(int color);\n"
+ +"}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/shape.h")));
+
+ // Add shape.h to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ cppSourceCode.getBytes());
+ IFile cppSourceFile = project.addFileToProject(
+ "/src",
+ "shape.h", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/shape.h")));
+
+ // Open a source file and get the IEditorPart
+ cppSourceEditorPart = openEditor(cppSourceFile);
+ // make sure editor content is correct
+ assertEquals(cppSourceCode, getContent(cppSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = cppSourceCode.indexOf(expectedIdentifier);
+ assertTrue(selectionStart >= 0);
+ // shouldn't need to mark whole length of identifier.
+ int selectionLength = expectedIdentifier.length() - 3;
+ AbstractTextEditor cppEditor = (AbstractTextEditor) cppSourceEditorPart;
+ cppEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualIdentifier = cParser.parseCurrentFunction(cppSourceEditorPart);
+
+ assertEquals(className + "." + expectedIdentifier, actualIdentifier);
+ }
+
+ /**
+ * Given an IEditorPart and not selected any variable identifier in a class, we should
+ * get the class name as selected function name only.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canParseClassNameIfNoVariableIdentifierSelectedInCppFile() throws Exception {
+ // make test project a C++ project
+ project.addCCNature();
+
+ final String className = "shape";
+ final String cppSourceCode = "class " + className + " {\n"
+ + "int x;\n"
+ + "int y;\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "private:\n"
+ + "int color;\n"
+ + "void set_color(int color);\n"
+ +"}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/shape.h")));
+
+ // Add shape.h to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ cppSourceCode.getBytes());
+ IFile cppSourceFile = project.addFileToProject(
+ "/src",
+ "shape.h", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/shape.h")));
+
+ // Open a source file and get the IEditorPart
+ cppSourceEditorPart = openEditor(cppSourceFile);
+ // make sure editor content is correct
+ assertEquals(cppSourceCode, getContent(cppSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = cppSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractTextEditor cppEditor = (AbstractTextEditor) cppSourceEditorPart;
+ cppEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualFunction = cParser.parseCurrentFunction(cppSourceEditorPart);
+
+ assertEquals(className, actualFunction);
+ }
+
+ /**
+ * Given an IEditorPart and current selection is inside a method,
+ * CParser should be able to figure that out.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canParseCurrentMethodNameInCppFile() throws Exception {
+ // make test project a C++ project
+ project.addCCNature();
+
+ final String expectedMethodName = "circle::area";
+ final String cppSourceCode = "#include \"circle.h\"\n"
+ + "#include <math.h>\n"
+ + "float " + expectedMethodName + "() {\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "return this->radius * this-> radius * M_PI\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/circle.cpp")));
+
+ // Add shape.h to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ cppSourceCode.getBytes());
+ IFile cppSourceFile = project.addFileToProject(
+ "/src",
+ "circle.cpp", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/circle.cpp")));
+
+ // Open a source file and get the IEditorPart
+ cppSourceEditorPart = openEditor(cppSourceFile);
+ // make sure editor content is correct
+ assertEquals(cppSourceCode, getContent(cppSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = cppSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractTextEditor cppEditor = (AbstractTextEditor) cppSourceEditorPart;
+ cppEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualMethodName = cParser.parseCurrentFunction(cppSourceEditorPart);
+
+ assertEquals(expectedMethodName, actualMethodName);
+ }
+
+ /**
+ * Given an IEditorPart and current selection is inside a method,
+ * CParser should be able to figure that out.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canParseCurrentFunctionInCppFile() throws Exception {
+ // make test project a C++ project
+ project.addCCNature();
+
+ final String expectedFunction = "main";
+ final String cppSourceCode = "#include \"circle.h\"\n"
+ + "#include <math.h>\n"
+ + "float circle::area() {\n"
+ + "return this->radius * this-> radius * M_PI\n"
+ + "}\n"
+ + "int " + expectedFunction + "() {\n"
+ + "int some_var = 0;\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "return 0;\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/circle.cpp")));
+
+ // Add shape.h to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ cppSourceCode.getBytes());
+ IFile cppSourceFile = project.addFileToProject(
+ "/src",
+ "circle.cpp", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/circle.cpp")));
+
+ // Open a source file and get the IEditorPart
+ cppSourceEditorPart = openEditor(cppSourceFile);
+ // make sure editor content is correct
+ assertEquals(cppSourceCode, getContent(cppSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( cppSourceEditorPart instanceof AbstractTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = cppSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractTextEditor cppEditor = (AbstractTextEditor) cppSourceEditorPart;
+ cppEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualFunction = cParser.parseCurrentFunction(cppSourceEditorPart);
+
+ assertEquals(expectedFunction, actualFunction);
+ }
+
+ /**
+ * Given an IStorageEditorInput we should be able to retrieve the currently
+ * active C function.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canParseCurrentFunctionFromCStringInIStorageEditorInput() throws Exception {
+ final String expectedFunctionName = "doSomething";
+ final String cSourceCode = "static int " + expectedFunctionName + "(char *test)\n"
+ + "{\n"
+ + "int index = 0;\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "return 0;\n"
+ + "}\n";
+
+ // prepare IStorageEditorInput
+ IStorage cStringStorage = new CStringStorage(cSourceCode);
+ IStorageEditorInput cStringStorageEditorInput = new CStringStorageInput(cStringStorage);
+
+ // Figure out the desired offset
+ int selectOffset = cSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectOffset >= 0);
+
+ final String actualFunctionName = cParser.parseCurrentFunction(cStringStorageEditorInput, selectOffset);
+
+ assertEquals(expectedFunctionName, actualFunctionName);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/JavaParserTest.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/JavaParserTest.java
index d57462adc5..3687d149c3 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/JavaParserTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/parsers/tests/JavaParserTest.java
@@ -35,429 +35,429 @@ import org.junit.Test;
/**
* JavaParser test suite.
- *
+ *
*/
public class JavaParserTest {
- // A unique string to mark the place of current selection in source code
- private static final String OFFSET_MARKER = "<# selection #>";
- // The parser under test
- private IParserChangeLogContrib javaParser;
- // A faked project
- private ChangeLogTestProject project;
- // The IEditorPart corresponding to the ChangeLog file
- private IEditorPart javaSourceEditorPart = null;
-
- @Before
- public void setUp() throws Exception {
- javaParser = ChangeLogExtensionManager.getExtensionManager().getParserContributor("CompilationUnitEditor");
- project = new ChangeLogTestProject("java-parser-test-project");
- // make it a Java project
- project.addJavaNature();
- }
-
- @After
- public void tearDown() throws Exception {
- // Tests in this class use javaSourceEditorPart. In order to avoid
- // spill-over from previous runs, truncate content (i.e. manually set
- // content to the empty string).
- if (javaSourceEditorPart != null) {
- AbstractTextEditor castEditor = (AbstractTextEditor) javaSourceEditorPart;
- IDocumentProvider iDocProvider = castEditor.getDocumentProvider();
- IDocument changelogContentDoc = iDocProvider.getDocument(castEditor.getEditorInput());
- changelogContentDoc.set("");
- javaSourceEditorPart.doSave(null);
- // Also close open editor in order for default content to work.
- // I.e. avoid spill over from previous test runs
- closeEditor(javaSourceEditorPart);
- }
- project.getTestProject().delete(true, true, null); // dispose
- }
-
- /**
- * Given an IEditorPart we should be able to retrieve the current function
- * we are in.
- *
- * @throws Exception
- */
- @Test
- public void canParseCurrentMethod() throws Exception {
- final String expectedMethodName = "doSomething";
- final String javaSourceCode = "public class JavaParserExampleClass {\n"
- + "private void " + expectedMethodName + "(String param) {\n"
- + "// " + OFFSET_MARKER + "\n"
- + "}\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Add JavaParserExampleClass.java to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- javaSourceCode.getBytes());
- IFile javaSourceFile = project.addFileToProject(
- "/src/org/eclipse/changelog/tests",
- "JavaParserExampleClass.java", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Open a source file and get the IEditorPart
- javaSourceEditorPart = openEditor(javaSourceFile);
- // make sure changelog editor content is right before merging
- assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
-
- // Select the snippet we want
- int selectionStart = javaSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
- javaEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualMethodName = javaParser.parseCurrentFunction(javaSourceEditorPart);
-
- assertEquals(expectedMethodName, actualMethodName);
- }
-
- /**
- * Given an IEditorPart we should be able to retrieve the currently selected
- * field.
- *
- * @throws Exception
- */
- @Test
- public void canParseSelectedField() throws Exception {
- final String expectedFieldName = "testVar";
- final String javaSourceCode = "public class JavaParserExampleClass {\n"
- + "private String " + expectedFieldName + " = null;\n"
- + "private void someMethod(String param) {\n"
- + "// empty \n"
- + "}\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Add JavaParserExampleClass.java to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- javaSourceCode.getBytes());
- IFile javaSourceFile = project.addFileToProject(
- "/src/org/eclipse/changelog/tests",
- "JavaParserExampleClass.java", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Open a source file and get the IEditorPart
- javaSourceEditorPart = openEditor(javaSourceFile);
- // make sure changelog editor content is right before merging
- assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
-
- // Select the snippet we want
- int selectionStart = javaSourceCode.indexOf(expectedFieldName);
- assertTrue(selectionStart >= 0);
- int selectionLength = expectedFieldName.length() - 3; // Shouldn't need to select the entire field
- AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
- javaEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualFieldName = javaParser.parseCurrentFunction(javaSourceEditorPart);
-
- assertEquals(expectedFieldName, actualFieldName);
- }
-
- /**
- * Given an IEditorPart and current selection is in a static instance initializer
- * block, JavaParser should be able to figure out that we were in an static
- * initializer block.
- *
- * @throws Exception
- */
- @Test
- public void canIdentifyStaticInitializerWhenInStaticInstanceInitializer() throws Exception {
- final String javaSourceCode = "public class JavaParserExampleClass {\n"
- + "private String someStrVariable = null;\n"
- // create static instance initializer block
- + "{\n"
- + "// " + OFFSET_MARKER + "\n"
- + "}\n"
- + "private void someMethod(String param) {\n"
- + "// empty \n"
- + "}\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Add JavaParserExampleClass.java to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- javaSourceCode.getBytes());
- IFile javaSourceFile = project.addFileToProject(
- "/src/org/eclipse/changelog/tests",
- "JavaParserExampleClass.java", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Open a source file and get the IEditorPart
- javaSourceEditorPart = openEditor(javaSourceFile);
- // make sure changelog editor content is right before merging
- assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
-
- // Select the snippet we want
- int selectionStart = javaSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
- javaEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
-
- assertEquals("static initializer", actualFunctionName);
- }
-
- /**
- * Given an IEditorPart and current selection is in a static class initializer
- * block, JavaParser should be able to figure out that we were in an static
- * initializer block.
- *
- * @throws Exception
- */
- @Test
- public void canIdentifyStaticInitializerWhenInStaticClassInitializer() throws Exception {
- final String javaSourceCode = "public class JavaParserExampleClass {\n"
- + "private String someStrVariable = null;\n"
- // create static class initializer block
- + "static {\n"
- + "// " + OFFSET_MARKER + "\n"
- + "}\n"
- + "private void someMethod(String param) {\n"
- + "// empty \n"
- + "}\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Add JavaParserExampleClass.java to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- javaSourceCode.getBytes());
- IFile javaSourceFile = project.addFileToProject(
- "/src/org/eclipse/changelog/tests",
- "JavaParserExampleClass.java", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Open a source file and get the IEditorPart
- javaSourceEditorPart = openEditor(javaSourceFile);
- // make sure changelog editor content is right before merging
- assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
-
- // Select the snippet we want
- int selectionStart = javaSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
- javaEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
-
- assertEquals("static initializer", actualFunctionName);
- }
-
- /**
- * Given an IEditorPart and current selection is inside a method within a nested
- * class, JavaParser should return a "nestedClass.methodName" construct for the
- * current function.
- *
- * @throws Exception
- */
- @Test
- public void canIdentifyMethodWithinNestedClass() throws Exception {
- final String nestedClassName = "Encapsulated";
- final String currentMethodName = "getString";
- final String javaSourceCode = "public class JavaParserExampleClass {\n"
- + "private String someStrVariable = null;\n"
- + "static {\n"
- + "// empty \n"
- + "}\n"
- + "private void someMethod(String param) {\n"
- + "// empty \n"
- + "}\n"
- + "private class " + nestedClassName + "{\n"
- + "public String " + currentMethodName + "() throws Exception {\n"
- + "// " + OFFSET_MARKER + "\n"
- + "return \"returnString\";\n"
- + "}\n"
- + "}\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Add JavaParserExampleClass.java to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- javaSourceCode.getBytes());
- IFile javaSourceFile = project.addFileToProject(
- "/src/org/eclipse/changelog/tests",
- "JavaParserExampleClass.java", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Open a source file and get the IEditorPart
- javaSourceEditorPart = openEditor(javaSourceFile);
- // make sure changelog editor content is right before merging
- assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
-
- // Select the snippet we want
- int selectionStart = javaSourceCode.indexOf(OFFSET_MARKER);
- assertTrue(selectionStart >= 0);
- int selectionLength = OFFSET_MARKER.length();
- AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
- javaEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String expectedFunctionName = nestedClassName + "." + currentMethodName;
- final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
-
- assertEquals(expectedFunctionName, actualFunctionName);
- }
-
- /**
- * Given an IEditorPart and currently a field within a nested
- * class is selected, JavaParser should return a "nestedClass.fieldName"
- * construct for the current function.
- *
- * @throws Exception
- */
- @Test
- public void canIdentifyFieldWithinNestedClass() throws Exception {
- final String nestedClassName = "Encapsulated";
- final String currentFieldName = "variableInNestedClass";
- final String javaSourceCode = "public class JavaParserExampleClass {\n"
- + "private String someStrVariable = null;\n"
- + "static {\n"
- + "// empty \n"
- + "}\n"
- + "private void someMethod(String param) {\n"
- + "// empty \n"
- + "}\n"
- + "private class " + nestedClassName + "{\n"
- + "private int " + currentFieldName + " = 10;\n"
- + "public String getString() throws Exception {\n"
- + "// return a String, yay ;-)\n"
- + "return \"returnString\";\n"
- + "}\n"
- + "}\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Add JavaParserExampleClass.java to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- javaSourceCode.getBytes());
- IFile javaSourceFile = project.addFileToProject(
- "/src/org/eclipse/changelog/tests",
- "JavaParserExampleClass.java", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Open a source file and get the IEditorPart
- javaSourceEditorPart = openEditor(javaSourceFile);
- // make sure changelog editor content is right before merging
- assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
-
- // Select the snippet we want
- int selectionStart = javaSourceCode.indexOf(currentFieldName);
- assertTrue(selectionStart >= 0);
- // select only a part of field name, as this should be sufficient
- int selectionLength = currentFieldName.length() - 3;
- AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
- javaEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String expectedFunctionName = nestedClassName + "." + currentFieldName;
- final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
-
- assertEquals(expectedFunctionName, actualFunctionName);
- }
-
- /**
- * Given an IEditorPart and current selection is inside a class but not within a
- * method, not selecting a field and not in a nested class (somewhere else in the
- * class) it should return an empty string for the function.
- *
- * @throws Exception
- */
- @Test
- public void canDetermineThatSelectionIsJustInClass() throws Exception {
- // Apparently comments don't show up in the compilation units. Makes
- // sense, right? But we can't use the OFFSET_MARKER trick in this case.
- final String javaSourceCode = "public class JavaParserExampleClass {\n"
- + "private String someStrVariable = null;\n"
- + "\n" // want to select this line indexOf(';') + 2
- + "\n"
- + "private void someMethod(String param) {\n"
- + "// empty \n"
- + "}\n"
- + "}\n";
-
- assertNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Add JavaParserExampleClass.java to project
- InputStream newFileInputStream = new ByteArrayInputStream(
- javaSourceCode.getBytes());
- IFile javaSourceFile = project.addFileToProject(
- "/src/org/eclipse/changelog/tests",
- "JavaParserExampleClass.java", newFileInputStream);
-
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
-
- // Open a source file and get the IEditorPart
- javaSourceEditorPart = openEditor(javaSourceFile);
- // make sure changelog editor content is right before merging
- assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
-
- // make sure we have the proper editor type
- assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
-
- // Select the right point
- int selectionStart = javaSourceCode.indexOf(';') + 2;
- assertTrue(selectionStart >= 2);
- int selectionLength = 0;
- AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
- javaEditor.getSelectionProvider().setSelection(
- new TextSelection(selectionStart, selectionLength));
-
- final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
-
- assertEquals("" /* expect empty string */, actualFunctionName);
- }
+ // A unique string to mark the place of current selection in source code
+ private static final String OFFSET_MARKER = "<# selection #>";
+ // The parser under test
+ private IParserChangeLogContrib javaParser;
+ // A faked project
+ private ChangeLogTestProject project;
+ // The IEditorPart corresponding to the ChangeLog file
+ private IEditorPart javaSourceEditorPart = null;
+
+ @Before
+ public void setUp() throws Exception {
+ javaParser = ChangeLogExtensionManager.getExtensionManager().getParserContributor("CompilationUnitEditor");
+ project = new ChangeLogTestProject("java-parser-test-project");
+ // make it a Java project
+ project.addJavaNature();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Tests in this class use javaSourceEditorPart. In order to avoid
+ // spill-over from previous runs, truncate content (i.e. manually set
+ // content to the empty string).
+ if (javaSourceEditorPart != null) {
+ AbstractTextEditor castEditor = (AbstractTextEditor) javaSourceEditorPart;
+ IDocumentProvider iDocProvider = castEditor.getDocumentProvider();
+ IDocument changelogContentDoc = iDocProvider.getDocument(castEditor.getEditorInput());
+ changelogContentDoc.set("");
+ javaSourceEditorPart.doSave(null);
+ // Also close open editor in order for default content to work.
+ // I.e. avoid spill over from previous test runs
+ closeEditor(javaSourceEditorPart);
+ }
+ project.getTestProject().delete(true, true, null); // dispose
+ }
+
+ /**
+ * Given an IEditorPart we should be able to retrieve the current function
+ * we are in.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canParseCurrentMethod() throws Exception {
+ final String expectedMethodName = "doSomething";
+ final String javaSourceCode = "public class JavaParserExampleClass {\n"
+ + "private void " + expectedMethodName + "(String param) {\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "}\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Add JavaParserExampleClass.java to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ javaSourceCode.getBytes());
+ IFile javaSourceFile = project.addFileToProject(
+ "/src/org/eclipse/changelog/tests",
+ "JavaParserExampleClass.java", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Open a source file and get the IEditorPart
+ javaSourceEditorPart = openEditor(javaSourceFile);
+ // make sure changelog editor content is right before merging
+ assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = javaSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
+ javaEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualMethodName = javaParser.parseCurrentFunction(javaSourceEditorPart);
+
+ assertEquals(expectedMethodName, actualMethodName);
+ }
+
+ /**
+ * Given an IEditorPart we should be able to retrieve the currently selected
+ * field.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canParseSelectedField() throws Exception {
+ final String expectedFieldName = "testVar";
+ final String javaSourceCode = "public class JavaParserExampleClass {\n"
+ + "private String " + expectedFieldName + " = null;\n"
+ + "private void someMethod(String param) {\n"
+ + "// empty \n"
+ + "}\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Add JavaParserExampleClass.java to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ javaSourceCode.getBytes());
+ IFile javaSourceFile = project.addFileToProject(
+ "/src/org/eclipse/changelog/tests",
+ "JavaParserExampleClass.java", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Open a source file and get the IEditorPart
+ javaSourceEditorPart = openEditor(javaSourceFile);
+ // make sure changelog editor content is right before merging
+ assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = javaSourceCode.indexOf(expectedFieldName);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = expectedFieldName.length() - 3; // Shouldn't need to select the entire field
+ AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
+ javaEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualFieldName = javaParser.parseCurrentFunction(javaSourceEditorPart);
+
+ assertEquals(expectedFieldName, actualFieldName);
+ }
+
+ /**
+ * Given an IEditorPart and current selection is in a static instance initializer
+ * block, JavaParser should be able to figure out that we were in an static
+ * initializer block.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canIdentifyStaticInitializerWhenInStaticInstanceInitializer() throws Exception {
+ final String javaSourceCode = "public class JavaParserExampleClass {\n"
+ + "private String someStrVariable = null;\n"
+ // create static instance initializer block
+ + "{\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "}\n"
+ + "private void someMethod(String param) {\n"
+ + "// empty \n"
+ + "}\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Add JavaParserExampleClass.java to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ javaSourceCode.getBytes());
+ IFile javaSourceFile = project.addFileToProject(
+ "/src/org/eclipse/changelog/tests",
+ "JavaParserExampleClass.java", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Open a source file and get the IEditorPart
+ javaSourceEditorPart = openEditor(javaSourceFile);
+ // make sure changelog editor content is right before merging
+ assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = javaSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
+ javaEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
+
+ assertEquals("static initializer", actualFunctionName);
+ }
+
+ /**
+ * Given an IEditorPart and current selection is in a static class initializer
+ * block, JavaParser should be able to figure out that we were in an static
+ * initializer block.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canIdentifyStaticInitializerWhenInStaticClassInitializer() throws Exception {
+ final String javaSourceCode = "public class JavaParserExampleClass {\n"
+ + "private String someStrVariable = null;\n"
+ // create static class initializer block
+ + "static {\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "}\n"
+ + "private void someMethod(String param) {\n"
+ + "// empty \n"
+ + "}\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Add JavaParserExampleClass.java to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ javaSourceCode.getBytes());
+ IFile javaSourceFile = project.addFileToProject(
+ "/src/org/eclipse/changelog/tests",
+ "JavaParserExampleClass.java", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Open a source file and get the IEditorPart
+ javaSourceEditorPart = openEditor(javaSourceFile);
+ // make sure changelog editor content is right before merging
+ assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = javaSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
+ javaEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
+
+ assertEquals("static initializer", actualFunctionName);
+ }
+
+ /**
+ * Given an IEditorPart and current selection is inside a method within a nested
+ * class, JavaParser should return a "nestedClass.methodName" construct for the
+ * current function.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canIdentifyMethodWithinNestedClass() throws Exception {
+ final String nestedClassName = "Encapsulated";
+ final String currentMethodName = "getString";
+ final String javaSourceCode = "public class JavaParserExampleClass {\n"
+ + "private String someStrVariable = null;\n"
+ + "static {\n"
+ + "// empty \n"
+ + "}\n"
+ + "private void someMethod(String param) {\n"
+ + "// empty \n"
+ + "}\n"
+ + "private class " + nestedClassName + "{\n"
+ + "public String " + currentMethodName + "() throws Exception {\n"
+ + "// " + OFFSET_MARKER + "\n"
+ + "return \"returnString\";\n"
+ + "}\n"
+ + "}\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Add JavaParserExampleClass.java to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ javaSourceCode.getBytes());
+ IFile javaSourceFile = project.addFileToProject(
+ "/src/org/eclipse/changelog/tests",
+ "JavaParserExampleClass.java", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Open a source file and get the IEditorPart
+ javaSourceEditorPart = openEditor(javaSourceFile);
+ // make sure changelog editor content is right before merging
+ assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = javaSourceCode.indexOf(OFFSET_MARKER);
+ assertTrue(selectionStart >= 0);
+ int selectionLength = OFFSET_MARKER.length();
+ AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
+ javaEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String expectedFunctionName = nestedClassName + "." + currentMethodName;
+ final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
+
+ assertEquals(expectedFunctionName, actualFunctionName);
+ }
+
+ /**
+ * Given an IEditorPart and currently a field within a nested
+ * class is selected, JavaParser should return a "nestedClass.fieldName"
+ * construct for the current function.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canIdentifyFieldWithinNestedClass() throws Exception {
+ final String nestedClassName = "Encapsulated";
+ final String currentFieldName = "variableInNestedClass";
+ final String javaSourceCode = "public class JavaParserExampleClass {\n"
+ + "private String someStrVariable = null;\n"
+ + "static {\n"
+ + "// empty \n"
+ + "}\n"
+ + "private void someMethod(String param) {\n"
+ + "// empty \n"
+ + "}\n"
+ + "private class " + nestedClassName + "{\n"
+ + "private int " + currentFieldName + " = 10;\n"
+ + "public String getString() throws Exception {\n"
+ + "// return a String, yay ;-)\n"
+ + "return \"returnString\";\n"
+ + "}\n"
+ + "}\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Add JavaParserExampleClass.java to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ javaSourceCode.getBytes());
+ IFile javaSourceFile = project.addFileToProject(
+ "/src/org/eclipse/changelog/tests",
+ "JavaParserExampleClass.java", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Open a source file and get the IEditorPart
+ javaSourceEditorPart = openEditor(javaSourceFile);
+ // make sure changelog editor content is right before merging
+ assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
+
+ // Select the snippet we want
+ int selectionStart = javaSourceCode.indexOf(currentFieldName);
+ assertTrue(selectionStart >= 0);
+ // select only a part of field name, as this should be sufficient
+ int selectionLength = currentFieldName.length() - 3;
+ AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
+ javaEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String expectedFunctionName = nestedClassName + "." + currentFieldName;
+ final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
+
+ assertEquals(expectedFunctionName, actualFunctionName);
+ }
+
+ /**
+ * Given an IEditorPart and current selection is inside a class but not within a
+ * method, not selecting a field and not in a nested class (somewhere else in the
+ * class) it should return an empty string for the function.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canDetermineThatSelectionIsJustInClass() throws Exception {
+ // Apparently comments don't show up in the compilation units. Makes
+ // sense, right? But we can't use the OFFSET_MARKER trick in this case.
+ final String javaSourceCode = "public class JavaParserExampleClass {\n"
+ + "private String someStrVariable = null;\n"
+ + "\n" // want to select this line indexOf(';') + 2
+ + "\n"
+ + "private void someMethod(String param) {\n"
+ + "// empty \n"
+ + "}\n"
+ + "}\n";
+
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Add JavaParserExampleClass.java to project
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ javaSourceCode.getBytes());
+ IFile javaSourceFile = project.addFileToProject(
+ "/src/org/eclipse/changelog/tests",
+ "JavaParserExampleClass.java", newFileInputStream);
+
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/org/eclipse/changelog/tests/JavaParserExampleClass.java")));
+
+ // Open a source file and get the IEditorPart
+ javaSourceEditorPart = openEditor(javaSourceFile);
+ // make sure changelog editor content is right before merging
+ assertEquals(javaSourceCode, getContent(javaSourceEditorPart));
+
+ // make sure we have the proper editor type
+ assertTrue( javaSourceEditorPart instanceof AbstractDecoratedTextEditor );
+
+ // Select the right point
+ int selectionStart = javaSourceCode.indexOf(';') + 2;
+ assertTrue(selectionStart >= 2);
+ int selectionLength = 0;
+ AbstractDecoratedTextEditor javaEditor = (AbstractDecoratedTextEditor) javaSourceEditorPart;
+ javaEditor.getSelectionProvider().setSelection(
+ new TextSelection(selectionStart, selectionLength));
+
+ final String actualFunctionName = javaParser.parseCurrentFunction(javaSourceEditorPart);
+
+ assertEquals("" /* expect empty string */, actualFunctionName);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorage.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorage.java
index 136f57c653..9f16aace40 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorage.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorage.java
@@ -18,35 +18,35 @@ import org.eclipse.core.runtime.IPath;
*
*/
public class CStringStorage implements IStorage {
- private String string;
-
- public CStringStorage(String input) {
- this.string = input;
- }
-
- @Override
- public InputStream getContents() {
- return new ByteArrayInputStream(string.getBytes());
- }
-
- @Override
- public IPath getFullPath() {
- return null;
- }
-
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- @Override
- public String getName() {
- int len = Math.min(5, string.length());
- return string.substring(0, len).concat("..."); //$NON-NLS-1$
- }
-
- @Override
- public boolean isReadOnly() {
- return true;
- }
+ private String string;
+
+ public CStringStorage(String input) {
+ this.string = input;
+ }
+
+ @Override
+ public InputStream getContents() {
+ return new ByteArrayInputStream(string.getBytes());
+ }
+
+ @Override
+ public IPath getFullPath() {
+ return null;
+ }
+
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ int len = Math.min(5, string.length());
+ return string.substring(0, len).concat("..."); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorageInput.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorageInput.java
index 117e8f1f40..9f3e638d5e 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorageInput.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/CStringStorageInput.java
@@ -17,46 +17,46 @@ import org.eclipse.ui.IStorageEditorInput;
*
*/
public class CStringStorageInput implements IStorageEditorInput {
-
- private IStorage storage;
-
- public CStringStorageInput(IStorage storage) {
- this.storage = storage;
- }
-
- @Override
- public boolean exists() {
- return true;
- }
-
- @Override
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- @Override
- public String getName() {
- return storage.getName();
- }
-
- @Override
- public IPersistableElement getPersistable() {
- return null;
- }
-
- @Override
- public IStorage getStorage() {
- return storage;
- }
-
- @Override
- public String getToolTipText() {
- return "String-based file: " + storage.getName();
- }
-
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
+
+ private IStorage storage;
+
+ public CStringStorageInput(IStorage storage) {
+ this.storage = storage;
+ }
+
+ @Override
+ public boolean exists() {
+ return true;
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return storage.getName();
+ }
+
+ @Override
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ @Override
+ public IStorage getStorage() {
+ return storage;
+ }
+
+ @Override
+ public String getToolTipText() {
+ return "String-based file: " + storage.getName();
+ }
+
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/ChangeLogTestProject.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/ChangeLogTestProject.java
index 144e31409d..455fd3b3b4 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/ChangeLogTestProject.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/ChangeLogTestProject.java
@@ -25,124 +25,124 @@ import org.eclipse.jdt.core.JavaCore;
/**
* Test fixture for the changelog plug-in tests.
- *
+ *
* Functionality:
* - Create a new project in the current workspace
*
*/
public class ChangeLogTestProject {
- private IProject testProject;
-
- /**
- * Create a new ChangelogTestProject
- *
- * @param projectName The name of the project to be created.
- * @throws Exception
- */
- public ChangeLogTestProject(String projectName) throws Exception {
- testProject = createNewProject(projectName);
- }
-
- /**
- * @return the testProject
- */
- public IProject getTestProject() {
- return testProject;
- }
+ private IProject testProject;
+
+ /**
+ * Create a new ChangelogTestProject
+ *
+ * @param projectName The name of the project to be created.
+ * @throws Exception
+ */
+ public ChangeLogTestProject(String projectName) throws Exception {
+ testProject = createNewProject(projectName);
+ }
+
+ /**
+ * @return the testProject
+ */
+ public IProject getTestProject() {
+ return testProject;
+ }
+
+ /**
+ * @param testProject the testProject to set
+ */
+ public void setTestProject(IProject testProject) {
+ this.testProject = testProject;
+ }
+
+ /**
+ * Adds a file to this project at the specified <code>path</code>
+ * and the provided <code>filename</code>. If segments of <code>path</code>
+ * do not exist, they will be created.
+ *
+ * @param destPath The path relative to the project (use '/' as path separator).
+ * @param filename The name of the to be created file
+ * @param fileInputStream A stream to the new files content.
+ */
+ public IFile addFileToProject(String destPath, String filename, InputStream fileInputStream) throws CoreException {
+ String[] pathSegments = destPath.split("/");
+
+ IContainer parent = this.testProject;
+ for (String segment: pathSegments) {
+ if (segment.equals("")) {
+ continue; // ignore
+ }
+ IResource segmentResource = parent.findMember(new Path(IPath.SEPARATOR + segment));
+ if (segmentResource == null) {
+ // create folder
+ IFolder newFolder = parent.getFolder(new Path(segment));
+ newFolder.create(false, true, null);
+ parent = newFolder;
+ } else {
+ // resource existed
+ parent = (IContainer)segmentResource;
+ }
+ }
+ // Finally add the file
+ IFile newFile = parent.getFile(new Path(filename));
+ if (fileInputStream == null) {
+ throw new IllegalStateException("fileInputStream must not be null");
+ }
+ newFile.create(fileInputStream, false, null);
+
+ // refresh project
+ this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ return newFile;
+ }
+
+ /**
+ * Add the Java nature to this project. I.e. make it a Java project.
+ */
+ public IJavaProject addJavaNature() throws CoreException {
+ IProjectDescription description = this.testProject.getDescription();
+ String[] natures = description.getNatureIds();
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = JavaCore.NATURE_ID;
+ description.setNatureIds(newNatures);
+ this.testProject.setDescription(description, null);
+ return JavaCore.create(this.testProject);
+ }
- /**
- * @param testProject the testProject to set
- */
- public void setTestProject(IProject testProject) {
- this.testProject = testProject;
- }
-
- /**
- * Adds a file to this project at the specified <code>path</code>
- * and the provided <code>filename</code>. If segments of <code>path</code>
- * do not exist, they will be created.
- *
- * @param destPath The path relative to the project (use '/' as path separator).
- * @param filename The name of the to be created file
- * @param fileInputStream A stream to the new files content.
- */
- public IFile addFileToProject(String destPath, String filename, InputStream fileInputStream) throws CoreException {
- String[] pathSegments = destPath.split("/");
-
- IContainer parent = this.testProject;
- for (String segment: pathSegments) {
- if (segment.equals("")) {
- continue; // ignore
- }
- IResource segmentResource = parent.findMember(new Path(IPath.SEPARATOR + segment));
- if (segmentResource == null) {
- // create folder
- IFolder newFolder = parent.getFolder(new Path(segment));
- newFolder.create(false, true, null);
- parent = newFolder;
- } else {
- // resource existed
- parent = (IContainer)segmentResource;
- }
- }
- // Finally add the file
- IFile newFile = parent.getFile(new Path(filename));
- if (fileInputStream == null) {
- throw new IllegalStateException("fileInputStream must not be null");
- }
- newFile.create(fileInputStream, false, null);
-
- // refresh project
- this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- return newFile;
- }
-
- /**
- * Add the Java nature to this project. I.e. make it a Java project.
- */
- public IJavaProject addJavaNature() throws CoreException {
- IProjectDescription description = this.testProject.getDescription();
- String[] natures = description.getNatureIds();
- String[] newNatures = new String[natures.length + 1];
- System.arraycopy(natures, 0, newNatures, 0, natures.length);
- newNatures[natures.length] = JavaCore.NATURE_ID;
- description.setNatureIds(newNatures);
- this.testProject.setDescription(description, null);
- return JavaCore.create(this.testProject);
- }
+ /**
+ * Add the C nature to this project. I.e. make it a C project.
+ * @throws CoreException
+ */
+ public void addCNature() throws CoreException {
+ this.testProject = CCorePlugin.getDefault().createCDTProject(
+ testProject.getDescription(), testProject, null);
+ }
- /**
- * Add the C nature to this project. I.e. make it a C project.
- * @throws CoreException
- */
- public void addCNature() throws CoreException {
- this.testProject = CCorePlugin.getDefault().createCDTProject(
- testProject.getDescription(), testProject, null);
- }
-
- /**
- * Add the C++ nature to this project. I.e. make it a C++ project.
- * @throws CoreException
- */
- public void addCCNature() throws CoreException {
- addCNature();
- CCorePlugin.getDefault().convertProjectFromCtoCC(testProject, null);
- }
+ /**
+ * Add the C++ nature to this project. I.e. make it a C++ project.
+ * @throws CoreException
+ */
+ public void addCCNature() throws CoreException {
+ addCNature();
+ CCorePlugin.getDefault().convertProjectFromCtoCC(testProject, null);
+ }
- /**
- * Create a new Eclipse project in the current workspace
- *
- * @param name
- * @throws CoreException if project creation fails for some reason.
- * @return The newly created project.
- */
- private IProject createNewProject(String name) throws CoreException {
- IProject newProject = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(name);
- newProject.create(null);
- newProject.open(null); // needs to be open
- return newProject;
- }
+ /**
+ * Create a new Eclipse project in the current workspace
+ *
+ * @param name
+ * @throws CoreException if project creation fails for some reason.
+ * @return The newly created project.
+ */
+ private IProject createNewProject(String name) throws CoreException {
+ IProject newProject = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(name);
+ newProject.create(null);
+ newProject.open(null); // needs to be open
+ return newProject;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/TestChangeLogTestProject.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/TestChangeLogTestProject.java
index 522f99f2a8..d9b19a6836 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/TestChangeLogTestProject.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/fixtures/TestChangeLogTestProject.java
@@ -27,124 +27,124 @@ import org.eclipse.cdt.core.model.CoreModel;
/**
* @author Redhat Inc.
- *
+ *
*/
public class TestChangeLogTestProject {
- private ChangeLogTestProject project;
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- project = new ChangeLogTestProject("com.redhat.testchangelog.project");
- }
-
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- // dispose
- project.getTestProject().delete(true, null);
- }
-
- /**
- * Test method for
- * {@link org.eclipse.linuxtools.changelog.tests.fixtures.ChangeLogTestProject#addFileToProject(java.lang.String, java.lang.String, java.io.InputStream)}
- * .
- */
- @Test
- public void testAddFileToProject() throws Exception {
- String fileContent = "some content";
- InputStream newFileInputStream = new ByteArrayInputStream(
- fileContent.getBytes());
- // Create file "testfile.txt" with content "some content" at
- // "/this/is/a/testpath"
- project.addFileToProject("/this/is/a/testpath", "testfile.txt",
- newFileInputStream);
- IProject p = project.getTestProject();
-
- // Paths along the way should have been created
- IResource member = p.findMember(new Path("/this"));
- assertNotNull(member);
- assertEquals("this", member.getName());
- member = p.findMember(new Path("/this/is"));
- assertNotNull(member);
- assertEquals("is", member.getName());
- member = p.findMember(new Path("/this/is/a"));
- assertNotNull(member);
- assertEquals("a", member.getName());
- member = p.findMember(new Path("/this/is/a/testpath"));
- assertNotNull(member);
- assertEquals("testpath", member.getName());
-
- // Testfile should be around
- IResource createdFile = p.findMember(new Path("/this/is/a/testpath/testfile.txt"));
- assertNotNull(createdFile);
- assertEquals("this/is/a/testpath/testfile.txt", createdFile.getProjectRelativePath().toString());
- assertEquals("testfile.txt", createdFile.getName());
- assertTrue(createdFile instanceof IFile);
-
- // Content should be "some content"
- try (BufferedReader br = new BufferedReader(new InputStreamReader(
- new FileInputStream(createdFile.getLocation().toFile())))) {
- String actualContent = br.readLine();
- assertEquals(fileContent, actualContent);
- }
-
- // this should throw an IllegalStateException
- boolean exceptionTrown = false;
- try {
- project.addFileToProject("donnot/care", "not_important.java",
- null /* should cause exception */);
- } catch (IllegalStateException e) {
- // pass
- exceptionTrown = true;
- }
- assertTrue(exceptionTrown);
- }
-
- /**
- * We should be able to add a Java nature to a project.
- *
- * @throws Exception
- */
- @Test
- public void canAddJavaNature() throws Exception {
- IJavaProject javaProject = this.project.addJavaNature();
- assertNotNull(javaProject);
- }
-
- /**
- * We should be able to add a C nature to a project.
- *
- * @throws Exception
- */
- @Test
- public void canAddCNature() throws Exception {
- IProject cProject = this.project.getTestProject();
- assertFalse(CoreModel.hasCNature(cProject));
- // Add C nature
- this.project.addCNature();
- cProject = this.project.getTestProject();
- assertTrue(CoreModel.hasCNature(cProject));
- }
-
- /**
- * We should be able to add a C++ nature to a project.
- *
- * @throws Exception
- */
- @Test
- public void canAddCCNature() throws Exception {
- IProject ccProject = this.project.getTestProject();
- assertFalse(CoreModel.hasCCNature(ccProject));
- // Add C++ nature
- this.project.addCCNature();
- ccProject = this.project.getTestProject();
- assertTrue(CoreModel.hasCCNature(ccProject));
- }
+ private ChangeLogTestProject project;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ project = new ChangeLogTestProject("com.redhat.testchangelog.project");
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ // dispose
+ project.getTestProject().delete(true, null);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.linuxtools.changelog.tests.fixtures.ChangeLogTestProject#addFileToProject(java.lang.String, java.lang.String, java.io.InputStream)}
+ * .
+ */
+ @Test
+ public void testAddFileToProject() throws Exception {
+ String fileContent = "some content";
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ fileContent.getBytes());
+ // Create file "testfile.txt" with content "some content" at
+ // "/this/is/a/testpath"
+ project.addFileToProject("/this/is/a/testpath", "testfile.txt",
+ newFileInputStream);
+ IProject p = project.getTestProject();
+
+ // Paths along the way should have been created
+ IResource member = p.findMember(new Path("/this"));
+ assertNotNull(member);
+ assertEquals("this", member.getName());
+ member = p.findMember(new Path("/this/is"));
+ assertNotNull(member);
+ assertEquals("is", member.getName());
+ member = p.findMember(new Path("/this/is/a"));
+ assertNotNull(member);
+ assertEquals("a", member.getName());
+ member = p.findMember(new Path("/this/is/a/testpath"));
+ assertNotNull(member);
+ assertEquals("testpath", member.getName());
+
+ // Testfile should be around
+ IResource createdFile = p.findMember(new Path("/this/is/a/testpath/testfile.txt"));
+ assertNotNull(createdFile);
+ assertEquals("this/is/a/testpath/testfile.txt", createdFile.getProjectRelativePath().toString());
+ assertEquals("testfile.txt", createdFile.getName());
+ assertTrue(createdFile instanceof IFile);
+
+ // Content should be "some content"
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(createdFile.getLocation().toFile())))) {
+ String actualContent = br.readLine();
+ assertEquals(fileContent, actualContent);
+ }
+
+ // this should throw an IllegalStateException
+ boolean exceptionTrown = false;
+ try {
+ project.addFileToProject("donnot/care", "not_important.java",
+ null /* should cause exception */);
+ } catch (IllegalStateException e) {
+ // pass
+ exceptionTrown = true;
+ }
+ assertTrue(exceptionTrown);
+ }
+
+ /**
+ * We should be able to add a Java nature to a project.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canAddJavaNature() throws Exception {
+ IJavaProject javaProject = this.project.addJavaNature();
+ assertNotNull(javaProject);
+ }
+
+ /**
+ * We should be able to add a C nature to a project.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canAddCNature() throws Exception {
+ IProject cProject = this.project.getTestProject();
+ assertFalse(CoreModel.hasCNature(cProject));
+ // Add C nature
+ this.project.addCNature();
+ cProject = this.project.getTestProject();
+ assertTrue(CoreModel.hasCNature(cProject));
+ }
+
+ /**
+ * We should be able to add a C++ nature to a project.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canAddCCNature() throws Exception {
+ IProject ccProject = this.project.getTestProject();
+ assertFalse(CoreModel.hasCCNature(ccProject));
+ // Add C++ nature
+ this.project.addCCNature();
+ ccProject = this.project.getTestProject();
+ assertTrue(CoreModel.hasCCNature(ccProject));
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/helpers/EditorHelper.java b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/helpers/EditorHelper.java
index 3f22957e0b..e3ffb389fd 100644
--- a/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/helpers/EditorHelper.java
+++ b/changelog/org.eclipse.linuxtools.changelog.tests/src/org/eclipse/linuxtools/changelog/tests/helpers/EditorHelper.java
@@ -18,52 +18,52 @@ import org.eclipse.ui.texteditor.IDocumentProvider;
public class EditorHelper {
- /**
- * Open file associated with <code>diskresource</code> in current
- * workspace.
- *
- * @param diskresource The file to be opened in the current workspace.
- * @return The IEditorPart associated with the opened file in the current workspace
- * or null if opening fails.
- */
- public static IEditorPart openEditor(IFile diskresource) {
- IWorkbench ws = PlatformUI.getWorkbench();
- try {
- return org.eclipse.ui.ide.IDE.openEditor(ws
- .getActiveWorkbenchWindow().getActivePage(), diskresource,
- true);
- } catch (PartInitException e) {
- e.printStackTrace();
+ /**
+ * Open file associated with <code>diskresource</code> in current
+ * workspace.
+ *
+ * @param diskresource The file to be opened in the current workspace.
+ * @return The IEditorPart associated with the opened file in the current workspace
+ * or null if opening fails.
+ */
+ public static IEditorPart openEditor(IFile diskresource) {
+ IWorkbench ws = PlatformUI.getWorkbench();
+ try {
+ return org.eclipse.ui.ide.IDE.openEditor(ws
+ .getActiveWorkbenchWindow().getActivePage(), diskresource,
+ true);
+ } catch (PartInitException e) {
+ e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Close editor if it is active.
- */
- public static void closeEditor(final IEditorPart editor) {
- if (editor.getSite().getWorkbenchWindow().getActivePage() != null) {
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- // close editor
- editor.getSite().getWorkbenchWindow().getActivePage()
- .closeEditor(editor, false);
- }
- });
- }
- }
-
- /**
- * Return the content of the given IEditorPart as String.
- * @param editorPart
- * @return Content of editorPart.
- */
- public static String getContent(IEditorPart editorPart) {
- AbstractTextEditor castEditor = (AbstractTextEditor) editorPart;
- IDocumentProvider provider = castEditor.getDocumentProvider();
- IDocument document = provider.getDocument(castEditor.getEditorInput());
- return document.get();
- }
+ return null;
+ }
+ }
+
+ /**
+ * Close editor if it is active.
+ */
+ public static void closeEditor(final IEditorPart editor) {
+ if (editor.getSite().getWorkbenchWindow().getActivePage() != null) {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ // close editor
+ editor.getSite().getWorkbenchWindow().getActivePage()
+ .closeEditor(editor, false);
+ }
+ });
+ }
+ }
+
+ /**
+ * Return the content of the given IEditorPart as String.
+ * @param editorPart
+ * @return Content of editorPart.
+ */
+ public static String getContent(IEditorPart editorPart) {
+ AbstractTextEditor castEditor = (AbstractTextEditor) editorPart;
+ IDocumentProvider provider = castEditor.getDocumentProvider();
+ IDocument document = provider.getDocument(castEditor.getEditorInput());
+ return document.get();
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/pom.xml b/changelog/org.eclipse.linuxtools.changelog.ui.tests/pom.xml
index 18dfe8f0de..68d5d44284 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/pom.xml
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/pom.xml
@@ -36,7 +36,7 @@
</excludes>
<testSuite>org.eclipse.linuxtools.changelog.ui.tests</testSuite>
<testClass>org.eclipse.linuxtools.changelog.ui.tests.swtbot.AllSWTBotTests</testClass>
- <useUIHarness>true</useUIHarness>
+ <useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<product>org.eclipse.platform.ide</product>
<surefire.timeout>1800</surefire.timeout>
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/log4j.xml b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/log4j.xml
index 87414d37ef..9bbb32c295 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/log4j.xml
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/log4j.xml
@@ -1,60 +1,60 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
- debug="false">
-
- <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern"
- value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
- </layout>
- </appender>
-
- <appender name="fileAppender" class="org.apache.log4j.FileAppender">
- <param name="File" value="swtbot_tests.log" />
- <param name="Append" value="false" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern"
- value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
- </layout>
- </appender>
-
- <appender name="asyncAppender" class="org.apache.log4j.AsyncAppender">
- <!-- appender-ref ref="consoleAppender" / -->
- <appender-ref ref="fileAppender" />
- </appender>
-
- <!-- don't log matchers, this is very high amount of chatter -->
- <category name="org.eclipse.swtbot.swt.finder.matchers">
- <priority value="OFF" />
- </category>
-
- <!--
- don't log widget notification events, this is moderately high chatter
- -->
- <category name="org.eclipse.swtbot.swt.finder.widgets">
- <priority value="DEBUG" />
- </category>
-
- <!-- don't log finders, this is moderate chatter -->
- <category name="org.eclipse.swtbot.swt.finder.finders">
- <priority value="DEBUG" />
- </category>
-
- <category name="org.eclipse.swtbot.swt.finder.keyboard">
- <!-- set to a value higher than debug to turn on. -->
- <priority value="DEBUG" />
- </category>
-
- <category name="org.eclipse.swtbot">
- <priority value="ALL" />
- </category>
-
- <root>
- <priority value="INFO" />
- <appender-ref ref="consoleAppender" />
- <appender-ref ref="fileAppender" />
- </root>
+ debug="false">
+
+ <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
+ </layout>
+ </appender>
+
+ <appender name="fileAppender" class="org.apache.log4j.FileAppender">
+ <param name="File" value="swtbot_tests.log" />
+ <param name="Append" value="false" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
+ </layout>
+ </appender>
+
+ <appender name="asyncAppender" class="org.apache.log4j.AsyncAppender">
+ <!-- appender-ref ref="consoleAppender" / -->
+ <appender-ref ref="fileAppender" />
+ </appender>
+
+ <!-- don't log matchers, this is very high amount of chatter -->
+ <category name="org.eclipse.swtbot.swt.finder.matchers">
+ <priority value="OFF" />
+ </category>
+
+ <!--
+ don't log widget notification events, this is moderately high chatter
+ -->
+ <category name="org.eclipse.swtbot.swt.finder.widgets">
+ <priority value="DEBUG" />
+ </category>
+
+ <!-- don't log finders, this is moderate chatter -->
+ <category name="org.eclipse.swtbot.swt.finder.finders">
+ <priority value="DEBUG" />
+ </category>
+
+ <category name="org.eclipse.swtbot.swt.finder.keyboard">
+ <!-- set to a value higher than debug to turn on. -->
+ <priority value="DEBUG" />
+ </category>
+
+ <category name="org.eclipse.swtbot">
+ <priority value="ALL" />
+ </category>
+
+ <root>
+ <priority value="INFO" />
+ <appender-ref ref="consoleAppender" />
+ <appender-ref ref="fileAppender" />
+ </root>
</log4j:configuration> \ No newline at end of file
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java
index 2ae9a4b6b4..f9c4d03ff0 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java
@@ -50,213 +50,213 @@ import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
public class AddChangelogEntrySWTBotTest {
- private static SWTWorkbenchBot bot;
- private static SWTBotTree projectExplorerViewTree;
- private ChangeLogTestProject project;
- private static final String OFFSET_MARKER = "<-- SELECT -->";
- // The name of the test project, we create
- private final String PROJECT_NAME = "changelog-java-project";
+ private static SWTWorkbenchBot bot;
+ private static SWTBotTree projectExplorerViewTree;
+ private ChangeLogTestProject project;
+ private static final String OFFSET_MARKER = "<-- SELECT -->";
+ // The name of the test project, we create
+ private final String PROJECT_NAME = "changelog-java-project";
- @BeforeClass
- public static void beforeClass() throws Exception {
- // delay click speed; with this turned on things get flaky
- //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
- bot = new SWTWorkbenchBot();
- try {
- bot.viewByTitle("Welcome").close();
- // hide Subclipse Usage stats popup if present/installed
- bot.shell("Subclipse Usage").activate();
- bot.button("Cancel").click();
- } catch (WidgetNotFoundException e) {
- // ignore
- }
- // Make sure project explorer is open and tree available
- ProjectExplorer.openView();
- projectExplorerViewTree = ProjectExplorer.getTree();
- }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ // delay click speed; with this turned on things get flaky
+ //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
+ bot = new SWTWorkbenchBot();
+ try {
+ bot.viewByTitle("Welcome").close();
+ // hide Subclipse Usage stats popup if present/installed
+ bot.shell("Subclipse Usage").activate();
+ bot.button("Cancel").click();
+ } catch (WidgetNotFoundException e) {
+ // ignore
+ }
+ // Make sure project explorer is open and tree available
+ ProjectExplorer.openView();
+ projectExplorerViewTree = ProjectExplorer.getTree();
+ }
- @Before
- public void setUp() throws Exception {
- // Create an empty test project
- project = new ChangeLogTestProject(PROJECT_NAME);
- project.addJavaNature(); // make it a Java project
- }
+ @Before
+ public void setUp() throws Exception {
+ // Create an empty test project
+ project = new ChangeLogTestProject(PROJECT_NAME);
+ project.addJavaNature(); // make it a Java project
+ }
- @After
- public void tearDown() throws Exception {
- this.project.getTestProject().delete(true, null);
- }
+ @After
+ public void tearDown() throws Exception {
+ this.project.getTestProject().delete(true, null);
+ }
- /**
- * ChangeLog editor should pop-up if inside an active editor
- * and a ChangeLog file exists in the project. Tests the CTRL+ALT+c
- * shortcut.
- *
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- @Test
- public void canAddChangeLogEntryUsingShortCutIfSourceIsActive() throws Exception {
- // Add a Java source file
- String sourceCode = "package src;\n" +
- "public class JavaTest {\n" +
- "public static void main(String args[]) {\n" +
- "//" + OFFSET_MARKER + "\n" +
- "System.out.println(\"Hello World!\");\n" +
- "}\n" +
- "}\n";
+ /**
+ * ChangeLog editor should pop-up if inside an active editor
+ * and a ChangeLog file exists in the project. Tests the CTRL+ALT+c
+ * shortcut.
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void canAddChangeLogEntryUsingShortCutIfSourceIsActive() throws Exception {
+ // Add a Java source file
+ String sourceCode = "package src;\n" +
+ "public class JavaTest {\n" +
+ "public static void main(String args[]) {\n" +
+ "//" + OFFSET_MARKER + "\n" +
+ "System.out.println(\"Hello World!\");\n" +
+ "}\n" +
+ "}\n";
- assertNull(project.getTestProject().findMember( new Path(
- "/src/JavaTest.java")));
- InputStream newFileInputStream = new ByteArrayInputStream(
- sourceCode.getBytes());
- project.addFileToProject("/src", "JavaTest.java", newFileInputStream);
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/JavaTest.java")));
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ sourceCode.getBytes());
+ project.addFileToProject("/src", "JavaTest.java", newFileInputStream);
- // Add a changelog file
- newFileInputStream = new ByteArrayInputStream(
- "".getBytes());
- project.addFileToProject("/", "ChangeLog", newFileInputStream);
+ // Add a changelog file
+ newFileInputStream = new ByteArrayInputStream(
+ "".getBytes());
+ project.addFileToProject("/", "ChangeLog", newFileInputStream);
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/JavaTest.java")));
- assertNotNull(project.getTestProject().findMember( new Path(
- "/ChangeLog")));
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/JavaTest.java")));
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/ChangeLog")));
- // Open JavaTest.java in an editor
- projectExplorerViewTree.expandNode(PROJECT_NAME).expandNode("src").expandNode("JavaTest.java").doubleClick();
+ // Open JavaTest.java in an editor
+ projectExplorerViewTree.expandNode(PROJECT_NAME).expandNode("src").expandNode("JavaTest.java").doubleClick();
- Matcher<?> editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName("JavaTest.java")
- );
- // Wait for Java editor to open
- bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
- SWTBotEditor swtBoteditor = bot.editorByTitle("JavaTest.java");
- SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
- eclipseEditor.selectLine(getLineOfOffsetMarker(sourceCode));
+ Matcher<?> editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName("JavaTest.java")
+ );
+ // Wait for Java editor to open
+ bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
+ SWTBotEditor swtBoteditor = bot.editorByTitle("JavaTest.java");
+ SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
+ eclipseEditor.selectLine(getLineOfOffsetMarker(sourceCode));
- // Press: CTRL + ALT + c
- eclipseEditor.pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("C"));
- // Wait for ChangeLog editor to open
- editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName("ChangeLog")
- );
- bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
- swtBoteditor = bot.activeEditor();
- swtBoteditor.save(); // save to avoid "save changes"-pop-up
- assertEquals("ChangeLog", swtBoteditor.getTitle());
- eclipseEditor = swtBoteditor.toTextEditor();
- // make sure expected entry has been added.
- assertTrue(eclipseEditor.getText().contains("\t* src/JavaTest.java (main):"));
- }
+ // Press: CTRL + ALT + c
+ eclipseEditor.pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("C"));
+ // Wait for ChangeLog editor to open
+ editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName("ChangeLog")
+ );
+ bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
+ swtBoteditor = bot.activeEditor();
+ swtBoteditor.save(); // save to avoid "save changes"-pop-up
+ assertEquals("ChangeLog", swtBoteditor.getTitle());
+ eclipseEditor = swtBoteditor.toTextEditor();
+ // make sure expected entry has been added.
+ assertTrue(eclipseEditor.getText().contains("\t* src/JavaTest.java (main):"));
+ }
- /**
- * ChangeLog editor should pop-up if inside an active editor
- * and a ChangeLog file exists in the project. Tests the "Edit" => "ChangeLog Entry"
- * menu item.
- *
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- @Test
- public void canAddChangeLogEntryUsingEditMenuIfSourceIsActive() throws Exception {
- // Add a Java source file
- String sourceCode = "package src;\n" +
- "public class JavaTest {\n" +
- "public static void main(String args[]) {\n" +
- "//" + OFFSET_MARKER + "\n" +
- "System.out.println(\"Hello World!\");\n" +
- "}\n" +
- "}\n";
+ /**
+ * ChangeLog editor should pop-up if inside an active editor
+ * and a ChangeLog file exists in the project. Tests the "Edit" => "ChangeLog Entry"
+ * menu item.
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void canAddChangeLogEntryUsingEditMenuIfSourceIsActive() throws Exception {
+ // Add a Java source file
+ String sourceCode = "package src;\n" +
+ "public class JavaTest {\n" +
+ "public static void main(String args[]) {\n" +
+ "//" + OFFSET_MARKER + "\n" +
+ "System.out.println(\"Hello World!\");\n" +
+ "}\n" +
+ "}\n";
- assertNull(project.getTestProject().findMember( new Path(
- "/src/JavaTest.java")));
- InputStream newFileInputStream = new ByteArrayInputStream(
- sourceCode.getBytes());
- project.addFileToProject("/src", "JavaTest.java", newFileInputStream);
+ assertNull(project.getTestProject().findMember( new Path(
+ "/src/JavaTest.java")));
+ InputStream newFileInputStream = new ByteArrayInputStream(
+ sourceCode.getBytes());
+ project.addFileToProject("/src", "JavaTest.java", newFileInputStream);
- // Add a changelog file
- newFileInputStream = new ByteArrayInputStream(
- "".getBytes());
- project.addFileToProject("/", "ChangeLog", newFileInputStream);
+ // Add a changelog file
+ newFileInputStream = new ByteArrayInputStream(
+ "".getBytes());
+ project.addFileToProject("/", "ChangeLog", newFileInputStream);
- assertNotNull(project.getTestProject().findMember( new Path(
- "/src/JavaTest.java")));
- assertNotNull(project.getTestProject().findMember( new Path(
- "/ChangeLog")));
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/src/JavaTest.java")));
+ assertNotNull(project.getTestProject().findMember( new Path(
+ "/ChangeLog")));
- // Open JavaTest.java in an editor
- SWTBotTreeItem projectItem = projectExplorerViewTree.expandNode(PROJECT_NAME);
- projectItem.expandNode("src").expandNode("JavaTest.java").doubleClick();
+ // Open JavaTest.java in an editor
+ SWTBotTreeItem projectItem = projectExplorerViewTree.expandNode(PROJECT_NAME);
+ projectItem.expandNode("src").expandNode("JavaTest.java").doubleClick();
- Matcher<?> editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName("JavaTest.java")
- );
- // Wait for editor to open
- bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
- SWTBotEditor swtBoteditor = bot.editorByTitle("JavaTest.java");
- SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
- eclipseEditor.selectLine(getLineOfOffsetMarker(sourceCode));
+ Matcher<?> editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName("JavaTest.java")
+ );
+ // Wait for editor to open
+ bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
+ SWTBotEditor swtBoteditor = bot.editorByTitle("JavaTest.java");
+ SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
+ eclipseEditor.selectLine(getLineOfOffsetMarker(sourceCode));
- // Click menu item.
- bot.menu("Edit").menu("ChangeLog Entry").click();
- // Wait for ChangeLog editor to open
- editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName("ChangeLog")
- );
- bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
- swtBoteditor = bot.activeEditor();
- swtBoteditor.save(); // save to avoid "save changes"-pop-up
- assertEquals("ChangeLog", swtBoteditor.getTitle());
- eclipseEditor = swtBoteditor.toTextEditor();
- // make sure expected entry has been added.
- assertTrue(eclipseEditor.getText().contains("\t* src/JavaTest.java (main):"));
- }
+ // Click menu item.
+ bot.menu("Edit").menu("ChangeLog Entry").click();
+ // Wait for ChangeLog editor to open
+ editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName("ChangeLog")
+ );
+ bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
+ swtBoteditor = bot.activeEditor();
+ swtBoteditor.save(); // save to avoid "save changes"-pop-up
+ assertEquals("ChangeLog", swtBoteditor.getTitle());
+ eclipseEditor = swtBoteditor.toTextEditor();
+ // make sure expected entry has been added.
+ assertTrue(eclipseEditor.getText().contains("\t* src/JavaTest.java (main):"));
+ }
- /**
- * FIXME: Disable menu item instead of showing it and doing nothing.
- *
- * This test throws WidgetNotFountException (i.e. shouldn't open any editor).
- */
- @Test(expected=WidgetNotFoundException.class)
- public void shouldDoNothingIfNoEditorIsActive() {
- assertNull(project.getTestProject().findMember( new Path("/src/dummy")));
- try {
- project.addFileToProject("src", "dummy", new ByteArrayInputStream("".getBytes()));
- } catch (CoreException e) {
- fail("Could not add /src/dummy file to project");
- }
- assertNotNull(project.getTestProject().findMember( new Path("/src/dummy")));
- // Make sure we are in the project explorer view and no editors are open
- bot.closeAllEditors();
- projectExplorerViewTree.expandNode(PROJECT_NAME).expandNode("src");
- // Try to create ChangeLog
- bot.menu("Edit").menu("ChangeLog Entry").click();
- // Don't wait 5 secs
- long oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 1000; // give it a full second :)
- bot.activeEditor();
- SWTBotPreferences.TIMEOUT = oldTimeout;
- }
+ /**
+ * FIXME: Disable menu item instead of showing it and doing nothing.
+ *
+ * This test throws WidgetNotFountException (i.e. shouldn't open any editor).
+ */
+ @Test(expected=WidgetNotFoundException.class)
+ public void shouldDoNothingIfNoEditorIsActive() {
+ assertNull(project.getTestProject().findMember( new Path("/src/dummy")));
+ try {
+ project.addFileToProject("src", "dummy", new ByteArrayInputStream("".getBytes()));
+ } catch (CoreException e) {
+ fail("Could not add /src/dummy file to project");
+ }
+ assertNotNull(project.getTestProject().findMember( new Path("/src/dummy")));
+ // Make sure we are in the project explorer view and no editors are open
+ bot.closeAllEditors();
+ projectExplorerViewTree.expandNode(PROJECT_NAME).expandNode("src");
+ // Try to create ChangeLog
+ bot.menu("Edit").menu("ChangeLog Entry").click();
+ // Don't wait 5 secs
+ long oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 1000; // give it a full second :)
+ bot.activeEditor();
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+ }
- /**
- * @param The source text.
- * @return The index of the first line containing the OFFSET_MARKER string in sourceCode.
- * -1 if not found.
- */
- private int getLineOfOffsetMarker(String sourceCode) {
- // select line containing the println() statement.
- int offset = -1, i = 0;
- for (String line: sourceCode.split("\n")) {
- if (line.indexOf(OFFSET_MARKER) >= 0) {
- offset = i;
- break;
- }
- i++;
- }
- return offset;
- }
+ /**
+ * @param The source text.
+ * @return The index of the first line containing the OFFSET_MARKER string in sourceCode.
+ * -1 if not found.
+ */
+ private int getLineOfOffsetMarker(String sourceCode) {
+ // select line containing the println() statement.
+ int offset = -1, i = 0;
+ for (String line: sourceCode.split("\n")) {
+ if (line.indexOf(OFFSET_MARKER) >= 0) {
+ offset = i;
+ break;
+ }
+ i++;
+ }
+ return offset;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AllSWTBotTests.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AllSWTBotTests.java
index 49e60230ae..165298c244 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AllSWTBotTests.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AllSWTBotTests.java
@@ -17,14 +17,14 @@ import org.junit.runners.Suite.SuiteClasses;
*/
@RunWith(Suite.class)
@SuiteClasses({
- AddChangelogEntrySWTBotTest.class,
- PrepareChangelogSWTBotTest.class,
- DisabledPrepareChangelogSWTBotTest.class,
- CreateChangeLogFromHistorySWTBotTest.class,
- FormatChangeLogSWTBotTest.class
- }
+ AddChangelogEntrySWTBotTest.class,
+ PrepareChangelogSWTBotTest.class,
+ DisabledPrepareChangelogSWTBotTest.class,
+ CreateChangeLogFromHistorySWTBotTest.class,
+ FormatChangeLogSWTBotTest.class
+ }
)
public class AllSWTBotTests {
- // empty
+ // empty
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java
index 5cc35ef759..c53c717b44 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java
@@ -55,140 +55,140 @@ import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
public class CreateChangeLogFromHistorySWTBotTest {
- private static SWTWorkbenchBot bot;
- private static SWTBotTree projectExplorerViewTree;
- private IProject project;
- private SVNProject subversionProject;
- // The name of the test project, we create
- private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.tests";
- // An available SVN repo
- private final String SVN_PROJECT_URL = "svn://dev.eclipse.org/svnroot/technology/" +
- "org.eclipse.linuxtools/changelog/trunk";
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- // delay click speed
- //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
- bot = new SWTWorkbenchBot();
- try {
- bot.viewByTitle("Welcome").close();
- // hide Subclipse Usage stats popup if present/installed
- bot.shell("Subclipse Usage").activate();
- bot.button("Cancel").click();
- } catch (WidgetNotFoundException e) {
- // ignore
- }
- // Make sure project explorer is open and tree available
- ProjectExplorer.openView();
- projectExplorerViewTree = ProjectExplorer.getTree();
- }
-
- @Before
- public void setUp() throws Exception {
- // Do an SVN checkout of the changelog.tests plugin
- subversionProject = new SVNProject(bot);
- project = subversionProject.setProjectName(PROJECT_NAME).setRepoURL(SVN_PROJECT_URL).checkoutProject();
- bot.waitUntil(new SVNProjectCreatedCondition(PROJECT_NAME));
- ProjectExplorer.openView();
- }
-
- @After
- public void tearDown() throws Exception {
- this.project.delete(true, null);
- // discard existing repo from previous test runs
- try {
- subversionProject.discardRepositoryLocation();
- } catch (WidgetNotFoundException e) {
- // Ignore case if repository not existing
- }
- }
-
- /**
- * Create changelog from SVN history (commit messages).
- *
- * @throws Exception
- */
- @Test
- public void canPrepareChangeLogFromSVNHistory() throws Exception {
- // select ChangeLog file
- String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
- SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
- long oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 5000;
- bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
- SWTBotPreferences.TIMEOUT = oldTimeout;
- SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
- changeLogItem.select();
-
- // open history for ChangeLog file
- clickOnShowHistory(projectExplorerViewTree);
- SWTBot historyViewBot = bot.viewByTitle("History").bot();
- // wait for SVN revision table to appear
- oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 3 * 5000;
- historyViewBot.waitUntil(new TableAppearsCondition());
- SWTBotPreferences.TIMEOUT = oldTimeout;
- SWTBotTable historyTable = historyViewBot.table();
- historyTable.select(0); // select the first row
-
- // right-click => Generate Changelog...
- clickOnGenerateChangeLog(historyTable);
- bot.waitUntil(Conditions.shellIsActive("Generate ChangeLog"));
- SWTBotShell shell = bot.shell("Generate ChangeLog");
-
- SWTBot generateChangelogBot = shell.bot();
- generateChangelogBot.radio("Clipboard").click();
- generateChangelogBot.button("OK").click();
-
- // create and open a new file for pasting
- String pasteFile = "newFile";
- IFile newFile = project.getFile(new Path(pasteFile));
- newFile.create(new ByteArrayInputStream("".getBytes()) /* empty content */, false, null);
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- assertNotNull(project.findMember(new Path(pasteFile)));
-
- ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME,
- teamProviderString).expandNode(pasteFile).select().doubleClick();
- Matcher<IEditorReference> editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName(pasteFile)
- );
- bot.waitUntil(Conditions.waitForEditor(editorMatcher));
- oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = oldTimeout;
- SWTBotEditor swtBoteditor = bot.activeEditor();
- assertEquals(pasteFile, swtBoteditor.getTitle());
- SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
-
- // go to beginning of editor
- eclipseEditor.selectRange(0, 0, 0);
- // paste
- eclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("V"));
- swtBoteditor.save();
- // make sure some changelog like text was pasted
- String text = eclipseEditor.getText();
- assertFalse(text.isEmpty());
- }
-
- /**
- * Helper method for right-clicking => Generate ChangeLog in History
- * view table.
- *
- * Pre: History view table row selected.
- */
- private void clickOnGenerateChangeLog(SWTBotTable table) {
- String menuItem = "Generate ChangeLog...";
- ContextMenuHelper.clickContextMenu(table, menuItem);
- }
-
- /**
- * Helper method for right-click => Team => Show History.
- */
- private void clickOnShowHistory(SWTBotTree tree) {
- String menuItem = "Team";
- String subMenuItem = "Show History";
- ContextMenuHelper.clickContextMenu(tree, menuItem, subMenuItem);
- }
+ private static SWTWorkbenchBot bot;
+ private static SWTBotTree projectExplorerViewTree;
+ private IProject project;
+ private SVNProject subversionProject;
+ // The name of the test project, we create
+ private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.tests";
+ // An available SVN repo
+ private final String SVN_PROJECT_URL = "svn://dev.eclipse.org/svnroot/technology/" +
+ "org.eclipse.linuxtools/changelog/trunk";
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ // delay click speed
+ //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
+ bot = new SWTWorkbenchBot();
+ try {
+ bot.viewByTitle("Welcome").close();
+ // hide Subclipse Usage stats popup if present/installed
+ bot.shell("Subclipse Usage").activate();
+ bot.button("Cancel").click();
+ } catch (WidgetNotFoundException e) {
+ // ignore
+ }
+ // Make sure project explorer is open and tree available
+ ProjectExplorer.openView();
+ projectExplorerViewTree = ProjectExplorer.getTree();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ // Do an SVN checkout of the changelog.tests plugin
+ subversionProject = new SVNProject(bot);
+ project = subversionProject.setProjectName(PROJECT_NAME).setRepoURL(SVN_PROJECT_URL).checkoutProject();
+ bot.waitUntil(new SVNProjectCreatedCondition(PROJECT_NAME));
+ ProjectExplorer.openView();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ this.project.delete(true, null);
+ // discard existing repo from previous test runs
+ try {
+ subversionProject.discardRepositoryLocation();
+ } catch (WidgetNotFoundException e) {
+ // Ignore case if repository not existing
+ }
+ }
+
+ /**
+ * Create changelog from SVN history (commit messages).
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canPrepareChangeLogFromSVNHistory() throws Exception {
+ // select ChangeLog file
+ String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
+ SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
+ long oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 5000;
+ bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+ SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
+ changeLogItem.select();
+
+ // open history for ChangeLog file
+ clickOnShowHistory(projectExplorerViewTree);
+ SWTBot historyViewBot = bot.viewByTitle("History").bot();
+ // wait for SVN revision table to appear
+ oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 3 * 5000;
+ historyViewBot.waitUntil(new TableAppearsCondition());
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+ SWTBotTable historyTable = historyViewBot.table();
+ historyTable.select(0); // select the first row
+
+ // right-click => Generate Changelog...
+ clickOnGenerateChangeLog(historyTable);
+ bot.waitUntil(Conditions.shellIsActive("Generate ChangeLog"));
+ SWTBotShell shell = bot.shell("Generate ChangeLog");
+
+ SWTBot generateChangelogBot = shell.bot();
+ generateChangelogBot.radio("Clipboard").click();
+ generateChangelogBot.button("OK").click();
+
+ // create and open a new file for pasting
+ String pasteFile = "newFile";
+ IFile newFile = project.getFile(new Path(pasteFile));
+ newFile.create(new ByteArrayInputStream("".getBytes()) /* empty content */, false, null);
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ assertNotNull(project.findMember(new Path(pasteFile)));
+
+ ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME,
+ teamProviderString).expandNode(pasteFile).select().doubleClick();
+ Matcher<IEditorReference> editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName(pasteFile)
+ );
+ bot.waitUntil(Conditions.waitForEditor(editorMatcher));
+ oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+ SWTBotEditor swtBoteditor = bot.activeEditor();
+ assertEquals(pasteFile, swtBoteditor.getTitle());
+ SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
+
+ // go to beginning of editor
+ eclipseEditor.selectRange(0, 0, 0);
+ // paste
+ eclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("V"));
+ swtBoteditor.save();
+ // make sure some changelog like text was pasted
+ String text = eclipseEditor.getText();
+ assertFalse(text.isEmpty());
+ }
+
+ /**
+ * Helper method for right-clicking => Generate ChangeLog in History
+ * view table.
+ *
+ * Pre: History view table row selected.
+ */
+ private void clickOnGenerateChangeLog(SWTBotTable table) {
+ String menuItem = "Generate ChangeLog...";
+ ContextMenuHelper.clickContextMenu(table, menuItem);
+ }
+
+ /**
+ * Helper method for right-click => Team => Show History.
+ */
+ private void clickOnShowHistory(SWTBotTree tree) {
+ String menuItem = "Team";
+ String subMenuItem = "Show History";
+ ContextMenuHelper.clickContextMenu(tree, menuItem, subMenuItem);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java
index ef232caabd..27982171ed 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java
@@ -39,69 +39,69 @@ import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
public class DisabledPrepareChangelogSWTBotTest {
- private static SWTWorkbenchBot bot;
- private static SWTBotTree projectExplorerViewTree;
- private final String projectName = "not-shared";
- private ChangeLogTestProject project;
+ private static SWTWorkbenchBot bot;
+ private static SWTBotTree projectExplorerViewTree;
+ private final String projectName = "not-shared";
+ private ChangeLogTestProject project;
- @BeforeClass
- public static void beforeClass() throws Exception {
- // delay click speed
- //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
- bot = new SWTWorkbenchBot();
- try {
- bot.viewByTitle("Welcome").close();
- // hide Subclipse Usage stats popup if present/installed
- bot.shell("Subclipse Usage").activate();
- bot.button("Cancel").click();
- } catch (WidgetNotFoundException e) {
- // ignore
- }
- // Make sure project explorer is open and tree available
- ProjectExplorer.openView();
- projectExplorerViewTree = ProjectExplorer.getTree();
- }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ // delay click speed
+ //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
+ bot = new SWTWorkbenchBot();
+ try {
+ bot.viewByTitle("Welcome").close();
+ // hide Subclipse Usage stats popup if present/installed
+ bot.shell("Subclipse Usage").activate();
+ bot.button("Cancel").click();
+ } catch (WidgetNotFoundException e) {
+ // ignore
+ }
+ // Make sure project explorer is open and tree available
+ ProjectExplorer.openView();
+ projectExplorerViewTree = ProjectExplorer.getTree();
+ }
- @Before
- public void setUp() throws Exception {
- project = new ChangeLogTestProject(projectName);
- }
+ @Before
+ public void setUp() throws Exception {
+ project = new ChangeLogTestProject(projectName);
+ }
- @After
- public void tearDown() throws Exception {
- this.project.getTestProject().delete(true, null);
- }
+ @After
+ public void tearDown() throws Exception {
+ this.project.getTestProject().delete(true, null);
+ }
- /**
- * If the project is not shared by any CVS or SVN team provider, "Prepare ChangeLog"
- * should be disabled.
- *
- * @throws Exception
- */
- @Test
- public void cannotPrepareChangeLogOnNonCVSOrSVNProject() throws Exception {
- assertNull(project.getTestProject().findMember(new Path("/ChangeLog")));
+ /**
+ * If the project is not shared by any CVS or SVN team provider, "Prepare ChangeLog"
+ * should be disabled.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void cannotPrepareChangeLogOnNonCVSOrSVNProject() throws Exception {
+ assertNull(project.getTestProject().findMember(new Path("/ChangeLog")));
- final String changeLogContent = "2010-12-08 Will Probe <will@example.com>\n\n" +
- "\t* path/to/some/non-existing/file.c: New file.\n";
- project.addFileToProject("/", "ChangeLog", new ByteArrayInputStream(changeLogContent.getBytes()));
+ final String changeLogContent = "2010-12-08 Will Probe <will@example.com>\n\n" +
+ "\t* path/to/some/non-existing/file.c: New file.\n";
+ project.addFileToProject("/", "ChangeLog", new ByteArrayInputStream(changeLogContent.getBytes()));
- assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog")));
+ assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog")));
- // select ChangeLog file
- String teamProviderString = "n/a";
- SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, projectName, teamProviderString);
- SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
- changeLogItem.select();
- long oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 100;
- try {
- bot.menu("Prepare ChangeLog").click(); // Should be disabled (throws exception)
- fail("'Prepare ChangeLog' should be disabled");
- } catch (TimeoutException e) {
- assertTrue(e.getMessage().contains("The widget with mnemonic 'Prepare ChangeLog' was not enabled."));
- }
- SWTBotPreferences.TIMEOUT = oldTimeout;
- }
+ // select ChangeLog file
+ String teamProviderString = "n/a";
+ SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, projectName, teamProviderString);
+ SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
+ changeLogItem.select();
+ long oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 100;
+ try {
+ bot.menu("Prepare ChangeLog").click(); // Should be disabled (throws exception)
+ fail("'Prepare ChangeLog' should be disabled");
+ } catch (TimeoutException e) {
+ assertTrue(e.getMessage().contains("The widget with mnemonic 'Prepare ChangeLog' was not enabled."));
+ }
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java
index 7d8b7192fa..061c02e73c 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java
@@ -48,100 +48,100 @@ import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
public class FormatChangeLogSWTBotTest {
- private static SWTWorkbenchBot bot;
- private static SWTBotTree projectExplorerViewTree;
- private ChangeLogTestProject project;
- // The name of the test project, we create
- private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.ui.formattestproject";
+ private static SWTWorkbenchBot bot;
+ private static SWTBotTree projectExplorerViewTree;
+ private ChangeLogTestProject project;
+ // The name of the test project, we create
+ private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.ui.formattestproject";
- @BeforeClass
- public static void beforeClass() throws Exception {
- // delay click speed
- //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
- bot = new SWTWorkbenchBot();
- try {
- bot.viewByTitle("Welcome").close();
- // hide Subclipse Usage stats popup if present/installed
- bot.shell("Subclipse Usage").activate();
- bot.button("Cancel").click();
- } catch (WidgetNotFoundException e) {
- // ignore
- }
- // Make sure project explorer is open and tree available
- ProjectExplorer.openView();
- projectExplorerViewTree = ProjectExplorer.getTree();
- }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ // delay click speed
+ //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
+ bot = new SWTWorkbenchBot();
+ try {
+ bot.viewByTitle("Welcome").close();
+ // hide Subclipse Usage stats popup if present/installed
+ bot.shell("Subclipse Usage").activate();
+ bot.button("Cancel").click();
+ } catch (WidgetNotFoundException e) {
+ // ignore
+ }
+ // Make sure project explorer is open and tree available
+ ProjectExplorer.openView();
+ projectExplorerViewTree = ProjectExplorer.getTree();
+ }
- @Before
- public void setUp() throws Exception {
- project = new ChangeLogTestProject(PROJECT_NAME);
- ProjectExplorer.openView();
- }
+ @Before
+ public void setUp() throws Exception {
+ project = new ChangeLogTestProject(PROJECT_NAME);
+ ProjectExplorer.openView();
+ }
- @After
- public void tearDown() throws Exception {
- this.project.getTestProject().delete(true, null);
- }
+ @After
+ public void tearDown() throws Exception {
+ this.project.getTestProject().delete(true, null);
+ }
- /**
- * Simple test for ChangeLog formatting.
- *
- * @throws Exception
- */
- @Test
- public void canFormatChangeLogFile() throws Exception {
- // add a ChangeLog file
- assertNull(project.getTestProject().findMember(new Path("/ChangeLog")));
- final String changelogContent = "2010-12-14 Severin Gehwolf <sgehwolf@redhat.com>\n\n" +
- "\tAdded org.eclipse.linuxtools.changelog.tests.ui plug-in.\n" +
- "\t* .classpath: New file.\n" +
- "\t* .project: New file.\n" +
- "\t* .settings/org.eclipse.jdt.core.prefs: New file.\n" +
- "\t* build.properties: New file.\n" +
- "\t* src/log4j.xml: New file.\n" +
- "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ContextMenuHelper.java: New file.\n" +
- "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorer.java: New file.\n" +
- "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorerTreeItemAppearsCondition.java: New file.\n";
- project.addFileToProject("/", "ChangeLog", new ByteArrayInputStream(changelogContent.getBytes()));
- assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog")));
+ /**
+ * Simple test for ChangeLog formatting.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canFormatChangeLogFile() throws Exception {
+ // add a ChangeLog file
+ assertNull(project.getTestProject().findMember(new Path("/ChangeLog")));
+ final String changelogContent = "2010-12-14 Severin Gehwolf <sgehwolf@redhat.com>\n\n" +
+ "\tAdded org.eclipse.linuxtools.changelog.tests.ui plug-in.\n" +
+ "\t* .classpath: New file.\n" +
+ "\t* .project: New file.\n" +
+ "\t* .settings/org.eclipse.jdt.core.prefs: New file.\n" +
+ "\t* build.properties: New file.\n" +
+ "\t* src/log4j.xml: New file.\n" +
+ "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ContextMenuHelper.java: New file.\n" +
+ "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorer.java: New file.\n" +
+ "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorerTreeItemAppearsCondition.java: New file.\n";
+ project.addFileToProject("/", "ChangeLog", new ByteArrayInputStream(changelogContent.getBytes()));
+ assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog")));
- // select ChangeLog file
- String teamProviderString = "n/a";
- SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
- long oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 5000;
- bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
- SWTBotPreferences.TIMEOUT = oldTimeout;
- SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
- changeLogItem.doubleClick(); // should open ChangeLog file
+ // select ChangeLog file
+ String teamProviderString = "n/a";
+ SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
+ long oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 5000;
+ bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+ SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
+ changeLogItem.doubleClick(); // should open ChangeLog file
- oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 3 * 5000;
- // Wait for ChangeLog editor to open
- Matcher<IEditorReference> editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName("ChangeLog")
- );
- bot.waitUntil(Conditions.waitForEditor(editorMatcher));
- SWTBotEditor swtBoteditor = bot.activeEditor();
- assertEquals("ChangeLog", swtBoteditor.getTitle());
+ oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 3 * 5000;
+ // Wait for ChangeLog editor to open
+ Matcher<IEditorReference> editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName("ChangeLog")
+ );
+ bot.waitUntil(Conditions.waitForEditor(editorMatcher));
+ SWTBotEditor swtBoteditor = bot.activeEditor();
+ assertEquals("ChangeLog", swtBoteditor.getTitle());
- SWTBotEclipseEditor swtBotEclipseEditor = swtBoteditor.toTextEditor();
+ SWTBotEclipseEditor swtBotEclipseEditor = swtBoteditor.toTextEditor();
- // Add two extra lines after the first date line
- swtBotEclipseEditor.insertText(1, 0, "\n\n");
- // Should have 3 empty lines between date-line and first file entry
- swtBotEclipseEditor.selectRange(1, 0, 3);
+ // Add two extra lines after the first date line
+ swtBotEclipseEditor.insertText(1, 0, "\n\n");
+ // Should have 3 empty lines between date-line and first file entry
+ swtBotEclipseEditor.selectRange(1, 0, 3);
- // format: ESC CTRL+F
- swtBotEclipseEditor.pressShortcut(Keystrokes.ESC);
- swtBotEclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("F"));
- swtBoteditor.save();
- String secondLine = swtBotEclipseEditor.getTextOnLine(1);
- String thirdLine = swtBotEclipseEditor.getTextOnLine(2);
- // FIXME: These assertions are lame.
- assertTrue(secondLine.isEmpty());
- assertFalse(thirdLine.isEmpty());
- }
+ // format: ESC CTRL+F
+ swtBotEclipseEditor.pressShortcut(Keystrokes.ESC);
+ swtBotEclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("F"));
+ swtBoteditor.save();
+ String secondLine = swtBotEclipseEditor.getTextOnLine(1);
+ String thirdLine = swtBotEclipseEditor.getTextOnLine(2);
+ // FIXME: These assertions are lame.
+ assertTrue(secondLine.isEmpty());
+ assertFalse(thirdLine.isEmpty());
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java
index 530f65cb6c..2aae0e4a9d 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java
@@ -52,200 +52,200 @@ import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
public class PrepareChangelogSWTBotTest {
- private static SWTWorkbenchBot bot;
- private static SWTBotTree projectExplorerViewTree;
- private SVNProject subversionProject;
- private IProject project;
- // The name of the test project, we create
- private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.tests";
- // An available SVN repo
- private final String SVN_PROJECT_URL = "svn://dev.eclipse.org/svnroot/technology/" +
- "org.eclipse.linuxtools/changelog/trunk";
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- // delay click speed
- //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
- bot = new SWTWorkbenchBot();
- try {
- bot.viewByTitle("Welcome").close();
- // hide Subclipse Usage stats popup if present/installed
- bot.shell("Subclipse Usage").activate();
- bot.button("Cancel").click();
- } catch (WidgetNotFoundException e) {
- // ignore
- }
- // Make sure project explorer is open and tree available
- ProjectExplorer.openView();
- projectExplorerViewTree = ProjectExplorer.getTree();
- }
-
- @Before
- public void setUp() throws Exception {
- // Do an SVN checkout of the changelog.tests plugin
- subversionProject = new SVNProject(bot);
- project = subversionProject.setProjectName(PROJECT_NAME).setRepoURL(SVN_PROJECT_URL).checkoutProject();
- bot.waitUntil(new SVNProjectCreatedCondition(PROJECT_NAME));
- ProjectExplorer.openView();
- }
-
- @After
- public void tearDown() throws Exception {
- this.project.delete(true, null);
- // discard existing repo from previous test runs
- try {
- subversionProject.discardRepositoryLocation();
- } catch (WidgetNotFoundException e) {
- // Ignore case if repository not existing
- }
- }
-
- /**
- * Basic prepare changelog test.
- *
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- @Test
- public void canPrepareChangeLog() throws Exception {
- // Find manifest file
- IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));
- assertNotNull(manifest);
- // delete it
- manifest.delete(true, null);
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- // select ChangeLog file
- String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
- SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
- SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
- changeLogItem.select();
- bot.menu("Prepare ChangeLog").click(); // Should be unique
-
- long oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 3 * 5000;
- // Wait for ChangeLog editor to open
- Matcher<?> editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName("ChangeLog")
- );
- bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
- SWTBotPreferences.TIMEOUT = oldTimeout;
-
- SWTBotEditor swtBoteditor = bot.activeEditor();
- swtBoteditor.save(); // save to avoid "save changes"-pop-up
- assertEquals("ChangeLog", swtBoteditor.getTitle());
- SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
- // make sure expected entry has been added.
- assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
- }
-
- /**
- * Should be able to save changes to ChangeLog file in clipboard.
- * Tests CTRL + ALT + V functionality.
- *
- * @throws Exception
- */
- @Test
- public void canPrepareChangeLogAndSaveChangesInChangeLogFileToClipboard() throws Exception {
- // Find manifest file
- IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));
- assertNotNull(manifest);
- // delete it
- manifest.delete(true, null);
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- // select ChangeLog file
- String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
- SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
- long oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 5000;
- bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
- SWTBotPreferences.TIMEOUT = oldTimeout;
- SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
- changeLogItem.select();
- // CTRL + ALT + P
- bot.activeShell().pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("P"));
-
- oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 3 * 5000;
- // Wait for ChangeLog editor to open
- Matcher<IEditorReference> editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName("ChangeLog")
- );
- bot.waitUntil(Conditions.waitForEditor(editorMatcher));
- SWTBotEditor swtBoteditor = bot.activeEditor();
- swtBoteditor.save(); // save to avoid "save changes"-pop-up
- assertEquals("ChangeLog", swtBoteditor.getTitle());
- SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
- // make sure expected entry has been added.
- assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
- eclipseEditor.selectLine(0); // select first line
- final String expectedFirstLineContent = eclipseEditor.getSelection();
-
- // save changes to clipboard: CTRL + ALT + V
- eclipseEditor.pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("V"));
-
- // create and open a new file for pasting
- String pasteFile = "newFile";
- IFile newFile = project.getFile(new Path(pasteFile));
- newFile.create(new ByteArrayInputStream("".getBytes()) /* empty content */, false, null);
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- assertNotNull(project.findMember(new Path(pasteFile)));
-
- ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME,
- teamProviderString).expandNode(pasteFile).select().doubleClick();
- //bot.activeShell().pressShortcut(Keystrokes.F3); // open file
- editorMatcher = allOf(
- IsInstanceOf.instanceOf(IEditorReference.class),
- withPartName(pasteFile)
- );
- bot.waitUntil(Conditions.waitForEditor(editorMatcher));
- SWTBotPreferences.TIMEOUT = oldTimeout;
- swtBoteditor = bot.activeEditor();
- assertEquals(pasteFile, swtBoteditor.getTitle());
- eclipseEditor = swtBoteditor.toTextEditor();
-
- // go to beginning of editor
- eclipseEditor.selectRange(0, 0, 0);
- // paste
- eclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("V"));
- swtBoteditor.save();
- // make sure proper content was pasted
- assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
- eclipseEditor.selectLine(0); // select first line
- final String actualFirstLineContent = eclipseEditor.getSelection();
- assertEquals(expectedFirstLineContent, actualFirstLineContent);
- }
-
- /**
- * Determine if first <code>i</code> lines in <code>text</code> contain
- * the string <code>matchText</code>.
- *
- * @param text The text to compare to.
- * @param matchText The match string to look for.
- * @param i The number of lines in text to consider.
- * @return
- *
- * @throws IllegalArgumentException if <code>i</code> is invalid.
- */
- private boolean matchHead(String text, String matchText, int i) throws IllegalArgumentException {
- if ( i < 0 ) {
- throw new IllegalArgumentException();
- }
- String[] lines = text.split("\n");
- if ( lines.length < i ) {
- throw new IllegalArgumentException();
- }
- // arguments appear to be good
- for (int j = 0; j < i; j++) {
- if (lines[j].contains(matchText)) {
- return true;
- }
- }
- return false; // no match
- }
+ private static SWTWorkbenchBot bot;
+ private static SWTBotTree projectExplorerViewTree;
+ private SVNProject subversionProject;
+ private IProject project;
+ // The name of the test project, we create
+ private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.tests";
+ // An available SVN repo
+ private final String SVN_PROJECT_URL = "svn://dev.eclipse.org/svnroot/technology/" +
+ "org.eclipse.linuxtools/changelog/trunk";
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ // delay click speed
+ //System.setProperty("org.eclipse.swtbot.playback.delay", "200");
+ bot = new SWTWorkbenchBot();
+ try {
+ bot.viewByTitle("Welcome").close();
+ // hide Subclipse Usage stats popup if present/installed
+ bot.shell("Subclipse Usage").activate();
+ bot.button("Cancel").click();
+ } catch (WidgetNotFoundException e) {
+ // ignore
+ }
+ // Make sure project explorer is open and tree available
+ ProjectExplorer.openView();
+ projectExplorerViewTree = ProjectExplorer.getTree();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ // Do an SVN checkout of the changelog.tests plugin
+ subversionProject = new SVNProject(bot);
+ project = subversionProject.setProjectName(PROJECT_NAME).setRepoURL(SVN_PROJECT_URL).checkoutProject();
+ bot.waitUntil(new SVNProjectCreatedCondition(PROJECT_NAME));
+ ProjectExplorer.openView();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ this.project.delete(true, null);
+ // discard existing repo from previous test runs
+ try {
+ subversionProject.discardRepositoryLocation();
+ } catch (WidgetNotFoundException e) {
+ // Ignore case if repository not existing
+ }
+ }
+
+ /**
+ * Basic prepare changelog test.
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void canPrepareChangeLog() throws Exception {
+ // Find manifest file
+ IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));
+ assertNotNull(manifest);
+ // delete it
+ manifest.delete(true, null);
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ // select ChangeLog file
+ String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
+ SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
+ SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
+ changeLogItem.select();
+ bot.menu("Prepare ChangeLog").click(); // Should be unique
+
+ long oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 3 * 5000;
+ // Wait for ChangeLog editor to open
+ Matcher<?> editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName("ChangeLog")
+ );
+ bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher));
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+
+ SWTBotEditor swtBoteditor = bot.activeEditor();
+ swtBoteditor.save(); // save to avoid "save changes"-pop-up
+ assertEquals("ChangeLog", swtBoteditor.getTitle());
+ SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
+ // make sure expected entry has been added.
+ assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
+ }
+
+ /**
+ * Should be able to save changes to ChangeLog file in clipboard.
+ * Tests CTRL + ALT + V functionality.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void canPrepareChangeLogAndSaveChangesInChangeLogFileToClipboard() throws Exception {
+ // Find manifest file
+ IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));
+ assertNotNull(manifest);
+ // delete it
+ manifest.delete(true, null);
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ // select ChangeLog file
+ String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
+ SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
+ long oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 5000;
+ bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+ SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
+ changeLogItem.select();
+ // CTRL + ALT + P
+ bot.activeShell().pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("P"));
+
+ oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 3 * 5000;
+ // Wait for ChangeLog editor to open
+ Matcher<IEditorReference> editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName("ChangeLog")
+ );
+ bot.waitUntil(Conditions.waitForEditor(editorMatcher));
+ SWTBotEditor swtBoteditor = bot.activeEditor();
+ swtBoteditor.save(); // save to avoid "save changes"-pop-up
+ assertEquals("ChangeLog", swtBoteditor.getTitle());
+ SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
+ // make sure expected entry has been added.
+ assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
+ eclipseEditor.selectLine(0); // select first line
+ final String expectedFirstLineContent = eclipseEditor.getSelection();
+
+ // save changes to clipboard: CTRL + ALT + V
+ eclipseEditor.pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("V"));
+
+ // create and open a new file for pasting
+ String pasteFile = "newFile";
+ IFile newFile = project.getFile(new Path(pasteFile));
+ newFile.create(new ByteArrayInputStream("".getBytes()) /* empty content */, false, null);
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ assertNotNull(project.findMember(new Path(pasteFile)));
+
+ ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME,
+ teamProviderString).expandNode(pasteFile).select().doubleClick();
+ //bot.activeShell().pressShortcut(Keystrokes.F3); // open file
+ editorMatcher = allOf(
+ IsInstanceOf.instanceOf(IEditorReference.class),
+ withPartName(pasteFile)
+ );
+ bot.waitUntil(Conditions.waitForEditor(editorMatcher));
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+ swtBoteditor = bot.activeEditor();
+ assertEquals(pasteFile, swtBoteditor.getTitle());
+ eclipseEditor = swtBoteditor.toTextEditor();
+
+ // go to beginning of editor
+ eclipseEditor.selectRange(0, 0, 0);
+ // paste
+ eclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("V"));
+ swtBoteditor.save();
+ // make sure proper content was pasted
+ assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
+ eclipseEditor.selectLine(0); // select first line
+ final String actualFirstLineContent = eclipseEditor.getSelection();
+ assertEquals(expectedFirstLineContent, actualFirstLineContent);
+ }
+
+ /**
+ * Determine if first <code>i</code> lines in <code>text</code> contain
+ * the string <code>matchText</code>.
+ *
+ * @param text The text to compare to.
+ * @param matchText The match string to look for.
+ * @param i The number of lines in text to consider.
+ * @return
+ *
+ * @throws IllegalArgumentException if <code>i</code> is invalid.
+ */
+ private boolean matchHead(String text, String matchText, int i) throws IllegalArgumentException {
+ if ( i < 0 ) {
+ throw new IllegalArgumentException();
+ }
+ String[] lines = text.split("\n");
+ if ( lines.length < i ) {
+ throw new IllegalArgumentException();
+ }
+ // arguments appear to be good
+ for (int j = 0; j < i; j++) {
+ if (lines[j].contains(matchText)) {
+ return true;
+ }
+ }
+ return false; // no match
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ChangeLogTestProject.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ChangeLogTestProject.java
index 6826806edb..e6fa276f77 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ChangeLogTestProject.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ChangeLogTestProject.java
@@ -32,117 +32,117 @@ import org.eclipse.jdt.core.JavaCore;
*/
public class ChangeLogTestProject {
- private IProject testProject;
+ private IProject testProject;
- /**
- * Create a new ChangelogTestProject
- *
- * @param projectName The name of the project to be created.
- * @throws Exception
- */
- public ChangeLogTestProject(String projectName) throws Exception {
- testProject = createNewProject(projectName);
- }
+ /**
+ * Create a new ChangelogTestProject
+ *
+ * @param projectName The name of the project to be created.
+ * @throws Exception
+ */
+ public ChangeLogTestProject(String projectName) throws Exception {
+ testProject = createNewProject(projectName);
+ }
- /**
- * @return the testProject
- */
- public IProject getTestProject() {
- return testProject;
- }
+ /**
+ * @return the testProject
+ */
+ public IProject getTestProject() {
+ return testProject;
+ }
- /**
- * @param testProject the testProject to set
- */
- public void setTestProject(IProject testProject) {
- this.testProject = testProject;
- }
+ /**
+ * @param testProject the testProject to set
+ */
+ public void setTestProject(IProject testProject) {
+ this.testProject = testProject;
+ }
- /**
- * Adds a file to this project at the specified <code>path</code>
- * and the provided <code>filename</code>. If segments of <code>path</code>
- * do not exist, they will be created.
- *
- * @param destPath The path relative to the project (use '/' as path separator).
- * @param filename The name of the to be created file
- * @param fileInputStream A stream to the new files content.
- */
- public IFile addFileToProject(String destPath, String filename, InputStream fileInputStream) throws CoreException {
- String[] pathSegments = destPath.split("/");
+ /**
+ * Adds a file to this project at the specified <code>path</code>
+ * and the provided <code>filename</code>. If segments of <code>path</code>
+ * do not exist, they will be created.
+ *
+ * @param destPath The path relative to the project (use '/' as path separator).
+ * @param filename The name of the to be created file
+ * @param fileInputStream A stream to the new files content.
+ */
+ public IFile addFileToProject(String destPath, String filename, InputStream fileInputStream) throws CoreException {
+ String[] pathSegments = destPath.split("/");
- IContainer parent = this.testProject;
- for (String segment: pathSegments) {
- if (segment.isEmpty()) {
- continue; // ignore
- }
- IResource segmentResource = parent.findMember(new Path(IPath.SEPARATOR + segment));
- if (segmentResource == null) {
- // create folder
- IFolder newFolder = parent.getFolder(new Path(segment));
- newFolder.create(false, true, null);
- parent = newFolder;
- } else {
- // resource existed
- parent = (IContainer)segmentResource;
- }
- }
- // Finally add the file
- IFile newFile = parent.getFile(new Path(filename));
- if (fileInputStream == null) {
- throw new IllegalStateException("fileInputStream must not be null");
- }
- newFile.create(fileInputStream, false, null);
+ IContainer parent = this.testProject;
+ for (String segment: pathSegments) {
+ if (segment.isEmpty()) {
+ continue; // ignore
+ }
+ IResource segmentResource = parent.findMember(new Path(IPath.SEPARATOR + segment));
+ if (segmentResource == null) {
+ // create folder
+ IFolder newFolder = parent.getFolder(new Path(segment));
+ newFolder.create(false, true, null);
+ parent = newFolder;
+ } else {
+ // resource existed
+ parent = (IContainer)segmentResource;
+ }
+ }
+ // Finally add the file
+ IFile newFile = parent.getFile(new Path(filename));
+ if (fileInputStream == null) {
+ throw new IllegalStateException("fileInputStream must not be null");
+ }
+ newFile.create(fileInputStream, false, null);
- // refresh project
- this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+ // refresh project
+ this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- return newFile;
- }
+ return newFile;
+ }
- /**
- * Add the Java nature to this project. I.e. make it a Java project.
- */
- public IJavaProject addJavaNature() throws CoreException {
- IProjectDescription description = this.testProject.getDescription();
- String[] natures = description.getNatureIds();
- String[] newNatures = new String[natures.length + 1];
- System.arraycopy(natures, 0, newNatures, 0, natures.length);
- newNatures[natures.length] = JavaCore.NATURE_ID;
- description.setNatureIds(newNatures);
- this.testProject.setDescription(description, null);
- return JavaCore.create(this.testProject);
- }
+ /**
+ * Add the Java nature to this project. I.e. make it a Java project.
+ */
+ public IJavaProject addJavaNature() throws CoreException {
+ IProjectDescription description = this.testProject.getDescription();
+ String[] natures = description.getNatureIds();
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = JavaCore.NATURE_ID;
+ description.setNatureIds(newNatures);
+ this.testProject.setDescription(description, null);
+ return JavaCore.create(this.testProject);
+ }
- /**
- * Add the C nature to this project. I.e. make it a C project.
- * @throws CoreException
- */
- public void addCNature() throws CoreException {
- this.testProject = CCorePlugin.getDefault().createCDTProject(
- testProject.getDescription(), testProject, null);
- }
+ /**
+ * Add the C nature to this project. I.e. make it a C project.
+ * @throws CoreException
+ */
+ public void addCNature() throws CoreException {
+ this.testProject = CCorePlugin.getDefault().createCDTProject(
+ testProject.getDescription(), testProject, null);
+ }
- /**
- * Add the C++ nature to this project. I.e. make it a C++ project.
- * @throws CoreException
- */
- public void addCCNature() throws CoreException {
- addCNature();
- CCorePlugin.getDefault().convertProjectFromCtoCC(testProject, null);
- }
+ /**
+ * Add the C++ nature to this project. I.e. make it a C++ project.
+ * @throws CoreException
+ */
+ public void addCCNature() throws CoreException {
+ addCNature();
+ CCorePlugin.getDefault().convertProjectFromCtoCC(testProject, null);
+ }
- /**
- * Create a new Eclipse project in the current workspace
- *
- * @param name
- * @throws CoreException if project creation fails for some reason.
- * @return The newly created project.
- */
- private IProject createNewProject(String name) throws CoreException {
- IProject newProject = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(name);
- newProject.create(null);
- newProject.open(null); // needs to be open
- return newProject;
- }
+ /**
+ * Create a new Eclipse project in the current workspace
+ *
+ * @param name
+ * @throws CoreException if project creation fails for some reason.
+ * @return The newly created project.
+ */
+ private IProject createNewProject(String name) throws CoreException {
+ IProject newProject = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(name);
+ newProject.create(null);
+ newProject.open(null); // needs to be open
+ return newProject;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ContextMenuHelper.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ContextMenuHelper.java
index 0d69b794b7..c1b4cdf7c7 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ContextMenuHelper.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ContextMenuHelper.java
@@ -34,150 +34,150 @@ import org.hamcrest.Matcher;
public class ContextMenuHelper {
- /**
- * Clicks the context menu matching the text.
- *
- * @param bot
- *
- * @param texts
- * the text on the context menu.
- * @throws WidgetNotFoundException
- * if the widget is not found.
- * @throws SWTException
- * if the menu item is disabled (the root cause being an
- * {@link IllegalStateException})
- */
- public static void clickContextMenu(final AbstractSWTBot<?> bot,
- final String... texts) {
-
- // show
- final MenuItem menuItem = UIThreadRunnable
- .syncExec(new WidgetResult<MenuItem>() {
- @Override
- public MenuItem run() {
- MenuItem theItem = getMenuItem(bot, texts);
- if (theItem != null && !theItem.isEnabled())
- throw new IllegalStateException(
- "Menu item is diabled");
-
- return theItem;
- }
- });
- if (menuItem == null) {
- throw new WidgetNotFoundException("Could not find menu: "
- + Arrays.asList(texts));
- }
-
- // click
- click(menuItem);
-
- // hide
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- if (menuItem.isDisposed())
- return; // menu already gone
- hide(menuItem.getParent());
- }
- });
- }
-
- private static MenuItem getMenuItem(final AbstractSWTBot<?> bot,
- final String... texts) {
- MenuItem theItem = null;
- Control control = (Control) bot.widget;
- // for dynamic menus, we need to issue this event
- control.notifyListeners(SWT.MenuDetect, new Event());
- Menu menu = control.getMenu();
- for (String text : texts) {
- Matcher<MenuItem> matcher = allOf(instanceOf(MenuItem.class),
- withMnemonic(text));
- theItem = show(menu, matcher);
- if (theItem != null) {
- menu = theItem.getMenu();
- } else {
- hide(menu);
- break;
- }
- }
- return theItem;
- }
-
- /**
- * Checks if the context menu matching the text is enabled
- *
- * @param bot
- *
- * @param texts
- * the text on the context menu.
- * @return true if the context menu is enabled
- * @throws WidgetNotFoundException
- * if the widget is not found.
- */
- public static boolean isContextMenuItemEnabled(final AbstractSWTBot<?> bot,
- final String... texts) {
-
- final AtomicBoolean enabled = new AtomicBoolean(false);
- // show
- final MenuItem menuItem = UIThreadRunnable
- .syncExec(new WidgetResult<MenuItem>() {
- @Override
- public MenuItem run() {
- MenuItem theItem = getMenuItem(bot, texts);
- if (theItem != null && theItem.isEnabled())
- enabled.set(true);
- return theItem;
- }
- });
- if (menuItem == null) {
- throw new WidgetNotFoundException("Could not find menu: "
- + Arrays.asList(texts));
- }
- // hide
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- if (menuItem.isDisposed())
- return; // menu already gone
- hide(menuItem.getParent());
- }
- });
- return enabled.get();
- }
-
- private static MenuItem show(final Menu menu, final Matcher<MenuItem> matcher) {
- if (menu != null) {
- menu.notifyListeners(SWT.Show, new Event());
- MenuItem[] items = menu.getItems();
- for (final MenuItem menuItem : items) {
- if (matcher.matches(menuItem)) {
- return menuItem;
- }
- }
- menu.notifyListeners(SWT.Hide, new Event());
- }
- return null;
- }
-
- private static void click(final MenuItem menuItem) {
- final Event event = new Event();
- event.time = (int) System.currentTimeMillis();
- event.widget = menuItem;
- event.display = menuItem.getDisplay();
- event.type = SWT.Selection;
-
- UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
- @Override
- public void run() {
- menuItem.notifyListeners(SWT.Selection, event);
- }
- });
- }
-
- private static void hide(final Menu menu) {
- menu.notifyListeners(SWT.Hide, new Event());
- if (menu.getParentMenu() != null) {
- hide(menu.getParentMenu());
- }
- }
+ /**
+ * Clicks the context menu matching the text.
+ *
+ * @param bot
+ *
+ * @param texts
+ * the text on the context menu.
+ * @throws WidgetNotFoundException
+ * if the widget is not found.
+ * @throws SWTException
+ * if the menu item is disabled (the root cause being an
+ * {@link IllegalStateException})
+ */
+ public static void clickContextMenu(final AbstractSWTBot<?> bot,
+ final String... texts) {
+
+ // show
+ final MenuItem menuItem = UIThreadRunnable
+ .syncExec(new WidgetResult<MenuItem>() {
+ @Override
+ public MenuItem run() {
+ MenuItem theItem = getMenuItem(bot, texts);
+ if (theItem != null && !theItem.isEnabled())
+ throw new IllegalStateException(
+ "Menu item is diabled");
+
+ return theItem;
+ }
+ });
+ if (menuItem == null) {
+ throw new WidgetNotFoundException("Could not find menu: "
+ + Arrays.asList(texts));
+ }
+
+ // click
+ click(menuItem);
+
+ // hide
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ if (menuItem.isDisposed())
+ return; // menu already gone
+ hide(menuItem.getParent());
+ }
+ });
+ }
+
+ private static MenuItem getMenuItem(final AbstractSWTBot<?> bot,
+ final String... texts) {
+ MenuItem theItem = null;
+ Control control = (Control) bot.widget;
+ // for dynamic menus, we need to issue this event
+ control.notifyListeners(SWT.MenuDetect, new Event());
+ Menu menu = control.getMenu();
+ for (String text : texts) {
+ Matcher<MenuItem> matcher = allOf(instanceOf(MenuItem.class),
+ withMnemonic(text));
+ theItem = show(menu, matcher);
+ if (theItem != null) {
+ menu = theItem.getMenu();
+ } else {
+ hide(menu);
+ break;
+ }
+ }
+ return theItem;
+ }
+
+ /**
+ * Checks if the context menu matching the text is enabled
+ *
+ * @param bot
+ *
+ * @param texts
+ * the text on the context menu.
+ * @return true if the context menu is enabled
+ * @throws WidgetNotFoundException
+ * if the widget is not found.
+ */
+ public static boolean isContextMenuItemEnabled(final AbstractSWTBot<?> bot,
+ final String... texts) {
+
+ final AtomicBoolean enabled = new AtomicBoolean(false);
+ // show
+ final MenuItem menuItem = UIThreadRunnable
+ .syncExec(new WidgetResult<MenuItem>() {
+ @Override
+ public MenuItem run() {
+ MenuItem theItem = getMenuItem(bot, texts);
+ if (theItem != null && theItem.isEnabled())
+ enabled.set(true);
+ return theItem;
+ }
+ });
+ if (menuItem == null) {
+ throw new WidgetNotFoundException("Could not find menu: "
+ + Arrays.asList(texts));
+ }
+ // hide
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ if (menuItem.isDisposed())
+ return; // menu already gone
+ hide(menuItem.getParent());
+ }
+ });
+ return enabled.get();
+ }
+
+ private static MenuItem show(final Menu menu, final Matcher<MenuItem> matcher) {
+ if (menu != null) {
+ menu.notifyListeners(SWT.Show, new Event());
+ MenuItem[] items = menu.getItems();
+ for (final MenuItem menuItem : items) {
+ if (matcher.matches(menuItem)) {
+ return menuItem;
+ }
+ }
+ menu.notifyListeners(SWT.Hide, new Event());
+ }
+ return null;
+ }
+
+ private static void click(final MenuItem menuItem) {
+ final Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = menuItem;
+ event.display = menuItem.getDisplay();
+ event.type = SWT.Selection;
+
+ UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
+ @Override
+ public void run() {
+ menuItem.notifyListeners(SWT.Selection, event);
+ }
+ });
+ }
+
+ private static void hide(final Menu menu) {
+ menu.notifyListeners(SWT.Hide, new Event());
+ if (menu.getParentMenu() != null) {
+ hide(menu.getParentMenu());
+ }
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorer.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorer.java
index 300c5e6912..eea9162702 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorer.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorer.java
@@ -23,73 +23,73 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
*/
public class ProjectExplorer {
- private static SWTWorkbenchBot bot = new SWTWorkbenchBot();
+ private static SWTWorkbenchBot bot = new SWTWorkbenchBot();
- /**
- * Opens the Project Explorer view.
- */
- public static void openView() throws Exception {
- bot.menu("Window").menu("Show View").menu("Project Explorer").click();
- }
+ /**
+ * Opens the Project Explorer view.
+ */
+ public static void openView() throws Exception {
+ bot.menu("Window").menu("Show View").menu("Project Explorer").click();
+ }
- /**
- * Assumes Project Explorer view is shown.
- *
- * @return The tree of the Project Explorer view
- */
- public static SWTBotTree getTree() {
- SWTBotView projectExplorer = bot.viewByTitle("Project Explorer");
- projectExplorer.show();
- Composite projectExplorerComposite = (Composite) projectExplorer.getWidget();
- Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), projectExplorerComposite);
- return new SWTBotTree(swtTree);
- }
+ /**
+ * Assumes Project Explorer view is shown.
+ *
+ * @return The tree of the Project Explorer view
+ */
+ public static SWTBotTree getTree() {
+ SWTBotView projectExplorer = bot.viewByTitle("Project Explorer");
+ projectExplorer.show();
+ Composite projectExplorerComposite = (Composite) projectExplorer.getWidget();
+ Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), projectExplorerComposite);
+ return new SWTBotTree(swtTree);
+ }
- /**
- * @param projectItem The tree item corresponding to the project.
- * @param name
- * name of an item
- * @return the project item pertaining to the project
- */
- public static SWTBotTreeItem getProjectItem(SWTBotTreeItem projectItem,
- String file) {
- for (SWTBotTreeItem item : projectItem.getItems()) {
- String itemText = item.getText();
- if (itemText.contains(file)) {
- if (itemText.contains(" ")) {
- StringTokenizer tok = new StringTokenizer(itemText, " ");
- String name = tok.nextToken();
- if (file.equals(name))
- return item;
- } else if (itemText.equals(file)) {
- return item;
- }
- }
- }
- return null;
- }
+ /**
+ * @param projectItem The tree item corresponding to the project.
+ * @param name
+ * name of an item
+ * @return the project item pertaining to the project
+ */
+ public static SWTBotTreeItem getProjectItem(SWTBotTreeItem projectItem,
+ String file) {
+ for (SWTBotTreeItem item : projectItem.getItems()) {
+ String itemText = item.getText();
+ if (itemText.contains(file)) {
+ if (itemText.contains(" ")) {
+ StringTokenizer tok = new StringTokenizer(itemText, " ");
+ String name = tok.nextToken();
+ if (file.equals(name))
+ return item;
+ } else if (itemText.equals(file)) {
+ return item;
+ }
+ }
+ }
+ return null;
+ }
- /**
- * Expand the given project (optionally stripping off the team provider bits)
- *
- * @param projectName
- * @param teamProviderString
- * @return
- */
- public static SWTBotTreeItem expandProject(SWTBotTree projectExplorerTree, String projectName, String teamProviderString) {
- String itemName;
- for (SWTBotTreeItem item: projectExplorerTree.getAllItems()) {
- itemName = item.getText();
- if (itemName.contains(projectName)) { // may also contain repo info
- if (itemName.contains(teamProviderString)) {
- return projectExplorerTree.expandNode(projectName + " "
- + teamProviderString);
- } else {
- return projectExplorerTree.expandNode(projectName);
- }
- }
- }
- // nothing appropriate found
- return null;
- }
+ /**
+ * Expand the given project (optionally stripping off the team provider bits)
+ *
+ * @param projectName
+ * @param teamProviderString
+ * @return
+ */
+ public static SWTBotTreeItem expandProject(SWTBotTree projectExplorerTree, String projectName, String teamProviderString) {
+ String itemName;
+ for (SWTBotTreeItem item: projectExplorerTree.getAllItems()) {
+ itemName = item.getText();
+ if (itemName.contains(projectName)) { // may also contain repo info
+ if (itemName.contains(teamProviderString)) {
+ return projectExplorerTree.expandNode(projectName + " "
+ + teamProviderString);
+ } else {
+ return projectExplorerTree.expandNode(projectName);
+ }
+ }
+ }
+ // nothing appropriate found
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorerTreeItemAppearsCondition.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorerTreeItemAppearsCondition.java
index aa54f8ccac..09716e3649 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorerTreeItemAppearsCondition.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorerTreeItemAppearsCondition.java
@@ -19,38 +19,38 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
*/
public class ProjectExplorerTreeItemAppearsCondition implements ICondition {
- private SWTBotTreeItem treeItem;
- private String itemName;
- private String parent;
- private String teamDirt;
- private SWTBotTree projectExplorerTree;
-
- public ProjectExplorerTreeItemAppearsCondition(SWTBotTree projectExplorerTree, String parent, String teamDirt, String treeItemName) {
- this.itemName = treeItemName;
- this.parent = parent;
- this.teamDirt = teamDirt;
- this.projectExplorerTree = projectExplorerTree;
- }
-
- @Override
- public boolean test() {
- treeItem = ProjectExplorer.expandProject(projectExplorerTree, parent, teamDirt);
- for (SWTBotTreeItem i : treeItem.getItems()) {
- if (i.getText().contains(itemName)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void init(SWTBot bot) {
- // no initialization
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
+ private SWTBotTreeItem treeItem;
+ private String itemName;
+ private String parent;
+ private String teamDirt;
+ private SWTBotTree projectExplorerTree;
+
+ public ProjectExplorerTreeItemAppearsCondition(SWTBotTree projectExplorerTree, String parent, String teamDirt, String treeItemName) {
+ this.itemName = treeItemName;
+ this.parent = parent;
+ this.teamDirt = teamDirt;
+ this.projectExplorerTree = projectExplorerTree;
+ }
+
+ @Override
+ public boolean test() {
+ treeItem = ProjectExplorer.expandProject(projectExplorerTree, parent, teamDirt);
+ for (SWTBotTreeItem i : treeItem.getItems()) {
+ if (i.getText().contains(itemName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ // no initialization
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java
index df0054a05e..4652fd70c6 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java
@@ -29,133 +29,133 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
*/
public class SVNProject {
- private SWTWorkbenchBot bot;
- private String repoURL;
- private String projectName;
- private IProject project; // available after checkout
-
- public SVNProject(SWTWorkbenchBot bot) {
- this.bot = bot;
- }
-
- /**
- * @return the repoURL
- */
- public String getRepoURL() {
- return repoURL;
- }
-
- /**
- * @param repoURL the repoURL to set
- */
- public SVNProject setRepoURL(String repoURL) {
- this.repoURL = repoURL;
- return this;
- }
-
- /**
- * @return the projectName
- */
- public String getProjectName() {
- return projectName;
- }
-
- /**
- * @param projectName the projectName to set
- */
- public SVNProject setProjectName(String projectName) {
- this.projectName = projectName;
- return this;
- }
-
- /**
- * @return the project
- */
- public IProject getProject() {
- return project;
- }
-
- /**
- * @param project the project to set
- */
- public SVNProject setProject(IProject project) {
- this.project = project;
- return this;
- }
-
- /**
- * Use File => Import => SVN to create a svn-backed project.
- */
- public IProject checkoutProject() throws IllegalStateException {
- if (repoURL == null || projectName == null) {
- // need to have url and project set
- throw new IllegalStateException();
- }
- bot.menu("File").menu("Import...").click();
-
- SWTBotShell shell = bot.shell("Import");
- shell.activate();
- bot.tree().expandNode("SVN").select("Checkout Projects from SVN");
- bot.button("Next >").click();
-
- // create new repo
- shell = bot.shell("Checkout from SVN");
- shell.activate();
- bot.button("Next >").click();
-
- shell = bot.shell("Checkout from SVN");
- shell.activate();
- // Enter url
- bot.comboBoxWithLabelInGroup("Url:", "Location").setText(repoURL);
- bot.button("Next >").click();
-
- // the next few operation can take quite a while, adjust
- // timout accordingly.
- long oldTimeout = SWTBotPreferences.TIMEOUT;
- SWTBotPreferences.TIMEOUT = 3 * 5000;
-
- bot.waitUntil(Conditions.shellIsActive("Progress Information"));
- shell = bot.shell("Progress Information");
- bot.waitUntil(Conditions.shellCloses(shell));
- bot.waitUntil(Conditions.shellIsActive("Checkout from SVN"));
- shell = bot.shell("Checkout from SVN");
- bot.waitUntil(new TreeItemAppearsCondition(repoURL, projectName));
- SWTBotTreeItem projectTree = bot.tree().expandNode(repoURL);
- projectTree.expandNode(projectName).select();
- bot.button("Finish").click();
- // Wait for import operation to finish
- bot.waitUntil(Conditions.shellCloses(shell));
- bot.waitUntil(Conditions.shellIsActive("SVN Checkout"));
- SWTBotShell svnCheckoutPopup = bot.shell("SVN Checkout");
- bot.waitUntil(Conditions.shellCloses(svnCheckoutPopup));
- // need a little delay
- bot.waitUntil(new SVNProjectCreatedCondition(projectName));
-
- // Set timout back what it was.
- SWTBotPreferences.TIMEOUT = oldTimeout;
-
- // A quick sanity check
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- IProject changelogTestsProject = (IProject)wsRoot.findMember(new Path(projectName));
- assertNotNull(changelogTestsProject);
- try {
- changelogTestsProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- IResource manifest = changelogTestsProject.findMember(new Path("/META-INF/MANIFEST.MF"));
- assertNotNull(manifest);
- return changelogTestsProject;
- }
-
- /**
- * Discard the automatically created SVN repo URL from the list.
- */
- public void discardRepositoryLocation() throws Exception {
- if (repoURL == null) { // need to have repoURL set
- throw new IllegalStateException();
- }
- new SVNReporsitoriesView(bot).open().discardRepository(repoURL);
- }
+ private SWTWorkbenchBot bot;
+ private String repoURL;
+ private String projectName;
+ private IProject project; // available after checkout
+
+ public SVNProject(SWTWorkbenchBot bot) {
+ this.bot = bot;
+ }
+
+ /**
+ * @return the repoURL
+ */
+ public String getRepoURL() {
+ return repoURL;
+ }
+
+ /**
+ * @param repoURL the repoURL to set
+ */
+ public SVNProject setRepoURL(String repoURL) {
+ this.repoURL = repoURL;
+ return this;
+ }
+
+ /**
+ * @return the projectName
+ */
+ public String getProjectName() {
+ return projectName;
+ }
+
+ /**
+ * @param projectName the projectName to set
+ */
+ public SVNProject setProjectName(String projectName) {
+ this.projectName = projectName;
+ return this;
+ }
+
+ /**
+ * @return the project
+ */
+ public IProject getProject() {
+ return project;
+ }
+
+ /**
+ * @param project the project to set
+ */
+ public SVNProject setProject(IProject project) {
+ this.project = project;
+ return this;
+ }
+
+ /**
+ * Use File => Import => SVN to create a svn-backed project.
+ */
+ public IProject checkoutProject() throws IllegalStateException {
+ if (repoURL == null || projectName == null) {
+ // need to have url and project set
+ throw new IllegalStateException();
+ }
+ bot.menu("File").menu("Import...").click();
+
+ SWTBotShell shell = bot.shell("Import");
+ shell.activate();
+ bot.tree().expandNode("SVN").select("Checkout Projects from SVN");
+ bot.button("Next >").click();
+
+ // create new repo
+ shell = bot.shell("Checkout from SVN");
+ shell.activate();
+ bot.button("Next >").click();
+
+ shell = bot.shell("Checkout from SVN");
+ shell.activate();
+ // Enter url
+ bot.comboBoxWithLabelInGroup("Url:", "Location").setText(repoURL);
+ bot.button("Next >").click();
+
+ // the next few operation can take quite a while, adjust
+ // timout accordingly.
+ long oldTimeout = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = 3 * 5000;
+
+ bot.waitUntil(Conditions.shellIsActive("Progress Information"));
+ shell = bot.shell("Progress Information");
+ bot.waitUntil(Conditions.shellCloses(shell));
+ bot.waitUntil(Conditions.shellIsActive("Checkout from SVN"));
+ shell = bot.shell("Checkout from SVN");
+ bot.waitUntil(new TreeItemAppearsCondition(repoURL, projectName));
+ SWTBotTreeItem projectTree = bot.tree().expandNode(repoURL);
+ projectTree.expandNode(projectName).select();
+ bot.button("Finish").click();
+ // Wait for import operation to finish
+ bot.waitUntil(Conditions.shellCloses(shell));
+ bot.waitUntil(Conditions.shellIsActive("SVN Checkout"));
+ SWTBotShell svnCheckoutPopup = bot.shell("SVN Checkout");
+ bot.waitUntil(Conditions.shellCloses(svnCheckoutPopup));
+ // need a little delay
+ bot.waitUntil(new SVNProjectCreatedCondition(projectName));
+
+ // Set timout back what it was.
+ SWTBotPreferences.TIMEOUT = oldTimeout;
+
+ // A quick sanity check
+ IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject changelogTestsProject = (IProject)wsRoot.findMember(new Path(projectName));
+ assertNotNull(changelogTestsProject);
+ try {
+ changelogTestsProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ IResource manifest = changelogTestsProject.findMember(new Path("/META-INF/MANIFEST.MF"));
+ assertNotNull(manifest);
+ return changelogTestsProject;
+ }
+
+ /**
+ * Discard the automatically created SVN repo URL from the list.
+ */
+ public void discardRepositoryLocation() throws Exception {
+ if (repoURL == null) { // need to have repoURL set
+ throw new IllegalStateException();
+ }
+ new SVNReporsitoriesView(bot).open().discardRepository(repoURL);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProjectCreatedCondition.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProjectCreatedCondition.java
index 661599dd8c..d21fb52021 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProjectCreatedCondition.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProjectCreatedCondition.java
@@ -22,31 +22,31 @@ import org.eclipse.swtbot.swt.finder.waits.ICondition;
*/
public class SVNProjectCreatedCondition implements ICondition {
- private String projectName;
-
- public SVNProjectCreatedCondition(String projectName) {
- this.projectName = projectName;
- }
-
- @Override
- public boolean test() {
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- IProject project = (IProject)wsRoot.findMember(new Path(projectName));
- if (project == null) {
- return false;
- } else {
- return true;
- }
- }
-
- @Override
- public void init(SWTBot bot) {
- // no initialization; don't need bot
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
+ private String projectName;
+
+ public SVNProjectCreatedCondition(String projectName) {
+ this.projectName = projectName;
+ }
+
+ @Override
+ public boolean test() {
+ IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = (IProject)wsRoot.findMember(new Path(projectName));
+ if (project == null) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ // no initialization; don't need bot
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNReporsitoriesView.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNReporsitoriesView.java
index 720aab0df9..1abf4509cb 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNReporsitoriesView.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNReporsitoriesView.java
@@ -17,44 +17,44 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
*/
public class SVNReporsitoriesView {
- private SWTWorkbenchBot bot;
+ private SWTWorkbenchBot bot;
- public SVNReporsitoriesView(SWTWorkbenchBot bot) {
- this.bot = bot;
- }
+ public SVNReporsitoriesView(SWTWorkbenchBot bot) {
+ this.bot = bot;
+ }
- /**
- * Open the SVNRepositoriesView
- */
- public SVNReporsitoriesView open() {
- bot.menu("Window").menu("Show View").menu("Other...").click();
- SWTBotShell shell = bot.shell("Show View");
- shell.activate();
- bot.tree().expandNode("SVN").select("SVN Repositories");
- bot.button("OK").click();
- return this;
- }
+ /**
+ * Open the SVNRepositoriesView
+ */
+ public SVNReporsitoriesView open() {
+ bot.menu("Window").menu("Show View").menu("Other...").click();
+ SWTBotShell shell = bot.shell("Show View");
+ shell.activate();
+ bot.tree().expandNode("SVN").select("SVN Repositories");
+ bot.button("OK").click();
+ return this;
+ }
- /**
- * Select repository
- */
- public void discardRepository(String repo) {
- SWTBotView svnRepoView = bot.viewByTitle("SVN Repositories");
- svnRepoView.show();
- svnRepoView.setFocus();
- SWTBotTree tree = svnRepoView.bot().tree();
- tree.select(repo);
- clickOnDiscardRepo(tree); // discard
- }
+ /**
+ * Select repository
+ */
+ public void discardRepository(String repo) {
+ SWTBotView svnRepoView = bot.viewByTitle("SVN Repositories");
+ svnRepoView.show();
+ svnRepoView.setFocus();
+ SWTBotTree tree = svnRepoView.bot().tree();
+ tree.select(repo);
+ clickOnDiscardRepo(tree); // discard
+ }
- /**
- * Context menu click helper. Click on "Add to existing sources".
- *
- * @param Tree of Package Explorer view.
- * @throws Exception
- */
- private void clickOnDiscardRepo(SWTBotTree svnReposTree) {
- String menuItem = "Discard location";
- ContextMenuHelper.clickContextMenu(svnReposTree, menuItem);
- }
+ /**
+ * Context menu click helper. Click on "Add to existing sources".
+ *
+ * @param Tree of Package Explorer view.
+ * @throws Exception
+ */
+ private void clickOnDiscardRepo(SWTBotTree svnReposTree) {
+ String menuItem = "Discard location";
+ ContextMenuHelper.clickContextMenu(svnReposTree, menuItem);
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TableAppearsCondition.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TableAppearsCondition.java
index 4d0a62895a..8a2967b261 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TableAppearsCondition.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TableAppearsCondition.java
@@ -18,31 +18,31 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
*/
public class TableAppearsCondition implements ICondition {
- private SWTBot bot;
+ private SWTBot bot;
- @Override
- public boolean test() {
- try {
- SWTBotTable table = bot.table();
- // table available
- // make sure rowcount > 0
- if (table.rowCount() > 0) {
- return true;
- }
- } catch (WidgetNotFoundException e) {
- // ignore
- }
- return false;
- }
+ @Override
+ public boolean test() {
+ try {
+ SWTBotTable table = bot.table();
+ // table available
+ // make sure rowcount > 0
+ if (table.rowCount() > 0) {
+ return true;
+ }
+ } catch (WidgetNotFoundException e) {
+ // ignore
+ }
+ return false;
+ }
- @Override
- public void init(SWTBot bot) {
- this.bot = bot;
- }
+ @Override
+ public void init(SWTBot bot) {
+ this.bot = bot;
+ }
- @Override
- public String getFailureMessage() {
- return null;
- }
+ @Override
+ public String getFailureMessage() {
+ return null;
+ }
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TreeItemAppearsCondition.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TreeItemAppearsCondition.java
index 23b4be12d8..03c10f853b 100644
--- a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TreeItemAppearsCondition.java
+++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TreeItemAppearsCondition.java
@@ -19,35 +19,35 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
*/
public class TreeItemAppearsCondition implements ICondition {
- private SWTBot bot;
- private SWTBotTreeItem treeItem;
- private String itemName;
- private String parent;
-
- public TreeItemAppearsCondition(String parent, String treeItemName) {
- this.itemName = treeItemName;
- this.parent = parent;
- }
-
- @Override
- public boolean test() {
- for (SWTBotTreeItem i : treeItem.getItems()) {
- if (i.getText().contains(itemName)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void init(SWTBot bot) {
- this.bot = bot;
- treeItem = this.bot.tree().expandNode(parent);
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
+ private SWTBot bot;
+ private SWTBotTreeItem treeItem;
+ private String itemName;
+ private String parent;
+
+ public TreeItemAppearsCondition(String parent, String treeItemName) {
+ this.itemName = treeItemName;
+ this.parent = parent;
+ }
+
+ @Override
+ public boolean test() {
+ for (SWTBotTreeItem i : treeItem.getItems()) {
+ if (i.getText().contains(itemName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ this.bot = bot;
+ treeItem = this.bot.tree().expandNode(parent);
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return null;
+ }
}

Back to the top