Search in sources :

Example 1 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class BaseStepDialog method setSize.

public static void setSize(Shell shell, int prefWidth, int prefHeight) {
    PropsUI props = PropsUI.getInstance();
    WindowProperty winprop = props.getScreen(shell.getText());
    if (winprop != null) {
        winprop.setShell(shell, prefWidth, prefHeight);
    } else {
        shell.layout();
        winprop = new WindowProperty(shell.getText(), false, new Rectangle(0, 0, prefWidth, prefHeight));
        winprop.setShell(shell);
        // Now, as this is the first time it gets opened, try to put it in the middle of the screen...
        Rectangle shellBounds = shell.getBounds();
        Monitor monitor = shell.getDisplay().getPrimaryMonitor();
        if (shell.getParent() != null) {
            monitor = shell.getParent().getMonitor();
        }
        Rectangle monitorClientArea = monitor.getClientArea();
        int middleX = monitorClientArea.x + (monitorClientArea.width - shellBounds.width) / 2;
        int middleY = monitorClientArea.y + (monitorClientArea.height - shellBounds.height) / 2;
        shell.setLocation(middleX, middleY);
    }
}
Also used : WindowProperty(org.pentaho.di.ui.core.gui.WindowProperty) Monitor(org.eclipse.swt.widgets.Monitor) Rectangle(org.eclipse.swt.graphics.Rectangle) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 2 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class TextFileInputDialogTest method hackPropsUi.

@BeforeClass
public static void hackPropsUi() throws Exception {
    Field props = getPropsField();
    if (props == null) {
        throw new IllegalStateException("Cannot find 'props' field in " + Props.class.getName());
    }
    Object value = FieldUtils.readStaticField(props, true);
    if (value == null) {
        PropsUI mock = mock(PropsUI.class);
        FieldUtils.writeStaticField(props, mock, true);
        changedPropsUi = true;
    } else {
        changedPropsUi = false;
    }
}
Also used : BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Field(java.lang.reflect.Field) PropsUI(org.pentaho.di.ui.core.PropsUI) BeforeClass(org.junit.BeforeClass)

Example 3 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class SFTPPutDialogTest method hackPropsUi.

@BeforeClass
public static void hackPropsUi() throws Exception {
    Field props = getPropsField();
    if (props == null) {
        throw new IllegalStateException("Cannot find 'props' field in " + Props.class.getName());
    }
    Object value = FieldUtils.readStaticField(props, true);
    if (value == null) {
        PropsUI mock = mock(PropsUI.class);
        FieldUtils.writeStaticField(props, mock, true);
        changedPropsUi = true;
    } else {
        changedPropsUi = false;
    }
}
Also used : Field(java.lang.reflect.Field) PropsUI(org.pentaho.di.ui.core.PropsUI) BeforeClass(org.junit.BeforeClass)

Example 4 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class TransFileListener method open.

public boolean open(Node transNode, String fname, boolean importfile) throws KettleMissingPluginsException {
    final Spoon spoon = Spoon.getInstance();
    final PropsUI props = PropsUI.getInstance();
    try {
        // Call extension point(s) before the file has been opened
        ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransBeforeOpen.id, fname);
        TransMeta transMeta = new TransMeta();
        transMeta.loadXML(transNode, fname, spoon.getMetaStore(), spoon.getRepository(), true, new Variables(), new OverwritePrompter() {

            public boolean overwritePrompt(String message, String rememberText, String rememberPropertyName) {
                MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
                Object[] res = spoon.messageDialogWithToggle(BaseMessages.getString(PKG, "System.Button.Yes"), null, message, Const.WARNING, new String[] { BaseMessages.getString(PKG, "System.Button.Yes"), BaseMessages.getString(PKG, "System.Button.No") }, 1, rememberText, !props.askAboutReplacingDatabaseConnections());
                int idx = ((Integer) res[0]).intValue();
                boolean toggleState = ((Boolean) res[1]).booleanValue();
                props.setAskAboutReplacingDatabaseConnections(!toggleState);
                // Yes means: overwrite
                return ((idx & 0xFF) == 0);
            }
        });
        if (transMeta.hasMissingPlugins()) {
            StepMeta stepMeta = transMeta.getStep(0);
            MissingTransDialog missingDialog = new MissingTransDialog(spoon.getShell(), transMeta.getMissingTrans(), stepMeta.getStepMetaInterface(), transMeta, stepMeta.getName());
            if (missingDialog.open() == null) {
                return true;
            }
        }
        transMeta.setRepositoryDirectory(spoon.getDefaultSaveLocation(transMeta));
        transMeta.setRepository(spoon.getRepository());
        transMeta.setMetaStore(spoon.getMetaStore());
        spoon.setTransMetaVariables(transMeta);
        spoon.getProperties().addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, fname, null, false, null);
        spoon.addMenuLast();
        // if any exist.
        if (importfile) {
            if (spoon.getRepository() != null) {
                transMeta = fixLinks(transMeta);
            }
        } else {
            transMeta.clearChanged();
        }
        transMeta.setFilename(fname);
        spoon.addTransGraph(transMeta);
        spoon.sharedObjectsFileMap.put(transMeta.getSharedObjects().getFilename(), transMeta.getSharedObjects());
        // Call extension point(s) now that the file has been opened
        ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransAfterOpen.id, transMeta);
        SpoonPerspectiveManager.getInstance().activatePerspective(MainSpoonPerspective.class);
        spoon.refreshTree();
        return true;
    } catch (KettleMissingPluginsException e) {
        throw e;
    } catch (KettleException e) {
        new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Message") + fname, e);
    }
    return false;
}
Also used : Variables(org.pentaho.di.core.variables.Variables) KettleException(org.pentaho.di.core.exception.KettleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) MissingTransDialog(org.pentaho.di.ui.trans.steps.missing.MissingTransDialog) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) OverwritePrompter(org.pentaho.di.core.gui.OverwritePrompter) StepMeta(org.pentaho.di.trans.step.StepMeta) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 5 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class SpoonTransformationDelegate method addTransGraph.

