/** * <code>doMouseClick</code> - For Constraint Network View, Mouse-left opens/closes variableNode * to show constraintNodes * * @param modifiers - <code>int</code> - * @param dc - <code>Point</code> - * @param vc - <code>Point</code> - * @param view - <code>JGoView</code> - * @return - <code>boolean</code> - */ public boolean doMouseClick(int modifiers, Point docCoords, Point viewCoords, JGoView view) { if (variable == null) { return false; } JGoObject obj = view.pickDocObject(docCoords, false); // System.err.println( "doMouseClick obj class " + // obj.getTopLevelObject().getClass().getName()); VariableNode variableNode = (VariableNode) obj.getTopLevelObject(); if (MouseEventOSX.isMouseLeftClick(modifiers, PlanWorks.isMacOSX())) { if ((!hasZeroConstraints) && (partialPlanView instanceof ConstraintNetworkView)) { if (!areNeighborsShown()) { // System.err.println // ( "doMouseClick: Mouse-L show constraint/token nodes of variable id " + // variableNode.getVariable().getId()); addVariableNodeContainersAndConstraints(this, (ConstraintNetworkView) partialPlanView); setAreNeighborsShown(true); } else { // System.err.println // ( "doMouseClick: Mouse-L hide constraint/token nodes of variable id " + // variableNode.getVariable().getId()); removeVariableNodeContainersAndConstraints(this, (ConstraintNetworkView) partialPlanView); setAreNeighborsShown(false); } return true; } } else if (MouseEventOSX.isMouseRightClick(modifiers, PlanWorks.isMacOSX())) { mouseRightPopupMenu(viewCoords); return true; } return false; } // end doMouseClick
/** * <code>doMouseClick</code> * * @param modifiers - <code>int</code> - * @param dc - <code>Point</code> - * @param vc - <code>Point</code> - * @param view - <code>JGoView</code> - * @return - <code>boolean</code> - */ public boolean doMouseClick(int modifiers, Point dc, Point vc, JGoView view) { JGoObject obj = view.pickDocObject(dc, false); if (MouseEventOSX.isMouseLeftClick(modifiers, PlanWorks.isMacOSX())) { // System.err.println( "doMouseClick obj class " + // obj.getTopLevelObject().getClass().getName()); // SlotNode slotNode = (SlotNode) obj.getTopLevelObject(); // System.err.println( "doMouseClick: slot predicate " + slotNode.getText()); // JGoSelection jGoSelection = view.getSelection(); // jGoSelection.clearSelection(); // System.err.println( "doMouseClick num: " + jGoSelection.getNumObjects()); // JGoListPosition position = jGoSelection.getFirstObjectPos(); // while (position != null) { // JGoObject object = jGoSelection.getObjectAtPos( position); // System.err.println( "doMouseClick selection obj class " + // object.getClass().getName()); // jGoSelection.toggleSelection( object); // // position = jGoSelection.getNextObjectPosAtTop( position); // // position = jGoSelection.getNextObjectPos( position); // position = jGoSelection.getFirstObjectPos(); // } return true; } else if (MouseEventOSX.isMouseRightClick(modifiers, PlanWorks.isMacOSX())) { // } return false; } // end doMouseClick
/** * <code>doBackgroundClick</code> - Mouse-Right pops up menu: * * @param modifiers - <code>int</code> - * @param docCoords - <code>Point</code> - * @param viewCoords - <code>Point</code> - */ public final void doBackgroundClick( final int modifiers, final Point docCoords, final Point viewCoords) { if (MouseEventOSX.isMouseLeftClick(modifiers, PlanWorks.isMacOSX())) { // do nothing } else if (MouseEventOSX.isMouseRightClick(modifiers, PlanWorks.isMacOSX())) { mouseRightPopupMenu(viewCoords); } } // end doBackgroundClick
/** * <code>doMouseClick</code> - * * @param modifiers - <code>int</code> - * @param docCoords - <code>Point</code> - * @param viewCoords - <code>Point</code> - * @param view - <code>JGoView</code> - * @return - <code>boolean</code> - */ public boolean doMouseClick(int modifiers, Point docCoords, Point viewCoords, JGoView view) { JGoObject obj = view.pickDocObject(docCoords, false); // System.err.println( "doMouseClick obj class " + // obj.getTopLevelObject().getClass().getName()); StepField stepField = (StepField) obj.getTopLevelObject(); if (MouseEventOSX.isMouseLeftClick(modifiers, PlanWorks.isMacOSX())) { } else if (MouseEventOSX.isMouseRightClick(modifiers, PlanWorks.isMacOSX())) { // mouseRightPopupMenu( viewCoords); // return true; } return false; } // end doMouseClick
/** * <code>hasLoadedTransactionFile</code> - for all plan steps * * @return - <code>boolean</code> - */ public boolean hasLoadedTransactionFile() { if (isTransactionFileOnDisk()) { return hasLoadedTransactionFile; } else { int maxStepNumber = getPlanDBSizeList().size() - 1; int maxTransStepNumber = MySQLDB.maxStepForTransactionsInDb(id); if (maxTransStepNumber == -1) { // no transactions in db return false; } else if (maxTransStepNumber < maxStepNumber) { JOptionPane.showMessageDialog( PlanWorks.getPlanWorks(), "Sequence " + name + ": step0 - step" + maxTransStepNumber + " (of " + maxStepNumber + ")", "Limited Transactions Available", JOptionPane.ERROR_MESSAGE); } return true; } } // end hasLoadedTransactionFile()
/** * <code>init</code> - wait for instance to become displayable, determine appropriate font * metrics, and render the JGo navigator, and slot widgets * * <p>These functions are not done in the constructor to avoid: "Cannot measure text until a * JGoView exists and is part of a visible window". called by componentShown method on the JFrame * JGoView.setVisible( true) must be completed -- use SwingWorker in constructor */ public final void init() { // wait for NavigatorView instance to become displayable if (!ViewGenerics.displayableWait(NavigatorView.this)) { closeView(this); return; } this.computeFontMetrics(this); jGoDocument = jGoView.getDocument(); jGoDocument.addDocumentListener(createDocListener()); renderInitialNode(); NavigatorViewLayout layout = new NavigatorViewLayout(jGoDocument, startTimeMSecs); layout.performLayout(); MDIInternalFrame contentFilterFrame = viewSet.getContentSpecWindow(); int contentFilterMaxY = (int) (contentFilterFrame.getLocation().getY() + contentFilterFrame.getSize().getHeight()); int delta = Math.min( ViewConstants.INTERNAL_FRAME_X_DELTA_DIV_4 * ((PartialPlanViewSet) viewSet).getNavigatorFrameCnt(), (int) (PlanWorks.getPlanWorks().getSize().getHeight() - contentFilterMaxY - (ViewConstants.MDI_FRAME_DECORATION_HEIGHT * 2))); navigatorFrame.setLocation( (ViewConstants.INTERNAL_FRAME_X_DELTA / 2) + delta, contentFilterMaxY + delta); // Rectangle documentBounds = jGoView.getDocument().computeBounds(); // jGoView.getDocument().setDocumentSize( (int) documentBounds.getWidth() + // (ViewConstants.TIMELINE_VIEW_X_INIT * 2), // (int) documentBounds.getHeight() + // (ViewConstants.TIMELINE_VIEW_Y_INIT * 2)); int maxViewWidth = (int) jGoView.getDocumentSize().getWidth(); int maxViewHeight = (int) jGoView.getDocumentSize().getHeight(); // navigatorFrame.setSize // ( maxViewWidth + ViewConstants.MDI_FRAME_DECORATION_WIDTH, // maxViewHeight + ViewConstants.MDI_FRAME_DECORATION_HEIGHT); expandViewFrame(navigatorFrame, maxViewWidth, maxViewHeight); long stopTimeMSecs = System.currentTimeMillis(); System.err.println( " ... " + ViewConstants.NAVIGATOR_VIEW + " elapsed time: " + (stopTimeMSecs - startTimeMSecs) + " msecs."); startTimeMSecs = 0L; isLayoutNeeded = false; focusNode = null; // print out info for created nodes // iterateOverJGoDocument(); // slower - many more nodes to go thru // iterateOverNodes(); } // end init
/** * <code>findAndSelectResource</code> * * @param resourceToFind - <code>PwResource</code> - * @param xLoc - <code>int</code> - */ public final void findAndSelectResource(final PwResource resourceToFind, final int xLoc) { boolean isResourceFound = false; Iterator resourceSetListItr = resourceTransactionSetList.iterator(); while (resourceSetListItr.hasNext()) { ResourceTransactionSet resourceTransactionSet = (ResourceTransactionSet) resourceSetListItr.next(); // System.err.println( "resourceToFind id = " + resourceToFind.getId() + // " resource id = " + // resourceTransactionSet.getResource().getId()); if (resourceTransactionSet.getResource().getId().equals(resourceToFind.getId())) { System.err.println( "ResourceTransactionView found resource: " + resourceToFind.getName() + " (key=" + resourceToFind.getId().toString() + ")"); isResourceFound = true; this.getJGoLevelScaleViewSelection().clearSelection(); this.getJGoExtentViewSelection().clearSelection(); this.getJGoExtentViewHScrollBar() .setValue(Math.max(0, (int) (xLoc - (this.getJGoExtentViewSize().getWidth() / 2)))); this.getJGoExtentViewVScrollBar() .setValue( Math.max( 0, (int) (findResourceYLoc(resourceToFind) - (this.getJGoExtentViewSize().getHeight() / 2)))); Iterator nameNodeItr = resourceNameNodeList.iterator(); while (nameNodeItr.hasNext()) { ResourceNameNode nameNode = (ResourceNameNode) nameNodeItr.next(); if (nameNode.getResource().getId().equals(resourceToFind.getId())) { this.getJGoLevelScaleViewSelection().extendSelection(nameNode); break; } } } } if (!isResourceFound) { // Content Spec filtering may cause this to happen String message = "Resource '" + resourceToFind.getName() + "' (key=" + resourceToFind.getId().toString() + ") not found."; JOptionPane.showMessageDialog( PlanWorks.getPlanWorks(), message, "Resource Not Found in ResourceTransactionView", JOptionPane.ERROR_MESSAGE); System.err.println(message); } } // end findAndSelectResource
/** * <code>mouseRightPopupMenu</code> * * @param resource - <code>PwResource</code> - * @param viewCoords - <code>Point</code> - */ protected final void mouseRightPopupMenu(final PwResource resource, final Point viewCoords) { String partialPlanName = partialPlan.getPartialPlanName(); PwPlanningSequence planSequence = PlanWorks.getPlanWorks().getPlanSequence(partialPlan); JPopupMenu mouseRightPopup = new JPopupMenu(); JMenuItem nodeByKeyItem = new JMenuItem("Find by Key"); createNodeByKeyItem(nodeByKeyItem); mouseRightPopup.add(nodeByKeyItem); createOpenViewItems( partialPlan, partialPlanName, planSequence, mouseRightPopup, ViewConstants.RESOURCE_TRANSACTION_VIEW); JMenuItem overviewWindowItem = new JMenuItem("Overview Window"); createOverviewWindowItem(overviewWindowItem, this, viewCoords); mouseRightPopup.add(overviewWindowItem); JMenuItem raiseContentSpecItem = new JMenuItem("Raise Content Filter"); createRaiseContentSpecItem(raiseContentSpecItem); mouseRightPopup.add(raiseContentSpecItem); String timeMarkTitle = "Set Time Scale Line"; if (viewSet.doesViewFrameExist(ViewConstants.RESOURCE_TRANSACTION_VIEW)) { timeMarkTitle = timeMarkTitle.concat("/Snap to Resource Profile"); } JMenuItem timeMarkItem = new JMenuItem(timeMarkTitle); createTimeMarkItem(timeMarkItem, resource); mouseRightPopup.add(timeMarkItem); if (((PartialPlanViewSet) this.getViewSet()).getActiveResource() != null) { JMenuItem activeResourceItem = new JMenuItem("Snap to Active Resource"); createActiveResourceItem(activeResourceItem); mouseRightPopup.add(activeResourceItem); } if (((PartialPlanViewSet) this.getViewSet()).getActiveToken() != null) { JMenuItem activeResourceTransItem = new JMenuItem("Snap to Active Resource Transaction"); createActiveResourceTransItem(activeResourceTransItem); mouseRightPopup.add(activeResourceTransItem); } if (viewSet.doesViewFrameExist(ViewConstants.NAVIGATOR_VIEW)) { mouseRightPopup.addSeparator(); JMenuItem closeWindowsItem = new JMenuItem("Close Navigator Views"); createCloseNavigatorWindowsItem(closeWindowsItem); mouseRightPopup.add(closeWindowsItem); } createAllViewItems(partialPlan, partialPlanName, planSequence, mouseRightPopup); ViewGenerics.showPopupMenu(mouseRightPopup, this, viewCoords); } // end mouseRightPopupMenu
/** * <code>doMouseClick</code> - For Constraint Network View, Mouse-left opens/closes constarintNode * to show variableNodes * * @param modifiers - <code>int</code> - * @param dc - <code>Point</code> - * @param vc - <code>Point</code> - * @param view - <code>JGoView</code> - * @return - <code>boolean</code> - */ public boolean doMouseClick(int modifiers, Point dc, Point vc, JGoView view) { JGoObject obj = view.pickDocObject(dc, false); // System.err.println( "doMouseClick obj class " + // obj.getTopLevelObject().getClass().getName()); ConstraintNode constraintNode = (ConstraintNode) obj.getTopLevelObject(); if (MouseEventOSX.isMouseLeftClick(modifiers, PlanWorks.isMacOSX())) { if ((!isUnaryConstraint) && (partialPlanView instanceof ConstraintNetworkView)) { if (!areNeighborsShown) { // System.err.println( "doMouseClick: Mouse-L show variable nodes of constraint id " + // constraintNode.getConstraint().getId()); addConstraintNodeVariables(this, (ConstraintNetworkView) partialPlanView); areNeighborsShown = true; } else { // System.err.println( "doMouseClick: Mouse-L hide variable nodes of constraint id " + // constraintNode.getConstraint().getId()); removeConstraintNodeVariables(this, (ConstraintNetworkView) partialPlanView); areNeighborsShown = false; } return true; } } else if (MouseEventOSX.isMouseRightClick(modifiers, PlanWorks.isMacOSX())) { } return false; } // end doMouseClick
private void loadTransactionFileDoit() { if (isTransactionFileOnDisk()) { long t1 = System.currentTimeMillis(); MySQLDB.loadFile( url + System.getProperty("file.separator") + DbConstants.SEQ_TRANSACTIONS, DbConstants.TBL_TRANSACTION); System.err.println( "Loading transaction file took " + (System.currentTimeMillis() - t1) + " msecs."); hasLoadedTransactionFile = true; } else { JOptionPane.showMessageDialog( PlanWorks.getPlanWorks(), "Sequence " + name, "No Transactions Available", JOptionPane.ERROR_MESSAGE); } } // end loadTransactionFileDoit
private void mouseRightPopupMenu(final Point viewCoords) { String partialPlanName = partialPlan.getPartialPlanName(); PwPlanningSequence planSequence = PlanWorks.getPlanWorks().getPlanSequence(partialPlan); JPopupMenu mouseRightPopup = new JPopupMenu(); JMenuItem nodeByKeyItem = new JMenuItem("Find by Key"); createNodeByKeyItem(nodeByKeyItem); mouseRightPopup.add(nodeByKeyItem); JMenuItem findEntityPathItem = new JMenuItem("Find Entity Path"); createFindEntityPathItem(findEntityPathItem); mouseRightPopup.add(findEntityPathItem); if (highlightPathNodesList != null) { JMenuItem highlightPathItem = new JMenuItem("Highlight Current Path"); createHighlightPathItem(highlightPathItem, highlightPathNodesList); mouseRightPopup.add(highlightPathItem); } createOpenViewItems( partialPlan, partialPlanName, planSequence, mouseRightPopup, viewListenerList, ViewConstants.NAVIGATOR_VIEW); JMenuItem overviewWindowItem = new JMenuItem("Overview Window"); createOverviewWindowItem(overviewWindowItem, this, viewCoords); mouseRightPopup.add(overviewWindowItem); this.createZoomItem(jGoView, zoomFactor, mouseRightPopup, this); createAllViewItems( partialPlan, partialPlanName, planSequence, viewListenerList, mouseRightPopup); ViewGenerics.showPopupMenu(mouseRightPopup, this, viewCoords); } // end mouseRightPopupMenu
/** * <code>findAndSelectResourceTransaction</code> * * @param resourceTransToFind - <code>PwResourceTransaction</code> - */ public final void findAndSelectResourceTransaction( final PwResourceTransaction resourceTransToFind) { boolean isResourceTransFound = false; if ((resourceTransToFind.getParentId() != null) && (!resourceTransToFind.getParentId().equals(DbConstants.NO_ID))) { PwResource resourceToFind = (PwResource) partialPlan.getObject(resourceTransToFind.getParentId()); // System.err.println( "findAndSelectResourceTransaction resourceToFind " + // resourceToFind); Iterator resourceSetListItr = resourceTransactionSetList.iterator(); foundIt: while (resourceSetListItr.hasNext()) { ResourceTransactionSet resourceTransactionSet = (ResourceTransactionSet) resourceSetListItr.next(); if (resourceTransactionSet.getResource().getId().equals(resourceToFind.getId())) { Iterator transNodeItr = resourceTransactionSet.getTransactionNodeList().iterator(); while (transNodeItr.hasNext()) { ResourceTransactionNode transNode = (ResourceTransactionNode) transNodeItr.next(); if (transNode.getTransaction().getId().equals(resourceTransToFind.getId())) { System.err.println( "ResourceTransactionView found resourceTransaction: " + resourceTransToFind.getName() + " (key=" + resourceTransToFind.getId().toString() + ")"); isResourceTransFound = true; this.getJGoLevelScaleViewSelection().clearSelection(); this.getJGoExtentViewSelection().clearSelection(); this.getJGoExtentViewHScrollBar() .setValue( Math.max( 0, (int) (transNode.getLocation().getX() - (this.getJGoExtentViewSize().getWidth() / 2)))); this.getJGoExtentViewVScrollBar() .setValue( Math.max( 0, (int) (transNode.getLocation().getY() - (this.getJGoExtentViewSize().getHeight() / 2)))); this.getJGoExtentViewSelection().extendSelection(transNode); break foundIt; } } } } if (!isResourceTransFound) { // Content Spec filtering may cause this to happen String message = "Resource Transaction'" + resourceTransToFind.getName() + "' (key=" + resourceTransToFind.getId().toString() + ") not found."; JOptionPane.showMessageDialog( PlanWorks.getPlanWorks(), message, "Resource TransactionNot Found in ResourceTransactionView", JOptionPane.ERROR_MESSAGE); System.err.println(message); } } } // end findAndSelectResourceTransaction
/** * <code>init</code> - wait for instance to become displayable, determine appropriate font * metrics, and render the JGo timeline, and slot widgets * * <p>These functions are not done in the constructor to avoid: "Cannot measure text until a * JGoView exists and is part of a visible window". called by componentShown method on the JFrame * JGoView.setVisible( true) must be completed -- use runInit in constructor */ public final void init() { handleEvent(ViewListener.EVT_INIT_BEGUN_DRAWING); // wait for TimelineView instance to become displayable while (!this.isDisplayable()) { try { Thread.currentThread().sleep(50); } catch (InterruptedException excp) { } // System.err.println( "timelineView displayable " + this.isDisplayable()); } this.computeFontMetrics(this); QueryHeaderView headerJGoView = new QueryHeaderView(query); headerJGoView.validate(); headerJGoView.setVisible(true); FixedHeightPanel variableHeaderPanel = new FixedHeightPanel(headerJGoView, this); variableHeaderPanel.setLayout(new BoxLayout(variableHeaderPanel, BoxLayout.Y_AXIS)); variableHeaderPanel.add(headerJGoView, BorderLayout.NORTH); add(variableHeaderPanel, BorderLayout.NORTH); String[] columnNames = { ViewConstants.DB_TRANSACTION_STEP_NUM_HEADER, ViewConstants.QUERY_VARIABLE_KEY_HEADER, ViewConstants.QUERY_VARIABLE_TYPE_HEADER, ViewConstants.DB_TRANSACTION_PARENT_HEADER, // empty last column to allow user adjusting of column widths "" }; PwPartialPlan partialPlan = null; try { partialPlan = planSequence.getPartialPlan(stepNumber); } catch (ResourceNotFoundException rnfExcep) { int index = rnfExcep.getMessage().indexOf(":"); JOptionPane.showMessageDialog( PlanWorks.getPlanWorks(), rnfExcep.getMessage().substring(index + 1), "Resource Not Found Exception", JOptionPane.ERROR_MESSAGE); System.err.println(rnfExcep); rnfExcep.printStackTrace(); } Object[][] data = new Object[variableList.size()][columnNames.length]; for (int row = 0, nRows = variableList.size(); row < nRows; row++) { PwVariableQuery variable = (PwVariableQuery) variableList.get(row); data[row][0] = variable.getStepNumber().toString(); data[row][1] = variable.getId().toString(); data[row][2] = variable.getType(); data[row][3] = partialPlan.getVariableParentName(variable.getParentId()); } objectKeyColumnIndx = 1; stepNumberColumnIndx = 0; TableSorter sorter = new TableSorter(new DBTransactionTableModel(columnNames, data)); variableTable = new DBTransactionTable(sorter, stepNumberColumnIndx, this); sorter.setTableHeader(variableTable.getTableHeader()); contentScrollPane = new JScrollPane(variableTable); add(contentScrollPane, BorderLayout.SOUTH); this.setVisible(true); int maxViewWidth = (int) headerJGoView.getDocumentSize().getWidth(); int maxViewHeight = (int) (headerJGoView.getDocumentSize().getHeight() + // contentJGoView.getDocumentSize().getHeight()); // keep contentJGoView small (ViewConstants.INTERNAL_FRAME_X_DELTA)); viewFrame.setSize( maxViewWidth + ViewConstants.MDI_FRAME_DECORATION_WIDTH, maxViewHeight + ViewConstants.MDI_FRAME_DECORATION_HEIGHT); int maxQueryFrameY = (int) (sequenceQueryWindow.getSequenceQueryFrame().getLocation().getY() + sequenceQueryWindow.getSequenceQueryFrame().getSize().getHeight()); int delta = Math.min( ViewConstants.INTERNAL_FRAME_X_DELTA_DIV_4 * sequenceQueryWindow.getQueryResultFrameCnt(), (int) (PlanWorks.getPlanWorks().getSize().getHeight() - maxQueryFrameY - (ViewConstants.MDI_FRAME_DECORATION_HEIGHT * 2))); viewFrame.setLocation(ViewConstants.INTERNAL_FRAME_X_DELTA + delta, maxQueryFrameY + delta); // prevent right edge from going outside the MDI frame expandViewFrame( viewFrame, Math.max( (int) headerJGoView.getDocumentSize().getWidth(), variableTable.getColumnModel().getTotalColumnWidth()), (int) (headerJGoView.getDocumentSize().getHeight() + variableTable.getRowCount() * variableTable.getRowHeight())); long stopTimeMSecs = System.currentTimeMillis(); System.err.println( " ... '" + this.getName() + "'elapsed time: " + (stopTimeMSecs - startTimeMSecs) + " msecs."); handleEvent(ViewListener.EVT_INIT_ENDED_DRAWING); } // end init