DBE: custom panel for refactoring dialog

This commit is contained in:
Alexander Kass
2015-09-17 13:28:01 +03:00
parent b8688c575e
commit bf3fecbb61
3 changed files with 18 additions and 1 deletions
@@ -387,7 +387,10 @@ public abstract class BaseRefactoringProcessor implements Runnable {
final UsageViewPresentation presentation = createPresentation(viewDescriptor, usages);
final UsageView usageView = viewManager.showUsages(targets, usages, presentation, factory);
customizeUsagesView(viewDescriptor, usageView);
}
protected void customizeUsagesView(@NotNull final UsageViewDescriptor viewDescriptor, @NotNull final UsageView usageView) {
final Runnable refactoringRunnable = new Runnable() {
@Override
public void run() {
@@ -66,6 +66,8 @@ public interface UsageView extends Disposable {
void addButtonToLowerPane(@NotNull Runnable runnable, @NotNull String text, char mnemonic);
void addButtonToLowerPane(@NotNull Runnable runnable, @NotNull String text);
void setAdditionalComponent(@Nullable JComponent component);
void addPerformOperationAction(@NotNull Runnable processRunnable, String commandName, String cannotMakeString, @NotNull String shortDescription);
/**
@@ -106,6 +106,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
private final Map<Usage, UsageNode> myUsageNodes = new ConcurrentHashMap<Usage, UsageNode>();
public static final UsageNode NULL_NODE = new UsageNode(NullUsage.INSTANCE, new UsageViewTreeModelBuilder(new UsageViewPresentation(), UsageTarget.EMPTY_ARRAY));
private final ButtonPanel myButtonPanel = new ButtonPanel();
private final JComponent myAdditionalComponent = new JPanel(new BorderLayout());
private volatile boolean isDisposed;
private volatile boolean myChangesDetected = false;
public static final Comparator<Usage> USAGE_COMPARATOR = new Comparator<Usage>() {
@@ -393,7 +394,8 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
myPreviewSplitter.setProportion(1);
}
myCentralPanel.add(myButtonPanel, BorderLayout.SOUTH);
myCentralPanel.add(myAdditionalComponent, BorderLayout.SOUTH);
myAdditionalComponent.add(myButtonPanel, BorderLayout.SOUTH);
myRootPanel.revalidate();
myRootPanel.repaint();
@@ -1235,6 +1237,16 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
myButtonPanel.addButtonRunnable(index, runnable, text);
}
@Override
public void setAdditionalComponent(@Nullable JComponent comp) {
BorderLayout layout = (BorderLayout)myAdditionalComponent.getLayout();
Component prev = layout.getLayoutComponent(myAdditionalComponent, BorderLayout.CENTER);
if (prev == comp) return;
if (prev != null) myAdditionalComponent.remove(prev);
if (comp != null) myAdditionalComponent.add(comp, BorderLayout.CENTER);
myAdditionalComponent.revalidate();
}
@Override
public void addButtonToLowerPane(@NotNull final Runnable runnable, @NotNull String text, char mnemonic) {
// implemented method is deprecated, so, it just calls non-deprecated overloading one