[hg] main-silver: removed the saved queries list from the QueryT...

  • From: Tomas Stupka < >
  • To:
  • Subject: [hg] main-silver: removed the saved queries list from the QueryT...
  • Date: Mon, 08 Apr 2013 12:45:19 -0700

changeset 9b6fca1a66cb in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/9b6fca1a66cb
description:
        removed the saved queries list from the QueryTopCompoenent as it 
became obsolete after the Tasks Dashboard was introduced

diffstat:

 bugtracking/src/org/netbeans/modules/bugtracking/kenai/spi/KenaiUtil.java    
                    |   10 -
 bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueriesPanel.java  
                    |  274 -------
 
bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryLinksPanel.java
                   |  384 ----------
 
bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponent.java
                 |   70 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentScrollPaneLayout.java
 |   17 -
 
bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewport.java
         |    4 -
 
bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewportLayout.java
   |    3 -
 bugtracking/src/org/netbeans/modules/bugtracking/ui/query/RepoPanel.java     
                    |   88 +--
 
bugtracking/src/org/netbeans/modules/bugtracking/ui/query/ViewportWidthAwarePanel.java
           |   82 --
 9 files changed, 6 insertions(+), 926 deletions(-)

diffs (1109 lines):

diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/kenai/spi/KenaiUtil.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/kenai/spi/KenaiUtil.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/kenai/spi/KenaiUtil.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/kenai/spi/KenaiUtil.java
@@ -235,16 +235,6 @@
     }
     
     /**
-     * Refreshes existing openend kenai queries
-     */
-    public static void refreshOpenedQueries() {
-        Set<QueryTopComponent> tcs = QueryTopComponent.getOpenQueries(); // 
XXX updates also non kenai TC
-        for (QueryTopComponent tc : tcs) {
-            tc.updateSavedQueries();
-        }
-    }
-
-    /**
      * @see KenaiAccessor#isNetbeansKenaiRegistered()
      */
     public static boolean isNetbeansKenaiRegistered() {
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueriesPanel.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueriesPanel.java
deleted file mode 100644
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueriesPanel.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License.  When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- *
- * Contributor(s):
- *
- * Portions Copyrighted 2009 Sun Microsystems, Inc.
- */
-
-package org.netbeans.modules.bugtracking.ui.query;
-
-import javax.swing.LayoutStyle;
-import java.awt.Dimension;
-import java.awt.Insets;
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.SwingConstants;
-import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.PanelUI;
-import org.netbeans.modules.bugtracking.QueryImpl;
-import org.openide.awt.Mnemonics;
-import org.openide.util.NbBundle;
-import static javax.swing.LayoutStyle.ComponentPlacement.RELATED;
-
-/**
- * Panel containing &quot;My Queries: My Issues | High Priority | ... &quot;.
- * It wraps automatically if it does not fit to the <em>visible part</em>
- * if the scrollpane's view.
- *
- * @author Marian Petras
- */
-public class QueriesPanel extends ViewportWidthAwarePanel {
-
-    private static final JLabel fakeLabel = new JLabel("fake");         
//NOI18N
-
-    private final JLabel queriesLabel;
-    private final QueryLinksPanel queryLinksPanel;
-
-    private int baseline;
-    private boolean baselineValid;
-
-    private int labelBaseline;
-    private boolean labelBaselineValid;
-
-    private int linksPanelOffset;
-    private boolean linksPanelOffsetValid;
-
-    private Dimension prefSize;
-    private Insets cachedInsets;
-
-    public QueriesPanel() {
-        super(null);
-        queriesLabel = new JLabel();
-        queryLinksPanel = new QueryLinksPanel();
-        
-        queriesLabel.setLabelFor(queryLinksPanel);
-
-        Mnemonics.setLocalizedText(
-               queriesLabel,
-               NbBundle.getMessage(getClass(),
-                                   
"QueryTopComponent.jLabel1.text_1"));//NOI18N
-
-        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
-        add(queriesLabel);
-        add(queryLinksPanel);
-    }
-
-    void setQueries(QueryImpl[] queries) {
-        invalidatePrefSize();
-        queryLinksPanel.setQueries(queries);
-    }
-
-    boolean hasQueries() {
-        return !queryLinksPanel.isEmpty();
-    }
-
-    boolean isWrapped() {
-        return queryLinksPanel.isWrapped();
-    }
-
-    @Override
-    protected void visibleWidthChanged(int newWidth) {
-        invalidatePrefSize();
-        super.visibleWidthChanged(newWidth);
-    }
-
-    @Override
-    protected void notifyChildrenOfVisibleWidth() {
-        queryLinksPanel.setAvailableWidth(
-                getAvailableWidth() - getLinksPanelOffset()
-                - getCachedInsets().left
-                - getCachedInsets().right);
-    }
-
-    @Override
-    public Dimension getPreferredSize() {
-        if (prefSize == null) {
-            Dimension labelPrefSize = queriesLabel.getPreferredSize();
-            Dimension panelPrefSize = queryLinksPanel.getPreferredSize();
-
-            int aboveBaseline = getBaseline();
-
-            int belowBaseline1 = labelPrefSize.height - getLabelBaseline();
-            int belowBaseline2 = panelPrefSize.height - 
queryLinksPanel.getBaseline();
-            int belowBaseline = Math.max(belowBaseline1, belowBaseline2);
-
-            int width = getLinksPanelOffset() + panelPrefSize.width;
-            int height = aboveBaseline + belowBaseline;
-
-            Insets insets = getCachedInsets();
-            width += insets.left + insets.right;
-            height += insets.bottom;    //top inset is included in the 
baseline
-
-            prefSize = new Dimension(width, height);
-        }
-        return prefSize;
-    }
-
-    @Override
-    public void invalidate() {
-        invalidatePrefSize();
-        super.invalidate();
-    }
-
-    @Override
-    public void doLayout() {
-        Dimension tmpPrefSize;
-
-        if (queryLinksPanel.isEmpty()) {
-            Insets insets = getCachedInsets();
-            tmpPrefSize = queriesLabel.getPreferredSize();
-            queriesLabel.setBounds(insets.left,
-                                   insets.top,
-                                   tmpPrefSize.width,
-                                   tmpPrefSize.height);
-            return;
-        }
-
-        validateBaseline();
-
-        tmpPrefSize = queriesLabel.getPreferredSize();
-        queriesLabel.setBounds(getCachedInsets().left,
-                               baseline - getLabelBaseline(),
-                               tmpPrefSize.width,
-                               tmpPrefSize.height);
-
-        tmpPrefSize = queryLinksPanel.getPreferredSize();
-        queryLinksPanel.setBounds(getCachedInsets().left + 
getLinksPanelOffset(),
-                                  baseline - queryLinksPanel.getBaseline(),
-                                  tmpPrefSize.width,
-                                  tmpPrefSize.height);
-    }
-
-    private int getLinksPanelOffset() {
-        if (!linksPanelOffsetValid) {
-            linksPanelOffset = queriesLabel.getPreferredSize().width
-                               + LayoutStyle.getInstance()
-                                 .getPreferredGap(queriesLabel,
-                                                  fakeLabel,
-                                                  RELATED,
-                                                  SwingConstants.EAST,
-                                                  this);
-            linksPanelOffsetValid = true;
-        }
-        return linksPanelOffset;
-    }
-
-    private Insets getCachedInsets() {
-        if (cachedInsets == null) {
-            cachedInsets = super.getInsets();
-        }
-        return cachedInsets;
-    }
-
-    /*
-     * To make it work correctly with GroupLayout.
-     */
-    @Override
-    public int getBaseline(int width, int height) {
-        return getBaseline();
-    }
-
-    public int getBaseline() {
-        validateBaseline();
-        return baseline;
-    }
-
-    private void validateBaseline() {
-        if (!baselineValid) {
-            queryLinksPanel.validateVerticalMetrics();
-
-            baseline = Math.max(getLabelBaseline(),
-                                queryLinksPanel.getBaseline())
-                       + getCachedInsets().top;
-            baselineValid = true;
-        }
-    }
-
-    private int getLabelBaseline() {
-        if (!labelBaselineValid) {
-            Dimension size = queriesLabel.getPreferredSize();
-            labelBaseline = queriesLabel.getBaseline(size.width, 
size.height);
-            labelBaselineValid = true;
-        }
-        return labelBaseline;
-    }
-
-    /*
-     * To make it work correctly with GroupLayout.
-     */
-    @Override
-    public BaselineResizeBehavior getBaselineResizeBehavior() {
-        return BaselineResizeBehavior.CONSTANT_ASCENT;
-    }
-
-    @Override
-    public void setUI(PanelUI ui) {
-        invalidateUiDependentValues();
-        super.setUI(ui);
-    }
-
-    @Override
-    protected void setUI(ComponentUI newUI) {
-        invalidateUiDependentValues();
-        super.setUI(newUI);
-    }
-
-    private void invalidateUiDependentValues() {
-        baselineValid = false;
-        labelBaselineValid = false;
-        linksPanelOffsetValid = false;
-        cachedInsets = null;
-        invalidatePrefSize();
-    }
-
-    private void invalidatePrefSize() {
-        prefSize = null;
-    }
-
-}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryLinksPanel.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryLinksPanel.java
deleted file mode 100644
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryLinksPanel.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License.  When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- *
- * Contributor(s):
- *
- * Portions Copyrighted 2009 Sun Microsystems, Inc.
- */
-
-package org.netbeans.modules.bugtracking.ui.query;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.EventQueue;
-import java.awt.Graphics;
-import java.awt.Insets;
-import java.awt.LayoutManager;
-import java.awt.Point;
-import java.awt.event.ActionEvent;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import javax.swing.AbstractAction;
-import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
-import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.PanelUI;
-import org.netbeans.modules.bugtracking.QueryImpl;
-import org.netbeans.modules.bugtracking.RepositoryImpl;
-import org.netbeans.modules.bugtracking.util.LinkButton;
-
-/**
- * Panel displaying names of saved queries.
- * The list of query names wraps automatically if it does not fit to the
- * <em>visible</em> part of the form.
- *
- * @author Marian Petras
- */
-class QueryLinksPanel extends ViewportWidthAwarePanel implements 
FocusListener {
-
-    private static final int SEPARATOR_WIDTH = 2;
-    private static final int SPACE_AROUND_SEPARATOR = 5;
-    private static final int TOTAL_SEPARATOR_WIDTH
-                             = SEPARATOR_WIDTH + (2 * 
SPACE_AROUND_SEPARATOR);
-
-    private static final int INTERLINE_SPACING = 2;
-
-    private RepositoryImpl repository;
-    private QueryButton[] buttons;
-
-    private Dimension[] buttonPrefSizes;
-    private int[] baselines;
-    private int[] rowNumbers;
-    private int baseline = -1;
-    private int rowHeight = -1;
-    private int rowCount = 0;
-
-    private Dimension prefSize;
-    private boolean verticalMetricsKnown;
-
-    public QueryLinksPanel() {
-        super(null);
-        setOpaque(false);
-    }
-
-    void setQueries(QueryImpl[] queries) {
-        if ((queries != null) && (queries.length == 0)) {
-            queries = null;
-        }
-
-        boolean queriesChanged = (this.buttons != null) || (queries != null);
-        if (!queriesChanged) {
-            return;
-        }
-
-        invalidateVerticalMetrics();
-        invalidatePrefSize();
-
-        if (buttons != null) {
-            removeAll();
-        }
-        if (queries == null) {
-            buttons = null;
-            rowNumbers = null;
-        } else {
-            buttons = new QueryButton[queries.length];
-            rowNumbers = new int[queries.length];
-            QueryTopComponent queryTopC = (QueryTopComponent)
-                                          SwingUtilities.getAncestorOfClass(
-                                                 QueryTopComponent.class, 
this);
-            for (int i = 0; i < queries.length; i++) {
-                QueryImpl query = queries[i];
-                query.addPropertyChangeListener(queryTopC);
-                QueryButton button = new QueryButton(repository, query);
-                button.setText(query.getDisplayName());
-                button.addFocusListener(this);
-                add(button);
-                buttons[i] = button;
-            }
-        }
-    }
-
-    boolean isEmpty() {
-        return (buttons == null);
-    }
-
-    boolean isWrapped() {
-        validatePrefSize();
-        return rowCount > 1;
-    }
-
-    @Override
-    protected void paintChildren(Graphics g) {
-        super.paintChildren(g);
-        if ((buttons != null) && (buttons.length > 1)) {
-
-            /* paint the separators: */
-
-            Graphics sg = g.create();
-            sg.setColor(Color.BLACK);
-            final Point tmpPoint = new Point();
-
-            int lastRowNum = 0;
-            for (int i = 1; i < buttons.length; i++) {
-                int rowNum = rowNumbers[i];
-                if (rowNum == lastRowNum) {
-                    int x = buttons[i].getLocation(tmpPoint).x
-                            - (SPACE_AROUND_SEPARATOR + SEPARATOR_WIDTH);
-                    int y = rowNum * (rowHeight + INTERLINE_SPACING);
-                    g.fillRect(x, y, SEPARATOR_WIDTH, rowHeight);
-                }
-                lastRowNum = rowNum;
-            }
-        }
-    }
-
-    @Override
-    public Dimension getPreferredSize() {
-        validatePrefSize();
-        return prefSize;
-    }
-
-    private void validatePrefSize() {
-        if (prefSize == null) {
-            computeLayout(false);
-        }
-    }
-
-    @Override
-    public void invalidate() {
-        invalidatePrefSize();
-        super.invalidate();
-    }
-
-    @Override
-    protected void visibleWidthChanged(int newWidth) {
-        super.visibleWidthChanged(newWidth);
-        EventQueue.invokeLater(new Runnable() {
-            public void run() {
-                //revalidate();
-            }
-        });
-        invalidate();
-    }
-
-    @Override
-    public void setLayout(LayoutManager mgr) {
-        if (mgr != null) {
-            throw new UnsupportedOperationException(
-                "QueriesListPanel does not support layout managers.");  
//NOI18N
-        }
-    }
-
-    @Override
-    public void doLayout() {
-        computeLayout(true);
-    }
-
-    private Dimension computeLayout(boolean setBounds) {
-        int width, height;
-
-        Insets insets = getInsets();
-        if (buttons == null) {
-            width = insets.left + insets.right;
-            height = insets.top + insets.bottom;
-            rowCount = 0;
-        } else {
-            validateVerticalMetrics();
-            int horizPos = insets.left;
-            int horizPosLimit = getAvailableWidth() - insets.right;
-            int rowBaseline = insets.top + baseline;
-            int rowNum = 0;
-            height = rowHeight;
-            rowCount = 1;
-
-            QueryButton button = buttons[0];
-            int buttonBaseline = baselines[0];
-            Dimension buttonPrefSize = buttonPrefSizes[0];
-            int startHorizPos = horizPos;
-            int endHorizPos = startHorizPos + buttonPrefSize.width;
-            int maxEndHorizPos = endHorizPos;
-            if (setBounds) {
-                button.setBounds(startHorizPos, rowBaseline - buttonBaseline,
-                                 buttonPrefSize.width, 
buttonPrefSize.height);
-            }
-            horizPos = endHorizPos;
-            rowNumbers[0] = rowNum;
-            for (int i = 1; i < buttons.length; i++) {
-                button = buttons[i];
-                buttonBaseline = baselines[i];
-                buttonPrefSize = buttonPrefSizes[i];
-                startHorizPos = horizPos + TOTAL_SEPARATOR_WIDTH;
-                endHorizPos = startHorizPos + buttonPrefSize.width;
-                if (endHorizPos > horizPosLimit) {
-                    startHorizPos = insets.left;
-                    endHorizPos = startHorizPos + buttonPrefSize.width;
-                    rowBaseline += INTERLINE_SPACING + rowHeight;
-                    height += INTERLINE_SPACING + rowHeight;
-                    rowCount++;
-                    rowNum++;
-                }
-                if (setBounds) {
-                    button.setBounds(startHorizPos, rowBaseline - 
buttonBaseline,
-                                     buttonPrefSize.width, 
buttonPrefSize.height);
-                }
-                maxEndHorizPos = Math.max(maxEndHorizPos, endHorizPos);
-                horizPos = endHorizPos;
-                rowNumbers[i] = rowNum;
-            }
-            width = maxEndHorizPos + insets.right;
-        }
-        prefSize = new Dimension(width, height);
-        return prefSize;
-    }
-
-    /*
-     * To make it work correctly with GroupLayout.
-     */
-    @Override
-    public int getBaseline(int width, int height) {
-        return getBaseline();
-    }
-
-    int getBaseline() {
-        validateVerticalMetrics();
-        return baseline;
-    }
-
-    void validateVerticalMetrics() {
-        if (verticalMetricsKnown) {
-            return;
-        }
-
-        int maxAboveBaseline = 0;
-        int maxBelowBaseline = 0;
-        if (buttons == null) {
-            baselines = null;
-            buttonPrefSizes = null;
-        } else {
-            baselines = new int[buttons.length];
-            buttonPrefSizes = new Dimension[buttons.length];
-            for (int i = 0; i < buttons.length; i++) {
-                QueryButton button = buttons[i];
-                Dimension buttonPrefSize = button.getPreferredSize();
-
-                int aboveBaseline = 
button.getBaseline(buttonPrefSize.width,buttonPrefSize.height);
-                int belowBaseline = buttonPrefSize.height - aboveBaseline;
-
-                buttonPrefSizes[i] = buttonPrefSize;
-                baselines[i] = aboveBaseline;
-
-                maxAboveBaseline = Math.max(maxAboveBaseline, aboveBaseline);
-                maxBelowBaseline = Math.max(maxBelowBaseline, belowBaseline);
-            }
-        }
-        baseline = maxAboveBaseline;
-        rowHeight = maxAboveBaseline + maxBelowBaseline;
-
-        verticalMetricsKnown = true;
-    }
-
-    /*
-     * To make it work correctly with GroupLayout.
-     */
-    @Override
-    public BaselineResizeBehavior getBaselineResizeBehavior() {
-        return BaselineResizeBehavior.CONSTANT_ASCENT;
-    }
-
-    @Override
-    protected void notifyChildrenOfVisibleWidth() {
-        //no-op
-    }
-
-    public void focusGained(FocusEvent e) {
-        final Component c = e.getComponent();
-        if (c instanceof JComponent) {
-            EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    QueryLinksPanel.this.scrollRectToVisible(c.getBounds());
-                }
-            });
-        }
-    }
-
-    public void focusLost(FocusEvent e) {
-        //do nothing
-    }
-
-    @Override
-    public void setUI(PanelUI ui) {
-        super.setUI(ui);
-        invalidateUiDependentValues();
-    }
-
-    @Override
-    protected void setUI(ComponentUI newUI) {
-        super.setUI(newUI);
-        invalidateUiDependentValues();
-    }
-
-    private void invalidateUiDependentValues() {
-        invalidateVerticalMetrics();
-    }
-
-    private void invalidateVerticalMetrics() {
-        verticalMetricsKnown = false;
-        buttonPrefSizes = null;
-        baseline = -1;
-        baselines = null;
-        rowHeight = 0;
-    }
-
-    private void invalidatePrefSize() {
-        prefSize = null;
-    }
-
-    private class QueryButton extends LinkButton {
-        public QueryButton(final RepositoryImpl repo, final QueryImpl query) 
{
-            super();
-            setText(query.getDisplayName());
-            
getAccessibleContext().setAccessibleDescription(query.getTooltip());
-            setAction(new AbstractAction() {
-                public void actionPerformed(ActionEvent e) {
-                    QueryAction.openQuery(query, repo);
-                }
-            });
-        }
-    }
-
-}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponent.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponent.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponent.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponent.java
@@ -128,8 +128,6 @@
     private final JComboBox repositoryComboBox;
     private final JScrollPane scrollPane;
 
