Last active
December 31, 2015 17:59
-
-
Save DinisCruz/8023990 to your computer and use it in GitHub Desktop.
Dynamically programming Eclipse preferences page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tm.eclipse.ui.PluginPreferences.*; | |
| def mainPreferences = new MainPreferences(); | |
| def viewId = "test login preferences"; | |
| eclipseUI.add_View(viewId).close() | |
| def view = eclipseUI.add_View(viewId); | |
| mainPreferences.control = view.composite; | |
| mainPreferences.createContents(view.composite) | |
| return "done"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void createFieldEditors() | |
| { | |
| addField(new StringFieldEditor (PreferenceInitializer.P_TEAMMENTOR_SERVER , "TeamMentor &Server:" , getFieldEditorParent())); | |
| addField(new StringFieldEditor (PreferenceInitializer.P_TEAMMENTOR_SESSION_ID , "TeamMentor &SessionId:" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_OPEN_ARTICLE_NEW_WINDOW , "&Open TeamMentor article in new window" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_TEAMMENTOR_LOAD_PLUGINS , "&Load Plugins on Startup" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_TEAMMENTOR_ADVANCED_MODE , "&Show Advanced Mode Features" , getFieldEditorParent())); | |
| Composite parent= getFieldEditorParent(); | |
| Label label1 = new Label(parent,SWT.BORDER); | |
| label1.setText("label #1"); | |
| Text text1 = new Text(parent,SWT.BORDER); | |
| text1.setText("text 1"); | |
| Label label2= new Label(parent,SWT.BORDER); | |
| label2.setText("label #2"); | |
| Text text2 = new Text(parent,SWT.BORDER); | |
| text2.setText("text 2"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void createFieldEditors() | |
| { | |
| addField(new StringFieldEditor (PreferenceInitializer.P_TEAMMENTOR_SERVER , "TeamMentor &Server:" , getFieldEditorParent())); | |
| addField(new StringFieldEditor (PreferenceInitializer.P_TEAMMENTOR_SESSION_ID , "TeamMentor &SessionId:" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_OPEN_ARTICLE_NEW_WINDOW , "&Open TeamMentor article in new window" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_TEAMMENTOR_LOAD_PLUGINS , "&Load Plugins on Startup" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_TEAMMENTOR_ADVANCED_MODE , "&Show Advanced Mode Features" , getFieldEditorParent())); | |
| Composite parent= getFieldEditorParent(); | |
| Group group = new Group(parent, SWT.BORDER); | |
| ObjectBrowser.inspect(group); | |
| .... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void createFieldEditors() | |
| { | |
| addField(new StringFieldEditor (PreferenceInitializer.P_TEAMMENTOR_SERVER , "TeamMentor &Server:" , getFieldEditorParent())); | |
| addField(new StringFieldEditor (PreferenceInitializer.P_TEAMMENTOR_SESSION_ID , "TeamMentor &SessionId:" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_OPEN_ARTICLE_NEW_WINDOW , "&Open TeamMentor article in new window" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_TEAMMENTOR_LOAD_PLUGINS , "&Load Plugins on Startup" , getFieldEditorParent())); | |
| addField(new BooleanFieldEditor(PreferenceInitializer.P_TEAMMENTOR_ADVANCED_MODE , "&Show Advanced Mode Features" , getFieldEditorParent())); | |
| Composite parent= getFieldEditorParent(); | |
| new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL) | |
| .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); | |
| String groupTitle = "To get a token You can use the form below to login into the current TeamMentor server (set above)"; | |
| new Label(parent,SWT.BORDER).setText(groupTitle); | |
| //Group group = new Group(parent, SWT.BORDER); | |
| Group group = new Group(parent, SWT.NONE); | |
| GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); | |
| gridData.verticalAlignment = 20; | |
| group.setLayoutData(gridData); | |
| group.setLayout(new GridLayout(2, false)); | |
| new Label(group,SWT.BORDER).setText("User name:"); | |
| Text username_Text = new Text(group,SWT.BORDER); | |
| username_Text.setText("...."); | |
| username_Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); | |
| new Label(group,SWT.BORDER).setText("Password"); | |
| Text password_Text = new Text(group,SWT.BORDER); | |
| password_Text.setText("***"); | |
| password_Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); | |
| Button login_Button = new Button(group, SWT.NONE); | |
| login_Button.setText("Get Token"); | |
| logMessage(parent.getLayout().toString()); | |
| } | |
| public void logMessage(String message) | |
| { | |
| String consoleName = "TeamMentor Scripts"; | |
| Console console = Startup.eclipseApi.console; | |
| console.new_MessageConsole(consoleName); | |
| //console.get(consoleName).clearConsole(); // use to clear | |
| console.write(consoleName, message); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment