cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

jlink activate window after open file

amedina
1-Newbie

jlink activate window after open file

Hey J-link peeps!

the question of the day is how to activate the window of a newly open
drawing. this does not seem to work:
window.Activate();
window.Repaint();
I was wonderin if I did a
curSession.OpenFile(file name);
could i do a
window.Activate(file name);

thanks for the help!

regards,

Alfonso


import java.awt.*;
import javax.swing.*;
import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcGlobal.*;
import com.ptc.pfc.pfcModel.*;
import com.ptc.pfc.pfcSelect.*;
import com.ptc.pfc.pfcWindow.*;


public class OpenDraw{
private static Session curSession=null;
private static Model model=null;
private static String modelName=";
private static ModelDescriptor descr;
private static ModelType
modTyp=com.ptc.pfc.pfcModel.ModelType.MDL_DRAWING;
private static SelectionOptions selectionOptions;
private static Selections selections;
private static com.ptc.pfc.pfcWindow.Window window;
static Frame pfcFrame = new Frame();

public static void start (){

try{
curSession = pfcGlobal.GetProESession();
model=curSession.GetCurrentModel();
modelName=model.GetInstanceName();
descr = pfcModel.ModelDescriptor_Create (modTyp, modelName, null);
curSession.OpenFile(descr);
//curSession.GetCurrentWindow();
com.ptc.pfc.pfcWindow.Window window =
curSession.GetCurrentWindow();
// This activate window does not work at all
window.Activate();
window.Repaint();
mes("Here is the drawing you wanted");
selectionOptions = pfcSelect.SelectionOptions_Create("dwg_table");
selections = curSession.Select(selectionOptions, null);
}
catch (jxthrowable jxth){
mes("cannot_find the file dummy!");
jxth.printStackTrace ();
}
stop();
}//end start

//=========================================================================
public static void stop (){
}
//=========================================================================
private static void mes(String message){ //Pop-op boks
JOptionPane.showMessageDialog ( pfcFrame, message,
"Message from Jlink!", JOptionPane.INFORMATION_MESSAGE );
}//end mes
}
1 REPLY 1

Get current window give you the activated window. So not the Window you want to activate.


When u make openFile u get a window discriptor. Thats the one u need.



JLink API:
Window OpenFile (ModelDescriptorMdlDescr)
Retrieves the specified model and displays it in a window.

This method is equivalent to calling BaseSession.RetrieveModel(ModelDescriptor) , BaseSession.CreateModelWindow(Model) , and Model.Display() .


<dl><dt> Manual References: </dt><dd> Models: Retrieving Models, Models: Retrieving Models, Models: Retrieving Models, Windows and Views: Getting a Window Object, Windows and Views: Getting a Window Object, Windchill Connectivity APIs: Retrieval, Windchill Connectivity APIs: Retrieval </dd></dl> <dl><dt> Parameters: </dt><dd> <dl><dt> MdlDescr </dt><dd>The model to retrieve</dd></dl> </dd></dl> <dl><dt> Returns: </dt><dd>The new window
</dd></dl>
Top Tags