[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| RE: [subversive-dev] subversive extension | 
Hello Andrey,
it's a pitty that you've given just some peaces of your 
code, so I can't help you find the problem in it.
 
Everithing should work just fine. The example of adding 
something to the commit message depending on the option chosen (it can also 
depend on some input, than not the bolean value should be saved before 
proceeding but the input string).
 
public class MyCommitActionFactory implements 
ICommitActionFactory {
 
    public ICommitDialog 
getCommitDialog(Shell shell, Collection allFilesToCommit, ICommentDialogPanel 
commentPanel) {
        return new 
MyCommitDialog(shell, commentPanel);
    }
 
    public void 
performAfterCommitTasks(CompositeOperation operation, IRevisionProvider 
revisionProvider, IActionOperation[] dependsOn, IWorkbenchPart part) 
{
    }
 
    public class MyCommitDialog extends 
DefaultDialog implements ICommitDialog 
{
  
        private 
ICommentDialogPanel 
panel;
  
        private 
boolean addTestMessage = 
false;
  
        public 
MyCommitDialog(Shell parentShell, ICommentDialogPanel panel) 
{
            
super(parentShell, 
panel);
            
this.panel = panel;
        
}
 
        public String 
getMessage() 
{
            if 
(this.addTestMessage) 
{
                
return this.panel.getMessage() + 
"\ntestCommitMessage";
            
}
            return 
this.panel.getMessage();
        
}
  
        public int 
open() {
            
return super.open();
        
}
  
        protected void 
buttonPressed(int buttonId) 
{
            if 
(IDialogConstants.OK_ID == buttonId) 
{
                
showMySimpleDialog(buttonId);
            
}
            else 
{
                
super.buttonPressed(buttonId);
            
}
        
}
 
        void 
showMySimpleDialog(int buttonId) 
{
            Object[] 
options = { "Yes", "No" 
};
            if 
(JOptionPane.showOptionDialog(null, "Should I add test message to commit 
message?", "Adding test message",  JOptionPane.YES_NO_OPTION, 
JOptionPane.QUESTION_MESSAGE, null, options, options[0]) == 
JOptionPane.YES_OPTION) 
{
                
this.addTestMessage = 
true;
            
}
            
super.buttonPressed(buttonId);
        
}
    }
}
 
This code works just 
fine for me. So, the clear answers for your 
questions:
1. To press the OK button in the commit 
dialog call super.buttonPressed(buttonId), as you are doing 
now.
2. To add a text to a commit message from 
your simple dialog you should pass this text in any suitable way to the 
ICommitDialog implementation and then add it to the appropriate part of the 
commit comment returned by getMessage().
 
Best regards, Alexei 
Goncharov.
Subversive Team
Greetings.
I want to build subversive extension which shows a simply MySimpleDialog 
after I press "OK" button on the commit dialog.
Then I can do some actions on MySimpleDialog and press button "go ahead" on 
it. 
After "go ahead" button pressed -> the commit process 
begins, 
all the windows closes and some text from MySimpleDialog adds to comment 
text.
Now I wrote some plugin which extends 
org.polarion.team.svn.ui.commit,
So, MyCommitActionFactory extends ICommitActionFactoty where "open" method 
returns MyComitDialog:
MyComitDialog extends DefaulDialog.
In MyComitDialog i overrided "buttonPressed" method to show MySimpleDialog 
(MySimpleDialog is inner-class in MyComitDialog).
Then I added a simple listener to  "go ahead" button on MySimpleDialog 
which do the same that "buttonPressed" in DefaulDialog does.
Here is the code:
...
public class MyCommitActionFactory implements ICommitActionFactory {
public ICommitDialog 
getCommitDialog(final Shell shell, Collection allFilesToCommit, final 
ICommentDialogPanel commentPanel) {
return new ICommitDialog() {
public String getMessage() {
return "testCommitMessage" + 
commentPanel.getMessage();
}
public int open() {
dialog = new MyCommitDialog(new 
Shell(shell), commentPanel);
return dialog.open();
}
};
}
...
}
...
public class MyCommitDialog extends DefaultDialog {
...
protected void buttonPressed(int 
buttonId) {
if (IDialogConstants.OK_ID == 
buttonId) {
showMySimpleDialog(buttonId);
} else {
super.buttonPressed(buttonId);
}
}
...
public void preCommitAction() {
JOptionPane.showMessageDialog(...);
//XXX:dont works
super.buttonPressed(IDialogConstants.OK_ID);
}
...
protected class MySimpleDialog 
{
...
public void addListener() {
buttonGoAhead.addActionListener(new 
ActionListener() {
@Override
public void 
actionPerformed(ActionEvent e) {
preCommitAction();
}
});
}
...
}
...
}
So, when I press GoAhead Button, the preCommitAction() invokes. It shows 
JOptionPane, but the Button in DefaultDialog doesnn't presses!
My questions are:
1. How can I press the button "OK" on DefaultDialog from MySimpeDialog (or 
how to do commit action)?
2. How can I add some text from MySimpleDialog to comment text?
Thank you!
With best regards, Andrey Pavlenko.