Page 1 of 1

Creating dialog boxes in eclipse oxygen plug-in

Posted: Fri Sep 26, 2014 1:12 pm
by mu258770
Hi team,

We are new to oxygen and working on customizing oxygen author 16.0 in eclipse plugin.

We need to create a new dialog box for some new feature in oxygen eclipse. We have followed the below steps for the same in oxygen eclipse.

1. We first opened Window-> Preferences-> Dita -> Document type association -> DITA.
2. Then we edited the same and in "Author" menu, we selected "actions" and added a new action with a name.
3. We gave IDs and its xpaths and all.
4. There is an option to select the operation, in that we could see many operations.

But we need our own operation, or we need to customize one of those operation.

For this we have extracted dita.jar file from the oxygen eclipse directory, and we could see many class file in that. We hope that if we create our own java class file there, and we create dita.jar file with the same (replacing the current), then it will work. We do not know whether this is the right approach.

We have queries as,
1. How we create our own java class operation file for the dialog box to appear. Please provide sample files in which we can edit and create the same, if possible. (The existing java class files are having so many import operations which is causing error while compiling)
2. If we create the same and creating dita.jar with the updated one, will it work or do we need to do more.

Please help us in the issue.

Regards,
Muhammed Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Fri Sep 26, 2014 4:32 pm
by alex_jitianu
Hello,

You are correct, you need to create a custom AuthorOperation. You should start with the Author Framework Development procedure. After following the procedure needed to install the oxygen SDK, you should focus on project oxygen-sample-framework. This project contains a sample framework and its customizations and you can find a lot of custom operations in it. Other interesting points in this project:
- inside the samples directory you will find the source code for all of our built-in frameworks, DITA included. Basically you can find here the source code for dita.jar. You can copy them inside the src folder if you want to start from them or to better see the code.
- please read README.html. It tells there how to make the SWT code compilable

After creating new operations in this project, you can just build it (using mvn package) . The resulting jar file will be located inside the target folder. You can just add this new jar inside the Classpath tab (Window-> Preferences-> Dita -> Document type association -> DITA), next to the dita.jar.

Please let me know if there is anything else I can help you with.

Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Mon Nov 24, 2014 10:28 am
by mu258770
Hi Alex,

I have installed the maven in my eclipse (kepler) and followed the instruction to setup the sample oxygen package. It has setup the package and it displayed me all the sample oxygen files in my package explorer in the eclipse. But I am getting several errors on the same package.

The errors are related to import operation. It is searching for some jar files (oxygen-jing-16.0.0.jar) in the .m2 directory and it is throwing some errors.

SOme of those errors are listed below:

Description Resource Path Location Type
Archive for required library: 'C:/Users/mu258770/.m2/repository/com/oxygenxml/oxygen-jing/16.0.0/oxygen-jing-16.0.0.jar' in project 'bundle-plugins' cannot be read or is not a valid ZIP file bundle-plugins Build path Build Path Problem
Archive for required library: 'C:/Users/mu258770/.m2/repository/com/oxygenxml/oxygen-jing/16.0.0/oxygen-jing-16.0.0.jar' in project 'bundle-options' cannot be read or is not a valid ZIP file bundle-options Build path Build Path Problem
Archive for required library: 'C:/Users/mu258770/.m2/repository/com/oxygenxml/oxygen-jing/16.0.0/oxygen-jing-16.0.0.jar' in project 'bundle-samplefiles' cannot be read or is not a valid ZIP file bundle-samplefiles Build path Build Path Problem
Archive for required library: 'C:/Users/mu258770/.m2/repository/com/oxygenxml/oxygen-jing/16.0.0/oxygen-jing-16.0.0.jar' in project 'bundle-frameworks' cannot be read or is not a valid ZIP file bundle-frameworks Build path Build Path Problem

Those jar files are already present in the .m2 directory. I have attached the screenshot of the same.

Please let me know how can I proceed on this.

Best Regards,
Shabeer[img]D:/error_in_eclpse.jpeg[/img]

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Mon Nov 24, 2014 10:56 am
by alex_jitianu
Hi Shabeer,

