List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:org.languagetool.gui.ConfigurationDialog.java
@NotNull private MouseAdapter getMouseAdapter() { return new MouseAdapter() { private void handlePopupEvent(MouseEvent e) { JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; }//w w w. j a va 2 s.c om DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); TreePath[] paths = tree.getSelectionPaths(); boolean isSelected = false; if (paths != null) { for (TreePath selectionPath : paths) { if (selectionPath.equals(path)) { isSelected = true; } } } if (!isSelected) { tree.setSelectionPath(path); } if (node.isLeaf()) { JPopupMenu popup = new JPopupMenu(); JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu")); aboutRuleMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent(); Rule rule = node.getRule(); Language lang = config.getLanguage(); if (lang == null) { lang = Languages.getLanguageForLocale(Locale.getDefault()); } Tools.showRuleInfoDialog(tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, rule.getUrl(), messages, lang.getShortCodeWithCountryAndVariant()); } }); popup.add(aboutRuleMenuItem); popup.show(tree, e.getX(), e.getY()); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } }; }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
private JPopupMenu createFilterTablePopUp() { final JPopupMenu result = new JPopupMenu(); JMenuItem excludeSelectedHosts = new JMenuItem("Exclude selected hosts", KeyEvent.VK_U); result.add(excludeSelectedHosts);/*from w ww . jav a2 s .com*/ excludeSelectedHosts.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).setSelection(selectedRows, false); } }); JMenuItem includeSelectedHost = new JMenuItem("Include selected hosts", KeyEvent.VK_I); result.add(includeSelectedHost); includeSelectedHost.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).setSelection(selectedRows, true); } }); result.addSeparator(); JMenuItem deleteSelectedHost = new JMenuItem("Deleted selected hosts", KeyEvent.VK_D); result.add(deleteSelectedHost); deleteSelectedHost.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).removeRows(selectedRows); } }); return result; }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
/** * Create Filter Button Panel.//w ww. j a v a2s. c om * * @return filter button panel */ protected JPanel createFilterButtonPanel() { JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(createSimpleTextButton("Unselect All", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { for (EndPoint each : connectionFilter.getConnectionEndPoints()) { connectionFilter.setFilter(each, true); } } })); DropDownButton resetDropDownButton = createSimpleDropDownButton("Reset", null); panel.add(resetDropDownButton); JPopupMenu menu = new JPopupMenu(); menu.add(createMenuItem("Clear all recording", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { messageBus.getPublisher(Topics.RESET) .propertyChange(new PropertyChangeEvent(RecordingControlPanel.this, "RESET", null, null)); connectionFilter.makeZeroCount(); } })); menu.add(createMenuItem("Clear all filters", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { connectionFilter.reset(); } })); menu.add(createMenuItem("Clear connection count", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { connectionFilter.makeZeroCount(); } })); menu.add(createMenuItem("Reset browser cache", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { BrowserServices browserServices = BrowserServices.getInstance(); for (BrowserType type : BrowserFactoryEx.getSupportedBrowser()) { clearCacheIfSupported(browserServices, type); } } private void clearCacheIfSupported(BrowserServices browserServices, BrowserType type) { if (type.isSupported()) { try { browserServices.getCacheStorage(type).clearCache(); } catch (Exception e) { NoOp.noOp(); } } } })); menu.add(createMenuItem("Reset cookies", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { BrowserServices browserServices = BrowserServices.getInstance(); for (BrowserType type : BrowserFactoryEx.getSupportedBrowser()) { clearCookieIfSupported(browserServices, type); } } private void clearCookieIfSupported(BrowserServices browserServices, BrowserType type) { if (type.isSupported()) { try { HttpCookieStorage cookieStorage = browserServices.getCookieStorage(type); List<HttpCookie> cookies = cookieStorage.getCookies(); cookieStorage.deleteCookie(cookies); } catch (Exception e) { NoOp.noOp(); } } } })); resetDropDownButton.setMenu(menu); return panel; }
From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java
private void initJResPlan() { resPlan = new JResPlanComponent<Collectable, Date, Collectable, Collectable>(resPlanModel, timeModel); resPlan.getTimelineHeader().setCategoryModel(timeGranularityModel.getSelectedItem()); resPlan.addMouseListener(new AbstractJPopupMenuListener() { @Override/*from www . j a v a 2s . co m*/ protected JPopupMenu getJPopupMenu(MouseEvent evt) { JPopupMenu popupMenu = new JPopupMenu(); Point pt = evt.getPoint(); Area<Collectable, Date> blankSelection = resPlan.getSelectedBlankArea(); if (blankSelection != null) { popupMenu.add(new AddAction(blankSelection.getResource(), blankSelection.getInterval())); } else { popupMenu.add(new AddAction(resPlan.getResourceAt(pt), resPlan.getTimeIntervalAt(pt))); } List<Collectable> selectedEntries = selectEntriesForEvent(pt); List<Collectable> selectedRelations = selectRelationsForEvent(pt); if (resPlan.isEditable() && (!selectedEntries.isEmpty() || !selectedRelations.isEmpty())) { JMenuItem menuItem = popupMenu.add(removeAction); boolean enabled = true; for (Collectable clct : selectedEntries) { if (!resPlanModel.isRemoveEntryAllowed(clct)) { enabled = false; break; } } for (Collectable clct : selectedRelations) { if (!resPlanModel.isRemoveRelationAllowed(clct)) { enabled = false; break; } } // Note: just change the state of the menu item (and leave the action as is) menuItem.setEnabled(enabled); } if (!selectedEntries.isEmpty() || !selectedRelations.isEmpty()) { popupMenu.add(detailsAction); } if (selectedEntries.size() == 1 && resPlanModel.getRelationEntity() != null && resPlanModel.isCreateRelationAllowed()) { popupMenu.addSeparator(); if (resPlan.getRelateBegin() != null) { Collectable to = selectedEntries.get(0); if (to != resPlan.getRelateBegin()) { popupMenu.add(relateFinishAction); } } popupMenu.add(relateBeginAction); } return popupMenu; } private List<Collectable> selectEntriesForEvent(Point pt) { List<Collectable> selection = resPlan.getSelectedEntries(); Collectable entryAt = resPlan.getEntryAt(pt); if (entryAt != null && (selection.isEmpty() || !selection.contains(entryAt))) { selection = Collections.singletonList(entryAt); resPlan.setSelectedEntries(selection); } return selection; } private List<Collectable> selectRelationsForEvent(Point pt) { List<Collectable> selection = resPlan.getSelectedRelations(); Collectable relAt = resPlan.getRelationAt(pt); if (relAt != null && (selection.isEmpty() || !selection.contains(relAt))) { selection = Collections.singletonList(relAt); resPlan.setSelectedRelations(selection); } return selection; } @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Collectable clct = resPlan.getEntryAt(evt.getPoint()); if (clct == null) { clct = resPlan.getRelationAt(evt.getPoint()); if (clct != null) { runDetailsCollectable(resPlanModel.getRelationEntity().getEntityName(), clct); } } else { runDetailsCollectable(resPlanModel.getEntryEntity().getEntityName(), clct); } evt.consume(); } } }); resPlan.getResourceHeader().addMouseListener(new AbstractJPopupMenuListener() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint()); runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct); evt.consume(); } } @Override protected JPopupMenu getJPopupMenu(MouseEvent evt) { final Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint()); if (clct != null) { JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new AbstractAction( SpringLocaleDelegate.getInstance().getText("nuclos.resplan.action.showDetails")) { @Override public void actionPerformed(ActionEvent e) { runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct); } }); return popupMenu; } return null; } }); Date start = DateUtils.addDays(DateUtils.getPureDate(new Date()), -5); Date end = DateUtils.addDays(start, 30); resPlan.setTimeHorizon(new Interval<Date>(start, end)); }
From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
protected JPopupMenu createPopupMenu() { JPopupMenu pop = new JPopupMenu(); JMenuItem i1 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.16", "neue Entit\u00e4t")); i1.addActionListener(new ActionListener() { @Override//from ww w . j a v a 2 s . c o m public void actionPerformed(ActionEvent e) { int x = xPos; int y = yPos; mxGeometry mxgeo = new mxGeometry(x, y, 100, 80); mxgeo.setSourcePoint(new mxPoint(100, 100)); mxgeo.setTargetPoint(new mxPoint(150, 150)); mxCell cell = new mxCell("", mxgeo, ENTITYSTYLE); cell.setVertex(true); mxCell cellRoot = (mxCell) graphComponent.getGraph().getModel().getRoot(); mxCell cellContainer = (mxCell) cellRoot.getChildAt(0); int childcount = cellContainer.getChildCount(); getGraphModel().add(cellContainer, cell, childcount); getGraphComponent().refresh(); } }); JMenuItem i3 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.8", "zoom in")); i3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { graphComponent.zoomIn(); } }); JMenuItem i4 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.9", "zoom out")); i4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { graphComponent.zoomOut(); } }); pop.add(i1); pop.addSeparator(); pop.add(i3); pop.add(i4); return pop; }
From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
protected JPopupMenu createRelationPopupMenu(final mxCell cell, boolean delete, boolean objectGeneration) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); JPopupMenu pop = new JPopupMenu(); JMenuItem i1 = new JMenuItem( localeDelegate.getMessage("nuclos.entityrelation.editor.10", "Bezug zu Stammdaten bearbeiten")); i1.addActionListener(new ActionListener() { @Override//from w w w .jav a2s . c o m public void actionPerformed(ActionEvent e) { editMasterdataRelation(cell); } }); JMenuItem i2 = new JMenuItem( localeDelegate.getMessage("nuclos.entityrelation.editor.11", "Unterfomularbezug bearbeiten")); i2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editSubformRelation(cell); } }); JMenuItem i4 = new JMenuItem( localeDelegate.getMessage("nuclos.entityrelation.editor.12", "Verbindung l\u00f6sen")); i4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int opt = JOptionPane.showConfirmDialog(mainPanel, localeDelegate.getMessage( "nuclos.entityrelation.editor.7", "M\u00f6chten Sie die Verbindung wirklich l\u00f6sen?")); if (opt != 0) { return; } mxCell cellSource = (mxCell) cell.getSource(); if (cellSource != null && cellSource.getValue() instanceof EntityMetaDataVO) { EntityMetaDataVO metaSource = (EntityMetaDataVO) cellSource.getValue(); if (cell.getValue() instanceof EntityFieldMetaDataVO) { EntityFieldMetaDataVO voField = (EntityFieldMetaDataVO) cell.getValue(); voField.flagRemove(); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(voField); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(metaSource, toList); if (mpRemoveRelation.containsKey(metaSource)) { mpRemoveRelation.get(metaSource).add(voField); } else { Set<EntityFieldMetaDataVO> s = new HashSet<EntityFieldMetaDataVO>(); s.add(voField); mpRemoveRelation.put(metaSource, s); } } else if (cell.getValue() != null && cell.getValue() instanceof String) { } } mxGraphModel model = (mxGraphModel) graphComponent.getGraph().getModel(); model.remove(cell); EntityRelationshipModelEditPanel.this.fireChangeListenEvent(); } }); JMenuItem i5 = new JMenuItem( localeDelegate.getMessage("nuclos.entityrelation.editor.13", "Arbeitsschritt bearbeiten")); i5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { mxCell cellSource = (mxCell) cell.getSource(); mxCell cellTarget = (mxCell) cell.getTarget(); EntityMetaDataVO sourceModule = (EntityMetaDataVO) cellSource.getValue(); EntityMetaDataVO targetModule = (EntityMetaDataVO) cellTarget.getValue(); String sSourceModule = sourceModule.getEntity(); String sTargetModule = targetModule.getEntity(); boolean blnFound = false; for (MasterDataVO voGeneration : MasterDataCache.getInstance() .get(NuclosEntity.GENERATION.getEntityName())) { String sSource = (String) voGeneration.getField("sourceModule"); String sTarget = (String) voGeneration.getField("targetModule"); if (org.apache.commons.lang.StringUtils.equals(sSource, sSourceModule) && org.apache.commons.lang.StringUtils.equals(sTarget, sTargetModule)) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); gcc.runViewSingleCollectableWithId(voGeneration.getId()); blnFound = true; break; } } if (!blnFound) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); Map<String, Object> mp = new HashMap<String, Object>(); mp.put("sourceModule", sSourceModule); mp.put("sourceModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sSourceModule).getId().intValue())); mp.put("targetModule", sTargetModule); mp.put("targetModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sTargetModule).getId().intValue())); MasterDataVO vo = new MasterDataVO(NuclosEntity.GENERATION.getEntityName(), null, null, null, null, null, null, mp); gcc.runWithNewCollectableWithSomeFields(vo); } } catch (NuclosBusinessException e1) { LOG.warn("actionPerformed failed: " + e1, e1); } catch (CommonPermissionException e1) { LOG.warn("actionPerformed failed: " + e1, e1); } catch (CommonFatalException e1) { LOG.warn("actionPerformed failed: " + e1, e1); } catch (CommonBusinessException e1) { LOG.warn("actionPerformed failed: " + e1, e1); } } }); if (cell.getStyle() != null && cell.getStyle().indexOf(OPENARROW) >= 0) { i1.setSelected(true); pop.add(i1); } else if (cell.getStyle() != null && cell.getStyle().indexOf(DIAMONDARROW) >= 0) { i2.setSelected(true); pop.add(i2); } if (objectGeneration) { //pop.addSeparator(); pop.add(i5); } if (delete) { pop.addSeparator(); pop.add(i4); } return pop; }
From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
protected JPopupMenu createPopupMenuEntity(final mxCell cell, boolean newCell) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); JPopupMenu pop = new JPopupMenu(); JMenuItem i1 = new JMenuItem( localeDelegate.getMessage("nuclos.entityrelation.editor.14", "Symbol l\u00f6schen")); i1.addActionListener(new ActionListener() { @Override//from w w w. j av a2 s . com public void actionPerformed(ActionEvent e) { mxGraphModel model = (mxGraphModel) graphComponent.getGraph().getModel(); int iEdge = cell.getEdgeCount(); for (int i = 0; i < iEdge; i++) { mxCell cellRelation = (mxCell) cell.getEdgeAt(0); model.remove(cellRelation); } model.remove(cell); fireChangeListenEvent(); } }); if (!newCell) pop.add(i1); if (cell.getStyle() == null || !(cell.getStyle().indexOf(ENTITYSTYLE) >= 0)) { return pop; } JMenuItem iWizard = new JMenuItem( localeDelegate.getMessage("nuclos.entityrelation.editor.15", "Wizard \u00f6ffnen")); iWizard.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (cell.getValue() != null && cell.getValue() instanceof EntityMetaDataVO) { String sValue = ((EntityMetaDataVO) cell.getValue()).getEntity(); if (sValue.length() > 0) { try { final EntityMetaDataVO vo = MetaDataClientProvider.getInstance().getEntity(sValue); new ShowNuclosWizard.NuclosWizardEditRunnable(false, mf.getHomePane(), vo).run(); } catch (Exception e1) { // neue Entity LOG.info("actionPerformed: " + e1 + " (new entity?)"); } } } } }); if (!newCell) { //pop.addSeparator(); pop.add(iWizard); } else { JMenuItem iNew = new JMenuItem( localeDelegate.getMessage("nuclos.entityrelation.editor.16", "neue Entit\u00e4t")); iNew.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (cell.getValue() != null && cell.getValue() instanceof EntityMetaDataVO) { final EntityMetaDataVO voTMP = (EntityMetaDataVO) cell.getValue(); final EntityMetaDataVO vo = MetaDataClientProvider.getInstance() .getEntity(voTMP.getEntity()); new ShowNuclosWizard.NuclosWizardEditRunnable(false, mf.getHomePane(), vo).run(); } else { cell.setValue( localeDelegate.getMessage("nuclos.entityrelation.editor.16", "neue Entit\u00e4t")); mxGraph graph = graphComponent.getGraph(); graph.refresh(); } } }); pop.add(iNew); } //pop.addSeparator(); Collection<EntityMetaDataVO> colMetaVO = MetaDataClientProvider.getInstance().getAllEntities(); List<EntityMetaDataVO> lst = new ArrayList<EntityMetaDataVO>(colMetaVO); Collections.sort(lst, new Comparator<EntityMetaDataVO>() { @Override public int compare(EntityMetaDataVO o1, EntityMetaDataVO o2) { return o1.getEntity().toLowerCase().compareTo(o2.getEntity().toLowerCase()); } }); for (final EntityMetaDataVO vo : lst) { if (vo.getEntity().startsWith("nuclos_")) continue; JCheckBoxMenuItem menu = new JCheckBoxMenuItem(vo.getEntity()); menu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JMenuItem item = (JMenuItem) e.getSource(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { cell.setValue(vo); graphComponent.repaint(); fireChangeListenEvent(); } }); } }); if (cell.getValue() != null && cell.getValue() instanceof EntityMetaDataVO) { EntityMetaDataVO sValue = (EntityMetaDataVO) cell.getValue(); if (vo.getEntity().equals(sValue.getEntity())) { menu.setSelected(true); } } //pop.add(menu); } return pop; }
From source file:org.nuclos.client.relation.MyGraphModel.java
public JPopupMenu createRelationPopupMenu(final mxCell cell, boolean delete) { final JPopupMenu pop = new JPopupMenu(); JMenuItem i1 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.1", "Bezug zu Stammdaten")); i1.addActionListener(new ActionListener() { @Override/*from w w w.j a va2s. co m*/ public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OPEN); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); RelationAttributePanel panel = new RelationAttributePanel(RelationAttributePanel.TYPE_ENTITY); mxCell target = (mxCell) cell.getTarget(); mxCell source = (mxCell) cell.getSource(); panel.setEntity((EntityMetaDataVO) target.getValue()); panel.setEntitySource((EntityMetaDataVO) source.getValue()); EntityMetaDataVO voSource = (EntityMetaDataVO) source.getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) target.getValue(); panel.setEntityFields( MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voSource.getEntity()).values()); double cellsDialog[][] = { { 5, TableLayout.PREFERRED, 5 }, { 5, TableLayout.PREFERRED, 5 } }; JDialog dia = new JDialog(mf); dia.setLayout(new TableLayout(cellsDialog)); dia.setTitle(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.10", "Bezug zu Stammdaten bearbeiten")); dia.setLocationRelativeTo(editPanel); dia.add(panel, "1,1"); dia.setModal(true); panel.setDialog(dia); dia.pack(); dia.setVisible(true); if (panel.getState() == 1) { EntityFieldMetaDataVO vo = panel.getField(); cell.setValue(vo); mpTransation.put(vo, panel.getTranslation().getRows()); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(panel.getTranslation().getRows()); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSource, toList); editPanel.loadReferenz(); } else { remove(cell); } } }); final JMenuItem i2 = new JMenuItem(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.3", "Bezug zu Vorg\u00e4ngen (Unterformularbezug)")); i2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_DIAMOND); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); mxCell target = (mxCell) cell.getTarget(); mxCell source = (mxCell) cell.getSource(); EntityMetaDataVO voSource = (EntityMetaDataVO) source.getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) target.getValue(); String sFieldName = null; boolean blnNotSet = true; while (blnNotSet) { sFieldName = JOptionPane.showInputDialog(editPanel, getSpringLocaleDelegate().getMessage( "nuclos.entityrelation.editor.1", "Bitte geben Sie den Namen des Feldes an!")); if (sFieldName == null || sFieldName.length() < 1) { MyGraphModel.this.remove(cell); return; } else if (sFieldName != null) { blnNotSet = false; } } EntityFieldMetaDataVO vo = new EntityFieldMetaDataVO(); vo.setModifiable(true); vo.setLogBookTracking(false); vo.setReadonly(false); vo.setShowMnemonic(true); vo.setInsertable(true); vo.setSearchable(true); vo.setNullable(false); vo.setUnique(true); vo.setDataType("java.lang.String"); List<TranslationVO> lstTranslation = new ArrayList<TranslationVO>(); for (LocaleInfo voLocale : LocaleDelegate.getInstance().getAllLocales(false)) { String sLocaleLabel = voLocale.language; Integer iLocaleID = voLocale.localeId; String sCountry = voLocale.title; Map<String, String> map = new HashMap<String, String>(); TranslationVO translation = new TranslationVO(iLocaleID, sCountry, sLocaleLabel, map); for (String sLabel : labels) { translation.getLabels().put(sLabel, sFieldName); } lstTranslation.add(translation); } vo.setForeignEntity(voTarget.getEntity()); vo.setField(sFieldName); vo.setDbColumn("INTID_" + sFieldName); cell.setValue(vo); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(lstTranslation); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSource, toList); editPanel.loadReferenz(); } }); final JMenuItem i4 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.5", "Arbeitsschritt")); i4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OVAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); try { mxCell cellSource = (mxCell) cell.getSource(); mxCell cellTarget = (mxCell) cell.getTarget(); EntityMetaDataVO sourceModule = (EntityMetaDataVO) cellSource.getValue(); EntityMetaDataVO targetModule = (EntityMetaDataVO) cellTarget.getValue(); String sSourceModule = sourceModule.getEntity(); String sTargetModule = targetModule.getEntity(); boolean blnFound = false; for (MasterDataVO voGeneration : MasterDataCache.getInstance() .get(NuclosEntity.GENERATION.getEntityName())) { String sSource = (String) voGeneration.getField("sourceModule"); String sTarget = (String) voGeneration.getField("targetModule"); if (org.apache.commons.lang.StringUtils.equals(sSource, sSourceModule) && org.apache.commons.lang.StringUtils.equals(sTarget, sTargetModule)) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); gcc.runViewSingleCollectableWithId(voGeneration.getId()); blnFound = true; break; } } if (!blnFound) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); Map<String, Object> mp = new HashMap<String, Object>(); mp.put("sourceModule", sSourceModule); mp.put("sourceModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sSourceModule).getId().intValue())); mp.put("targetModule", sTargetModule); mp.put("targetModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sTargetModule).getId().intValue())); MasterDataVO vo = new MasterDataVO(NuclosEntity.GENERATION.getEntityName(), null, null, null, null, null, null, mp); gcc.runWithNewCollectableWithSomeFields(vo); } } catch (NuclosBusinessException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonPermissionException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonFatalException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonBusinessException e1) { LOG.warn("actionPerformed: " + e1); } } }); JMenuItem i5 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.12", "Verbindung l\u00f6sen")); i5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mxGraphModel model = (mxGraphModel) graphComponent.getGraph().getModel(); model.remove(cell); } }); pop.add(i1); pop.add(i2); //pop.add(i3); pop.add(i4); if (delete) { pop.addSeparator(); pop.add(i5); } return pop; }
From source file:org.nuclos.client.relation.MyGraphModel.java
protected JPopupMenu createPopupMenuEntity(final mxCell cell, boolean newCell) { JPopupMenu pop = new JPopupMenu(); JMenuItem i1 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.14", "Symbol l\u00f6schen")); i1.addActionListener(new ActionListener() { @Override/*from ww w . j a va 2 s . c o m*/ public void actionPerformed(ActionEvent e) { mxGraphModel model = (mxGraphModel) graphComponent.getGraph().getModel(); model.remove(cell); } }); if (!newCell) pop.add(i1); if (cell.getStyle() == null || !(cell.getStyle().indexOf(ENTITYSTYLE) >= 0)) { return pop; } JMenuItem iWizard = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.15", "Wizard \u00f6ffnen")); iWizard.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (cell.getValue() != null && cell.getValue() instanceof EntityMetaDataVO) { String sValue = ((EntityMetaDataVO) cell.getValue()).getEntity(); if (sValue.length() > 0) { final EntityMetaDataVO vo = MetaDataClientProvider.getInstance().getEntity(sValue); new ShowNuclosWizard.NuclosWizardEditRunnable(false, mf.getHomePane(), vo).run(); } } } }); if (!newCell) { pop.addSeparator(); pop.add(iWizard); } else { JMenuItem iNew = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.16", "neue Entit\u00e4t")); iNew.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (cell.getValue() != null && cell.getValue() instanceof EntityMetaDataVO) { String sValue = ((EntityMetaDataVO) cell.getValue()).getEntity(); if (sValue.length() > 0) { try { final EntityMetaDataVO vo = MetaDataClientProvider.getInstance().getEntity(sValue); new ShowNuclosWizard.NuclosWizardEditRunnable(false, mf.getHomePane(), vo).run(); } catch (CommonFatalException e1) { // do noting here Entity does not exist LOG.warn("actionPerformed: " + e1 + "(entity does not exist?)"); } } } else { cell.setValue(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.16", "neue Entit\u00e4t")); mxGraph graph = graphComponent.getGraph(); graph.refresh(); } } }); pop.add(iNew); } return pop; }
From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java
/** * Subclasses may add menu items to the default popup menu or provide their own completely. * @return a new popup menu for this component. * @see JPopupMenuFactory/* ww w . j a v a2 s .c o m*/ */ @Override public JPopupMenu newJPopupMenu() { JPopupMenu result; if (isSearchComponent() && hasComparisonOperator()) { result = newComparisonOperatorPopupMenu(); } else { // regular popup menu: result = new JPopupMenu(); if (isMultiEditable()) { result.add(newNoChangeEntry()); result.add(newClearEntry()); } if (getEntityField().isReferencing()) { if (result.getComponentCount() > 0) { result.addSeparator(); } result.add(newShowDetailsEntry()); result.add(newInsertEntry()); } if (result.getComponentCount() == 0) { result = null; } } return result; }