Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fe65976b6518fb72f408fd6a44c935c3b65a83d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*******************************************************************************
 * Copyright (c) 2006, 2007 Red Hat Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * 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:
 *    Kyu Lee <klee@redhat.com> - initial API and implementation
 *******************************************************************************/
package org.eclipse.linuxtools.internal.changelog.core;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.linuxtools.changelog.core.IFormatterChangeLogContrib;
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 guessedFName = null;

	private IFormatterChangeLogContrib formatter = null;

	private IEditorPart changelog = null;

	private String dateLine = null;

	private String changelogLocation = null;

	public IEditorPart getChangelog() {
		return changelog;
	}

	public void setChangelog(IEditorPart changelog) {
		this.changelog = changelog;
	}

	public String getChangelogLocation() {
		return changelogLocation;
	}

	public void setChangelogLocation(String changelogLocation) {
		this.changelogLocation = changelogLocation;
	}

	public String getDateLine() {
		return dateLine;
	}

	public void setDateLine(String dateLine) {
		this.dateLine = dateLine;
	}

	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 IFormatterChangeLogContrib getFormatter() {
		return formatter;
	}

	public void setFormatter(IFormatterChangeLogContrib formatter) {
		this.formatter = formatter;
	}

	public String getGuessedFName() {
		return guessedFName;
	}

	public void setGuessedFName(String guessedFName) {
		this.guessedFName = guessedFName;
	}

	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");

		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;
		}

		formatter.mergeChangelog(dateLine, guessedFName, defaultContent, changelog,
				changelogLocation, entryFilePath);

	}

	public String getDefaultContent() {
		return defaultContent;
	}

	public void setDefaultContent(String defaultContent) {
		this.defaultContent = defaultContent;
	}

}

Back to the top