Example usage for org.eclipse.jgit.events IndexChangedEvent IndexChangedEvent

List of usage examples for org.eclipse.jgit.events IndexChangedEvent IndexChangedEvent

Introduction

In this page you can find the example usage for org.eclipse.jgit.events IndexChangedEvent IndexChangedEvent.

Prototype

IndexChangedEvent

Source Link

Usage

From source file:de.br0tbox.gitfx.ui.controllers.CommitDialogController.java

License:Apache License

@FXML
public void commit() {
    try {/*from  www  .  ja  v  a  2s . c  o  m*/
        final CommitCommand commit = projectModel.getFxProject().getGit().commit();
        final ObservableList<String> unstagedChanges = projectModel.getStagedChangesProperty().get();
        if (unstagedChanges.size() < 1) {
            final Action commitAll = Dialogs.create().owner(getStage())
                    .message("There are no changes staged, do you want to commit every changed File?")
                    .showConfirm();
            if (Dialog.Actions.YES.equals(commitAll)) {
                //FIXME: Threading issue, this is a workaround that seems to work for now.
                stageAll();
                projectModel.getFxProject().getGit().getRepository().getListenerList()
                        .dispatch(new IndexChangedEvent());
                Platform.runLater(new Runnable() {

                    @Override
                    public void run() {
                        commit();
                    }
                });
            }
        } else {
            commit.setMessage(commitMessage.getText());
            commit.call();
            this.hide();
        }
    } catch (final GitAPIException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:de.br0tbox.gitfx.ui.sync.GitRefreshTimerTask.java

License:Apache License

@Override
public void run() {
    try {//from   w ww.  j  av  a  2s.  co  m
        final Integer uncommitedChangesNumber = projectModel.getFxProject().getUncommitedChangesNumber();
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                final int changesInRepo = projectModel.getChangesProperty().get();
                if (changesInRepo != uncommitedChangesNumber) {
                    projectModel.getFxProject().getGit().getRepository().getListenerList()
                            .dispatch(new IndexChangedEvent());
                }
                projectModel.getChangesProperty().set(uncommitedChangesNumber);
            }
        });
        repository.scanForRepoChanges();
    } catch (final IOException e) {
        LOGGER.error(e);
    }
}

From source file:org.eclipse.egit.ui.internal.synchronize.compare.LocalNonWorkspaceTypedElement.java

License:Open Source License

/** {@inheritDoc} */
@Override// w w  w.j a v a2 s. co m
public void commit(IProgressMonitor monitor) throws CoreException {
    if (isDirty()) {
        if (isConnected()) {
            super.commit(monitor);
        } else {
            FileOutputStream out = null;
            File file = path.toFile();
            try {
                if (!file.exists())
                    FileUtils.createNewFile(file);
                out = new FileOutputStream(file);
                out.write(getContent());
                fDirty = false;
            } catch (IOException e) {
                throw new CoreException(new Status(IStatus.ERROR, Activator.getPluginId(),
                        UIText.LocalNonWorkspaceTypedElement_errorWritingContents, e));
            } finally {
                fireContentChanged();
                RepositoryMapping mapping = RepositoryMapping.getMapping(path);
                if (mapping != null)
                    mapping.getRepository().fireEvent(new IndexChangedEvent());
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ex) {
                    }
            }
        }
    }
}