Java源码示例:org.pentaho.di.ui.core.PropsUI
示例1
public GraphModelDialog( Shell parent, GraphModel graphModel, RowMetaInterface inputRowMeta ) {
super( parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.CLOSE );
this.inputRowMeta = inputRowMeta;
props = PropsUI.getInstance();
ok = false;
// We will only replace at OK
//
this.originalGraphModel = graphModel;
// We will change graphModel, copy it first
//
this.graphModel = new GraphModel( graphModel );
mouseDownPoint = new Point( -1, -1 );
}
示例2
public boolean updateRecentFiles( String oldPath, String newPath ) {
try {
Collection<List<LastUsedFile>> lastUsedRepoFiles = PropsUI.getInstance().getLastUsedRepoFiles().values();
for ( List<LastUsedFile> lastUsedFiles : lastUsedRepoFiles ) {
for ( int i = 0; i < lastUsedFiles.size(); i++ ) {
if ( ( lastUsedFiles.get( i ).getDirectory() + "/" ).startsWith( oldPath + "/" ) ) {
if ( lastUsedFiles.get( i ).getDirectory().length() == oldPath.length() ) {
lastUsedFiles.get( i ).setDirectory( newPath );
} else {
String prefix = newPath.substring( 0, newPath.lastIndexOf( "/" ) ) + "/";
String newFolder = newPath.substring( newPath.lastIndexOf( "/" ) + 1 );
String suffix = lastUsedFiles.get( i ).getDirectory().substring( oldPath.length() );
lastUsedFiles.get( i ).setDirectory( prefix + newFolder + suffix );
}
}
}
}
} catch ( Exception e ) {
return false;
}
return true;
}
示例3
public static void main( String[] args ) throws Exception {
Display display = new Display();
KettleEnvironment.init();
PropsUI.init( display, PropsUI.TYPE_PROPERTIES_SPOON );
Shell shell = new Shell( display );
ImportRules importRules = new ImportRules();
importRules.loadXML( XMLHandler.getSubNode(
XMLHandler.loadXMLFile( "bin/import-rules.xml" ), ImportRules.XML_TAG ) );
ImportRulesDialog dialog = new ImportRulesDialog( shell, importRules );
if ( dialog.open() ) {
for ( ImportRuleInterface rule : importRules.getRules() ) {
System.out.println( " - " + rule.toString() );
}
}
}
示例4
public Composite getComposite( Composite parent, ImportRuleInterface importRule ) {
PropsUI props = PropsUI.getInstance();
composite = new Composite( parent, SWT.NONE );
props.setLook( composite );
composite.setLayout( new FillLayout() );
Label label = new Label( composite, SWT.SINGLE | SWT.BORDER | SWT.LEFT );
props.setLook( label );
label.setText( "Minimum length: " );
text = new Text( composite, SWT.SINGLE | SWT.BORDER | SWT.LEFT );
props.setLook( text );
return composite;
}
示例5
public ConfigurationDialog( Shell parent, ExecutionConfiguration configuration, AbstractMeta meta ) {
super( parent );
this.parent = parent;
this.configuration = configuration;
this.abstractMeta = meta;
// Fill the parameters, maybe do this in another place?
Map<String, String> params = configuration.getParams();
params.clear();
String[] paramNames = meta.listParameters();
for ( String name : paramNames ) {
params.put( name, "" );
}
props = PropsUI.getInstance();
}
示例6
public EditRowsDialog( Shell parent, int style,
String title, String message, RowMetaInterface rowMeta, List<Object[]> rowBuffer ) {
this.title = title;
this.message = message;
this.rowBuffer = rowBuffer;
this.rowMeta = rowMeta;
this.parentShell = parent;
this.style = ( style != SWT.None ) ? style : this.style;
props = PropsUI.getInstance();
bounds = null;
hscroll = -1;
vscroll = -1;
title = null;
message = null;
this.log = LogChannel.GENERAL;
}
示例7
public KettleDatabaseRepositoryDialog( Shell parent, int style,
RepositoryMeta repositoryMeta,
RepositoriesMeta repositoriesMeta ) {
this.display = parent.getDisplay();
this.props = PropsUI.getInstance();
this.input = (KettleDatabaseRepositoryMeta) repositoryMeta;
this.repositories = repositoriesMeta;
this.masterRepositoriesMeta = repositoriesMeta.clone();
this.masterRepositoryName = repositoryMeta.getName();
shell =
new Shell( parent, style | SWT.DIALOG_TRIM | SWT.RESIZE
| SWT.MAX | SWT.MIN | SWT.APPLICATION_MODAL | SWT.SHEET );
shell.setText( BaseMessages.getString( PKG, "RepositoryDialog.Dialog.Main.Title" ) );
}
示例8
private boolean renameRecent( String id, String type, String name ) {
RepositoryObject repositoryObject = null;
try {
repositoryObject = getRepository().getObjectInformation( () -> id,
( type.equals( TRANSFORMATION ) ? RepositoryObjectType.TRANSFORMATION : RepositoryObjectType.JOB ) );
} catch ( Exception e ) {
return false;
}
if ( repositoryObject != null ) {
Collection<List<LastUsedFile>> lastUsedRepoFiles = PropsUI.getInstance().getLastUsedRepoFiles().values();
for ( List<LastUsedFile> lastUsedFiles : lastUsedRepoFiles ) {
for ( LastUsedFile lastUsedFile : lastUsedFiles ) {
if ( lastUsedFile.getDirectory().equals( repositoryObject.getRepositoryDirectory().getPath() ) && lastUsedFile
.getFilename().equals( repositoryObject.getName() ) ) {
lastUsedFile.setFilename( name );
return true;
}
}
}
}
return true;
}
示例9
public BaseStepXulDialog( String xulFile, Shell parent, BaseStepMeta baseStepMeta, TransMeta transMeta,
String stepname ) {
super( xulFile, parent, baseStepMeta, transMeta, stepname );
this.backupChanged = baseStepMeta.hasChanged();
this.props = PropsUI.getInstance();
try {
initializeXul();
} catch ( Exception e ) {
e.printStackTrace();
log.logError( "Error initializing (" + stepname + ") step dialog", e );
throw new IllegalStateException( "Cannot load dialog due to error in initialization", e );
}
}
示例10
@Before
public void setUp() {
mockStatic( PropsUI.class );
when( PropsUI.getInstance() ).thenReturn( mock( PropsUI.class ) );
LoggingRegistry logging = mock( LoggingRegistry.class );
doReturn( null ).when( logging ).registerLoggingSource( anyObject() );
mockStatic( LoggingRegistry.class );
when( LoggingRegistry.getInstance() ).thenReturn( logging );
dialog = spy( new JobEntryJobDialog( mock( Shell.class ), job, mock( Repository.class ), mock( JobMeta.class ) ) );
doReturn( "My Job" ).when( dialog ).getName();
doNothing().when( dialog ).getInfo( job );
doNothing().when( dialog ).getData();
doNothing().when( dialog ).dispose();
}
示例11
@Override
public boolean open(Node transNode, String fname, boolean importfile) {
try {
String xml = KettleVFS.getTextFileContent(fname, Const.XML_ENCODING);
Domain domain = new SerializationService().deserializeDomain(xml);
StarDomain starDomain = new StarDomain();
starDomain.setDomain(domain);
starDomain.setFilename(fname);
createTabForDomain(starDomain);
PropsUI.getInstance().addLastFile(LastUsedFile.FILE_TYPE_SCHEMA, fname, null, false, null);
Spoon.getInstance().addMenuLast();
return true;
} catch(Exception e) {
new ErrorDialog(Spoon.getInstance().getShell(), "Error", "There was an error opening model from file '"+fname+"'", e);
}
return false;
}
示例12
public JSONArray storeRecentSearch( String recentSearch ) {
JSONArray recentSearches = getRecentSearches();
try {
if ( recentSearch == null || recentSearches.contains( recentSearch ) ) {
return recentSearches;
}
recentSearches.add( recentSearch );
if ( recentSearches.size() > 5 ) {
recentSearches.remove( 0 );
}
PropsUI props = PropsUI.getInstance();
String jsonValue = props.getRecentSearches();
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = jsonValue != null ? (JSONObject) jsonParser.parse( jsonValue ) : new JSONObject();
jsonObject.put( getLogin(), recentSearches );
props.setRecentSearches( jsonObject.toJSONString() );
} catch ( Exception e ) {
e.printStackTrace();
}
return recentSearches;
}
示例13
public void setFont( String fontName, int fontSize, boolean fontBold, boolean fontItalic ) {
int swt = SWT.NORMAL;
if ( fontBold ) {
swt = SWT.BOLD;
}
if ( fontItalic ) {
swt = swt | SWT.ITALIC;
}
Font font = new Font( PropsUI.getDisplay(), fontName, fontSize, swt );
int index = fonts.indexOf( font );
if ( index < 0 ) {
fonts.add( font );
} else {
font.dispose();
font = fonts.get( index );
}
gc.setFont( font );
}
示例14
@Test
public void getDataForRow() throws Exception {
RowMetaInterface rowMetaInterface = Mockito.mock( RowMetaInterface.class );
Mockito.when( rowMetaInterface.size() ).thenReturn( 3 );
Mockito.when( rowMetaInterface.getValueMeta( Mockito.anyInt() ) ).thenReturn( Mockito.mock( ValueMetaInterface.class ) );
Field propsField = Props.class.getDeclaredField( "props" );
propsField.setAccessible( true );
propsField.set( PropsUI.class, Mockito.mock( PropsUI.class ) );
PreviewRowsDialog previewRowsDialog = new PreviewRowsDialog( Mockito.mock( Shell.class ), Mockito.mock( VariableSpace.class ), SWT.None, "test",
rowMetaInterface, Collections.emptyList() );
//run without NPE
int actualResult = previewRowsDialog.getDataForRow( Mockito.mock( TableItem.class ), null );
Assert.assertEquals( 0, actualResult );
}
示例15
/**
* Creates a series of LabeledControls, managing vertical layout between each.
*
* @param prevControl The swt control above the series of LabeledControls
* @param labelTexts The list of label texts, required to be one text per control.
* @param controls The set of controls in the series
* @param controlWidths The widths of each control in the series.
* @param props PropsUI to apply.
*/
public Series( Composite parent, Control prevControl, List<String> labelTexts, List<Control> controls,
List<Integer> controlWidths,
PropsUI props ) {
Preconditions.checkState( labelTexts.size() == controls.size()
&& labelTexts.size() == controlWidths.size() );
this.prevControl = prevControl;
this.parent = parent;
labeledControlSequence = IntStream.range( 0, labelTexts.size() )
.mapToObj( i -> new LabeledControl(
parent, labelTexts.get( i ), controls.get( i ), controlWidths.get( i ), props ) )
.collect( Collectors.toList() );
lookup = labeledControlSequence.stream().collect( Collectors.toMap( LabeledControl::control, lc -> lc ) );
layout();
}
示例16
public StarModelDialog(Shell parent, LogicalModel logicalModel, String locale) {
super(parent, SWT.DIALOG_TRIM);
this.logicalModel = logicalModel;
this.props = PropsUI.getInstance();
this.locale = locale;
List<LogicalTable> factTables = ConceptUtil.findLogicalTables(logicalModel, TableType.FACT);
if (factTables.isEmpty()) {
this.factTable = new LogicalTable();
this.factTable.setId(UUID.randomUUID().toString());
this.factTable.setProperty(DefaultPropertyID.TABLE_TYPE.getId(), TableType.FACT);
logicalModel.addLogicalTable(this.factTable);
} else {
this.factTable = factTables.get(0);
}
}
示例17
@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;
}
}
示例18
public CreateDatabaseWizardPage2( String arg, PropsUI props, DatabaseMeta info ) {
super( arg );
this.props = props;
this.databaseMeta = info;
setTitle( BaseMessages.getString( PKG, "CreateDatabaseWizardPage2.DialogTitle" ) );
setDescription( BaseMessages.getString( PKG, "CreateDatabaseWizardPage2.DialogMessage" ) );
setPageComplete( false );
}
示例19
public CreateDatabaseWizardPageJDBC( String arg, PropsUI props, DatabaseMeta info ) {
super( arg );
this.props = props;
this.databaseMeta = info;
setTitle( BaseMessages.getString( PKG, "CreateDatabaseWizardPageJDBC.DialogTitle" ) );
setDescription( BaseMessages.getString( PKG, "CreateDatabaseWizardPageJDBC.DialogMessage" ) );
setPageComplete( false );
}
示例20
public RadioTab( Composite composite, int i, String title, PropsUI props ) {
super( composite, i );
this.props = props;
props.setLook( this );
noMarginLayout = new FormLayout();
this.setLayout( noMarginLayout );
fdMaximize = new FormData();
fdMaximize.left = new FormAttachment( 0 );
fdMaximize.top = new FormAttachment( 0 );
fdMaximize.right = new FormAttachment( 100 );
fdMaximize.bottom = new FormAttachment( 100 );
this.setLayoutData( fdMaximize );
FormLayout marginLayout = new FormLayout();
marginLayout.marginWidth = 15;
marginLayout.marginHeight = 15;
radioGroup = new Group( this, i );
radioGroup.setLayout( marginLayout );
radioGroup.setText( title );
FormData fdRadioGroup = new FormData();
fdRadioGroup.top = new FormAttachment( 0 );
fdRadioGroup.left = new FormAttachment( 0 );
fdRadioGroup.right = new FormAttachment( 100 );
radioGroup.setLayoutData( fdRadioGroup );
props.setLook( radioGroup );
contentArea = new Composite( this, i );
contentArea.setLayout( noMarginLayout );
FormData fdContentArea = new FormData();
fdContentArea.left = new FormAttachment( 0 );
fdContentArea.top = new FormAttachment( radioGroup, 15 );
fdContentArea.bottom = new FormAttachment( 100 );
fdContentArea.right = new FormAttachment( 100 );
contentArea.setLayoutData( fdContentArea );
props.setLook( contentArea );
}
示例21
public DataSetGroupDialog( Shell parent, DataSetGroup dataSetGroup, List<DatabaseMeta> databases ) {
super( parent, SWT.NONE );
this.dataSetGroup = dataSetGroup;
this.databases = databases;
props = PropsUI.getInstance();
ok = false;
space = new Variables();
space.initializeVariablesFrom( null );
}
示例22
public static GUIResource getInstance() {
if ( guiResource != null ) {
return guiResource;
}
guiResource = new GUIResource( PropsUI.getDisplay() );
return guiResource;
}
示例23
@Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException {
FileDialogOperation fileDialogOperation = (FileDialogOperation) o;
PropsUI propsUI = propsUISupplier.get();
String startingDir = null;
if ( fileDialogOperation.getRepository() == null ) {
String username = getRepository().getUserInfo() != null ? getRepository().getUserInfo().getLogin() : "";
String repoAndUser = getRepository().getName() + ":" + username;
List<LastUsedFile> lastUsedFileList =
propsUI.getLastUsedRepoFiles().getOrDefault( repoAndUser, Collections.emptyList() );
startingDir = getStartingDir( fileDialogOperation, lastUsedFileList );
} else {
startingDir = fileDialogOperation.getStartDir();
}
RepositoryOpenSaveDialog repositoryOpenSaveDialog =
new RepositoryOpenSaveDialog( spoonSupplier.get().getShell(), WIDTH, HEIGHT );
repositoryOpenSaveDialog.open( fileDialogOperation.getRepository(), startingDir, fileDialogOperation.getCommand(),
fileDialogOperation.getTitle(), fileDialogOperation.getFilter(), fileDialogOperation.getOrigin(),
fileDialogOperation.getFilename(), fileDialogOperation.getFileType() );
if ( !Utils.isEmpty( repositoryOpenSaveDialog.getObjectName() ) ) {
RepositoryObject repositoryObject = new RepositoryObject();
repositoryObject.setObjectId( repositoryOpenSaveDialog::getObjectId );
repositoryObject.setName( repositoryOpenSaveDialog.getObjectName() );
repositoryObject
.setRepositoryDirectory( getRepository().findDirectory( repositoryOpenSaveDialog.getObjectDirectory() ) );
repositoryObject.setObjectType(
repositoryOpenSaveDialog.getObjectType().equals( TRANSFORMATION ) ? RepositoryObjectType.TRANSFORMATION
: RepositoryObjectType.JOB );
fileDialogOperation.setRepositoryObject( repositoryObject );
}
}
示例24
public EnterCQLDialog(Shell parent, TransMeta transMeta, ModifyListener lsMod,
String title, String cql) {
super(parent, SWT.NONE);
m_parent = parent;
m_props = PropsUI.getInstance();
m_title = title;
m_originalCQL = cql;
m_transMeta = transMeta;
m_lsMod = lsMod;
}
示例25
public CreateDatabaseWizardPageGeneric( String arg, PropsUI props, DatabaseMeta info ) {
super( arg );
this.props = props;
this.info = info;
setTitle( BaseMessages.getString( PKG, "CreateDatabaseWizardPageGeneric.DialogTitle" ) );
setDescription( BaseMessages.getString( PKG, "CreateDatabaseWizardPageGeneric.DialogMessage" ) );
setPageComplete( false );
}
示例26
/**
* @deprecated Use CT without the <i>props</i> parameter (at 2nd position)
*/
@Deprecated
public EnterPasswordDialog( Shell parent, PropsUI props, String title, String message, String description ) {
super( parent, SWT.NONE );
this.props = props;
this.title = title;
this.message = message;
this.description = description;
this.readonly = false;
}
示例27
public PaloCubeDeleteDialog( Shell parent, JobEntryInterface jobEntryInt, Repository rep, JobMeta jobMeta ) {
super( parent, jobEntryInt, rep, jobMeta );
props = PropsUI.getInstance();
this.jobEntry = (PaloCubeDelete) jobEntryInt;
if ( this.jobEntry.getName() == null ) {
this.jobEntry.setName( jobEntryInt.getName() );
}
this.jobMeta = jobMeta;
}
示例28
public CreateDatabaseWizardPageOracle( String arg, PropsUI props, DatabaseMeta info ) {
super( arg );
this.props = props;
this.info = info;
setTitle( BaseMessages.getString( PKG, "CreateDatabaseWizardPageOracle.DialogTitle" ) );
setDescription( BaseMessages.getString( PKG, "CreateDatabaseWizardPageOracle.DialogMessage" ) );
setPageComplete( false );
}
示例29
public Translator( Display display ) {
this.display = display;
this.log = new LogChannel( APP_NAME );
this.props = PropsUI.getInstance();
clear();
unusedColor = display.getSystemColor( SWT.COLOR_YELLOW );
}
示例30
/**
* This dialog grabs a UserMeta structure, valid for the specified repository.
*/
public UserDialog( Shell parent, int style, Repository repository, IUser userInfo ) {
super( parent, style );
this.securityManager = repository.getSecurityManager();
// this.repository = repository;
this.userinfo = userInfo;
this.props = PropsUI.getInstance();
}