use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class Spoon method setShellText.
public void setShellText() {
if (shell.isDisposed()) {
return;
}
String filename = null;
String name = null;
String version = null;
ChangedFlagInterface changed = null;
boolean versioningEnabled = true;
AbstractMeta meta = getActiveJob() != null ? getActiveJob() : getActiveTransformation();
if (meta != null) {
changed = meta;
filename = meta.getFilename();
name = meta.getName();
version = meta.getObjectRevision() == null ? null : meta.getObjectRevision().getName();
try {
versioningEnabled = isVersionEnabled(rep, meta);
} catch (KettleRepositoryLostException krle) {
handleRepositoryLost(krle);
}
}
String text = "";
if (rep != null) {
text += APP_TITLE + " - [" + getRepositoryName() + "] ";
} else {
text += APP_TITLE + " - ";
}
if (Utils.isEmpty(name)) {
if (!Utils.isEmpty(filename)) {
text += filename;
} else {
String tab = getActiveTabText();
if (!Utils.isEmpty(tab)) {
text += tab;
} else {
// "[no name]"
text += BaseMessages.getString(PKG, "Spoon.Various.NoName");
}
}
} else {
text += name;
}
if (versioningEnabled && !Utils.isEmpty(version)) {
text += " v" + version;
}
if (changed != null && changed.hasChanged()) {
text += " " + BaseMessages.getString(PKG, "Spoon.Various.Changed");
}
shell.setText(text);
markTabsChanged(false);
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class ConditionSelectionAdapterFileDialogTest method testWidgetSelectedHelper.
@Test
public void testWidgetSelectedHelper() {
// SETUP
LogChannelInterface log = mock(LogChannelInterface.class);
TextVar textVar = mock(TextVar.class);
AbstractMeta meta = mock(AbstractMeta.class);
RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
SelectionEvent event = mock(SelectionEvent.class);
String testPath = "/home/devuser/some/path";
when(meta.environmentSubstitute(testPath)).thenReturn(testPath);
when(textVar.getText()).thenReturn(testPath);
ArgumentCaptor textCapture = ArgumentCaptor.forClass(String.class);
doNothing().when(textVar).setText((String) textCapture.capture());
ConditionSelectionAdapterFileDialogTextVar testInstance = new ConditionSelectionAdapterFileDialogTextVar(log, textVar, meta, options, repositoryUtility, extensionPointWrapper, () -> SelectionOperation.FOLDER);
testInstance.widgetSelected(event);
assertTrue(testInstance.getSelectionOptions().getSelectionOperation() == SelectionOperation.FOLDER);
options = new SelectionAdapterOptions(SelectionOperation.FILE);
ConditionSelectionAdapterFileDialogTextVar testInstance2 = new ConditionSelectionAdapterFileDialogTextVar(log, textVar, meta, options, repositoryUtility, extensionPointWrapper, () -> SelectionOperation.FILE);
testInstance.widgetSelected(event);
assertTrue(testInstance2.getSelectionOptions().getSelectionOperation() == SelectionOperation.FILE);
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method testIsConnectedToRepository.
@Test
public void testIsConnectedToRepository() {
// SETUP
LogChannelInterface log = mock(LogChannelInterface.class);
StringBuilder textVar = new StringBuilder();
AbstractMeta meta = mock(AbstractMeta.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
// True case:
RepositoryUtility repositoryUtilityTrue = mock(RepositoryUtility.class);
when(repositoryUtilityTrue.isConnectedToRepository()).thenReturn(true);
SelectionAdapterFileDialog testInstance1 = createTestInstance(log, textVar, meta, options, repositoryUtilityTrue, extensionPointWrapper);
assertTrue(testInstance1.isConnectedToRepository());
// False case:
RepositoryUtility repositoryUtilityFalse = mock(RepositoryUtility.class);
when(repositoryUtilityFalse.isConnectedToRepository()).thenReturn(false);
SelectionAdapterFileDialog testInstance2 = createTestInstance(log, textVar, meta, options, repositoryUtilityFalse, extensionPointWrapper);
assertFalse(testInstance2.isConnectedToRepository());
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method testApplyRelativePathEnvVar.
@Test
public void testApplyRelativePathEnvVar() throws IOException {
// SETUP
LogChannelInterface log = mock(LogChannelInterface.class);
StringBuilder textVar = new StringBuilder();
AbstractMeta meta = mock(AbstractMeta.class);
RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
File testFile = temporaryFolder.newFile("testFileName");
String testPath = testFile.getPath();
when(meta.environmentSubstitute(testPath)).thenReturn(testPath);
SelectionAdapterFileDialog testInstance1 = createTestInstance(log, textVar, meta, options, repositoryUtility, extensionPointWrapper);
testInstance1.setText(testPath);
String pathWithCurrentDirVar = testInstance1.applyRelativePathEnvVar(testPath);
assertEquals(testPath, pathWithCurrentDirVar);
when(meta.getFilename()).thenReturn(testPath);
pathWithCurrentDirVar = testInstance1.applyRelativePathEnvVar(testPath);
assertEquals("${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/testFileName", pathWithCurrentDirVar);
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method testResolveFile.
@Test
public void testResolveFile() throws Exception {
String unresolvedPath = "{SOME_VAR}/some/path";
String resolvedPath = "/home/devuser/some/path";
AbstractMeta abstractMeta = mock(AbstractMeta.class);
when(abstractMeta.environmentSubstitute(unresolvedPath)).thenReturn(resolvedPath);
assertNotNull(testInstance.resolveFile(abstractMeta, unresolvedPath));
}
Aggregations