public boolean canBeEnabled() { final ModeController modeController = Controller.getCurrentModeController(); if (modeController == null) { return false; } boolean isEncryptedNode = false; boolean isOpened = false; final MapController mapController = modeController.getMapController(); final NodeModel selectedNode = mapController.getSelectedNode(); if (selectedNode != null) { if (modeController.canEdit()) { return true; } final EncryptionModel enode = EncryptionModel.getModel(selectedNode); if (enode != null) { isEncryptedNode = true; isOpened = enode.isAccessible(); } } return (isEncryptedNode && !isOpened); }
void createViewer(final ExternalResource model, final NodeView view) { final JComponent viewer = createViewer(view.getMap().getModel(), model); if (imagePopupMenu == null) { imagePopupMenu = new ExternalImagePopupMenu(); } viewer.setBorder(VIEWER_BORDER_INSTANCE); final Set<NodeView> viewers = model.getViewers(); viewers.add(view); viewer.setBounds(viewer.getX() - 5, viewer.getY() - 5, viewer.getWidth() + 15, viewer.getHeight() + 15); view.addContent(viewer, VIEWER_POSITION); if(view.getMap().getModeController().canEdit()){ final DropTarget dropTarget = new DropTarget(viewer, DTL); dropTarget.setActive(true); } if(view.isShortened()) viewer.setVisible(false); else { viewer.revalidate(); viewer.repaint(); } }
private void addTableListeners() { if (!getMapView().getModeController().canEdit()) { return; } if (attributeTable != null) { if (AttributeView.tablePopupMenu == null) { AttributeView.tablePopupMenu = new AttributePopupMenu(); } getAttributes().getLayout().addColumnWidthChangeListener(attributeTable); attributeTable.addMouseListener(AttributeView.tablePopupMenu); tableHeader.addMouseListener(AttributeView.tablePopupMenu); if (tableSelectionListener != null) { attributeTable.getSelectionModel().addListSelectionListener(tableSelectionListener); attributeTable.getColumnModel().getSelectionModel().addListSelectionListener(tableSelectionListener); } } else { getAttributes().addTableModelListener(this); } }
if(modeController.canEdit(getModel())) { final IUserInputListenerFactory userInputListenerFactory = modeController .getUserInputListenerFactory();
private void removeListeners() { getAttributeRegistry().removeChangeListener(this); if (!getMapView().getModeController().canEdit()) { return; } if (attributeTable != null) { getAttributes().getLayout().removeColumnWidthChangeListener(attributeTable); attributeTable.getModel().removeTableModelListener(attributeTable); attributeTable.removeMouseListener(AttributeView.tablePopupMenu); tableHeader.removeMouseListener(AttributeView.tablePopupMenu); AttributeView.tablePopupMenu = null; } else { getAttributes().removeTableModelListener(this); } }
AttributeTable(final AttributeView attributeView) { super(); this.attributeView = attributeView; initializeTooltipManager(attributeView); addMouseListener(AttributeTable.cursorUpdater); addMouseMotionListener(AttributeTable.cursorUpdater); if (attributeView.getMapView().getModeController().canEdit()) { tableHeader.addMouseListener(AttributeTable.componentListener); } else { tableHeader.setResizingAllowed(false); } setModel(attributeView.getCurrentAttributeTableModel()); setAutoResizeMode(JTable.AUTO_RESIZE_OFF); getTableHeader().setReorderingAllowed(false); setCellSelectionEnabled(true); getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); putClientProperty("JTable.autoStartsEdit", Boolean.FALSE); adaptActionMap(this); setShowGrid(true); }