How to change the setting of DialogComponentDate or DateInputDialog?

#1

i am using DialogComponentDate now but i want to show the date and hide the time part.

I also want to set default date as current date, where i can config those features ? Because i can’t set in SettingsModelDate.

Then i tried to use DateInputDialog and i found

new DateInputDialog(DateInputDialog.Mode. NOTIME );

which fit my need. But how this work with addDialogComponent()? because i don’t know how to put this on my panel like cast to DialogComponent. Thank you

0 Likes

#2

Hi @eaton1632,

Have you looked into org.knime.time.util.DialogComponentDateTimeSelection? This is the new dialog component which was used in the new Date&Time nodes. There you can set the DisplayOption to SHOW_DATE_ONLY. If you want to have the current date set when opening the dialog, you need to specify this during loading the dialog settings.

Cheers,
Simon

1 Like

#3

Did not find the class DialogComponentDateTimeSelection in https://www.knime.com/docs/api/index.html
and in Eclipse SDK

THANKS

0 Likes

#4

I use SettingsModelDate and set the default time with the following code,but not work

@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
	/*
	 * Load (valid) settings from the NodeSettings object. It can be safely assumed that
	 * the settings are validated by the method below.
	 * 
	 * The SettingsModel will handle the loading. After this call, the current value
	 * (from the view) can be retrieved from the settings model.
	 */
	m_numberFormatSettings.loadSettingsFrom(settings);
	startDateSettings.setTimeInMillis(new Date().getTime());
	startDateSettings.loadSettingsFrom(settings);
}
0 Likes

#5

Hi @lou,

It’s this class: https://github.com/knime/knime-base/blob/master/org.knime.time/src/org/knime/time/util/DialogComponentDateTimeSelection.java
Did you setup the sdk correctly? Follow the instructions here https://github.com/knime/knime-sdk-setup .

What does not work?

Cheers,
Simon

0 Likes

#6

My sdk version is

Not work:the date component default did not update with my init value.

thanks

0 Likes

#7

The class is in knime-base, not in knime-core.

You are loading the settings after you have set the value, i.e., you overwrite your value by loading the settings. I think that’s the issue.

0 Likes

#8

According to the document https://github.com/knime/knime-sdk-setup did not find how to import the knime-base jar

You mean set the default date must within which method?

0 Likes

#9

You don’t need any jar at all. All you need is to set the target platform as described there. The target platform brings all these dependencies and you will be able to use the DialogComponentDateTimeSelection class.

Did you take a look at this blog post https://www.knime.com/blog/the-five-steps-to-writing-your-own-knime-extension or at this documentation https://www.knime.com/developer-guide? They might help you to understand how to work with default dialog components.

Cheers,
Simon

1 Like

#10

thanks i will try reload target platform.
by the way,could you give me some suggestion on how to set the init date on

org.knime.core.node.defaultnodesettings.DialogComponentDate


I set the init date value within configure method

@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
	LogUtil.printLog("configure");
	startTimeSetting.setTimeInMillis(new Date().getTime());
	endTimeSetting.setTimeInMillis(new Date().getTime());
	return new DataTableSpec[] { null };
}

but open configure dialog the init date always 1970-01-01

image

0 Likes

#11

Where is the https://github.com/knime/knime-core API DOC?

I changed the target to target-complete and core-base.jar is in the dependency,but class
https://github.com/knime/knime-base/blob/master/org.knime.time/src/org/knime/time/util/DialogComponentDateTimeSelection.java
not found.

image

0 Likes

#12

The API documentation is in the code. It is open source, so you can just have a look at it. I don’t think we have a website which lists the API.

Hard to guess what the problem is. The only advice I can give is to double check that you didn’t skip any of the steps in the instruction and that all the dependencies are correctly set up.

1 Like