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);
}
}
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;
}
}
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;
}
}
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;
}
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();
}
}
}
Aggregations