public void addTransGraph(TransMeta transMeta) {
    boolean added = addTransformation(transMeta);
    if (added) {
        // See if there already is a tab for this graph with the short default name.
        // If there is, set that one to show the location as well.
        // If not, simply add it without
        // If no, add it
        // If yes, select that tab
        // 
        boolean showLocation = false;
        boolean addTab = true;
        String tabName = spoon.delegates.tabs.makeTabName(transMeta, showLocation);
        TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.TRANSFORMATION_GRAPH);
        if (tabEntry != null) {
            // We change the already loaded transformation to also show the location.
            // 
            showLocation = true;
            // Try again, including the location of the object...
            // 
            tabName = spoon.delegates.tabs.makeTabName(transMeta, showLocation);
            TabMapEntry exactSameEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.TRANSFORMATION_GRAPH);
            if (exactSameEntry != null) {
                // Already loaded, simply select the tab item in question...
                // 
                addTab = false;
            } else {
                // We might need to rename the tab of the entry already loaded!
                // 
                tabEntry.setShowingLocation(true);
                String newTabName = spoon.delegates.tabs.makeTabName(tabEntry.getObject().getMeta(), showLocation);
                tabEntry.getTabItem().setText(newTabName);
            }
        }
        TransGraph transGraph = null;
        if (addTab) {
            transGraph = new TransGraph(spoon.tabfolder.getSwtTabset(), spoon, transMeta);
            PropsUI props = PropsUI.getInstance();
            TabItem tabItem = new TabItem(spoon.tabfolder, tabName, tabName, props.getSashWeights());
            String toolTipText = BaseMessages.getString(PKG, "Spoon.TabTrans.Tooltip", spoon.delegates.tabs.makeTabName(transMeta, showLocation));
            if (!Utils.isEmpty(transMeta.getFilename())) {
                toolTipText += Const.CR + Const.CR + transMeta.getFilename();
            }
            tabItem.setToolTipText(toolTipText);
            tabItem.setImage(GUIResource.getInstance().getImageTransGraph());
            tabItem.setControl(transGraph);
            TransLogTable logTable = transMeta.getTransLogTable();
            String versionLabel = transMeta.getObjectRevision() == null ? null : transMeta.getObjectRevision().getName();
            tabEntry = new TabMapEntry(tabItem, transMeta.getFilename(), transMeta.getName(), transMeta.getRepositoryDirectory(), versionLabel, transGraph, ObjectType.TRANSFORMATION_GRAPH);
            tabEntry.setShowingLocation(showLocation);
            spoon.delegates.tabs.addTab(tabEntry);
        }
        int idx = spoon.tabfolder.indexOf(tabEntry.getTabItem());
        // keep the focus on the graph
        spoon.tabfolder.setSelected(idx);
        if (addTab) {
            TransLogTable logTable = transMeta.getTransLogTable();
            // OK, also see if we need to open a new history window.
            if (isLogTableDefined(logTable) && !transMeta.isSlaveTransformation()) {
                addTabsToTransGraph(transGraph);
            }
        }
        spoon.setUndoMenu(transMeta);
        spoon.enableMenus();
    } else {
        TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(transMeta);
        if (tabEntry != null) {
            int idx = spoon.tabfolder.indexOf(tabEntry.getTabItem());
            // keep the focus on the graph
            spoon.tabfolder.setSelected(idx);
            spoon.setUndoMenu(transMeta);
            spoon.enableMenus();
        }
    }
}
Also used : TabItem(org.pentaho.xul.swt.tab.TabItem) TransLogTable(org.pentaho.di.core.logging.TransLogTable) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) PropsUI(org.pentaho.di.ui.core.PropsUI)

Aggregations

PropsUI (org.pentaho.di.ui.core.PropsUI)28 Label (org.eclipse.swt.widgets.Label)9 FormLayout (org.eclipse.swt.layout.FormLayout)6 Composite (org.eclipse.swt.widgets.Composite)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)5 FormData (org.eclipse.swt.layout.FormData)5 Text (org.eclipse.swt.widgets.Text)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 FillLayout (org.eclipse.swt.layout.FillLayout)4 Button (org.eclipse.swt.widgets.Button)4 KettleException (org.pentaho.di.core.exception.KettleException)4 Field (java.lang.reflect.Field)3 Group (org.eclipse.swt.widgets.Group)3 Monitor (org.eclipse.swt.widgets.Monitor)3 BeforeClass (org.junit.BeforeClass)3 TabMapEntry (org.pentaho.di.ui.spoon.TabMapEntry)3 TabItem (org.pentaho.xul.swt.tab.TabItem)3 WindowEvent (org.eclipse.swt.browser.WindowEvent)2