mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
refactoring
* separated disableOkActions created for start edit property change event; * clarifying comment added; * enableOkActions method renamed to updateOkActions with appropriate logic moved inside
This commit is contained in:
@@ -88,8 +88,12 @@ public class PushController implements Disposable {
|
||||
myPushLog.getTree().addPropertyChangeListener(PushLogTreeUtil.EDIT_MODE_PROP, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
// when user starts edit we need to force disable ok actions, because tree.isEditing() still false;
|
||||
// after editing completed okActions will be enabled automatically by dialog validation
|
||||
Boolean isEditMode = (Boolean)evt.getNewValue();
|
||||
myDialog.enableOkActions(!isEditMode && isPushAllowed());
|
||||
if (isEditMode) {
|
||||
myDialog.disableOkActions();
|
||||
}
|
||||
}
|
||||
});
|
||||
startLoadingCommits();
|
||||
@@ -234,7 +238,7 @@ public class PushController implements Disposable {
|
||||
|
||||
@Override
|
||||
public void onSelectionChanged(boolean isSelected) {
|
||||
myDialog.enableOkActions(isPushAllowed());
|
||||
myDialog.updateOkActions();
|
||||
if (isSelected) {
|
||||
boolean forceLoad = myExcludedRepositoryRoots.remove(model.getRepository().getRoot().getPath());
|
||||
if (!model.hasCommitInfo() && (forceLoad || !model.getSupport().shouldRequestIncomingChangesForNotCheckedRepositories())) {
|
||||
@@ -399,7 +403,7 @@ public class PushController implements Disposable {
|
||||
if (shouldBeSelected) { // never remove selection; initially all checkboxes are not selected
|
||||
node.setChecked(true);
|
||||
}
|
||||
myDialog.enableOkActions(isPushAllowed());
|
||||
myDialog.updateOkActions();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
myListPanel = myController.getPushPanelLog();
|
||||
|
||||
init();
|
||||
enableOkActions(myController.isPushAllowed());
|
||||
updateOkActions();
|
||||
setOKButtonText("Push");
|
||||
setOKButtonMnemonic('P');
|
||||
setTitle("Push Commits");
|
||||
@@ -78,7 +78,7 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
@Nullable
|
||||
@Override
|
||||
protected ValidationInfo doValidate() {
|
||||
enableOkActions(myController.isPushAllowed());
|
||||
updateOkActions();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,10 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
return actions.toArray(new Action[actions.size()]);
|
||||
}
|
||||
|
||||
private boolean canPush() {
|
||||
return myController.isPushAllowed();
|
||||
}
|
||||
|
||||
private boolean canForcePush() {
|
||||
return myController.isForcePushEnabled() && myController.getProhibitedTarget() == null;
|
||||
}
|
||||
@@ -121,11 +125,13 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
protected String getHelpId() {
|
||||
return ID;
|
||||
}
|
||||
public void enableOkActions(boolean isEnabled) {
|
||||
myPushAction.setEnabled(isEnabled);
|
||||
|
||||
public void updateOkActions() {
|
||||
boolean canPush = canPush();
|
||||
myPushAction.setEnabled(canPush);
|
||||
if (myForcePushAction != null) {
|
||||
boolean canForcePush = canForcePush();
|
||||
myForcePushAction.setEnabled(isEnabled && canForcePush);
|
||||
myForcePushAction.setEnabled(canPush && canForcePush);
|
||||
String tooltip = null;
|
||||
if (!canForcePush) {
|
||||
PushTarget target = myController.getProhibitedTarget();
|
||||
@@ -137,6 +143,10 @@ public class VcsPushDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public void disableOkActions() {
|
||||
myPushAction.setEnabled(false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public VcsPushOptionValue getAdditionalOptionValue(@NotNull PushSupport support) {
|
||||
VcsPushOptionsPanel panel = myAdditionalPanels.get(support);
|
||||
|
||||
Reference in New Issue
Block a user