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/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core
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/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core')
-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
38 files changed, 3773 insertions, 3773 deletions
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);
+ }
}

Back to the top