private void setupComponents() { fileTable = new DiffFileTable(this); splitPane.setTopComponent(fileTable.getComponent()); splitPane.setBottomComponent( new NoContentPanel(NbBundle.getMessage(MultiDiffPanel.class, "MSG_DiffPanel_NoContent"))); commitButton.addActionListener(this); commitButton.setToolTipText( NbBundle.getMessage(MultiDiffPanel.class, "MSG_CommitDiff_Tooltip", contextName)); updateButton.setToolTipText( NbBundle.getMessage(MultiDiffPanel.class, "MSG_UpdateDiff_Tooltip", contextName)); ButtonGroup grp = new ButtonGroup(); nextAction = new AbstractAction( null, new javax.swing.ImageIcon( getClass().getResource("/org/nbgit/resources/icons/diff-next.png"))) { // NOI18N { putValue( Action.SHORT_DESCRIPTION, java.util.ResourceBundle.getBundle("org/nbgit/ui/diff/Bundle") .getString("CTL_DiffPanel_Next_Tooltip")); } public void actionPerformed(ActionEvent e) { onNextButton(); } }; prevAction = new AbstractAction( null, new javax.swing.ImageIcon( getClass().getResource("/org/nbgit/resources/icons/diff-prev.png"))) { // NOI18N { putValue( Action.SHORT_DESCRIPTION, java.util.ResourceBundle.getBundle("org/nbgit/ui/diff/Bundle") .getString("CTL_DiffPanel_Prev_Tooltip")); } public void actionPerformed(ActionEvent e) { onPrevButton(); } }; nextButton.setAction(nextAction); prevButton.setAction(prevAction); }
/** * Construct diff component showing just one file. It hides All, Local, Remote toggles and file * chooser combo. */ public MultiDiffPanel(File file, String rev1, String rev2) { context = null; contextName = file.getName(); initComponents(); setupComponents(); fileTable.getComponent().setVisible(false); commitButton.setVisible(false); // mimics refreshSetups() setups = new Setup[] {new Setup(file, rev1, rev2)}; setDiffIndex(0, 0); dpt = new DiffPrepareTask(setups); prepareTask = RequestProcessor.getDefault().post(dpt); }
private void refreshSetups() { if (dpt != null) { prepareTask.cancel(); } File[] files; switch (currentType) { case Setup.DIFFTYPE_LOCAL: displayStatuses = StatusInfo.STATUS_LOCAL_CHANGE; break; case Setup.DIFFTYPE_REMOTE: displayStatuses = StatusInfo.STATUS_REMOTE_CHANGE; break; case Setup.DIFFTYPE_ALL: displayStatuses = StatusInfo.STATUS_LOCAL_CHANGE | StatusInfo.STATUS_REMOTE_CHANGE; break; default: throw new IllegalStateException("Unknown DIFF type:" + currentType); // NOI18N } files = GitUtils.getModifiedFiles(context, displayStatuses); setups = computeSetups(files); boolean propertyColumnVisible = false; for (Setup setup : setups) { if (setup.getPropertyName() != null) { propertyColumnVisible = true; break; } } fileTable.setColumns( propertyColumnVisible ? new String[] { DiffNode.COLUMN_NAME_NAME, DiffNode.COLUMN_NAME_PROPERTY, DiffNode.COLUMN_NAME_STATUS, DiffNode.COLUMN_NAME_LOCATION } : new String[] { DiffNode.COLUMN_NAME_NAME, DiffNode.COLUMN_NAME_STATUS, DiffNode.COLUMN_NAME_LOCATION }); fileTable.setTableModel(setupToNodes(setups)); if (setups.length == 0) { String noContentLabel; switch (currentType) { case Setup.DIFFTYPE_LOCAL: noContentLabel = NbBundle.getMessage(MultiDiffPanel.class, "MSG_DiffPanel_NoLocalChanges"); break; case Setup.DIFFTYPE_REMOTE: noContentLabel = NbBundle.getMessage(MultiDiffPanel.class, "MSG_DiffPanel_NoRemoteChanges"); break; case Setup.DIFFTYPE_ALL: noContentLabel = NbBundle.getMessage(MultiDiffPanel.class, "MSG_DiffPanel_NoAllChanges"); break; default: throw new IllegalStateException("Unknown DIFF type:" + currentType); // NOI18N } setups = null; fileTable.setTableModel(new Node[0]); fileTable.getComponent().setEnabled(false); fileTable.getComponent().setPreferredSize(null); Dimension dim = fileTable.getComponent().getPreferredSize(); fileTable.getComponent().setPreferredSize(new Dimension(dim.width + 1, dim.height)); diffView = null; diffView = new NoContentPanel(noContentLabel); setBottomComponent(); nextAction.setEnabled(false); prevAction.setEnabled(false); revalidate(); repaint(); } else { fileTable.getComponent().setEnabled(true); fileTable.getComponent().setPreferredSize(null); Dimension dim = fileTable.getComponent().getPreferredSize(); fileTable.getComponent().setPreferredSize(new Dimension(dim.width + 1, dim.height)); setDiffIndex(0, 0); dpt = new DiffPrepareTask(setups); prepareTask = RequestProcessor.getDefault().post(dpt); } }
private boolean showingFileTable() { return fileTable.getComponent().isVisible(); }