use of org.netbeans.modules.refactoring.api.ui.ExplorerContext in project netbeans-mmd-plugin by raydac.
the class MovePanel method initValues.
private void initValues() {
final String text;
if (this.files.length > 1) {
text = String.format(BUNDLE.getString("MovePanel.multiFileText"), Integer.toString(this.files.length));
} else {
text = String.format(BUNDLE.getString("MovePanel.singleFileText"), this.files[0].getName());
}
this.labelMessage.setText(text);
final List<Project> projects = new ArrayList<Project>();
for (final Project p : OpenProjects.getDefault().getOpenProjects()) {
projects.add(p);
}
final ComboBoxModel<Project> projectModel = new DefaultComboBoxModel<Project>(projects.toArray(new Project[projects.size()]));
final ItemListener listener = new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (comboProjects.equals(e.getSource())) {
updateFolders();
parent.stateChanged(null);
} else if (comboFolders.equals(e.getSource())) {
parent.stateChanged(null);
}
}
};
this.comboProjects.addItemListener(listener);
this.comboFolders.addItemListener(listener);
this.comboProjects.setModel(projectModel);
this.comboProjects.setSelectedItem(FileOwnerQuery.getOwner(this.files[0]));
updateFolders();
final ExplorerContext explorerContext = this.lookup.lookup(ExplorerContext.class);
if (explorerContext != null) {
final Node targetNode = explorerContext.getTargetNode();
if (targetNode != null) {
final DataObject dobj = targetNode.getLookup().lookup(DataObject.class);
if (dobj != null) {
final FileObject fo = dobj.getPrimaryFile();
if (fo != null && fo.isValid() && fo.isFolder()) {
final Project proj = FileOwnerQuery.getOwner(fo);
if (proj != null) {
this.comboProjects.setSelectedItem(proj);
this.comboFolders.setSelectedItem(FileUtil.getRelativePath(proj.getProjectDirectory(), fo));
}
}
}
}
}
}
Aggregations