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

com.anrisoftware.prefdialog.csvimportdialog.previewpaneldock.PreviewPanelDock Maven / Gradle / Ivy

/*
 * Copyright 2013-2015 Erwin Müller 
 *
 * This file is part of prefdialog-csvimportdialog.
 *
 * prefdialog-csvimportdialog is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * prefdialog-csvimportdialog is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with prefdialog-csvimportdialog. If not, see .
 */
package com.anrisoftware.prefdialog.csvimportdialog.previewpaneldock;

import java.awt.Component;
import java.beans.PropertyVetoException;

import javax.inject.Inject;

import com.anrisoftware.globalpom.dataimport.CsvImportProperties;
import com.anrisoftware.prefdialog.csvimportdialog.previewpanel.PreviewPanel;
import com.anrisoftware.prefdialog.csvimportdialog.previewpanel.PreviewPanelFactory;
import com.anrisoftware.prefdialog.miscswing.awtcheck.OnAwt;
import com.anrisoftware.prefdialog.miscswing.docks.api.DockPosition;
import com.anrisoftware.prefdialog.miscswing.docks.dockingframes.dock.AbstractViewDockWindow;
import com.anrisoftware.resources.texts.api.Texts;
import com.anrisoftware.resources.texts.api.TextsFactory;
import com.google.inject.Injector;

/**
 * Dock containing the preview panel.
 *
 * @author Erwin Mueller, [email protected]
 * @since 3.1
 */
@SuppressWarnings("serial")
public class PreviewPanelDock extends AbstractViewDockWindow {

    public static final String ID = "previewPanelDock";

    @Inject
    private transient PreviewPanelFactory panelFactory;

    private PreviewPanel previewPanel;

    private Texts texts;

    @Inject
    public void setTextsFactory(TextsFactory factory) {
        this.texts = factory.create(PreviewPanelDock.class.getSimpleName());
    }

    /**
     * Creates the panel with the CSV import properties.
     * 

*

AWT Thread

*

* Should be called in the AWT thread. * * @param injector * the parent {@link Injector}. * * @return this {@link PreviewPanelDock}. */ @OnAwt public PreviewPanelDock createPanel(Injector injector) { setTexts(texts); previewPanel = panelFactory.create(); previewPanel.createPanel(injector); return this; } /** * Sets the CSV importer properties. * *

AWT Thread

*

* Should be called in the AWT thread. * * @param properties * the {@link CsvImportProperties}. */ @OnAwt public void setProperties(CsvImportProperties properties) { previewPanel.setProperties(properties); } /** * Sets the localized texts resources. The texts must contain the following * resources: * *

    *
  • {@code "preview_panel_dock_title"}
  • *
* * @param texts * the {@link Texts}. */ @OnAwt public void setTexts(Texts texts) { setTitle(texts.getResource("preview_panel_dock_title").getText()); } /** * Returns the preview panel. * * @return the {@link PreviewPanel}. */ public PreviewPanel getImportPanel() { return previewPanel; } /** * Restores the input of the panel to default values. * * @throws PropertyVetoException * if the old user input is not valid. */ public void restoreInput() throws PropertyVetoException { previewPanel.retoreInput(); } @Override public String getId() { return ID; } @Override public Component getComponent() { return previewPanel.getAWTComponent(); } @Override public DockPosition getPosition() { return DockPosition.WEST; } @Override public boolean isCloseable() { return false; } @Override public boolean isExternalizable() { return false; } @Override public boolean isMaximizable() { return true; } @Override public boolean isMinimizable() { return true; } @Override public boolean isStackable() { return true; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy