blob: 636cc450bc39f0b3dbff8f5a294ea911d0fc0b76 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.refactoring.java.ui;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeListener;
import org.netbeans.api.java.source.CompilationController;
import org.netbeans.api.java.source.ui.ElementIcons;
import org.netbeans.modules.refactoring.java.RefactoringModule;
/**
*
* @author Ralph Ruijs <ralphbenjamin@netbeans.org>
*/
public class WhereUsedPanelPackage extends WhereUsedPanel.WhereUsedInnerPanel {
private final ChangeListener parent;
/**
* Creates new form WhereUsedVariable
*/
public WhereUsedPanelPackage(ChangeListener parent) {
this.parent = parent;
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
searchInComments = new javax.swing.JCheckBox();
lbl_usagesof = new javax.swing.JLabel();
label = new javax.swing.JLabel();
searchInComments.setSelected(((Boolean) RefactoringModule.getOption("searchInComments.whereUsed", Boolean.FALSE)).booleanValue());
org.openide.awt.Mnemonics.setLocalizedText(searchInComments, org.openide.util.NbBundle.getBundle(WhereUsedPanelPackage.class).getString("LBL_SearchInComents")); // NOI18N
searchInComments.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
searchInCommentsItemStateChanged(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(lbl_usagesof, org.openide.util.NbBundle.getMessage(WhereUsedPanelPackage.class, "LBL_UsagesOfElement")); // NOI18N
label.setIcon(org.openide.util.ImageUtilities.loadImageIcon("/org/netbeans/modules/refactoring/java/resources/warning_16.png", false)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(label, "<<Element>>"); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(lbl_usagesof)
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(searchInComments)
.addComponent(label, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lbl_usagesof)
.addComponent(label))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(searchInComments)
.addGap(0, 0, 0))
);
}// </editor-fold>//GEN-END:initComponents
private void searchInCommentsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_searchInCommentsItemStateChanged
// used for change default value for searchInComments check-box.
// The value is persisted and then used as default in next IDE run.
Boolean b = evt.getStateChange() == ItemEvent.SELECTED ? Boolean.TRUE : Boolean.FALSE;
RefactoringModule.setOption("searchInComments.whereUsed", b); // NOI18N
}//GEN-LAST:event_searchInCommentsItemStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel label;
private javax.swing.JLabel lbl_usagesof;
private javax.swing.JCheckBox searchInComments;
// End of variables declaration//GEN-END:variables
@Override
void initialize(final Element element, CompilationController info) {
final String labelText = UIUtilities.createHeader((PackageElement) element, info.getElements().isDeprecated(element), false, false, true);
final Icon labelIcon = ElementIcons.getElementIcon(element.getKind(), element.getModifiers());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Dimension preferredSize = label.getPreferredSize();
label.setText(labelText);
label.setIcon(labelIcon);
label.setPreferredSize(preferredSize);
label.setMinimumSize(preferredSize);
}
});
}
@Override
public boolean isSearchInComments() {
return searchInComments.isSelected();
}
}