template commit commentary [message #1115706] |
Tue, 24 September 2013 09:04  |
Eclipse User |
|
|
|
hello.
i'm trying to develop a feature for subversive, and i think that one extends the commit action. that feature would allow me to have some template messages to put in the commit commentary, and some kind of drop down list to choose the template message.
but i think that i can't do it by myself, so i decided to get some help with this, if you guys want to help me.
the thing is, i'm not confortable with subversive extension points.
- it is possible to do this feature? (both the drop down list to choose the message, and the text insertion on commentary text field)
- do i need to analyse subversive source code to do this?
- what should i do to start the plugin? (the new one)
thanks for your attention.
best regards,
Gabriel.
|
|
|
|
Re: template commit commentary [message #1118583 is a reply to message #1116449] |
Fri, 27 September 2013 10:57   |
Eclipse User |
|
|
|
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 13:21   |
Eclipse User |
|
|
|
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 13:24] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 1.41341 seconds