mbien commented on code in PR #7694:
URL: https://github.com/apache/netbeans/pull/7694#discussion_r1732113220


##########
ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java:
##########
@@ -1090,17 +1147,45 @@ public void restoreDeviderLocation() {
         }
     }
 
+    public boolean isPreview()
+    {
+        return getPrefPreview();
+    }
+
+    public boolean isSelectedPreview()
+    {
+        if (previewButton != null) {
+            return previewButton.isSelected();
+        }
+        return false;
+    }
+
+    public boolean isQuery()
+    {
+        return isQuery;
+    }

Review Comment:
   formatting:
   ```
   public boolean isPreview() {
   ```
   .. etc
   
   opening brace in same line of the method declaration
   



##########
ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/PreviewManager.java:
##########
@@ -106,6 +113,47 @@ private Pair 
getPair(SimpleRefactoringElementImplementation element) {
     }
     
     public void refresh(SimpleRefactoringElementImplementation element) {
+        RefactoringPanel current = 
RefactoringPanel.getCurrentRefactoringPanel();
+        if (current != null && current.isQuery() && 
current.isSelectedPreview()) {
+            showQueryPreview(element);
+        } else {
+            showDiffView(element);
+        }
+    }
+
+    private void showQueryPreview(SimpleRefactoringElementImplementation 
element) {
+        try {
+            FileObject fileObject = element.getParentFile();
+            DataObject dataObject = DataObject.find(fileObject);
+            EditorCookie editorCookie = dataObject != null ? 
dataObject.getLookup().lookup(org.openide.cookies.EditorCookie.class) : null;
+            if (editorCookie != null) {
+                StyledDocument document = editorCookie.openDocument();
+                if (document != null) {
+                String mimeType = (String) document.getProperty("mimeType"); 
//NOI18N
+                    if (mimeType != null) {

Review Comment:
   `String mime..` has wrong indentation



##########
ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java:
##########
@@ -1090,17 +1147,45 @@ public void restoreDeviderLocation() {
         }
     }
 
+    public boolean isPreview()
+    {
+        return getPrefPreview();
+    }
+
+    public boolean isSelectedPreview()

Review Comment:
   the state of the toggle button is persisted right away if I see this 
correctly, so  `isPreviewEnabled()` could be used instead and this method can 
be removed.



##########
ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java:
##########
@@ -1090,17 +1147,45 @@ public void restoreDeviderLocation() {
         }
     }
 
+    public boolean isPreview()

Review Comment:
   -> `isPreviewEnabled()`



##########
ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java:
##########
@@ -784,6 +815,29 @@ public void run() {
                                                     
root.setNodeLabel(description + getErrorDesc(0, occurrences, hiddenOccurrences, 
isQuery && sizeIsApproximate.get()));
                                                     if (last) {
                                                         tree.repaint();
+                                                        if 
(previewButton.isSelected()) {
+                                                            if 
(showParametersPanel) {
+                                                                
splitPane.setDividerLocation(0.3);
+                                                                if (size.get() 
< MAX_ROWS) {
+                                                                    
expandAll();
+                                                                    if 
(isQuery) {
+                                                                        
selectNextUsage();
+                                                                    }
+                                                                } else {
+                                                                    
expandButton.setSelected(false);
+                                                                }
+                                                            } else {
+                                                                
splitPane.setDividerLocation(0.3);

Review Comment:
   those two `splitPane.setDividerLocation(0.3);` are probably not needed since 
it was already set. This could get annoying that the divider moves every time a 
button on the toolbar is hit.



##########
ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java:
##########
@@ -418,8 +434,11 @@ private JButton[] getButtons() {
     private static final byte LOGICAL = 0;
     private static final byte PHYSICAL = 1;
     private static final byte GRAPHICAL = 2;
-    
+
+    private static final boolean PREVIEW = false;

Review Comment:
   i think this should be enabled by default to stay consistent with comparable 
windows (bookmarks etc) which don't have a button.
   
   There are essentially two options to stay consistent:
    - add a button to all windows which have a preview (bookmarks too etc)
    - or don't add a button and always show the preview
   
   I think having no button is still the easiest option + I am not convinced 
that there is a need for the button.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to