com.intellij.openapi.vcs.ui.RefreshableOnComponent Java Examples

The following examples show how to use com.intellij.openapi.vcs.ui.RefreshableOnComponent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: P4CheckinEnvironment.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
@Nullable
//@Override
@Deprecated
public RefreshableOnComponent createAdditionalOptionsPanel(CheckinProjectPanel panel, PairConsumer<Object, Object> additionalDataConsumer) {
    // #52 - we could be able to monitor panel.getCommitMessage(); to ensure
    // that there's a message, and when there isn't, disable the submit
    // button.
    // We can monitor the message (with a thread, disposing of it is
    // a bit of a bother, but it's doable).  However, disabling the button
    // currently requires:
    //  1. Grabbing the owning dialog object of the panel.
    //  2. Using reflection to make the protected "disableOKButton" method
    //     accessible and callable.
    // All of this means that this isn't a very good idea.
    // The panel has a "setWarning" method, but that doesn't do anything.

    return new P4OnCheckinPanel(project, panel, additionalDataConsumer);
}
 
Example #2
Source File: CheckRemoteStatusCheckinHandlerFactory.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  final JCheckBox checkUpToDate = new JCheckBox(VcsBundle.message("checkbox.checkin.options.check.files.up.to.date"));

  return new RefreshableOnComponent() {
    public JComponent getComponent() {
      final JPanel panel = new JPanel(new BorderLayout());
      panel.add(checkUpToDate, BorderLayout.WEST);
      return panel;
    }

    public void refresh() {
    }

    public void saveState() {
      myVcsConfiguration.CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT = checkUpToDate.isSelected();
    }

    public void restoreState() {
      checkUpToDate.setSelected(myVcsConfiguration.CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT);
    }
  };
}
 
Example #3
Source File: CodeAnalysisBeforeCheckinHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@javax.annotation.Nullable
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  final JCheckBox checkBox = new JCheckBox(VcsBundle.message("before.checkin.standard.options.check.smells"));
  return new RefreshableOnComponent() {
    @Override
    public JComponent getComponent() {
      JPanel panel = new JPanel(new BorderLayout());
      panel.add(checkBox);
      CheckinHandlerUtil.disableWhenDumb(myProject, checkBox, "Code analysis is impossible until indices are up-to-date");
      return panel;
    }

    @Override
    public void refresh() {
    }

    @Override
    public void saveState() {
      getSettings().CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT = checkBox.isSelected();
    }

    @Override
    public void restoreState() {
      checkBox.setSelected(getSettings().CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT);
    }
  };
}
 
Example #4
Source File: ReformatBeforeCheckinHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  final JCheckBox reformatBox = new JCheckBox(VcsBundle.message("checkbox.checkin.options.reformat.code"));

  return new RefreshableOnComponent() {
    @Override
    public JComponent getComponent() {
      final JPanel panel = new JPanel(new GridLayout(1, 0));
      panel.add(reformatBox);
      return panel;
    }

    @Override
    public void refresh() {
    }

    @Override
    public void saveState() {
      getSettings().REFORMAT_BEFORE_PROJECT_COMMIT = reformatBox.isSelected();
    }

    @Override
    public void restoreState() {
      reformatBox.setSelected(getSettings().REFORMAT_BEFORE_PROJECT_COMMIT);
    }
  };

}
 
Example #5
Source File: OptimizeImportsBeforeCheckinHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  final JCheckBox optimizeBox = new JCheckBox(VcsBundle.message("checkbox.checkin.options.optimize.imports"));
  CheckinHandlerUtil.disableWhenDumb(myProject, optimizeBox, "Impossible until indices are up-to-date");

  return new RefreshableOnComponent() {
    @Override
    public JComponent getComponent() {
      final JPanel panel = new JPanel(new GridLayout(1, 0));
      panel.add(optimizeBox);
      return panel;
    }

    @Override
    public void refresh() {
    }

    @Override
    public void saveState() {
      getSettings().OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT = optimizeBox.isSelected();
    }

    @Override
    public void restoreState() {
      optimizeBox.setSelected(getSettings().OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT);
    }
  };

}
 