I'm not sure what happened. Are the archives corrupted? can you open them manually? If you've managed to create the sample project then your maven should be configured correctly. Please try this procedure:
- delete the directory C:/Users/mu258770/.m2/repository/com/oxygenxml
- Go to Eclipse, right click on the root project and select Maven->Update Project.... Make sure that the option Force Update of Snapshots/Releases is checked and press OK.

Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Nov 25, 2014 12:42 pm
by mu258770
Hi Alex,

Thank you for the answer. It really worked for me.

I have some more queries regarding the dialog box creation,
I need to implement an action whose functionality is a little similar to the "Web Link" in the oxygen. Here my requirement is,
I want a dialog box having two text boxes
1. For selecting a dita file from repository
2. For selecting an intermediate topic.

After browsing these, I need to combine these two values and keep it into an xref attribute.
I think the source code of InsertLinkOperation.java will help me doing this. Now I have setup complete package in eclipse, but I don't know how to view the o/p of the code of dita.jar file and customize it. I am able to see the output of InsertImageOperation.java using Run as java application.
Please tell me the steps to follow to work with the code of "InsertLinkOperation.java" (like where to place this code and how to run this).

Thanks in advance.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Nov 25, 2014 5:02 pm
by alex_jitianu
Hi Shabeer,

I'm glad to hear you solved the problem. You should focus on the oxygen-sample-framework sub-module. Inside samples/Oxygen Default Frameworks/ you can find the source files for the build-in frameworks extensions. Here is what you can do:
1. copy the files you need inside oxygen-sample-framework/src/main/java and work on them. Maybe rename the classes or change the package so that you distinguish between them and the original ones.
2. on the oxygen-sample-framework project, select Run as->Maven install from the contextual menu.
3. will get a jar file target/oxygen-sample-framework-16.1-SNAPSHOT.jar that contains the compile classes.
4. in Oxygen, go to Document Type Association Preferences, edit the document type and add this JAR to the Classpath.
5. Create an author action that uses that custom operation.

Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Wed Nov 26, 2014 3:25 pm
by mu258770
Hi Alex,

Thanks again for your quick response!

As mentioned in the previous mail, I need to make use of the code for insertion of "Web link" dialog box and its functionalities.

Is it possible to just edit InsertlinkOperation.java or InsertXrefOperation.java and add only these two files to a jar file. Will it work?.

We can see there are so many files which are part of dita.jar. So if we want to make use of only one or two file will it work without adding other files into the new .jar file.

Please tell me how can I proceed on this.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Thu Nov 27, 2014 10:19 am
by alex_jitianu
Hello Shabeer,

Yes, you can just just take the source files that interest you. For example you can:
1. copy InsertlinkOperation inside *oxygen-sample-framework/src/main/java*. Prior to that you might want to create the correct package location for this class. Because this class has reference to other DITA related classes, you need the JAR with those compiled classes. So we go to the next step.
2. Copy {oxygenInstallDir}/frameworks/dita/dita.jar inside oxygen-sample-framework
3. Open pom.xml and add a dependency to that jar. Something like this:

Code: Select all


<dependency>
<groupId>oxygen.extensions</groupId>
<artifactId>oxygen.extensions.dita</artifactId>
<version>16.1</version>
<scope>system</scope>
<systemPath>dita.jar</systemPath>
</dependency>
4. Now your class should compile. The JAR built by Maven will contain just this class (together with wathever other classes you have in src). The resulting JAR file must be added in the Document Type Classpath. If you have kept the name and package of the class unchanged, you must take care to add this JAR before dita.jar so that your classes will be preferred.

I want to warn you though that the "Web link" dialog box is not public API so you wont be able to customize it. As you will notice the InsertlinkOperation just calls a method to present the dialog and passes some parameters. You will have to create such a dialog from scratch.

Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Thu Dec 04, 2014 4:52 pm
by mu258770
Hi Alex,

Now I left the idea of extending "web link" operation.
I have tried two other ways for way forward.
In that, I have two queries.


Query1

1. From the sample project provided by oxygen, I have created a .jar file out of "simple\documentation\framework\operations\insertImageOperation.java".
2. I placed it in frameworks/dita folder and added classpath file in Document type association.
3. In invoke the operation box I could see "simple.documentation.operations.insertImageOperation".
4. I invoked it and placed in DITA menu.
5. I opened dita menu and selected the operation and got below error.
"oxygen plugin
Couldn't execute operation:
'simple.documentation.operations.insertImageOperation' for action: 'URN_new' because of: class java.lang.ClassCastException-org.eclipse.swt.widgets.Shell cannot be cast to javax.swing.JFrame"

Please let me know how to get rid of this error.
What's confusing me is that it worked for oxygen standalone version. I am getting this error only in oxygen eclipse.
The error message is attached also.
[img]C:\Users\shabeer\Desktop\error_dita_cms.jpeg[/img]

Query 2
This is the second way I tried to get the new action.

I have created a new java swing operation file from scratch and created jar out of it.
I placed it in frameworks/dita folder and I added classpath file in Document type association.
In invoke the operation box I could see the classpath, but I am not able to see the corresponding operational action files in list of actions. I could see there are 85 class files existing. I need my classes inside jar file also to be added in this.
How can I get the class files be present in the list of class files. Please let me know this also.

Thanks in advance.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Thu Dec 04, 2014 6:08 pm
by Radu
Hi Shabeer,

About query 1:

You are on the right track but if you want to make an operation work both with Oxygen standalone and Oxygen Eclipse plugin, you need to create two dialogs, for the standalone editor you need to create a Java Swing-based dialog and for the Oxygen Eclipse plugin you need to create an SWT-based dialog.

As an example, the Maven project should have the Java source code for this class:

Code: Select all


ro.sync.ecss.extensions.dita.topic.table.InsertTableOperation.insertTable(AuthorDocumentFragment[], boolean, AuthorAccess, String, AuthorTableHelper)
basically it does something like:

Code: Select all

    TableInfo tableInfo = null;
if(authorAccess.getWorkspaceAccess().isStandalone()) {
tableInfo = SADITATableCustomizer.getInstance().customizeTable(authorAccess, rowsCount, columnsCount);
} else {
//Eclipse table customization
tableInfo = ECDITATableCustomizer.getInstance().customizeTable(authorAccess, rowsCount, columnsCount);
}
so depending whether the action is running in the standalone Oxygen or in the Oxygen Eclipse plugin, it will delegate either to a table customizer which shows a Swing-based dialog or to a customizer which shows an SWT-based dialog. And you should proceed in a similar way.

I'm not sure about query 2, maybe the JAR you created manually does not contain the compiled operation or maybe it does not contain the packages structure which contains the compiled operation.

Regards,
Radu

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Mon Dec 08, 2014 12:14 pm
by mu258770
Hi Radu,

Thank you for the reply!

Our main target is to develop an action for oxygen eclipse. So now we are proceeding with SWT dialog creation. As we are new to SWT, we are facing little difficulty in creating a new action using swt.

For developing an action for standalone, insertImageOperation.java file was really helpful.
Likewise, can you please provide a sample SWT code (by which we can create a jar and will work in oxygen eclipse),using which we can develop our own action which has some functionality.

Thanks in advance!

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Mon Dec 08, 2014 12:39 pm
by Radu
Hi Shabeer,

In the Java sources which we make publicly available:

http://oxygenxml.com/maven/com/oxygenxm ... ources.jar

you can look to see how the DITA action for inserting a table ro.sync.ecss.extensions.dita.topic.table.InsertTableOperation does to invoke an eclipse or a swing-based dialog.

Regards,
Radu

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Dec 09, 2014 4:20 pm
by mu258770
Hi Radu,

Thank you for the source codes provided.

As our implementation is a little bit different than table operation, we are proceeding with the one which we built. But we are facing issues in the same also(issue which I reported already(query 2 in the previous communication)).

We now tried to compile the swt java file in command prompt. Please find the below commands we used.

"C:\Program Files (x86)\Java\jdk1.6.0_45\bin\javac" -cp "C:\Users\siven\Downloads\swt-4.4-win32-win32-x86_64\swt.jar" D:\URNCustomization\src\oxygen\custom\URNGUI.java

This command helped to create 2 '.class' files (URNGUI$1.class, URNGUI.class).

Then we created .jar file using the below command,

jar -cvf output.jar oxygen\custom\URNGUI$1.class oxygen\custom\URNGUI.class

This has created the output.jar file which has the same folder structure of the source. Also it created MANIFEST folder which contains Manifest.mf with the below details,

Manifest-Version: 1.0
Created-By: 1.8.0_25 (Oracle Corporation)

Then we tried all the steps like adding classpath in oxygen eclipse in order to make it work. But when we tried to invoke operation, the mentioned jar file is there in the classpath section, but the '.class' file is missing in the class section.

Please let us know is there anything more we need to do, or whether do we need to add anything more in the source file. Our swt file is just a normal dialog which has some buttons. We have not added any oxygen dependency in the source. (This file we have created as a baseline).

Thanks in advance!

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Dec 09, 2014 4:48 pm
by alex_jitianu
Hi Shabeer,

Since you're having a Maven the easiest way to create a jar would be to use the Maven phases. You can invoke the contextual menu on the .pom file (in Eclipse) and select Run as->Maven Install. After the execution ends you will find a jar file in {projectDirectory}/target/.

Another way to do it is to right click on the project (in Eclipse) and select Export.... Select the JAR File as the export type and follow the wizard.

Please create a JAR file using one of the following methods and see if it works.

Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Wed Dec 10, 2014 12:24 pm
by mu258770
Hi team,

I have tried both alternatives which you mentioned for creating jar file, but the result is same.

I have tried one more thing that I placed insertImageOperation.java(the swing sample file which you provided) and my java files in the jar. In invoke operation dialogue, it took only insertImageOperation.class file. My java file is just a small dialog box based on swt(created for testing).

Please see the below content of the java file, I created.

Code: Select all

package simple.documentation.framework.operations;


import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


import ro.sync.ecss.extensions.api.AuthorOperation;

public abstract class Swtdialog implements AuthorOperation {

     //
     // Implementing the Author Operation Interface.
     //

     /**
      * Performs the operation.
      */


     public static void main(String[] args) {
          Display display = new Display();
          Shell shell = new Shell(display);

          shell.setText("Hello, URN!");

          shell.open();
          // Set up the event loop.
          while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
              // If no more entries in the event queue
              display.sleep();
            }
          }
          display.dispose();
        }
      }
Please let me know whether I need to add any dependency to oxygen in the java file to make it appear in the invoke operation list.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Wed Dec 10, 2014 1:34 pm
by alex_jitianu
Hello Shabeer,

The reason you are not seeing the class is because you declared it as an abstract class so it can't be instantiated. ro.sync.ecss.extensions.api.AuthorOperation is an interface and in order for your custom operation to work properly you have to implement all of its methods. The dialog you want to present has to be presented on the doOperation() method which is called when the user invokes the action. Something like this:

Code: Select all


public class Swtdialog implements AuthorOperation {

@Override
public String getDescription() {
return "Shows a Dialog";
}

@Override
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
throws IllegalArgumentException, AuthorOperationException {
Display display = new Display();
Shell shell = new Shell(display);

shell.setText("Hello, URN!");

shell.open();
// Set up the event loop.
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
// If no more entries in the event queue
display.sleep();
}
}
display.dispose();
}

@Override
public ArgumentDescriptor[] getArguments() {
// TODO These arguments will be configured in the author action.
return null;
}

}
best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Wed Dec 10, 2014 4:45 pm
by mu258770
Hi Alex,

Thank you for the reply!

Now with your help I could move a little further on my task. I am able to see the created class file in invoke operation window now.

Now I added the created action in my DITA menu.

But I am getting error while opening the same as below,

[quote]Couldn't execute operation:
'simple.documentation.framework.operations.Swtdialog' for action: 'New Dialog' because of: class org.eclipse.swt.SWTException - Invalid thread access[/quote]

Please help.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Wed Dec 10, 2014 4:59 pm
by alex_jitianu
Hello Shabeer,

The exception tells you should perform a specific action on the SWT thread. The full exception should be available in Eclipse Error Log view.

I don't know exactly how your code is intended to work but I suspect you are trying to modify/update the GUI from a thread. If these type of situations you can wrap that code inside a Display.getDefault().asyncExec() or Display.getDefault().syncExec() call.

Best Regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Thu Dec 11, 2014 5:51 pm
by mu258770
Hi Alex,

