List of usage examples for java.awt KeyboardFocusManager getCurrentKeyboardFocusManager
public static KeyboardFocusManager getCurrentKeyboardFocusManager()
From source file:eu.apenet.dpt.standalone.gui.eag2012.EagContactPanel.java
@Override protected JComponent buildEditorPanel(List<String> errors) { if (errors == null) errors = new ArrayList<String>(0); else if (Utilities.isDev && errors.size() > 0) { LOG.info("Errors in form:"); for (String error : errors) { LOG.info(error);//from ww w . j av a2s . com } } FormLayout layout = new FormLayout("right:max(50dlu;p), 4dlu, 100dlu, 7dlu, right:p, 4dlu, 100dlu", EDITOR_ROW_SPEC); layout.setColumnGroups(new int[][] { { 1, 3, 5, 7 } }); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); rowNb = 1; Repository repository = eag.getArchguide().getDesc().getRepositories().getRepository().get(repositoryNb); if (repositoryNb > 0) { if (repository.getRepositoryRole() == null) repository.setRepositoryRole(new RepositoryRole()); if (Arrays.asList(repositoryRoles).contains(repository.getRepositoryRole().getValue())) repositoryRoleTypeCombo.setSelectedItem(repository.getRepositoryRole().getValue()); builder.addLabel(labels.getString("eag2012.commons.roleOfRepository"), cc.xy(1, rowNb)); builder.add(repositoryRoleTypeCombo, cc.xy(3, rowNb)); setNextRow(); if (repository.getRepositoryName().size() == 0) repository.getRepositoryName().add(new RepositoryName()); repositoryNameTfs = new ArrayList<TextFieldWithLanguage>(repository.getRepositoryName().size()); for (RepositoryName repositoryName : repository.getRepositoryName()) { builder.addLabel(labels.getString("eag2012.commons.nameOfRepository"), cc.xy(1, rowNb)); TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(repositoryName.getContent(), repositoryName.getLang()); repositoryNameTfs.add(textFieldWithLanguage); builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); } JButton addNewRepositoryNameBtn = new ButtonTab( labels.getString("eag2012.contact.addNameOfRepository")); addNewRepositoryNameBtn.addActionListener(new AddRepositoryNameAction(eag, tabbedPane, model)); builder.add(addNewRepositoryNameBtn, cc.xy(3, rowNb)); setNextRow(); } //visitors address and postal address boolean hasMinimumOnePostalAddress = false; boolean hasMinimumOneVisitorAddress = false; locationFields = new ArrayList<LocationType>(repository.getLocation().size()); //loop to load Visitors address for (Location location : repository.getLocation()) { if (location.getLocalType() != null && location.getLocalType().equals("visitors address")) { LocationType locationType = new LocationType(location); locationFields.add(locationType); if (hasMinimumOneVisitorAddress) { locationType.getLatitudeTf().setEnabled(false); locationType.getLongitudeTf().setEnabled(false); } builder.addSeparator(labels.getString("eag2012.commons.visitorsAddress"), cc.xyw(1, rowNb, 7)); hasMinimumOneVisitorAddress = true; setNextRow(); String mandatoryStar = "*"; if (location != repository.getLocation().get(0)) mandatoryStar = ""; builder.addLabel(labels.getString("eag2012.commons.street") + mandatoryStar, cc.xy(1, rowNb)); builder.add(locationType.getStreetTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getStreetTf().getLanguageBox(), cc.xy(7, rowNb)); if (errors.contains("streetTf") && StringUtils.isEmpty(locationType.getStreetTfValue())) { setNextRow(); builder.add(createErrorLabel(labels.getString("eag2012.errors.street")), cc.xy(1, rowNb)); } setNextRow(); builder.addLabel(labels.getString("eag2012.commons.cityTownWithPostalcode") + mandatoryStar, cc.xy(1, rowNb)); builder.add(locationType.getCityTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getCityTf().getLanguageBox(), cc.xy(7, rowNb)); if (errors.contains("cityTf") && StringUtils.isEmpty(locationType.getCityTfValue())) { setNextRow(); builder.add(createErrorLabel(labels.getString("eag2012.errors.city")), cc.xy(1, rowNb)); } setNextRow(); builder.addLabel(labels.getString("eag2012.contact.district"), cc.xy(1, rowNb)); builder.add(locationType.getDistrictTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getDistrictTf().getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.contact.countyLocalAuthority"), cc.xy(1, rowNb)); builder.add(locationType.getCountyTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getCountyTf().getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.contact.region"), cc.xy(1, rowNb)); builder.add(locationType.getRegionTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getRegionTf().getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.commons.country") + mandatoryStar, cc.xy(1, rowNb)); builder.add(locationType.getCountryTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getCountryTf().getLanguageBox(), cc.xy(7, rowNb)); if (errors.contains("countryTf") && StringUtils.isEmpty(locationType.getCountryTfValue())) { setNextRow(); builder.add(createErrorLabel(labels.getString("eag2012.errors.country")), cc.xy(1, rowNb)); } setNextRow(); builder.addLabel(labels.getString("eag2012.commons.latitude"), cc.xy(1, rowNb)); locationType.getLatitudeTf() .addFocusListener(new UpdateCoordsText(locationType, EagContactPanel.LATITUDE)); builder.add(locationType.getLatitudeTf(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.longitude"), cc.xy(5, rowNb)); locationType.getLongitudeTf() .addFocusListener(new UpdateCoordsText(locationType, EagContactPanel.LONGITUDE)); builder.add(locationType.getLongitudeTf(), cc.xy(7, rowNb)); setNextRow(); } // end if visitors address } //end loop to load Visitors address //add visitors address button if (hasMinimumOneVisitorAddress) { JButton addNewVisitorTranslationAddressBtn = new ButtonTab( labels.getString("eag2012.commons.addVisitorTranslationAddress"), true); addNewVisitorTranslationAddressBtn .addActionListener(new AddAddressAction(eag, tabbedPane, model, false)); builder.add(addNewVisitorTranslationAddressBtn, cc.xy(3, rowNb)); setNextRow(); } else { JButton addNewVisitorAddressBtn = new ButtonTab(labels.getString("eag2012.commons.addVisitorAddress")); addNewVisitorAddressBtn.addActionListener(new AddAddressAction(eag, tabbedPane, model, false)); builder.add(addNewVisitorAddressBtn, cc.xy(3, rowNb)); setNextRow(); } //end add visitors address button // loop to load Postal address for (Location location : repository.getLocation()) { if (location.getLocalType() != null && location.getLocalType().equals("postal address")) { LocationType locationType = new LocationType(location); locationFields.add(locationType); builder.addSeparator(labels.getString("eag2012.commons.postalAddress"), cc.xyw(1, rowNb, 7)); hasMinimumOnePostalAddress = true; setNextRow(); String mandatoryStar = ""; builder.addLabel(labels.getString("eag2012.commons.street") + mandatoryStar, cc.xy(1, rowNb)); builder.add(locationType.getStreetTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getStreetTf().getLanguageBox(), cc.xy(7, rowNb)); if (errors.contains("streetTf") && StringUtils.isEmpty(locationType.getStreetTfValue())) { setNextRow(); builder.add(createErrorLabel(labels.getString("eag2012.errors.street")), cc.xy(1, rowNb)); } setNextRow(); builder.addLabel(labels.getString("eag2012.commons.cityTownWithPostalcode") + mandatoryStar, cc.xy(1, rowNb)); builder.add(locationType.getCityTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getCityTf().getLanguageBox(), cc.xy(7, rowNb)); if (errors.contains("cityTf") && StringUtils.isEmpty(locationType.getCityTfValue())) { setNextRow(); builder.add(createErrorLabel(labels.getString("eag2012.errors.city")), cc.xy(1, rowNb)); } setNextRow(); } //end if postal address } // end loop to load Postal address //add postal address button if (hasMinimumOnePostalAddress) { JButton addNewPostalTranslationAddressBtn = new ButtonTab( labels.getString("eag2012.commons.addPostalTranslationAddress"), true); addNewPostalTranslationAddressBtn.addActionListener(new AddAddressAction(eag, tabbedPane, model, true)); builder.add(addNewPostalTranslationAddressBtn, cc.xy(3, rowNb)); setNextRow(); } else { JButton addNewPostalAddressBtn = new ButtonTab(labels.getString("eag2012.commons.addPostalAddress")); addNewPostalAddressBtn.addActionListener(new AddAddressAction(eag, tabbedPane, model, true)); builder.add(addNewPostalAddressBtn, cc.xy(3, rowNb)); setNextRow(); } //end add postal address button builder.addLabel(labels.getString("eag2012.commons.continent") + "*", cc.xy(1, rowNb)); if (Arrays.asList(continents).contains(repository.getGeogarea().getValue())) { continentCombo.setSelectedItem(repository.getGeogarea().getValue()); } else { continentCombo.setSelectedItem("Europe"); } builder.add(continentCombo, cc.xy(3, rowNb)); setNextRow(); //getTelephone() builder.addLabel(labels.getString("eag2012.commons.telephone"), cc.xy(1, rowNb)); int i = 0; telephoneTfs = new ArrayList<JTextField>(repository.getTelephone().size()); for (Telephone telephone : repository.getTelephone()) { JTextField telephoneTf = new JTextField(telephone.getContent()); telephoneTfs.add(telephoneTf); builder.add(telephoneTf, cc.xy(3, rowNb)); if (i++ == 0) { JButton addTelephoneBtn = new ButtonTab( labels.getString("eag2012.contact.addFurtherTelephoneNumbers")); addTelephoneBtn.addActionListener(new AddTelephoneAction(eag, tabbedPane, model)); builder.add(addTelephoneBtn, cc.xy(5, rowNb)); } setNextRow(); } if (repository.getTelephone().size() == 0) { JTextField telephoneTf = new JTextField(); telephoneTfs.add(telephoneTf); builder.add(telephoneTf, cc.xy(3, rowNb)); JButton addTelephoneBtn = new ButtonTab(labels.getString("eag2012.contact.addFurtherTelephoneNumbers")); addTelephoneBtn.addActionListener(new AddTelephoneAction(eag, tabbedPane, model)); builder.add(addTelephoneBtn, cc.xy(5, rowNb)); setNextRow(); } builder.addLabel(labels.getString("eag2012.contact.fax"), cc.xy(1, rowNb)); i = 0; faxTfs = new ArrayList<JTextField>(repository.getFax().size()); for (Fax fax : repository.getFax()) { JTextField faxTf = new JTextField(fax.getContent()); faxTfs.add(faxTf); builder.add(faxTf, cc.xy(3, rowNb)); if (i++ == 0) { JButton addFaxBtn = new ButtonTab(labels.getString("eag2012.contact.addFaxNumbers")); addFaxBtn.addActionListener(new AddFaxAction(eag, tabbedPane, model)); builder.add(addFaxBtn, cc.xy(5, rowNb)); } setNextRow(); } if (repository.getFax().size() == 0) { JTextField faxTf = new JTextField(); faxTfs.add(faxTf); builder.add(faxTf, cc.xy(3, rowNb)); JButton addFaxBtn = new ButtonTab(labels.getString("eag2012.contact.addFaxNumbers")); addFaxBtn.addActionListener(new AddFaxAction(eag, tabbedPane, model)); builder.add(addFaxBtn, cc.xy(5, rowNb)); setNextRow(); } //getEmail() emailTfs = new ArrayList<JTextField>(repository.getEmail().size()); emailTitleTfs = new ArrayList<JTextField>(repository.getEmail().size()); if (repository.getEmail().size() == 0) repository.getEmail().add(new Email()); for (Email email : repository.getEmail()) { JTextField emailTf = new JTextField(email.getHref()); JTextField emailTitleTf = new JTextField(email.getContent()); emailTfs.add(emailTf); emailTitleTfs.add(emailTitleTf); builder.addLabel(labels.getString("eag2012.commons.email"), cc.xy(1, rowNb)); builder.add(emailTf, cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb)); builder.add(emailTitleTf, cc.xy(7, rowNb)); setNextRow(); } JButton addEmailBtn = new ButtonTab(labels.getString("eag2012.commons.addEmail")); addEmailBtn.addActionListener(new AddEmailAction(eag, tabbedPane, model)); builder.add(addEmailBtn, cc.xy(1, rowNb)); setNextRow(); //getWebpage() webpageTfs = new ArrayList<JTextField>(repository.getWebpage().size()); webpageTitleTfs = new ArrayList<JTextField>(repository.getWebpage().size()); if (repository.getWebpage().size() == 0) repository.getWebpage().add(new Webpage()); for (Webpage webpage : repository.getWebpage()) { JTextField webpageTf = new JTextField(webpage.getHref()); JTextField webpageTitleTf = new JTextField(webpage.getContent()); webpageTitleTfs.add(webpageTitleTf); webpageTfs.add(webpageTf); builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb)); builder.add(webpageTf, cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb)); builder.add(webpageTitleTf, cc.xy(7, rowNb)); setNextRow(); if (errors.contains("webpageTfs")) { if (StringUtils.isNotBlank(webpageTf.getText()) && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) { builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xyw(1, rowNb, 3)); setNextRow(); } } else if (StringUtils.isNotBlank(webpageTf.getText()) && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) { builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xyw(1, rowNb, 3)); setNextRow(); } } JButton addWebpageBtn = new ButtonTab(labels.getString("eag2012.commons.addWebpage")); addWebpageBtn.addActionListener(new AddWebpageAction(eag, tabbedPane, model)); builder.add(addWebpageBtn, cc.xy(1, rowNb)); setNextRow(); builder.addSeparator("", cc.xyw(1, rowNb, 7)); setNextRow(); JButton exitBtn = new ButtonTab(labels.getString("eag2012.commons.exit")); builder.add(exitBtn, cc.xy(1, rowNb)); exitBtn.addActionListener(new ExitBtnAction(eag, tabbedPane, model)); if (repositoryNb == 0) { JButton previousTabBtn = new ButtonTab(labels.getString("eag2012.commons.previousTab")); builder.add(previousTabBtn, cc.xy(3, rowNb)); previousTabBtn.addActionListener(new ChangeTabBtnAction(eag, tabbedPane, model, false)); } JButton nextTabBtn = new ButtonTab(labels.getString("eag2012.commons.nextTab")); builder.add(nextTabBtn, cc.xy(5, rowNb)); nextTabBtn.addActionListener(new ChangeTabBtnAction(eag, tabbedPane, model, true)); setNextRow(); JButton saveBtn = new ButtonTab(labels.getString("eag2012.commons.save")); builder.add(saveBtn, cc.xy(5, rowNb)); saveBtn.addActionListener(new SaveBtnAction(eag, tabbedPane, model)); setNextRow(); builder.addSeparator("", cc.xyw(1, rowNb, 7)); setNextRow(); JButton previousInstitutionTabBtn = new ButtonTab(labels.getString("eag2012.controls.previousInstitution")); previousInstitutionTabBtn.addActionListener(new PreviousInstitutionTabBtnAction(eag, tabbedPane, model)); builder.add(previousInstitutionTabBtn, cc.xy(1, rowNb)); JButton nextInstitutionTabBtn = new ButtonTab(labels.getString("eag2012.controls.nextInstitution")); nextInstitutionTabBtn.addActionListener(new NextInstitutionTabBtnAction(eag, tabbedPane, model)); builder.add(nextInstitutionTabBtn, cc.xy(5, rowNb)); // Define the change tab listener. this.removeChangeListener(); this.tabbedPane.addChangeListener( new ChangeTabListener(this.eag, this.tabbedPane, this.model, 2, this.repositoryNb)); JPanel panel = builder.getPanel(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .addPropertyChangeListener(new FocusManagerListener(panel)); return panel; }
From source file:edu.ku.brc.af.ui.forms.ResultSetController.java
/** * // w w w. j a v a 2 s . c om */ private static void registerFocusListener() { final KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Component permanentFocusOwner = null; String propName = e.getPropertyName(); if (propName.equals("permanentFocusOwner")) { permanentFocusOwner = focusManager.getFocusOwner(); } Component comp = permanentFocusOwner; while (comp != null && !(comp instanceof MultiView)) { comp = comp.getParent(); } ResultSetController rsc = null; boolean fnd = false; if (comp instanceof MultiView) { FormViewObj fvo = ((MultiView) comp).getCurrentViewAsFormViewObj(); if (fvo != null && fvo.getRsController() != null) { rsc = fvo.getRsController(); if (currentFocusedRS == null || currentFocusedRS != rsc) { currentFocusedRS = rsc; fnd = true; } } } if (!fnd) { currentFocusedRS = backStopRS; } installRS(currentFocusedRS); } }); }
From source file:com.ejie.uda.jsonI18nEditor.Editor.java
private void setupUI() { setTitle(TITLE);//w ww. j a v a 2 s .com setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new EditorWindowListener()); setIconImages(Lists.newArrayList(getResourceImage("images/icon-512.png"), getResourceImage("images/icon-256.png"), getResourceImage("images/icon-128.png"), getResourceImage("images/icon-64.png"), getResourceImage("images/icon-48.png"), getResourceImage("images/icon-32.png"), getResourceImage("images/icon-24.png"), getResourceImage("images/icon-20.png"), getResourceImage("images/icon-16.png"))); translationsPanel = new JPanel(new BorderLayout()); translationTree = new TranslationTree(this); translationTree.addTreeSelectionListener(new TranslationTreeNodeSelectionListener()); translationField = new TranslationField(); translationField.addKeyListener(new TranslationFieldKeyListener()); translationsPanel.add(new JScrollPane(translationTree)); translationsPanel.add(translationField, BorderLayout.SOUTH); resourcesPanel = new JScrollablePanel(true, false); resourcesPanel.setLayout(new BoxLayout(resourcesPanel, BoxLayout.Y_AXIS)); resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); resourcesScrollPane = new JScrollPane(resourcesPanel); resourcesScrollPane.getViewport().setOpaque(false); contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, translationsPanel, resourcesScrollPane); editorMenu = new EditorMenu(this, translationTree); Container container = getContentPane(); container.add(editorMenu, BorderLayout.NORTH); container.add(contentPane); // Instead of selecting text in text field when applying focus, set caret position to end of input KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("permanentFocusOwner", e -> { if (e.getNewValue() instanceof JTextField) { JTextField field = (JTextField) e.getNewValue(); field.setCaretPosition(field.getText().length()); } }); }
From source file:com.jvms.i18neditor.editor.Editor.java
private void setupGlobalKeyEventDispatcher() { KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(e -> { if (e.getID() != KeyEvent.KEY_PRESSED || !e.isAltDown() || (SystemUtils.IS_OS_MAC && !e.isMetaDown()) || (!SystemUtils.IS_OS_MAC && !e.isShiftDown())) { return false; }// w ww .ja v a2 s. c o m TreePath selected = translationTree.getSelectionPath(); if (selected == null) { return false; } boolean result = false; int row = translationTree.getRowForPath(selected); switch (e.getKeyCode()) { case KeyEvent.VK_RIGHT: if (!translationTree.isExpanded(row)) { translationTree.expandRow(row); } result = true; break; case KeyEvent.VK_LEFT: if (translationTree.isCollapsed(row)) { translationTree.setSelectionPath(selected.getParentPath()); } else { translationTree.collapseRow(row); } result = true; break; case KeyEvent.VK_UP: TreePath prev = translationTree.getPathForRow(Math.max(0, row - 1)); if (prev != null) { translationTree.setSelectionPath(prev); } result = true; break; case KeyEvent.VK_DOWN: TreePath next = translationTree.getPathForRow(row + 1); if (next != null) { translationTree.setSelectionPath(next); } result = true; break; } if (result && !resourceFields.isEmpty()) { Component comp = getFocusOwner(); if (comp != null && (comp instanceof ResourceField || comp.equals(this))) { TranslationTreeNode current = translationTree.getSelectionNode(); if (!current.isLeaf() || current.isRoot()) { requestFocusInWindow(); } else if (comp.equals(this)) { requestFocusInFirstResourceField(); } } } return result; }); }
From source file:eu.apenet.dpt.standalone.gui.eag2012.EagInstitutionPanel.java
/** * Builds and answer the editor's general tab for the given layout. * * @return the editor's general panel/*www . j a va 2 s.c o m*/ */ protected JComponent buildEditorPanel(List<String> errors) { if (errors == null) { errors = new ArrayList<String>(0); } else if (Utilities.isDev && errors.size() > 0) { LOG.info("Errors in form:"); for (String error : errors) { LOG.info(error); } } FormLayout layout = new FormLayout("right:max(50dlu;p), 4dlu, 100dlu, 7dlu, right:p, 4dlu, 100dlu", EDITOR_ROW_SPEC); layout.setColumnGroups(new int[][] { { 1, 3, 5, 7 } }); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); rowNb = 1; builder.addSeparator(labels.getString("eag2012.tab.yourInstitution"), cc.xyw(1, rowNb, 7)); setNextRow(); builder.addLabel(labels.getString("eag2012.commons.personResponsible"), cc.xy(1, rowNb)); int sizeEvents = eag.getControl().getMaintenanceHistory().getMaintenanceEvent().size(); if (sizeEvents == 0) { if (StringUtils.isNotEmpty(Eag2012Frame.getPersonResponsible())) { personTf = new JTextField(Eag2012Frame.getPersonResponsible()); } else { personTf = new JTextField(""); } } else { MaintenanceEvent event = eag.getControl().getMaintenanceHistory().getMaintenanceEvent() .get(sizeEvents - 1); personTf = new JTextField(event.getAgent().getContent()); } builder.add(personTf, cc.xy(3, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.commons.countryCode") + "*", cc.xy(1, rowNb)); if (isNew && StringUtils.isEmpty(eag.getArchguide().getIdentity().getRepositorid().getCountrycode())) { countryCodeTf = new JTextField(countrycode); } else { countryCodeTf = new JTextField(eag.getArchguide().getIdentity().getRepositorid().getCountrycode()); } countryCodeTf.addKeyListener(new CheckKeyListener()); builder.add(countryCodeTf, cc.xy(3, rowNb)); setNextRow(); if (errors.contains("countryCodeTf")) { builder.add(createErrorLabel(labels.getString("eag2012.errors.countryCode")), cc.xy(1, rowNb)); setNextRow(); } if (eag.getControl().getOtherRecordId().size() == 0) { eag.getControl().getOtherRecordId().add(new OtherRecordId()); if (isNew && StringUtils.isNotEmpty(mainagencycode)) { eag.getControl().getOtherRecordId().get(0).setLocalType("yes"); eag.getControl().getOtherRecordId().get(0).setValue(mainagencycode); } } otherRecordIdTfs = new ArrayList<TextFieldWithCheckbox>(eag.getControl().getOtherRecordId().size()); for (OtherRecordId otherRecordId : eag.getControl().getOtherRecordId()) { String mandatoryStar = "*"; if (otherRecordId != eag.getControl().getOtherRecordId().get(0)) mandatoryStar = ""; TextFieldWithCheckbox textFieldWithCheckbox = new TextFieldWithCheckbox(otherRecordId.getValue(), otherRecordId.getLocalType()); otherRecordIdTfs.add(textFieldWithCheckbox); builder.addLabel(labels.getString("eag2012.control.identifierInstitution") + mandatoryStar, cc.xy(1, rowNb)); builder.add(textFieldWithCheckbox.getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.isil.isThisISIL"), cc.xy(5, rowNb)); textFieldWithCheckbox.getTextField().addKeyListener(new CheckKeyListener()); builder.add(textFieldWithCheckbox.getIsilOrNotCombo(), cc.xy(7, rowNb)); textFieldWithCheckbox.getIsilOrNotCombo() .addActionListener(new ComboboxActionListener(textFieldWithCheckbox)); setNextRow(); } if (errors.contains("otherRecordIdTfs")) { builder.add(createErrorLabel(labels.getString("eag2012.errors.notIdentifierInstitution")), cc.xy(1, rowNb)); setNextRow(); } JButton addNewOtherIdentifierBtn = new ButtonTab( labels.getString("eag2012.yourinstitution.addOtherIdentifier")); addNewOtherIdentifierBtn.addActionListener(new AddOtherIdentifierAction(eag, tabbedPane, model)); builder.add(addNewOtherIdentifierBtn, cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.idUsedInApe"), cc.xy(5, rowNb)); if (Eag2012ValidFields.isRepositoryCodeCorrect(eag.getControl().getRecordId().getValue())) { idUsedInApeTf = new JTextField(eag.getControl().getRecordId().getValue()); } else { idUsedInApeTf = new JTextField(TextChanger.getNewText(otherRecordIdTfs, countryCodeTf.getText())); } idUsedInApeTf.setEnabled(false); idUsedInApeTf.setEditable(false); builder.add(idUsedInApeTf, cc.xy(7, rowNb)); setNextRow(); if (eag.getArchguide().getIdentity().getAutform().size() == 0) { eag.getArchguide().getIdentity().getAutform().add(new Autform()); } nameInstitutionTfs = new ArrayList<TextFieldWithLanguage>( eag.getArchguide().getIdentity().getAutform().size()); for (Autform autform : eag.getArchguide().getIdentity().getAutform()) { TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(autform.getContent(), autform.getLang()); nameInstitutionTfs.add(textFieldWithLanguage); builder.addLabel(labels.getString("eag2012.commons.nameOfInstitution") + "*", cc.xy(1, rowNb)); builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); } if (errors.contains("nameInstitutionTfs")) { builder.add(createErrorLabel(labels.getString("eag2012.errors.nameInstitutionEmpty")), cc.xy(1, rowNb)); setNextRow(); } if (eag.getArchguide().getIdentity().getParform().size() == 0) { eag.getArchguide().getIdentity().getParform().add(new Parform()); } parallelNameTfs = new ArrayList<TextFieldWithLanguage>( eag.getArchguide().getIdentity().getParform().size()); for (Parform parform : eag.getArchguide().getIdentity().getParform()) { TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(parform.getContent(), parform.getLang()); parallelNameTfs.add(textFieldWithLanguage); builder.addLabel(labels.getString("eag2012.commons.parallelNameOfInstitution"), cc.xy(1, rowNb)); builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); } //print repositoryType combo if (eag.getArchguide().getIdentity().getRepositoryType() != null && !eag.getArchguide().getIdentity().getRepositoryType().isEmpty()) { for (RepositoryType repoType : eag.getArchguide().getIdentity().getRepositoryType()) { builder.addLabel(labels.getString("eag2012.identity.selectType"), cc.xy(1, rowNb)); JComboBox comboBox = new JComboBox(typeInstitution); if (repoType.getValue() != null && !repoType.getValue().isEmpty()) { comboBox.setSelectedItem(repoType.getValue()); } else { comboBox.setSelectedItem("---"); } typeInstitutionComboList.add(comboBox); builder.add(comboBox, cc.xy(3, rowNb)); setNextRow(); } } else { builder.addLabel(labels.getString("eag2012.identity.selectType"), cc.xy(1, rowNb)); JComboBox comboBox = new JComboBox(typeInstitution); comboBox.setSelectedItem("---"); typeInstitutionComboList.add(comboBox); builder.add(comboBox, cc.xy(3, rowNb)); setNextRow(); } //add another repositoryType button JButton addNewTypeOfTheInstitution = new ButtonTab( labels.getString("eag2012.yourinstitution.addAnotherRepositoryType")); addNewTypeOfTheInstitution.addActionListener(new AddRepositoryTypeAction(eag, tabbedPane, model)); builder.add(addNewTypeOfTheInstitution, cc.xy(1, rowNb)); setNextRow(); builder.addSeparator("", cc.xyw(1, this.rowNb, 7)); setNextRow(); // if(eag.getArchguide().getDesc().getRepositories().getRepository().size() == 1) { //todo: BECAUSE FOR NOW ONLY ONE REPOSITORY!!!! Repository repository = eag.getArchguide().getDesc().getRepositories().getRepository().get(repositoryNb); boolean hasMinimumOnePostalAddress = false; boolean hasMinimumOneVisitorAddress = false; locationFields = new ArrayList<LocationType>(repository.getLocation().size()); // int locationNb = 0; for (Location location : repository.getLocation()) { // locationNb++; boolean isPostal = false; LocationType locationType = new LocationType(location); if (StringUtils.isEmpty(location.getLocalType()) || location.getLocalType().equals("visitors address")) { locationType.setLocalType("visitors address"); if (hasMinimumOneVisitorAddress) { locationType.getLatitudeTf().setEnabled(false); locationType.getLongitudeTf().setEnabled(false); } builder.addSeparator(labels.getString("eag2012.commons.visitorsAddress"), cc.xyw(1, rowNb, 7)); isPostal = false; hasMinimumOneVisitorAddress = true; } else if (location.getLocalType().equals("postal address")) { // builder.addSeparator(labels.getString("eag2012.commons.postalAddress"), cc.xyw(1, rowNb, 7)); isPostal = true; // hasMinimumOnePostalAddress = true; } if (!isPostal) { locationFields.add(locationType); setNextRow(); String mandatoryStar = "*"; if (isPostal || location != repository.getLocation().get(0)) { mandatoryStar = ""; } builder.addLabel(labels.getString("eag2012.commons.street") + mandatoryStar, cc.xy(1, rowNb)); builder.add(locationType.getStreetTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getStreetTf().getLanguageBox(), cc.xy(7, rowNb)); if (errors.contains("streetTf") && StringUtils.isEmpty(locationType.getStreetTfValue())) { setNextRow(); builder.add(createErrorLabel(labels.getString("eag2012.errors.street")), cc.xy(1, rowNb)); } setNextRow(); builder.addLabel(labels.getString("eag2012.commons.cityTownWithPostalcode") + mandatoryStar, cc.xy(1, rowNb)); builder.add(locationType.getCityTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getCityTf().getLanguageBox(), cc.xy(7, rowNb)); if (errors.contains("cityTf") && StringUtils.isEmpty(locationType.getCityTfValue())) { setNextRow(); builder.add(createErrorLabel(labels.getString("eag2012.errors.city")), cc.xy(1, rowNb)); } setNextRow(); builder.addLabel(labels.getString("eag2012.commons.country") + mandatoryStar, cc.xy(1, rowNb)); builder.add(locationType.getCountryTf().getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(locationType.getCountryTf().getLanguageBox(), cc.xy(7, rowNb)); if (errors.contains("countryTf") && StringUtils.isEmpty(locationType.getCountryTfValue())) { setNextRow(); builder.add(createErrorLabel(labels.getString("eag2012.errors.country")), cc.xy(1, rowNb)); } setNextRow(); builder.addLabel(labels.getString("eag2012.commons.latitude"), cc.xy(1, rowNb)); locationType.getLatitudeTf() .addFocusListener(new UpdateCoordsText(locationType, EagContactPanel.LATITUDE)); builder.add(locationType.getLatitudeTf(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.longitude"), cc.xy(5, rowNb)); locationType.getLongitudeTf() .addFocusListener(new UpdateCoordsText(locationType, EagContactPanel.LONGITUDE)); builder.add(locationType.getLongitudeTf(), cc.xy(7, rowNb)); setNextRow(); } } if (hasMinimumOneVisitorAddress) { JButton addNewVisitorTranslationAddressBtn = new ButtonTab( labels.getString("eag2012.commons.addVisitorTranslationAddress"), true); addNewVisitorTranslationAddressBtn .addActionListener(new AddAddressAction(eag, tabbedPane, model, false)); builder.add(addNewVisitorTranslationAddressBtn, cc.xy(3, rowNb)); setNextRow(); } else { JButton addNewVisitorAddressBtn = new ButtonTab(labels.getString("eag2012.commons.addVisitorAddress")); addNewVisitorAddressBtn.addActionListener(new AddAddressAction(eag, tabbedPane, model, false)); builder.add(addNewVisitorAddressBtn, cc.xy(3, rowNb)); setNextRow(); } builder.addLabel(labels.getString("eag2012.commons.continent") + "*", cc.xy(1, rowNb)); if (Arrays.asList(continents).contains(repository.getGeogarea().getValue())) { continentCombo.setSelectedItem(repository.getGeogarea().getValue()); } else { continentCombo.setSelectedItem("Europe"); } builder.add(continentCombo, cc.xy(3, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.commons.telephone"), cc.xy(1, rowNb)); if (repository.getTelephone().size() > 0) { telephoneTf = new JTextField(repository.getTelephone().get(0).getContent()); } else { telephoneTf = new JTextField(); } builder.add(telephoneTf, cc.xy(3, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.commons.email"), cc.xy(1, rowNb)); if (repository.getEmail().size() > 0) { emailTf = new JTextField(repository.getEmail().get(0).getHref()); emailTitleTf = new JTextField(repository.getEmail().get(0).getContent()); } else { emailTf = new JTextField(); emailTitleTf = new JTextField(); } builder.add(emailTf, cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb)); builder.add(emailTitleTf, cc.xy(7, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb)); if (repository.getWebpage().size() > 0) { webpageTf = new JTextField(repository.getWebpage().get(0).getHref()); if (!StringUtils.isBlank(repository.getWebpage().get(0).getContent())) { webpageTitleTf = new JTextField(repository.getWebpage().get(0).getContent()); } else { webpageTitleTf = new JTextField(); } } else { webpageTf = new JTextField(); webpageTitleTf = new JTextField(); } builder.add(webpageTf, cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb)); builder.add(webpageTitleTf, cc.xy(7, rowNb)); setNextRow(); if ((StringUtils.isNotBlank(webpageTf.getText()) && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) || errors.contains("webpageTf")) { builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb)); setNextRow(); } if (repository.getTimetable().getOpening().size() == 0) { repository.getTimetable().getOpening().add(new Opening()); } openingHoursTfs = new ArrayList<TextFieldWithLanguage>(repository.getTimetable().getOpening().size()); for (Opening opening : repository.getTimetable().getOpening()) { builder.addLabel(labels.getString("eag2012.commons.openingHours") + "*", cc.xy(1, rowNb)); TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(opening.getContent(), opening.getLang()); openingHoursTfs.add(textFieldWithLanguage); builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); } if (errors.contains("openingHoursTfs")) { builder.add(createErrorLabel(labels.getString("eag2012.errors.openingHours")), cc.xy(1, rowNb)); setNextRow(); } if (repository.getTimetable().getClosing().size() == 0) { repository.getTimetable().getClosing().add(new Closing()); } // closingDatesTfs = new ArrayList<TextFieldWithLanguage>(repository.getTimetable().getClosing().size()); // for(Closing closing : repository.getTimetable().getClosing()) { // builder.addLabel(labels.getString("eag2012.commons.closingDates"), cc.xy(1, rowNb)); // TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(closing.getContent(), closing.getLang()); // closingDatesTfs.add(textFieldWithLanguage); // builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb)); // builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy (5, rowNb)); // builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb)); // setNextRow(); // } builder.addLabel(labels.getString("eag2012.commons.accessiblePublic") + "*", cc.xy(1, rowNb)); if (repository.getAccess() != null && Arrays.asList(yesOrNo).contains(repository.getAccess().getQuestion())) { accessiblePublicCombo.setSelectedItem(repository.getAccess().getQuestion()); } builder.add(accessiblePublicCombo, cc.xy(3, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.commons.disabledAccess") + "*", cc.xy(1, rowNb)); if (repository.getAccessibility().size() > 0 && Arrays.asList(yesOrNo).contains(repository.getAccessibility().get(0).getQuestion())) { facilitiesForDisabledCombo.setSelectedItem(repository.getAccessibility().get(0).getQuestion()); } builder.add(facilitiesForDisabledCombo, cc.xy(3, rowNb)); setNextRow(); // builder.addLabel(labels.getString("eag2012.yourinstitution.linkToHoldingsGuide"), cc.xy(1, rowNb)); // if(eag.getRelations() == null) { // eag.setRelations(new Relations()); // } // if(eag.getRelations().getResourceRelation().size() > 0) { // refInstitutionHoldingsGuideTf = new JTextField(eag.getRelations().getResourceRelation().get(0).getHref()); // if(eag.getRelations().getResourceRelation().get(0).getRelationEntry() != null) // refInstitutionHoldingsGuideTitleTf = new JTextField(eag.getRelations().getResourceRelation().get(0).getRelationEntry().getContent()); // else // refInstitutionHoldingsGuideTitleTf = new JTextField(); // } else { // refInstitutionHoldingsGuideTf = new JTextField(); // refInstitutionHoldingsGuideTitleTf = new JTextField(); // } // builder.add(refInstitutionHoldingsGuideTf, cc.xy(3, rowNb)); // builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy (5, rowNb)); // builder.add(refInstitutionHoldingsGuideTitleTf, cc.xy(7, rowNb)); // setNextRow(); // if((StringUtils.isNotBlank(refInstitutionHoldingsGuideTf.getText()) && !StringUtils.startsWithAny(refInstitutionHoldingsGuideTf.getText(), webPrefixes)) || errors.contains("refInstitutionHoldingsGuideTf")) { // builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb)); // setNextRow(); // } // } builder.addSeparator("", cc.xyw(1, rowNb, 7)); setNextRow(); JButton addRepositoryBtn = new ButtonTab( labels.getString("eag2012.yourinstitution.addRepositoryTabButton")); builder.add(addRepositoryBtn, cc.xy(1, rowNb)); addRepositoryBtn.addActionListener(new AddRepositoryTabButton()); JButton nextTabBtn = new ButtonTab(labels.getString("eag2012.commons.nextTab")); builder.add(nextTabBtn, cc.xy(5, rowNb)); nextTabBtn.addActionListener(new NextTabBtnAction(eag, tabbedPane, model)); setNextRow(); JButton exitBtn = new ButtonTab(labels.getString("eag2012.commons.exit")); builder.add(exitBtn, cc.xy(1, rowNb)); exitBtn.addActionListener(new ExitBtnAction(eag, tabbedPane, model)); JButton saveBtn = new ButtonTab(labels.getString("eag2012.commons.save")); builder.add(saveBtn, cc.xy(5, rowNb)); saveBtn.addActionListener(new SaveBtnAction(eag, tabbedPane, model)); setNextRow(); builder.addSeparator("", cc.xyw(1, rowNb, 7)); setNextRow(); JButton nextInstitutionTabBtn = new ButtonTab(labels.getString("eag2012.controls.nextInstitution")); nextInstitutionTabBtn.addActionListener(new NextInstitutionTabBtnAction(eag, tabbedPane, model)); builder.add(nextInstitutionTabBtn, cc.xy(5, rowNb)); // Define the change tab listener. this.removeChangeListener(); this.tabbedPane.addChangeListener(new ChangeTabListener(this.eag, this.tabbedPane, this.model, 0)); JPanel panel = builder.getPanel(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .addPropertyChangeListener(new FocusManagerListener(panel)); return panel; }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
private void menuFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFullScreenActionPerformed final Component currentComponent = this.tabPane.getSelectedComponent(); if (!(currentComponent instanceof Container)) { LOGGER.warn("Detected attempt to full screen not a container : " + currentComponent); return;/* ww w .ja va2s. c o m*/ } final GraphicsConfiguration gconfig = this.getGraphicsConfiguration(); if (gconfig != null) { final GraphicsDevice device = gconfig.getDevice(); if (device.isFullScreenSupported()) { if (device.getFullScreenWindow() == null) { final JLabel label = new JLabel("Opened in full screen"); final int tabIndex = this.tabPane.getSelectedIndex(); this.tabPane.setComponentAt(tabIndex, label); final JWindow window = new JWindow(Main.getApplicationFrame()); window.setAlwaysOnTop(true); window.setContentPane((Container) currentComponent); endFullScreenIfActive(); final KeyEventDispatcher fullScreenEscCatcher = new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(@Nonnull final KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED && (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_F11)) { endFullScreenIfActive(); return true; } return false; } }; if (this.taskToEndFullScreen.compareAndSet(null, new Runnable() { @Override public void run() { try { window.dispose(); } finally { tabPane.setComponentAt(tabIndex, currentComponent); device.setFullScreenWindow(null); KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(fullScreenEscCatcher); } } })) { try { KeyboardFocusManager.getCurrentKeyboardFocusManager() .addKeyEventDispatcher(fullScreenEscCatcher); device.setFullScreenWindow(window); } catch (Exception ex) { LOGGER.error("Can't turn on full screen", ex); endFullScreenIfActive(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(fullScreenEscCatcher); } } else { LOGGER.error("Unexpected state, processor is not null!"); } } else { LOGGER.warn("Attempt to full screen device which already in full screen!"); } } else { LOGGER.warn("Device doesn's support full screen"); DialogProviderManager.getInstance().getDialogProvider() .msgWarn("The Device doesn't support full-screen mode!"); } } else { LOGGER.warn("Can't find graphics config for the frame"); } }
From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java
protected AbstractRenderComponent(final ReportDesignerContext designerContext, final ReportDocumentContext renderContext) { if (renderContext == null) { throw new NullPointerException(); }// w w w . j a va2s . co m if (designerContext == null) { throw new NullPointerException(); } setDoubleBuffered(true); setOpaque(false); setFocusable(true); setFocusCycleRoot(true); setFocusTraversalKeysEnabled(false); setLayout(null); this.fpsCalculator = new FpsCalculator(); this.showLeftBorder = true; this.showTopBorder = false; this.repaintHandler = new RepaintHandler(this); this.designerContext = designerContext; this.renderContext = renderContext; this.settingsUpdateHandler = new SettingsUpdateHandler(); this.horizontalSnapModel = new FullSnapModel(); this.verticalSnapModel = new FullSnapModel(); this.terminateEditOnFocusLost = true; gridSize = WorkspaceSettings.getInstance().getGridSize(); gridDivisions = WorkspaceSettings.getInstance().getGridDivisions(); WorkspaceSettings.getInstance().addSettingsListener(settingsUpdateHandler); new DropTarget(this, new BandDndHandler(this)); renderContext.getZoomModel().addZoomModelListener(repaintHandler); renderContext.getReportDefinition().addReportModelListener(new DragAbortReportModelListener()); addMouseListener(new MouseEditorActionHandler()); addKeyListener(new KeyboardElementMoveHandler()); selectionStateHandler = new SelectionStateHandler(); designerContext.addPropertyChangeListener(ReportDesignerContext.SELECTION_WAITING_PROPERTY, selectionStateHandler); focusHandler = new RequestFocusHandler(); addMouseListener(focusHandler); KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("permanentFocusOwner", focusHandler); // NON-NLS this.selectionHandler = new MouseSelectionHandler(); addMouseListener(selectionHandler); addMouseMotionListener(selectionHandler); this.changeHandler = new RootBandChangeHandler(); this.selectionModelListener = new SelectionModelListener(); renderContext.getSelectionModel().addReportSelectionListener(selectionModelListener); new DropTarget(this, new BandDndHandler(this)); installMouseOperationHandler(); styleResolver = new SimpleStyleResolver(true); resolvedStyle = new ResolverStyleSheet(); renderContext.getReportDefinition().addReportModelListener(changeHandler); }
From source file:org.nuclos.client.main.MainController.java
private void initActions() { try {//from w w w . j av a 2 s . c om dha = new DirectHelpActionListener(); // init Actions cmdDirectHelp = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dha.actionPerformed(e); } }; cmdShowTimelimitTasks = new AbstractAction( getSpringLocaleDelegate().getMessage("miShowTimelimitTasks", "Fristen anzeigen"), Icons.getInstance().getIconTabTimtlimit()) { @Override public void actionPerformed(ActionEvent e) { MainController.this.getTaskController().getTimelimitTaskController().cmdShowTimelimitTasks(); } @Override public boolean isEnabled() { return getSecurityCache().isActionAllowed(Actions.ACTION_TIMELIMIT_LIST); } }; cmdShowPersonalTasks = new AbstractAction( getSpringLocaleDelegate().getMessage("miShowPersonalTasks", "Meine Aufgaben anzeigen"), Icons.getInstance().getIconTabTask()) { @Override public void actionPerformed(ActionEvent e) { MainController.this.getTaskController().getPersonalTaskController().cmdShowPersonalTasks(); } @Override public boolean isEnabled() { return getSecurityCache().isActionAllowed(Actions.ACTION_TASKLIST); } }; cmdShowPersonalSearchFilters = new AbstractAction( getSpringLocaleDelegate().getMessage("ExplorerPanel.3", "Meine Suchfilter anzeigen"), Icons.getInstance().getIconFilter16()) { @Override public void actionPerformed(ActionEvent e) { MainController.this.getExplorerController().cmdShowPersonalSearchFilters(); } }; cmdChangePassword = new AbstractAction() { private Boolean enabled; @Override public void actionPerformed(ActionEvent evt) { ChangePasswordPanel cpp = new ChangePasswordPanel(true, "", false); boolean result = cpp.showInDialog(getFrame(), new ChangePasswordPanel.ChangePasswordDelegate() { @Override public void changePassword(String oldPw, String newPw) throws CommonBusinessException { RemoteAuthenticationManager ram = SpringApplicationContextHolder .getBean(RemoteAuthenticationManager.class); ram.changePassword(sUserName, oldPw, newPw); getNuclosRemoteServerSession().relogin(sUserName, newPw); try { MainController.this.prefs.flush(); } catch (BackingStoreException e) { LOG.fatal("actionPerformed failed: " + e, e); } LocalUserProperties props = LocalUserProperties.getInstance(); props.setUserPasswd(""); props.store(); } }); } @Override public synchronized boolean isEnabled() { if (enabled == null) { enabled = !SecurityDelegate.getInstance().isLdapAuthenticationActive() || SecurityDelegate.getInstance().isSuperUser(); } return LangUtils.defaultIfNull(enabled, Boolean.FALSE); } }; cmdOpenManagementConsole = new AbstractAction( getSpringLocaleDelegate().getMessage("miManagementConsole", "Management Console"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.158-wrench-2.png"))) { @Override public void actionPerformed(ActionEvent evt) { UIUtils.runCommand(getMainFrame(), new Runnable() { @Override public void run() { try { NuclosConsoleGui.showInFrame(getMainFrame().getHomePane().getComponentPanel()); } catch (Exception e) { LOG.error("showInFrame failed: " + e, e); } } }); } }; cmdOpenEntityWizard = new AbstractAction( getSpringLocaleDelegate().getMessage("miEntityWizard", "Entity Wizard"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.81-dashboard.png"))) { @Override public void actionPerformed(ActionEvent evt) { final MainFrameTabbedPane desktopPane = MainController.this.getHomePane(); UIUtils.runCommand(getMainFrame(), new ShowNuclosWizard.NuclosWizardRoRunnable(desktopPane)); } }; cmdOpenEventSupportManagement = new AbstractAction( getSpringLocaleDelegate().getMessage("miEventSupportManagement", "Regelmanagement"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.34-coffee.png"))) { @Override public void actionPerformed(ActionEvent evt) { final MainFrameTabbedPane desktopPane = MainController.this.getHomePane(); UIUtils.runCommand(getMainFrame(), new EventSupportManagementController.NuclosESMRunnable(desktopPane)); } }; cmdOpenCustomComponentWizard = new AbstractAction( getSpringLocaleDelegate().getMessage("miResPlanWizard", "Ressourcenplanung"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.83-calendar.png"))) { @Override public void actionPerformed(final ActionEvent evt) { UIUtils.runCommand(getMainFrame(), new Runnable() { @Override public void run() { try { CustomComponentWizard.run(); } catch (Exception e) { LOG.error("CustomComponentWizard failed: " + e, e); } } }); } }; cmdOpenRelationEditor = new AbstractAction( getSpringLocaleDelegate().getMessage("miRelationEditor", "Relationeneditor"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.55-network.png"))) { @Override public void actionPerformed(final ActionEvent evt) { UIUtils.runCommand(getMainFrame(), new Runnable() { @Override public void run() { try { final CollectControllerFactorySingleton factory = CollectControllerFactorySingleton .getInstance(); Collection<MasterDataVO> colRelation = MasterDataDelegate.getInstance() .getMasterData(NuclosEntity.ENTITYRELATION.getEntityName()); EntityRelationShipCollectController result = factory .newEntityRelationShipCollectController(MainController.this.getFrame(), null); if (colRelation.size() > 0) { MasterDataVO vo = colRelation.iterator().next(); result.runViewSingleCollectableWithId(vo.getId()); } else { result.runNew(); } } catch (/* CommonBusiness */ Exception e1) { LOG.error("actionPerformed " + evt + ": " + e1); } } }); } }; cmdOpenRelationEditor = new AbstractAction( getSpringLocaleDelegate().getMessage("miRelationEditor", "Relationeneditor"), MainFrame.resizeAndCacheTabIcon(NuclosResourceCache.getNuclosResourceIcon( "org.nuclos.client.resource.icon.glyphish-blue.55-network.png"))) { @Override public void actionPerformed(final ActionEvent evt) { UIUtils.runCommand(getMainFrame(), new Runnable() { @Override public void run() { try { final CollectControllerFactorySingleton factory = CollectControllerFactorySingleton .getInstance(); Collection<MasterDataVO> colRelation = MasterDataDelegate.getInstance() .getMasterData(NuclosEntity.ENTITYRELATION.getEntityName()); EntityRelationShipCollectController result = factory .newEntityRelationShipCollectController(MainController.this.getFrame(), null); if (colRelation.size() > 0) { MasterDataVO vo = colRelation.iterator().next(); result.runViewSingleCollectableWithId(vo.getId()); } else { result.runNew(); } } catch (/* CommonBusiness */ Exception e1) { LOG.error("actionPerformed " + evt + ": " + e1); } } }); } }; cmdOpenSettings = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cmdOpenSettings(); } }; cmdRefreshClientCaches = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { UIUtils.runCommandLater(getFrame(), new CommonRunnable() { @Override public void run() throws CommonBusinessException { invalidateAllClientCaches(); JOptionPane.showMessageDialog(getFrame(), getSpringLocaleDelegate().getMessage( "MainController.3", "Die folgenden Aktionen wurden erfolgreich durchgef\u00fchrt:\n" + "Caches aktualisiert: MasterDataCache, SecurityCache, AttributeCache, GenericObjectLayoutCache, GeneratorCache, MetaDataCache, ResourceCache, SearchFilterCache.\n" + "Men\u00fcs aktualisiert.")); } }); } }; cmdSelectAll = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { // select all rows in the Result panel of the current CollectController (if any): final MainFrameTab ifrm = (MainFrameTab) MainController.this.frm.getHomePane() .getSelectedComponent(); if (ifrm != null) { final CollectController<?> ctl = getControllerForTab(ifrm); if (ctl != null && ctl.getCollectState().getOuterState() == CollectStateModel.OUTERSTATE_RESULT) { ctl.getResultTable().selectAll(); } else if (ctl != null && ((ctl.getCollectState().getOuterState() == CollectStateModel.OUTERSTATE_DETAILS) || ctl.getCollectState() .getOuterState() == CollectStateModel.OUTERSTATE_SEARCH)) { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager() .getPermanentFocusOwner(); if (focusOwner instanceof JTextComponent) { ((JTextComponent) focusOwner).selectAll(); } } } } }; cmdHelpContents = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { WikiController.getInstance().openURLinBrowser(ClientParameterProvider.getInstance() .getValue(ClientParameterProvider.KEY_WIKI_STARTPAGE)); } }; cmdShowAboutDialog = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { cmdShowAboutDialog(); } }; cmdShowProjectReleaseNotes = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { new ReleaseNotesController().showReleaseNotes(ApplicationProperties.getInstance().getName()); } }; cmdShowNuclosReleaseNotes = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { ReleaseNotesController.openReleaseNotesInBrowser(); } }; cmdWindowClosing = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cmdWindowClosing(new ResultListener<Boolean>() { @Override public void done(Boolean result) { } }); } }; cmdLogoutExit = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cmdLogoutExit(); } }; cmdExecuteRport = createEntityAction(NuclosEntity.REPORTEXECUTION); } catch (Throwable e) { LOG.fatal("Creating MainController failed, this is fatal: " + e.toString(), e); throw new ExceptionInInitializerError(e); } }
From source file:vista.ventas.DiagOrdenesDeCompra.java
private void eventosDeTeclas() { KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventDispatcher(new KeyEventDispatcher() { public boolean dispatchKeyEvent(KeyEvent e) { if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow().getClass() .getSimpleName().equals("DiagOrdenesDeCompra")) { if (e.getID() == KeyEvent.KEY_PRESSED) { if (e.getKeyCode() == KeyEvent.VK_F3) { agregarArticulo(); calcularTotal(); }//from ww w. j av a 2 s . c o m if (e.getKeyCode() == KeyEvent.VK_F7) { realizarVenta(); } if (e.getKeyCode() == KeyEvent.VK_F4) { cerrar(); } if (e.getKeyCode() == KeyEvent.VK_DELETE && tblArticulos.getSelectedRow() != -1) { quitarArticuloLista(); } } } return false; } }); }