001 /*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 * http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014 /*
015 * This file has been modified by Chris Pheby in accordance with Section 4.2
016 * of the Apache Software License
017 */
018 package org.jadira.dependencynavigator.gui;
019
020 import java.io.File;
021
022 import javax.swing.JLabel;
023 import javax.swing.SwingUtilities;
024
025 import org.jadira.dependencynavigator.implementations.IProgressMeter;
026 import org.jadira.dependencynavigator.model.Artifact;
027
028 public class ProgressMeter implements IProgressMeter {
029
030 private final JLabel label;
031
032 public ProgressMeter(JLabel label) {
033 this.label = label;
034 }
035
036 public JLabel getLabel() {
037 return this.label;
038 }
039
040 private void report(String message) {
041 SwingUtilities.invokeLater(new ProgressUpdateThread(message));
042 }
043
044 public void resolving(Artifact artifact) {
045 report("resolving: " + artifact.getId());
046 }
047
048 public void scanning(File pomFile) {
049 report("scanning: " + pomFile.getPath());
050 }
051
052 public void adding(File pomFile) {
053 report("adding: " + pomFile.getPath());
054 }
055
056 public void error(Exception e) {
057 report("error [" + e.getClass().getName() + "] " + e.getMessage());
058 }
059
060 public void ready() {
061 report("ready");
062 }
063
064 public void snapshotComplete() {
065 report("snapshot complete");
066 }
067
068 private class ProgressUpdateThread implements Runnable {
069
070 private String message;
071
072 public ProgressUpdateThread(String message) {
073 this.message = message;
074 }
075
076 public void run() {
077 label.setText(message);
078 }
079
080 }
081 }