1 19 20 package org.netbeans.modules.refactoring.spi.ui; 21 22 import java.awt.Component ; 23 import javax.swing.Action ; 24 import javax.swing.JLabel ; 25 import javax.swing.SwingConstants ; 26 import org.netbeans.modules.refactoring.api.RefactoringSession; 27 import org.netbeans.modules.refactoring.spi.ui.RefactoringUI; 28 import org.netbeans.modules.refactoring.spi.impl.RefactoringPanel; 29 import org.netbeans.modules.refactoring.spi.impl.RefactoringPanelContainer; 30 import org.openide.windows.TopComponent; 31 32 37 public final class UI { 38 39 private UI() { 40 } 41 42 47 public static void openRefactoringUI(RefactoringUI ui) { 48 new RefactoringPanel(ui); 49 } 50 51 58 public static void openRefactoringUI(RefactoringUI ui, TopComponent callerTC) { 59 new RefactoringPanel(ui, callerTC); 60 } 61 62 71 public static void openRefactoringUI(RefactoringUI ui, RefactoringSession callerTC, Action callback) { 72 new RefactoringPanel(ui, callerTC, callback).setVisible(true); 73 } 74 75 80 public static boolean setComponentForRefactoringPreview(Component component) { 81 TopComponent activated = TopComponent.getRegistry().getActivated(); 82 RefactoringPanel refactoringPanel = null; 83 if (activated instanceof RefactoringPanelContainer) { 84 RefactoringPanelContainer panel = (RefactoringPanelContainer) activated; 85 refactoringPanel = panel.getCurrentPanel(); 86 } 87 if (refactoringPanel == null) { 88 refactoringPanel = RefactoringPanelContainer.getRefactoringComponent().getCurrentPanel(); 89 } 90 if (refactoringPanel == null) { 91 refactoringPanel = RefactoringPanelContainer.getUsagesComponent().getCurrentPanel(); 92 } 93 if (refactoringPanel == null) 94 return false; 95 if (component == null) { 96 if (refactoringPanel.splitPane.getRightComponent() == null) 97 return false; 98 component = new JLabel ("<Preview not Available>", SwingConstants.CENTER); 99 } 100 refactoringPanel.splitPane.setRightComponent(component); 101 return true; 102 103 } 104 } 105 | Popular Tags |