Example #6
Source File: CommitChangeListDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void refresh() {
  ChangeListManager.getInstance(myProject).invokeAfterUpdate(new Runnable() {
    @Override
    public void run() {
      myBrowser.rebuildList();
      for (RefreshableOnComponent component : myAdditionalComponents) {
        component.refresh();
      }
    }
  }, InvokeAfterUpdateMode.SILENT, "commit dialog", ModalityState.current());   // title not shown for silently
}
 
Example #7
Source File: RearrangeBeforeCheckinHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  final JCheckBox rearrangeBox = new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.rearrange.code"));
  CheckinHandlerUtil.disableWhenDumb(myProject, rearrangeBox, "Impossible until indices are up-to-date");
  return new RefreshableOnComponent() {
    @Override
    public JComponent getComponent() {
      final JPanel panel = new JPanel(new GridLayout(1, 0));
      panel.add(rearrangeBox);
      return panel;
    }

    @Override
    public void refresh() {
    }

    @Override
    public void saveState() {
      getSettings().REARRANGE_BEFORE_PROJECT_COMMIT = rearrangeBox.isSelected();
    }

    @Override
    public void restoreState() {
      rearrangeBox.setSelected(getSettings().REARRANGE_BEFORE_PROJECT_COMMIT);
    }
  };
}
 
Example #8
Source File: CodeCleanupCheckinHandlerFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  final JCheckBox cleanupCodeCb = new NonFocusableCheckBox(VcsBundle.message("before.checkin.cleanup.code"));
  return new RefreshableOnComponent() {
    @Override
    public JComponent getComponent() {
      final JPanel cbPanel = new JPanel(new BorderLayout());
      cbPanel.add(cleanupCodeCb, BorderLayout.WEST);
      CheckinHandlerUtil
              .disableWhenDumb(myProject, cleanupCodeCb, "Code analysis is impossible until indices are up-to-date");
      return cbPanel;
    }

    @Override
    public void refresh() {
    }

    @Override
    public void saveState() {
      VcsConfiguration.getInstance(myProject).CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT = cleanupCodeCb.isSelected();
    }

    @Override
    public void restoreState() {
      cleanupCodeCb.setSelected(VcsConfiguration.getInstance(myProject).CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT);
    }
  };
}
 
Example #9
Source File: CommitMessageValidationCheckinHandler.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  GitToolBoxConfigPrj config = getConfig();
  return new BooleanCommitOption(panel, ResBundle.message("commit.message.validation.label"),
      false, config::getCommitMessageValidation,
      config::setCommitMessageValidation);
}
 
Example #10
Source File: TFSCheckinEnvironment.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
@Nullable
    public RefreshableOnComponent createAdditionalOptionsPanel(final CheckinProjectPanel checkinProjectPanel,
                                                               PairConsumer<Object, Object> additionalDataConsumer) {
//        boolean isAffected = false;
//        for (File file : checkinProjectPanel.getFiles()) {
//            if (TFSVcs.isUnderTFS(VcsUtil.getFilePath(file), checkinProjectPanel.getProject())) {
//                isAffected = true;
//                break;
//            }
//        }
//        if (!isAffected) {
//            return null;
//        }
//
//        final JComponent panel = new JPanel();
//        panel.setLayout(new BorderLayout(5, 0));
//
//        myVcs.getCheckinData().messageLabel = new BoldLabel() {
//
//            @Override
//            public JToolTip createToolTip() {
//                JToolTip toolTip = new JToolTip() {{
//                    setUI(new MultiLineTooltipUI());
//                }};
//                toolTip.setComponent(this);
//                return toolTip;
//            }
//
//        };
//
//        panel.add(myVcs.getCheckinData().messageLabel, BorderLayout.WEST);
//
//        final JButton configureButton = new JButton("Configure...");
//        panel.add(configureButton, BorderLayout.EAST);
//
//        configureButton.addActionListener(new ActionListener() {
//
//            public void actionPerformed(final ActionEvent event) {
//                CheckinParameters copy = myVcs.getCheckinData().parameters.createCopy();
//
//                CheckinParametersDialog d = new CheckinParametersDialog(checkinProjectPanel.getProject(), copy);
//                if (d.showAndGet()) {
//                    myVcs.getCheckinData().parameters = copy;
//                    updateMessage(myVcs.getCheckinData());
//                }
//            }
//        });
//
//        return new TFSAdditionalOptionsPanel(panel, checkinProjectPanel, configureButton);
        return null;
    }
 
