All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.vectorpublish.desktop.vp.StatusBarImpl Maven / Gradle / Ivy

There is a newer version: 0.9.27
Show newest version
/*
 * Copyright (c) 2016, Peter Rader. All rights reserved.
 *  ___ ___               __                 ______         __     __  __         __
 * |   |   |.-----..----.|  |_ .-----..----.|   __ \.--.--.|  |--.|  ||__|.-----.|  |--.
 * |   |   ||  -__||  __||   _||  _  ||   _||    __/|  |  ||  _  ||  ||  ||__ --||     |
 *  \_____/ |_____||____||____||_____||__|  |___|   |_____||_____||__||__||_____||__|__|
 *
 * http://www.gnu.org/licenses/gpl-3.0.html
 */
package net.vectorpublish.desktop.vp;

import java.awt.BorderLayout;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import javax.swing.JLabel;

import net.vectorpublish.desktop.vp.api.layer.LayerSelectionListener;
import net.vectorpublish.desktop.vp.api.ui.StatusBar;
import net.vectorpublish.desktop.vp.api.ui.UserInterface;
import net.vectorpublish.desktop.vp.api.vpd.StatusName;
import net.vectorpublish.desktop.vp.api.vpd.VectorPublishNode;

@Named
public class StatusBarImpl extends StatusBar implements LayerSelectionListener, Status {


	@Inject
	private final UserInterface ui = null;

	private final JLabel text = new JLabel("Vectorpublish");

	public StatusBarImpl() {
		super();
		setLayout(new BorderLayout());
		add(text, BorderLayout.EAST);
	}

	@Override
	public void notify(Set selection) {
		String status = "";
		for (final VectorPublishNode vectorPublishNode : selection) {
			if (vectorPublishNode instanceof StatusName) {
				final StatusName statusName = (StatusName) vectorPublishNode;
				if (!status.isEmpty())
					status += ", ";
				status += statusName.getStatusName();
			}
		}
		if (status.isEmpty()) {
			status = "No description available";
		}
		setStatus(status);
	}

	@PostConstruct
	private void setup() {
		ui.addStatus(this);
	}

	@Override
	public void setStatus(final String status){
		text.setText(status);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy