Search in sources :

Example 1 with FilePathAndPathInPackage

use of com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions.FilePathAndPathInPackage in project intellij-plugins by JetBrains.

the class FilesToPackageForm method initTableButtons.

private void initTableButtons() {
    ToolbarDecorator d = ToolbarDecorator.createDecorator(myFilesToPackageTable);
    d.setAddAction(new AnActionButtonRunnable() {

        public void run(AnActionButton button) {
            final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, true, false, true);
            final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myProject, null);
            final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
            for (final VirtualFile file : files) {
                final VirtualFile sourceRoot = fileIndex.getSourceRootForFile(file);
                String relativePath = sourceRoot == null ? null : sourceRoot.equals(file) ? "." : VfsUtilCore.getRelativePath(file, sourceRoot, '/');
                myFilesToPackage.add(new FilePathAndPathInPackage(file.getPath(), StringUtil.notNullize(relativePath, file.getName())));
            }
            if (files.length > 0) {
                fireDataChanged();
                IdeFocusManager.getInstance(myProject).requestFocus(myFilesToPackageTable, true);
                final int rowCount = myFilesToPackageTable.getRowCount();
                myFilesToPackageTable.setRowSelectionInterval(rowCount - files.length, rowCount - 1);
            }
        }
    });
    d.setRemoveAction(new AnActionButtonRunnable() {

        public void run(AnActionButton anActionButton) {
            TableUtil.stopEditing(myFilesToPackageTable);
            final int[] selectedRows = myFilesToPackageTable.getSelectedRows();
            Arrays.sort(selectedRows);
            for (int i = selectedRows.length - 1; i >= 0; i--) {
                myFilesToPackage.remove(selectedRows[i]);
            }
            fireDataChanged();
        }
    });
    myMainPanel.add(d.createPanel(), BorderLayout.CENTER);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePathAndPathInPackage(com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions.FilePathAndPathInPackage) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AnActionButton(com.intellij.ui.AnActionButton)

Example 2 with FilePathAndPathInPackage

use of com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions.FilePathAndPathInPackage in project intellij-plugins by JetBrains.

the class AdtTask method appendPaths.

public static void appendPaths(final List<String> command, final Module module, final FlexBuildConfiguration bc, final AirPackagingOptions packagingOptions, @Nullable final String platformSdkPath, final String packageFileExtension) {
    final String outputFilePath = bc.getActualOutputFilePath();
    final String outputFolder = PathUtil.getParentPath(outputFilePath);
    command.add(FileUtil.toSystemDependentName(outputFolder + "/" + packagingOptions.getPackageFileName() + packageFileExtension));
    command.add(FileUtil.toSystemDependentName(FlexBaseRunner.getAirDescriptorPath(bc, packagingOptions)));
    if (platformSdkPath != null && !platformSdkPath.isEmpty()) {
        command.add("-platformsdk");
        command.add(FileUtil.toSystemDependentName(platformSdkPath));
    }
    appendANEPaths(command, module, bc);
    command.add("-C");
    command.add(FileUtil.toSystemDependentName(outputFolder));
    command.add(FileUtil.toSystemDependentName(PathUtil.getFileName(outputFilePath)));
    for (FilePathAndPathInPackage entry : packagingOptions.getFilesToPackage()) {
        final String fullPath = FileUtil.toSystemIndependentName(entry.FILE_PATH.trim());
        String relPathInPackage = FileUtil.toSystemIndependentName(entry.PATH_IN_PACKAGE.trim());
        relPathInPackage = StringUtil.trimStart(relPathInPackage, "/");
        final String pathEnd = "/" + relPathInPackage;
        if (fullPath.endsWith(pathEnd)) {
            command.add("-C");
            command.add(FileUtil.toSystemDependentName(fullPath.substring(0, fullPath.length() - pathEnd.length())));
            command.add(FileUtil.toSystemDependentName(relPathInPackage));
        } else if (".".equals(relPathInPackage)) {
            command.add("-C");
            command.add(FileUtil.toSystemDependentName(fullPath));
            command.add(FileUtil.toSystemDependentName("."));
        } else {
            command.add("-e");
            command.add(FileUtil.toSystemDependentName(fullPath));
            command.add(relPathInPackage);
        }
    }
}
Also used : FilePathAndPathInPackage(com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions.FilePathAndPathInPackage)

Aggregations

FilePathAndPathInPackage (com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions.FilePathAndPathInPackage)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 AnActionButton (com.intellij.ui.AnActionButton)1 AnActionButtonRunnable (com.intellij.ui.AnActionButtonRunnable)1 ToolbarDecorator (com.intellij.ui.ToolbarDecorator)1