-    private QueryImpl[] savedQueries = null;
-    
     private static final String PREFERRED_ID = "QueryTopComponent"; // NOI18N
     private QueryImpl query; // XXX synchronized
     private static final Object LOCK = new Object();
@@ -153,12 +151,7 @@
 
         repoPanel = new RepoPanel(repositoryComboBox, newButton);
         panel = new PlaceholderPanel();
-        jPanel2 = new ViewportWidthAwarePanel(null) {
-            @Override
-            protected void notifyChildrenOfVisibleWidth() {
-                repoPanel.setAvailableWidth(getAvailableWidth());
-            }
-        };
+        jPanel2 = new JPanel();
         jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.Y_AXIS));
         jPanel2.add(createVerticalStrut(null, title));
         jPanel2.add(title);
@@ -400,8 +393,6 @@
                 // removed
                 closeInAwt();
             }
-        } else 
if(evt.getPropertyName().equals(Repository.EVENT_QUERY_LIST_CHANGED)) {
-            updateSavedQueries();
         } else 
if(evt.getPropertyName().equals(RepositoryRegistry.EVENT_REPOSITORIES_CHANGED))
 {
             if(query != null) {
                 Object cOld = evt.getOldValue();
@@ -540,8 +531,6 @@
                     }
                     query.addPropertyChangeListener(QueryTopComponent.this);
 
-                    updateSavedQueriesIntern(repo);
-
                     final QueryController addController = 
getController(query);
                     SwingUtilities.invokeLater(new Runnable() {
                         @Override
@@ -602,66 +591,9 @@
         setNameAndTooltip();
     }
 
-    public void updateSavedQueries() {
-        final RepositoryImpl repo = getRepository();
-        if(repo == null) {
-            return;
-        }
-        rp.post(new Runnable() {
-            @Override
-            public void run() {
-                updateSavedQueriesIntern(repo);
-            }
-        });        
-    }
-
-    private void updateSavedQueriesIntern(final RepositoryImpl repo) {
-        if(repo == null) {
-            return;
-        }
-        BugtrackingManager.LOG.log(Level.FINE, "updateSavedQueries for {0} 
start", new Object[] {repo.getDisplayName()} );
-        Collection<QueryImpl> cq = repo.getQueries();
-        QueryImpl[] queries = cq != null ? cq.toArray(new 
QueryImpl[cq.size()]) : new QueryImpl[0];
-        final QueryImpl[] finQueries;
-        synchronized (LOCK) {
-            Arrays.sort(queries, new QueryComparator());
-            savedQueries = queries;
-            finQueries = savedQueries;
-        }
-
-        EventQueue.invokeLater(new Runnable() {
-            @Override
-            public void run() {
-                repoPanel.setQueries(finQueries);
-                if(finQueries == null || finQueries.length == 0) {
-                    BugtrackingManager.LOG.log(Level.FINE, 
"updateSavedQueries for {0} finnished. No queries.", new Object[] 
{repo.getDisplayName()} );
-                } else {
-                    BugtrackingManager.LOG.log(Level.FINE, 
"updateSavedQueries for {0} finnished. {1} saved queries.", new Object[] 
{repo.getDisplayName(), savedQueries.length} );
-                }
-            }
-        });
-    }
-
     @Override
     public boolean requestFocusInWindow() {
         return jPanel2.requestFocusInWindow();
     }
 
-    private class QueryComparator implements Comparator<QueryImpl> {
-
-        @Override
-        public int compare(QueryImpl q1, QueryImpl q2) {
-            if(q1 == null && q2 == null) {
-                return 0;
             }
-            if(q1 == null) {
-                return -1;
-            }
-            if(q2 == null) {
-                return 1;
-            }
-            return q1.getDisplayName().compareTo(q2.getDisplayName());
-        }
-        
-    }
-}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentScrollPaneLayout.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentScrollPaneLayout.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentScrollPaneLayout.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentScrollPaneLayout.java
@@ -218,19 +218,12 @@
         */
 
        Component view = (viewport != null) ? viewport.getView() : null;
-        ViewportWidthAwarePanel viewportWidthAwareView
-                                = (view instanceof ViewportWidthAwarePanel)
-                                  ? (ViewportWidthAwarePanel) view
-                                  : null;
        Dimension extentSize = (viewport != null)
                                ? viewport.toViewCoordinates(availR.getSize())
                               : new Dimension(0,0);
 
        Dimension viewPrefSize;
         if (view != null) {
-            if (viewportWidthAwareView != null) {
-                viewportWidthAwareView.setAvailableWidth(extentSize.width);
-            }
             viewPrefSize = view.getPreferredSize();
         } else {
             viewPrefSize = new Dimension(0,0);
@@ -257,11 +250,6 @@
        if ((vsb != null) && vsbNeeded) {
            adjustForVSB(availR, vsbR, vpbInsets);
            extentSize = viewport.toViewCoordinates(availR.getSize());
-
-            if (viewportWidthAwareView != null) {
-                viewportWidthAwareView.setAvailableWidth(extentSize.width);
-                viewPrefSize = view.getPreferredSize();
-            }
        }
 
        /*
@@ -295,11 +283,6 @@
 
                if (vsbNeeded) {
                    adjustForVSB(availR, vsbR, vpbInsets);
-
-                    if (viewportWidthAwareView != null) {
-                        extentSize = 
viewport.toViewCoordinates(availR.getSize());
-                        
viewportWidthAwareView.setAvailableWidth(extentSize.width);
-                    }
                }
            }
        }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewport.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewport.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewport.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewport.java
@@ -65,10 +65,6 @@
 
     @Override
     public void setSize(int width, int height) {
-        Component view = getView();
-        if (view instanceof ViewportWidthAwarePanel) {
-            ((ViewportWidthAwarePanel) view).setAvailableWidth(width);
-        }
         super.setSize(width, height);
     }
 
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewportLayout.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewportLayout.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewportLayout.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryTopComponentViewportLayout.java
@@ -73,9 +73,6 @@
         */
 
        Dimension vpSize = vp.getSize();
-        if (view instanceof ViewportWidthAwarePanel) {
-            ((ViewportWidthAwarePanel) view).setAvailableWidth(vpSize.width);
-        }
        Dimension viewPrefSize = view.getPreferredSize();
        Dimension extentSize = vp.toViewCoordinates(vpSize);
        Dimension viewSize = new Dimension(viewPrefSize);
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/RepoPanel.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/RepoPanel.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/RepoPanel.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/RepoPanel.java
@@ -50,6 +50,7 @@
 import javax.swing.BorderFactory;
 import javax.swing.JComponent;
 import static java.lang.Math.max;
+import javax.swing.JPanel;
 import static javax.swing.SwingConstants.EAST;
 import static javax.swing.SwingConstants.WEST;
 import org.netbeans.modules.bugtracking.QueryImpl;
@@ -61,21 +62,16 @@
  *
  * @author Marian Petras
  */
-class RepoPanel extends ViewportWidthAwarePanel {
+class RepoPanel extends JPanel {
 
     private static final int MIN_SPACE = 24;
 
     private final RepoSelectorPanel repoSelectorPanel;
-    private final QueriesPanel queriesPanel;
 
     RepoPanel(JComponent repoSelector,
               JComponent newRepoButton) {
         super(null);
         repoSelectorPanel = new RepoSelectorPanel(repoSelector, 
newRepoButton);
-        queriesPanel      = new QueriesPanel();
-        queriesPanel.setVisible(false);
-
-        queriesPanel.setBackground(UIUtils.getSectionPanelBackground());
 
         LayoutStyle layoutStyle = LayoutStyle.getInstance();
         setBorder(BorderFactory.createEmptyBorder(
@@ -83,7 +79,6 @@
                       0, layoutStyle.getContainerGap(this, EAST, 
getParent())));
 
         add(repoSelectorPanel);
-        add(queriesPanel);
     }
 
     @Override
@@ -95,25 +90,8 @@
 
         Insets insets = getInsets();
 
-        if (!queriesPanel.isVisible()) {
             height = repoSelectorPrefSize.height
                      + insets.top + insets.bottom;
-        } else {
-            Dimension queriesPanelPrefSize = queriesPanel.getPreferredSize();
-
-            int aboveBaseline = getBaseline();
-
-            int belowBaseline1 = repoSelectorPrefSize.height
-                                 - repoSelectorPanel.getBaseline();
-            int belowBaseline2 = queriesPanelPrefSize.height
-                                 - queriesPanel.getBaseline();
-            int belowBaseline = max(belowBaseline1, belowBaseline2);
-
-            width += MIN_SPACE + queriesPanelPrefSize.width;
-            height = aboveBaseline + belowBaseline
-                     + insets.bottom;//top inset is included in the baseline
-        }
-
         width += insets.left + insets.right;
 
         return new Dimension(width, height);
@@ -124,40 +102,16 @@
         int baseline = getBaseline();
         Insets insets = getInsets();
 
-        int x;
-        Dimension tmpPrefSize;
-        int availableWidth = getAvailableWidth()
-                             - insets.left
-                             - insets.right;
-
-        x = insets.left;
-        tmpPrefSize = repoSelectorPanel.getPreferredSize();
+        int x = insets.left;
+        Dimension tmpPrefSize = repoSelectorPanel.getPreferredSize();
         repoSelectorPanel.setBounds(x,
                                     baseline - 
repoSelectorPanel.getBaseline(),
                                     tmpPrefSize.width,
                                     tmpPrefSize.height);
-
-        if (queriesPanel.isVisible()) {
-            availableWidth -= tmpPrefSize.width;
-            x              += tmpPrefSize.width;
-
-            tmpPrefSize = queriesPanel.getPreferredSize();
-            int space = !queriesPanel.isWrapped()
-                        ? max(MIN_SPACE, availableWidth - tmpPrefSize.width)
-                        : MIN_SPACE;
-            x += space;
-            queriesPanel.setBounds(x,
-                                   baseline - queriesPanel.getBaseline(),
-                                   tmpPrefSize.width,
-                                   tmpPrefSize.height);
-        }
     }
 
     public int getBaseline() {
-        int baseline = queriesPanel.isVisible()
-                   ? max(repoSelectorPanel.getBaseline(),
-                         queriesPanel.getBaseline())
-                   : repoSelectorPanel.getBaseline();
+        int baseline = repoSelectorPanel.getBaseline();
         baseline += getInsets().top;
         return baseline;
     }
@@ -167,36 +121,4 @@
         return new Dimension(Short.MAX_VALUE, getPreferredSize().height);
     }
 
-    void setQueries(QueryImpl[] queries) {
-        assert EventQueue.isDispatchThread();
-
-        if ((queries != null) && (queries.length == 0)) {
-            queries = null;
         }
-
-        boolean hadQueries = queriesPanel.hasQueries();
-        boolean queriesChanged = hadQueries || (queries != null);
-
-        if (queriesChanged) {
-            if (queries == null) {
-                queriesPanel.setVisible(false);
-            }
-            queriesPanel.setQueries(queries);
-            if (!hadQueries && (queries != null)) {
-                notifyChildrenOfVisibleWidth();
-                queriesPanel.setVisible(true);
-            }
-        }
-    }
-
-    @Override
-    protected void notifyChildrenOfVisibleWidth() {
-        if (queriesPanel.hasQueries()) {
-            int availableWidth = getAvailableWidth();
-            int usedWidth = getInsets().left
-                            + repoSelectorPanel.getPreferredSize().width;
-            queriesPanel.setAvailableWidth(availableWidth - usedWidth - 
MIN_SPACE);
-        }
-    }
-
-}
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/ViewportWidthAwarePanel.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/ViewportWidthAwarePanel.java
deleted file mode 100644
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/ViewportWidthAwarePanel.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License.  When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- *
- * Contributor(s):
- *
- * Portions Copyrighted 2009 Sun Microsystems, Inc.
- */
-
-package org.netbeans.modules.bugtracking.ui.query;
-
-import java.awt.LayoutManager;
-import javax.swing.JPanel;
-
-/**
- *
- * @author Marian Petras
- */
-abstract class ViewportWidthAwarePanel extends JPanel {
-
-    private int visibleWidth = -1;
-
-    public ViewportWidthAwarePanel() {
-        super();
-    }
-
-    public ViewportWidthAwarePanel(LayoutManager lm) {
-        super(lm);
-    }
-
-    protected void setAvailableWidth(int width) {
-        if (width != visibleWidth) {
-            this.visibleWidth = width;
-            visibleWidthChanged(width);
-        }
-    }
-
-    protected void visibleWidthChanged(int newWidth) {
-        invalidate();
-        notifyChildrenOfVisibleWidth();
-    }
-
-    int getAvailableWidth() {
-        return visibleWidth;
-    }
-
-    protected abstract void notifyChildrenOfVisibleWidth();
-
-}

[hg] main-silver: removed the saved queries list from the QueryT...

Tomas Stupka 04/08/2013

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 66 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close