Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 package org.apache.cayenne.modeler;
 import java.util.List;
 import  org.apache.cayenne.project.Project;
 import  org.apache.cayenne.project.ProjectFile;

ProjectWatchdog class is responsible for tracking changes in cayenne.xml and other Cayenne project files
 public class ProjectWatchdog extends FileWatchdog {

A project to watch
     protected ProjectController mediator;

Creates new watchdog for a specified project
     public ProjectWatchdog(ProjectController mediator) {
         this. = mediator;
         setSingleNotification(true); // one message is more than enough

Reloads files to watch from the project. Useful when project's structure has changed
     public void reconfigure() {
         Project project = .getProject();
         if (project != null // project opened
                 && project.getProjectDirectory() != null// not new project
             String projectPath = project.getProjectDirectory().getPath() + .;
             List<ProjectFile> files = project.buildFileList();
             for (ProjectFile pr : files)
                 addFile(projectPath + pr.getLocation());
     protected void doOnChange(FileInfo fileInfo) {
         if (showConfirmation("One or more project files were changed by external program. "
                 + "Do you want to load the changes?")) {
Currently we are reloading all project
             if (.getProject() != null) {
                 ((OpenProjectAction) Application.getInstance().getAction(
     protected void doOnRemove(FileInfo fileInfo) {
         if (.getProject() != null
                 /*&& fileInfo.getFile().equals(mediator.getProject().getMainFile()) */ ) {
            FileDeletedDialog dialog = new FileDeletedDialog(Application.getFrame());
            if (dialog.shouldSave()) {
            else if (dialog.shouldClose()) {
                CayenneModelerController controller = Application

Shows confirmation dialog
    private boolean showConfirmation(String message) {
        return . == JOptionPane.showConfirmDialog(
                "File changed",
New to GrepCode? Check out our FAQ X