protected void installDefaults(JFileChooser fc) { installIcons(fc); installStrings(fc); usesSingleFilePane = UIManager.getBoolean("FileChooser.usesSingleFilePane"); readOnly = UIManager.getBoolean("FileChooser.readOnly"); TransferHandler th = fc.getTransferHandler(); if (th == null || th instanceof UIResource) { fc.setTransferHandler(defaultTransferHandler); } LookAndFeel.installProperty(fc, "opaque", Boolean.FALSE); }
@Override public void addNotify() { super.addNotify(); if (UIManager.getBoolean("Sheet.showAsSheet") && !isExperimentalSheet()) { QuaquaUtilities.setWindowAlpha(this, 240); } }
public void focusGained(FocusEvent event) { QuaquaUtilities.repaintBorder((JComponent) event.getComponent()); final JTextComponent tc = (JTextComponent) event.getSource(); if (tc.isEditable() && tc.isEnabled()) { String uiProperty; if (tc instanceof JPasswordField) { uiProperty = "PasswordField.autoSelect"; } else if (tc instanceof JFormattedTextField) { uiProperty = "FormattedTextField.autoSelect"; } else { uiProperty = "TextField.autoSelect"; } if (tc.getClientProperty("Quaqua.TextComponent.autoSelect") == Boolean.TRUE || tc.getClientProperty("Quaqua.TextComponent.autoSelect") == null && UIManager.getBoolean(uiProperty)) { if (event instanceof CausedFocusEvent) { CausedFocusEvent cfEvent = (CausedFocusEvent) event; if (cfEvent.getCause() == Cause.TRAVERSAL_FORWARD || cfEvent.getCause() == Cause.TRAVERSAL_BACKWARD) { tc.selectAll(); } } } } if (KeyboardFocusManager.getCurrentKeyboardFocusManager() instanceof QuaquaKeyboardFocusManager) { QuaquaKeyboardFocusManager kfm = (QuaquaKeyboardFocusManager) KeyboardFocusManager.getCurrentKeyboardFocusManager(); kfm.setLastKeyboardTraversingComponent(null); } }
private void init() { isExperimentalSheet = UIManager.getBoolean("Sheet.experimentalSheet"); if (getOwner() != null && isShowAsSheet()) { if (isNativeSheetSupported()) { // J2SE 7 requires that we set undecorated to true. setUndecorated(true); getRootPane().putClientProperty("apple.awt.documentModalSheet", Boolean.TRUE); } else if (isExperimentalSheet()) { setUndecorated(true); } else { setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.NONE); getRootPane().setBorder(UIManager.getBorder("Sheet.border")); } if (isDocumentModalitySupported()) { Methods.invokeIfExistsWithEnum( this, "setModalityType", "java.awt.Dialog$ModalityType", "DOCUMENT_MODAL"); } } // We move the sheet when the user moves the owner, so that it // will always stay centered below the title bar of the owner. // If the user has moved the owner, we 'forget' the shift back location, // and don't shift the owner back to the place it was, when we opened // the sheet. ownerMovementHandler = new ComponentAdapter() { @Override public void componentMoved(ComponentEvent evt) { Window owner = getOwner(); Point newLocation = owner.getLocation(); if (!newLocation.equals(oldLocation)) { setLocation( newLocation.x + (owner.getWidth() - getWidth()) / 2, newLocation.y + owner.getInsets().top); shiftBackLocation = null; oldLocation = newLocation; } } }; // If the sheet is experimental, we need some special handling // so that the JSheet is handled correctly windowEventHandler = new WindowAdapter() { // public void windowIconified(WindowEvent e) { // TODO The sheet is reshown when the parent window is iconified. // setVisible(false) on the sheet only deiconifies the owner window. // } @Override public void windowActivated(WindowEvent e) { if (JSheet.this.isVisible() && JSheet.this.getOwner() == e.getWindow()) JSheet.this.toFront(); } }; }
@Override public void setPopupVisible(boolean visible) { if (!isSwingPopup()) { if (visible && (myJBPopup == null || myJBPopup.isDisposed())) { final JBList list = createJBList(getModel()); myJBPopup = JBPopupFactory.getInstance() .createListPopupBuilder(list) .setItemChoosenCallback( new Runnable() { @Override public void run() { final Object value = list.getSelectedValue(); if (value != null) { configureEditor(getEditor(), value); IdeFocusManager.getGlobalInstance().requestFocus(ComboBox.this, true); assert myJBPopup != null; ComboBox.this.getUI().setPopupVisible(ComboBox.this, false); myJBPopup.cancel(); } } }) .setFocusOwners(new Component[] {this}) .setMinSize(new Dimension(getWidth(), -1)) .createPopup(); list.setBorder(IdeBorderFactory.createEmptyBorder()); myJBPopup.showUnderneathOf(this); list.addFocusListener( new FocusAdapter() { @Override public void focusLost(FocusEvent e) { ComboBox.this.getUI().setPopupVisible(ComboBox.this, false); myJBPopup.cancel(); } }); } return; } if (getModel().getSize() == 0 && visible) return; if (visible && JBPopupFactory.getInstance().getChildFocusedPopup(this) != null) return; final boolean wasShown = isPopupVisible(); super.setPopupVisible(visible); if (!wasShown && visible && isEditable() && !UIManager.getBoolean("ComboBox.isEnterSelectablePopup")) { final ComboBoxEditor editor = getEditor(); final Object item = editor.getItem(); final Object selectedItem = getSelectedItem(); if (isSwingPopup() && (item == null || item != selectedItem)) { configureEditor(editor, selectedItem); } } }
/** Adds a new group to our tree and element model. */ final void addNewGroup() { DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel(); boolean groupSummaryVisibleByDefault = UIManager.getBoolean(GROUP_SUMMARY_VISIBLE_DEFAULT); boolean scopeVisibleByDefault = UIManager.getBoolean(ANALOG_SCOPE_VISIBLE_DEFAULT); int groupCount = this.model.getGroups().size(); String name = String.format("Group %d", Integer.valueOf(groupCount + 1)); // Create model structure... ElementGroup newGroup = this.model.addGroup(name); newGroup.setVisible(true); SignalElement groupSummaryElement = SignalElement.createGroupSummaryElement(newGroup); groupSummaryElement.setEnabled(groupSummaryVisibleByDefault); newGroup.addElement(groupSummaryElement); SignalElement analogScopeElement = SignalElement.createAnalogScopeElement(newGroup); analogScopeElement.setEnabled(scopeVisibleByDefault); newGroup.addElement(analogScopeElement); // Create tree structure... ElementTreeNode rootNode = (ElementTreeNode) model.getRoot(); ElementTreeNode groupNode = new ElementTreeNode(newGroup); rootNode.add(groupNode); groupNode.add(new ElementTreeNode(groupSummaryElement)); groupNode.add(new ElementTreeNode(analogScopeElement)); int index = rootNode.getIndex(groupNode); model.nodesWereInserted(rootNode, new int[] {index}); model.nodeStructureChanged(groupNode); this.tree.expandRow(index); }
/** {@inheritDoc} */ public void setArmed(boolean b) { if (isMenuItem() && UIManager.getBoolean("MenuItem.disabledAreNavigable")) { if ((isArmed() == b)) { return; } } else { if ((isArmed() == b) || !isEnabled()) { return; } } if (b) { stateMask |= ARMED; } else { stateMask &= ~ARMED; } fireStateChanged(); }
protected boolean isShowAsSheet() { return UIManager.getBoolean("Sheet.showAsSheet"); }