add convenient constructor

This commit is contained in:
Vladimir Krivosheev
2014-08-25 10:05:36 +02:00
parent 998c7ba5af
commit f0ea331b24
2 changed files with 16 additions and 5 deletions
@@ -59,16 +59,20 @@ public class DialogBuilder implements Disposable {
showImpl(false);
}
public DialogBuilder(Project project) {
public DialogBuilder(@Nullable Project project) {
myDialogWrapper = new MyDialogWrapper(project, true);
Disposer.register(myDialogWrapper.getDisposable(), this);
}
public DialogBuilder(Component parent) {
public DialogBuilder(@Nullable Component parent) {
myDialogWrapper = new MyDialogWrapper(parent, true);
Disposer.register(myDialogWrapper.getDisposable(), this);
}
public DialogBuilder() {
this(((Project)null));
}
@Override
public void dispose() {
}
@@ -90,6 +94,12 @@ public class DialogBuilder implements Disposable {
myCenterPanel = centerPanel;
}
@NotNull
public DialogBuilder centerPanel(@NotNull JComponent centerPanel) {
myCenterPanel = centerPanel;
return this;
}
@NotNull
public DialogBuilder setNorthPanel(@NotNull JComponent northPanel) {
myNorthPanel = northPanel;
@@ -100,6 +110,7 @@ public class DialogBuilder implements Disposable {
myTitle = title;
}
@NotNull
public DialogBuilder title(@NotNull String title) {
myTitle = title;
return this;
@@ -267,7 +278,7 @@ public class DialogBuilder implements Disposable {
protected Action createAction(final DialogWrapper dialogWrapper) {
return new AbstractAction(){
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
dialogWrapper.close(myExitCode);
}
};
@@ -325,7 +336,7 @@ public class DialogBuilder implements Disposable {
private class MyDialogWrapper extends DialogWrapper {
private String myHelpId = null;
private MyDialogWrapper(Project project, boolean canBeParent) {
private MyDialogWrapper(@Nullable Project project, boolean canBeParent) {
super(project, canBeParent);
}
@@ -651,7 +651,7 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Virt
public boolean process(final VirtualFile file, final Document document) {
String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());
final DialogBuilder builder = new DialogBuilder((Project)null);
final DialogBuilder builder = new DialogBuilder();
builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER));
builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button"));
builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button"));