Home » Eclipse Projects » Subversive » template commit commentary
| |
Re: template commit commentary [message #1118583 is a reply to message #1116449] |
Fri, 27 September 2013 14:57 |
Gabriel Ferreira Messages: 6 Registered: September 2013 |
Junior Member |
|
|
Ok guys, so i managed, somehow, to put some content in the commit dialog. These contents (combobox and button) work together so that when the user press the button, it will trigger a runnable to append some specific text into the comment area of commit dialog.
For this, i created my plugin that connects to commit extension point. I created my "CustomFactory implements ICommitActionFactory", and my "CustomDialog extends DefaultDialog".
To put my own contents in the commit dialog, i overrided "createMainPanel" from DefaultDialog:
protected Control createMainPanel(Composite parent) {
Control control = super.createMainPanel(parent);
if(Composite.class.isAssignableFrom(control.getClass())) {
Composite aux = (Composite)control;
Composite composite = new Composite(aux, SWT.NONE);
composite.setLayout(new FillLayout());
...
Combo combo_box = new Combo(composite, SWT.READ_ONLY);
combo_box.setItems(items);
combo_box.select(0);
Button button = new Button(composite, SWT.PUSH);
button.setText("ADD REFERENCE");
button.addSelectionListener(new CustomSelectionListener(combo_box));
}
return control;
}
The Listener will get the text selected in the Combo, and put it in the panel. Having this class attribute:
private CommentPanel panel;
The runnable will change the textarea (StyledText in CommentComposite).
public void run() {
panel.buttonPressed(0); //This is done so i can get the current text in the text field.
String str = (panel.getMessage() != null ? panel.getMessage() : "") + '\n' + TEXT_TO_APPEND;
panel.setMessage(str);
}
Can you guys give me some feedback please?
|
|
| |
Re: template commit commentary [message #1128422 is a reply to message #1115706] |
Mon, 07 October 2013 17:21 |
Gabriel Ferreira Messages: 6 Registered: September 2013 |
Junior Member |
|
|
Hello.
Thanks for the feedback.
Yeah, it's kinda like what you said.
But i think that would be better if subversion had some kind of extension point that allows the user to insert extra components on the commit dialog, and allow those components to interact with the commit dialog in real time. In my case, my components would interact with the text box (revision comments), just to append some text. With my code, i can do that. But it's not perfect. Notice this:
public void run() {
panel.buttonPressed(0); //This is done so i can get the current text in the text field.
String str = (panel.getMessage() != null ? panel.getMessage() : "") + '\n' + TEXT_TO_APPEND;
panel.setMessage(str);
}
If i just do "panel.getMessage()", i will get empty text because this method just returns some String content, and not the text in the text box. To fix this, i call "panel.buttonPressed(0);" before, because it will put the text box content on that String. Then, it will return what i want to get. BUT, this will also save that content in the comment history, and i dont want that. We can see that below:
public abstract class AbstractDialogPanel implements IDialogPanel, IValidationManager {
...
public void buttonPressed(int idx) {
if (idx == 0) {
this.saveChanges();
}
else {
this.cancelChanges();
}
}
...
}
...
public class CommentComposite extends Composite {
public void saveChanges() {
this.message = this.text.getText();
this.history.addLine(this.message);
CommentComposite.TEMPORARY_COMMENT = null;
if (this.bugIdText != null) {
this.bugID = this.bugIdText.getText();
}
}
...
}
And, besides, this is not a very intuitive way of doing things.
Eventually, i decided to change my code. Now, i can interact directly with the text box object. But, for that, i did something that i dont like either. From the Composite, i search for the text box object (StyledText), keep it, and then use it directly. You can see it below:
public class CustomDialog extends DefaultDialog {
private StyledText comment_text;
protected Control createMainPanel(Composite parent) {
Control control = super.createMainPanel(parent);
if(Composite.class.isAssignableFrom(control.getClass())) {
Composite aux = (Composite)control;
comment_text = findStyledText(aux);
createExtraComponents(aux);
}
return control;
}
private StyledText findStyledText(Composite composite) {
StyledText text = null;
Control[] children = composite.getChildren();
int i = 0;
while(i < children.length && text == null) {
if(StyledText.class.isAssignableFrom(children[i].getClass())) {
text = ((StyledText)children[i]);
}
else if(Composite.class.isAssignableFrom(children[i].getClass())) {
text = findStyledText((Composite)children[i]); //May return null
}
i++;
}
return text; //May be null
}
...
}
AGENT CODE:
public void run() {
if(CustomDialog.this.comment_text != null) {
CustomDialog.this.comment_text.append(text_to_append);
}
}
This code works. But, again, it's not very intuitive, and maybe is not safe to do it.
___
EDIT: sorry for my weak English.
[Updated on: Mon, 07 October 2013 17:24] Report message to a moderator
|
|
| |
Re: template commit commentary [message #1129245 is a reply to message #1129132] |
Tue, 08 October 2013 12:50 |
Gabriel Ferreira Messages: 6 Registered: September 2013 |
Junior Member |
|
|
Alexander Gurov wrote on Tue, 08 October 2013 06:15What is the reson for not wanting it to be stored in history? Is there is no chance of reusing the same comment or its variations in the future?
because i can append text many times in the same revision comment. so, it will save many variations of the same comment. it will save the current status of the comment everytime i append something with the combo box.
__
EDIT: in my opinion, the history should only save the final status of the message to comment in the revision.
[Updated on: Tue, 08 October 2013 12:52] Report message to a moderator
|
|
| | |
Goto Forum:
Current Time: Thu Sep 26 01:28:59 GMT 2024
Powered by FUDForum. Page generated in 0.03783 seconds
|