Presently we are just trying to get some dialog on the screen while performing the operation which we created.

We have used Display.getDefault().asyncExec() function also, but it is causing not to display anything in the output.(Now the error message also disappeared)

We used the code which you provided to get the output. But still it failed.

What we want is to display some dialog in the screen while performing our operation. If we get that done, we can go on and extend that operation to a working action.

Please find the below code which we are using now.

Code: Select all

package simple.documentation.framework.operations;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import ro.sync.ecss.extensions.api.ArgumentDescriptor;
import ro.sync.ecss.extensions.api.ArgumentsMap;
import ro.sync.ecss.extensions.api.AuthorAccess;
import ro.sync.ecss.extensions.api.AuthorOperation;
import ro.sync.ecss.extensions.api.AuthorOperationException;

public class swtOxygen
  implements AuthorOperation
{
 
  public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
    throws IllegalArgumentException, AuthorOperationException
  {

        Shell oxygenFrame = (Shell) authorAccess.getWorkspaceAccess().getParentFrame();
         displayURLDialog(oxygenFrame);
        
  }
        private void displayURLDialog(Shell parentFrame) {
                          Display.getDefault().asyncExec(new Runnable() {
                             public void run() {
                              Display display = new Display();
                               Shell shell = new Shell(display);
                              
                               shell.setText("Hello, URN!");
                              
                               shell.open();
                               while (!shell.isDisposed()) {
                                   if (!display.readAndDispatch()) {
                                     display.sleep();
                                   }
                                 }
                                 display.dispose();
                             }
                          });     
       }
           
  public ArgumentDescriptor[] getArguments()
  {
    return null;
  } 
  public String getDescription()
  {
    return "Shows a URN Dialog";
  }
}
Please suggest us the changes required.

Many thanks for your great support!

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Fri Dec 12, 2014 10:26 am
by alex_jitianu
Hello Shabeer,

Most likely you are not seeing the dialog because you are instantiating a new display. You could just get the existing one Display.getDefault() or just use an org.eclipse.jface.dialogs.Dialog like in the code below:

Code: Select all

package simple.documentation.framework.operations;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import ro.sync.ecss.extensions.api.ArgumentDescriptor;
import ro.sync.ecss.extensions.api.ArgumentsMap;
import ro.sync.ecss.extensions.api.AuthorAccess;
import ro.sync.ecss.extensions.api.AuthorOperation;
import ro.sync.ecss.extensions.api.AuthorOperationException;


/**
*/
public class ShowDialogOperation implements AuthorOperation {
/**
* Performs the operation.
*/
public void doOperation(AuthorAccess authorAccess,
ArgumentsMap arguments)
throws IllegalArgumentException,
AuthorOperationException {
Dialog dialog = new Dialog((Shell) authorAccess.getWorkspaceAccess().getParentFrame()) {
@Override
protected void configureShell(Shell newShell) {
newShell.setText("Text");
super.configureShell(newShell);
}
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Label label = new Label(area, SWT.LEFT);
label.setText("Label");

return area;
}
};

dialog.open();
}

/**
* Has no arguments.
*
* @return null.
*/
public ArgumentDescriptor[] getArguments() {
return null;
}

/**
* @return A description of the operation.
*/
public String getDescription() {
return "shows a dialog";
}
}
Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Dec 16, 2014 9:50 am
by mu258770
Hi Alex,

Now we have setup everything in our maven based eclipse development for customizing XML menu in oxygen eclipse.

We have added CustomActionBarContributorCustomizer.java file in oxygen sample eclipse plugin file. We need to know how we integrate the customization in oxygen eclipse.

Should we create a jar out of this and place it in eclipse/dropins folder or should we follow any other way. Also let us know whether we need to add the resulting file in any classpath or anywhere else in oxygen eclipse and how this plugin effect in oxygen eclipse.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Dec 16, 2014 10:20 am
by mu258770
Hi Alex,

The last question was not meant dialog box creation. Its for XML menu customization in oxygen eclipse.

I was replying to the post with the title XML Menu customization
http://www.oxygenxml.com/forum/post31940.html#p31940 .

Sorry for the confusion made.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Dec 16, 2014 1:40 pm
by alex_jitianu
Hello Shabeer,