Example #11
Source File: CommitChangeListDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
@Nonnull
public List<RefreshableOnComponent> getAdditionalComponents() {
  return Collections.unmodifiableList(myAdditionalComponents);
}
 
Example #12
Source File: CommitChangeListDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void saveState() {
  for (RefreshableOnComponent component : myAdditionalComponents) {
    component.saveState();
  }
}
 
Example #13
Source File: CommitChangeListDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void restoreState() {
  for (RefreshableOnComponent component : myAdditionalComponents) {
    component.restoreState();
  }
}
 
Example #14
Source File: CheckinEnvironment.java    From consulo with Apache License 2.0 4 votes vote down vote up
@javax.annotation.Nullable
RefreshableOnComponent createAdditionalOptionsPanel(CheckinProjectPanel panel, PairConsumer<Object, Object> additionalDataConsumer);
 
Example #15
Source File: TodoCheckinHandler.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  JCheckBox checkBox = new JCheckBox(VcsBundle.message("before.checkin.new.todo.check", ""));
  return new RefreshableOnComponent() {
    @Override
    public JComponent getComponent() {
      JPanel panel = new JPanel(new BorderLayout(4, 0));
      panel.add(checkBox, BorderLayout.WEST);
      setFilterText(myConfiguration.myTodoPanelSettings.todoFilterName);
      if (myConfiguration.myTodoPanelSettings.todoFilterName != null) {
        myTodoFilter = TodoConfiguration.getInstance().getTodoFilter(myConfiguration.myTodoPanelSettings.todoFilterName);
      }

      Consumer<TodoFilter> consumer = todoFilter -> {
        myTodoFilter = todoFilter;
        String name = todoFilter == null ? null : todoFilter.getName();
        myConfiguration.myTodoPanelSettings.todoFilterName = name;
        setFilterText(name);
      };
      LinkLabel linkLabel = new LinkLabel("Configure", null);
      linkLabel.setListener(new LinkListener() {
        @Override
        public void linkSelected(LinkLabel aSource, Object aLinkData) {
          DefaultActionGroup group = SetTodoFilterAction.createPopupActionGroup(myProject, myConfiguration.myTodoPanelSettings, consumer);
          ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.TODO_VIEW_TOOLBAR, group);
          popupMenu.getComponent().show(linkLabel, 0, linkLabel.getHeight());
        }
      }, null);
      panel.add(linkLabel, BorderLayout.CENTER);

      CheckinHandlerUtil.disableWhenDumb(myProject, checkBox, "TODO check is impossible until indices are up-to-date");
      return panel;
    }

    private void setFilterText(String filterName) {
      if (filterName == null) {
        checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", IdeBundle.message("action.todo.show.all")));
      } else {
        checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", "Filter: " + filterName));
      }
    }

    @Override
    public void refresh() {
    }

    @Override
    public void saveState() {
      myConfiguration.CHECK_NEW_TODO = checkBox.isSelected();
    }

    @Override
    public void restoreState() {
      checkBox.setSelected(myConfiguration.CHECK_NEW_TODO);
    }
  };
}
 
Example #16
Source File: CheckinHandler.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the panel which is inserted in the "After Check In" group box of the Checkin Project
 * or Checkin File dialogs.
 *
 * @return the panel instance, or null if the handler does not provide any options to show in the
 * "After Check In" group.
 * @param parentDisposable
 */
@Nullable
public RefreshableOnComponent getAfterCheckinConfigurationPanel(final Disposable parentDisposable) {
  return null;
}
 
Example #17
Source File: CheckinHandler.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the panel which is inserted in the "Before Check In" group box of the Checkin Project
 * or Checkin File dialogs.
 *
 * @return the panel instance, or null if the handler does not provide any options to show in the
 * "Before Check In" group.
 */
@javax.annotation.Nullable
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
  return null;
}