Run maven install and afterwards copy target/oxygen-sample-eclipse-plugin-17.0-SNAPSHOT.jar inside Eclipse's dropins folder.

Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Fri Dec 26, 2014 12:42 pm
by mu258770
Hi Alex,

With your help we are able to develop our own action and able to include the same in DITA menu.

For some more improvements to the action which we developed, we need some more help,

We have two queries,

1. If we open 'Web Link' dialog and try to edit something in the oxygen editor, the 'Web Link' dialog will blink. We need same behavior for our dialog also.

We have used "SWT.SYSTEM_MODAL" for shell definition, but not working as expected. Please let us know how it is done for all the dialogs present in oxygen.

2. Using our dialog, we are able to insert a special link in our editor by reusing the code in the InsertImageOperation. But we need some more changes. As for all other links, our insert link should also have the capability of selecting text and inserting the link. The selected text should come between the link which is inserted using our new action.

Please provide us support on this too.

Thanks in advance!

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Mon Dec 29, 2014 11:59 am
by alex_jitianu
Hi Shabeer,

1. So you need a modal dialog to block user interaction in the editor behind it. In Oxygen we normally use org.eclipse.jface.dialogs.Dialog with the SWT.APPLICATION_MODAL flag. Like this:

Code: Select all


public class ResizableDialog extends Dialog {
/**
* Resizable dialog.
*
* @param parentShell The parent shell of the dialog.
* @param resizable If <code>true</code> the dialog can be resized.
* @param modal If <code>true</code> the dialog will be modal, if <code>false</code> it won't.
*/
public ResizableDialog(Shell parentShell, boolean resizable, boolean modal) {
super(parentShell);
int style = SWT.DIALOG_TRIM;
if (resizable) {
style |= SWT.RESIZE;
}
if (modal) {
style |= SWT.APPLICATION_MODAL;
}
setShellStyle(style);
}
}
2. I didn't understand the exact steps nor what exactly you want to select. Nevertheless if you want to select something you can do it like this:

Code: Select all

AuthorDocumentController documentController = authorAccess.getDocumentController();
AuthorEditorAccess editorAccess = authorAccess.getEditorAccess();
// Selects the node at caret.
AuthorNode nodeAtOffset = documentController.getNodeAtOffset(editorAccess.getCaretOffset());
editorAccess.select(nodeAtOffset.getStartOffset(), nodeAtOffset.getEndOffset() + 1);
Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Dec 30, 2014 2:42 pm
by mu258770
Hi Alex,

Thank you for the response!

I have some points to add for both queries.

Query 1:

We have already tried with SWT.APPLICATION MODAL. But it didn't work as we expected.
Using this we can able to block user interaction in the editor behind it, but what we need is the same behavior as other (eg:-web link) dialogs in the oxygen. ie if the action dialog is open, user should not be able to interact with the editor and also the dialog box should blink while user trying to interact with the editor behind it.
For eg :- Consider we opened web link dialog box. Keeping it open, we are trying to edit in the editor behind it. Now what happens is that the user will not be able to edit it, also the web link dialog box will blink which acquires attention from the user that we should close the opened window before editing the doc.

This behavior is what we require. Please suggest a solution.

Query 2:

This also I can explain you with an example.

1. In the eclipse oxygen author, we select some text in the editor, say "Test".
2. Then using DITA->Link->Web Link option we are opening the web link dialog box.
3. Giving http://www.google.com as input in the opened web link dialog and pressing OK.
4. Now in oxygen editor text view it will come as below,

<xref href="http://www.google.com" format="html" scope="external">Test</xref>

In Author view, we will just get the underlined text, "Test" with a symbol for accessing the web link which that text is linked to.

What we need is the same behavior.

Presently this behavior is not there for our customized link. Our current code looks like this,

Code: Select all

public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
    throws IllegalArgumentException, AuthorOperationException
  {
    Shell oxygenFrame = (Shell) authorAccess.getWorkspaceAccess().getParentFrame();
    String href = displayURLDialog(oxygenFrame);
    if (href.length() != 0) {      
     // Creates the xref fragment.
     String xrefFragment =
       "<xref href='" + href + "' scope = \"external\" format= \"html\"/>";

     // Inserts this fragment at the caret position.
     int caretPosition = authorAccess.getEditorAccess().getCaretOffset();      
     authorAccess.getDocumentController().insertXMLFragment(xrefFragment, caretPosition);         
    }

  }
Please let us know how we can proceed on this too.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Dec 30, 2014 3:39 pm
by alex_jitianu
Hi Shabeer,

1. The behavior you are describing is the default behavior for a modal dialog.
The modality of an instance may be specified using style bits. The modality style bits are used to determine whether input is blocked for other shells on the display. The PRIMARY_MODAL style allows an instance to block input to its parent. The APPLICATION_MODAL style allows an instance to block input to every other shell in the display. The SYSTEM_MODAL style allows an instance to block input to all shells, including shells belonging to different applications.
APPLICATION_MODAL should make your dialog work just as you want it. This is what we use for the web link dialog. If it's not working then something is missing while creating the dialog. Perhaps you haven't used the the parent shell obtained from the Oxygen API? You can send us the code for displayURLDialog() (the code where the dialog is created and displayed) on the support list and we can take a look to see if we spot anything wrong.

2. You can achieve this behavior like this:

Code: Select all

AuthorEditorAccess editorAccess = authorAccess.getEditorAccess();
if (editorAccess.hasSelection()) {
int selectionStart = editorAccess.getSelectionStart();
int selectionEnd = authorAccess.getEditorAccess().getSelectionEnd();
authorAccess.getDocumentController().surroundInFragment(xmlFragment, selectionStart, selectionEnd - 1);
} else {
authorAccess.getDocumentController().insertXMLFragment(xmlFragment, editorAccess.getCaretOffset());
}
Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Wed Dec 31, 2014 10:26 am
by mu258770
Hi ALEX,

As I mentioned early, when I have used APPLICATION_MODEL, when dialogue box is opened all actions on the application are blocked, but blinking is not happening!!!!

Any way I have placed the code below:

Code: Select all

  public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
    throws IllegalArgumentException, AuthorOperationException
  {
    Shell oxygenFrame = (Shell) authorAccess.getWorkspaceAccess().getParentFrame();
    URNString = "";
    String href = displayURLDialog(oxygenFrame);
    if (href.length() != 0) {      
     // Creates the image XML fragment.
     String xrefFragment =
       "<xref href='" + href + "' scope = \"external\" format= \"html\"/>";

     // Inserts this fragment at the caret position.
     int caretPosition = authorAccess.getEditorAccess().getCaretOffset();      
     authorAccess.getDocumentController().insertXMLFragment(xrefFragment, caretPosition);         
    }

  }

  private String displayURLDialog(Shell parentFrame) {

    try {
      final Display display = parentFrame.getDisplay();
      bgColor = new Color(Display.getCurrent(), 244,244,244);       
      shlInsertExter = new Shell( display , SWT.CLOSE | SWT.TITLE | SWT.CENTER | SWT.APPLICATION_MODAL);
/* Our business logic */

 }
When I was doing these changes I also observed that, by just using SWT.center the dialogue box is not placed in the middle of the application window, so could you pls guide me in that aspect as well.

And FYI, below code ( Query 2 ) worked fine in case of selected text, thanks.

Regards,
Shabeer

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Mon Jan 05, 2015 4:51 pm
by alex_jitianu
Hi Shabeer,

One thing that I don't understand is why are you creating a new shell?

Code: Select all

shlInsertExter = new Shell( display , SWT.CLOSE | SWT.TITLE | SWT.CENTER | SWT.APPLICATION_MODAL);
Just create a dialog over the Shell obtained from our API. If we refer to the ResizableDialog code I've given you earlier you can do this:

Code: Select all

new ResizableDialog (parentFrame, true, true)
Best regards,
Alex

Re: Creating dialog boxes in eclipse oxygen plug-in

Posted: Tue Jan 06, 2015 2:31 pm
by mu258770
Hi Alex,

We have tried the mentioned method, but getting error.

First of all, we have not configured jface in our eclipse. So while importing Dialog, we get jface error.

The other error is in the function call "setShellStyle(style);". Please let us know whether this is an existing API or we need to define it.

Regards,
Shabeer